Skip to content
Success

Changes

Summary

  1. Makefile:am: Improve formatting and order of CFLAGS and LIBS (details)
Commit 45a452d732cdc6acece030d4ae55361c41859183 by Pau Espin Pedrol
Makefile:am: Improve formatting and order of CFLAGS and LIBS

Place osmocom libraries in proper dependency order.
It seems in general the linker searches from left to right, and notes
unresolved symbols as it goes.
So libs should be placed so that the library that needs symbols must be
first, then the library that resolves the symbol.
This is actually more important for static libraries than shared libraries, see:
https://praveenv253.github.io/logs/2014/03/15/log-message-1.html
https://stackoverflow.com/questions/45135/why-does-the-order-in-which-libraries-are-linked-sometimes-cause-errors-in-gcc

Some distros like debian and ubuntu started passing -Wl,--as-needed by default,
which then require the object files to be passed before the libraries.
According to https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed
"Importance of linking order" this is not much of a problem with autoamke since we
properly use LDADD instead of LDFLAGS.

See also:
https://wiki.ubuntu.com/OneiricOcelot/ReleaseNotes#GCC_4.6_Toolchain
https://wiki.ubuntu.com/ToolChain/CompilerFlags#A-Wl.2C--as-needed
https://wiki.debian.org/ToolChain/DSOLinking#Only_link_with_needed_libraries

The problem is actually those places where we pass .o objects in LDADD. There, we
need to put the .o files first, and then the libraries in the order mentioned above.
Nevertheless, it's good to always follow the same order always everywhere to avoid
potential problems though.

Change-Id: Ia766a09103d2216258a83cc98899e6cae4b0351d
The file was modifiedsrc/Makefile.am
The file was modifiedsrc/client/Makefile.am
The file was modifiedsrc/bankd/Makefile.am
The file was modifiedsrc/server/Makefile.am