[cmake-developers] Ubuntu 15.10 and --[no-]-as-needed

Brad King brad.king at kitware.com
Wed Nov 18 08:55:56 EST 2015


On 11/17/2015 06:51 PM, Roger Leigh wrote:
> 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.

You should not rely on just having linked to a shared library to have
its static initialization and destruction executed.  Some systems use
lazy initialization and won't perform static initialization of any
data in a translation unit until just before the first actual call
to a symbol in that unit at run time.

In order to reliably cause a library to be initialized one must call
into it explicitly.  I'm not familiar with boost_log_setup but they
should have some way to do this.  Otherwise there would be no way
to make it work for statically linked binaries.

-Brad



More information about the cmake-developers mailing list