Skip to content

[th/build-link-static-libraries-later]

Thomas Haller requested to merge th/build-link-static-libraries-later into master

This fixes a real bug with autotools [1], where our tests in libnm/tests would dynamically link against libnm.so, but also statically link with libnm-core.la. That is wrong, because it will for example invoke the construct function _nm_utils_init() twice.

Note that the libnm tests need access to internal functionality of libnm, hence they need to statically link against libnm-core. The correct solution is that they only statically link, and don't also dynamically link libnm.so.


The rest of the branch tries to cleanup building our static libraries.

We build a lot of intermediate (static) libraries, that we later combine.

With meson, this all works nicely.

With autotools, when you link

  • (libA -> libB) && ((libA + libB) -> libC)

or

  • (libA -> libB) && (libA -> libC) && ((libB + libC) -> libD)

you get duplicate symbols from libA.

As we have a large number of static libraries, it's not obvious how they are combined, to avoid duplicate.

As a rule, avoid linking static libraries with other static libraries. That means, we will only combine static libraries in the last step, and it becomes quite clear where the symbol must come from. For convenience, there are still exceptions to this rule: src/libNetworkManager.la, src/libNetworkManagerTest.la, and libnm/liblibnm.la are internal static libraries, that act as a combination of other static libraries.

Merge request reports

Loading