what's with the linking warnings? (alias: [EasyHack] duplicate linked objects)

Bjoern Michaelsen bjoern.michaelsen at canonical.com
Mon Mar 12 11:40:09 PDT 2012


Hi Noel,

On Mon, Mar 12, 2012 at 11:10:20AM +0200, Noel Grandin wrote:
> I'm curious - what's with the linking warnings:
>     [ WARN   ] !!!
>     [ WARN   ] !!! smoketest/smoketest is linked in by
> Library/libsmoketest.so CppunitTest/libtest_smoketest.so
>     [ WARN   ] !!!
> 
> They seem to have been there for as long as I've been building
> LibreOffice (the last 4 months) - are they indicative of an actual
> problem?

They are do not have to be a deadly problem, but they can introduce very hard
to debug problems. As we set stuff like compile flags and include paths on the
linktarget (aka the library) and in the above case the object file is linked in
by two libraries, the flags it is compiled with are actually nondeterministic.
That is Very Bad(tm)!

So the smoketest/smoketest.cxx will either be compiled with the CFLAGS of
Library/libsmoketest.so or with those of CppunitTest/libtest_smoketest.so --
actually it can be compiled different on different machines with the same code.
It can even be compiled different on the same machine! So again: This is Very
Bad(tm) and we should probably never ever have let that happen.

Now it might be possible that the one doing the initial migration carefully
checked that both libs are compiled exactly the same on all platforms (I highly
doubt that), but even then this totally unproof against future changes. Someone
might innocently add a define to the compile flags of one library and create a
terribly hard to reproduce heisenbug.

So this has to go, it should never have been there in the first place. How can
this be removed? There are two possibilities:
a) create a smoketest/smoketest_libtest_smoketest.cxx with this content:

    #include "smoketest.cxx"

   and then use that file instead of smoketest/smoketest.cxx in
   CppunitTest/libtest_smoketest. That way, the object gets build twice (with
   possibly different flags and defines) and everything is fine.
   Ugly, but does the job.
b) create a static library smoketest and add the smoketest/smoketest.cxx to it.
   Now instead link that static library into both of the dynamic ones and
   everything is fine.

I just created a EasyHack for this:

 https://bugs.freedesktop.org/show_bug.cgi?id=47246

Best,

Bjoern


More information about the LibreOffice mailing list