On Thu, Jul 28, 2022 at 3:17 PM Ilya Maximets <i.maxim...@ovn.org> wrote:
>
> On 7/27/22 23:02, David Marchand wrote:
> > On Mon, Jul 25, 2022 at 2:29 PM Ilya Maximets <i.maxim...@ovn.org> wrote:
> >>
> >> Current version of debian/rules simply passes the libopenvswitch.a
> >> as a command line argument via LDFLAGS, but that doesn't actually
> >> lead to this library being statically linked into python extension,
> >> which is a shared library.  Instead, the build "succeeds", but the
> >> resulted extension is not usable, because most of the symbols are
> >> missing:
> >>
> >>   from ovs import _json
> >>
> >>   ImportError:
> >>     
> >> /usr/lib/python3/dist-packages/ovs/_json.cpython-310-x86_64-linux-gnu.so:
> >>       undefined symbol: json_parser_finish
> >>
> >> '-lopenvswitch' with a path to a static library should be passed
> >> instead to make it actually statically linked.  But even that is not
> >> enough as all the libraries that libopenvswitch.a was built with also
> >> has to be passed.  Otherwise, we'll have unresolved symbols like ssl,
> >> cap-ng, etc.
> >>
> >> The most convenient way to get all the required libraries and cflags
> >> seems to be by using pkg-config.
> >>
> >> Setting several environment variables for pkg-config, so it can find
> >> the libopenvswitch.pc in non-standard directory, not skip default
> >> locations and also report them with the right base directory.
> >>
> >> Extra '-Wl,-Bstatic -lopenvswitch -Wl,-Bdynamic' is added before all
> >> the libs to ensure static linking of libopenvswitch even if the
> >> dynamic library is available in a system.
> >
> > Did you consider the simple :filename form to tell ld to link an archive?
> > Here that would translate to a simple -l:libopenvswitch.a
>
> Yes, I looked into that.  There shouldn't be any difference for this
> particular use case.  -l:filename syntax is supported since binutils 2.18
> that was released about 11 years ago, not sure if that's a priblem or
> not.  It's certainly not a problem for current debian packaging, since it
> will likely not work on systems that old anyway.
>
> >
> > This is only a suggestion to avoid adding too many -Wl options as they
> > stack up if you are not careful.
>
> I see. Though, it is probably not a big concern for this particular use-case.
>
> I can replace '-Wl,-Bstatic -lopenvswitch -Wl,-Bdynamic' with
> '-l:libopenvswitch.a' and send a new version, or replace on commit,
> if you think that will be better.  I don't have a strong preference.
>
> What do you think?
>
> Frode, do you have any comments on this?

David, thank you for sharing the `-l:` syntax, I was not aware of that.

I have no strong opinions about what to use, if it helps to tip the
scale, I have to admit in this specific use-case where we only have
two of these, the longer syntax appears more clear on the tin to see
what's going on.  We could switch to `-l:` if we need to add more of
these for example?

-- 
Frode Nordahl

> Best regards, Ilya Maximets.
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to