I've just upgraded my work development system to Ubuntu 15.10. While
testing the FindBoost work in a separate thread, I noticed that with
this release the system linker is using --as-needed by default. This
means that the system no longer respects the compiler linker arguments,
and will deliberately fail to link any libraries for which it can't see
any symbols being used.
While this is possibly useful in trimming unnecessary libraries from
DT_NEEDED where they are genuinely unused and removal is harmless, it
completely breaks the case where there is no direct symbol usage but the
library is still required for correct functioning of the library or
program, e.g. as a side-effect of ELF constructors for C++ static
initialisation and destruction. One case in point: boost_log_setup. If
I explicitly request it be linked, it's automatically dropped, against
my specific wishes.
While previously such behaviour could be explicitly enabled by using
-Wl,--as-needed, it's now the case that if you want the old correct
behaviour you need to explictly *disable* with -Wl,--no-as-needed.
While I can see this was useful for certain reasons, I think this is a
terrible default.
The reason for bringing this up here is to ask whether this is something
CMake should expose as a property to allow some measure of control.
Given that it's a positional parameter which can be turned off and on on
a per-library basis for each target, I'm not sure how that could be
done, unless e.g. dummy interface targets could be added to the target
link libraries to inject the linker options in the correct positions (if
that's possible).
Regards,
Roger
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers