Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#73 undefined symbols with LTO builds

open
nobody
5
2012-08-12
2012-08-12
Václav Haisman
No

Hi. I am having problems with LTO compilation of a library (DLL). I am trying to cross compile log4cplus library from Linux to i686-w64-mingw32 with the following configure parameters: --enable-threads=yes --with-gnu-ld --with-working-c-locale --host=i686-w64-mingw32 CPPFLAGS="-D_WIN32_WINNT=0x600" CXXFLAGS="-save-temps -fverbose-asm -O2 -flto -flto-partition=none -fuse-linker-plugin -flto-report". But I am getting error messages about undefined symbols that I am NOT getting in non-LTO builds:

/tmp/ccja58f6.lto.o:appenderattachableimpl.o:(.text+0x3e7e): undefined reference to `log4cplus::thread::Mutex::Mutex(log4cplus::thread::Mutex::Type)'
/tmp/ccja58f6.lto.o:appenderattachableimpl.o:(.text+0x589a): undefined reference to `log4cplus::thread::Mutex::Mutex(log4cplus::thread::Mutex::Type)'
/tmp/ccja58f6.lto.o:appenderattachableimpl.o:(.text+0x651d): undefined reference to `log4cplus::thread::Mutex::Mutex(log4cplus::thread::Mutex::Type)'
/tmp/ccja58f6.lto.o:appenderattachableimpl.o:(.text+0xedf8): undefined reference to `log4cplus::thread::Mutex::Mutex(log4cplus::thread::Mutex::Type)'
/tmp/ccja58f6.lto.o:appenderattachableimpl.o:(.text+0x14cd1): undefined reference to `log4cplus::thread::Mutex::Mutex(log4cplus::thread::Mutex::Type)'
/tmp/ccja58f6.lto.o:appenderattachableimpl.o:(.text+0x28368): more undefined references to `log4cplus::thread::Mutex::Mutex(log4cplus::thread::Mutex::Type)' follow
collect2: ld returned 1 exit status
make[1]: *** [liblog4cplus.la] Error 1
make[1]: Leaving directory `/home/wilx/log4cplus-bzr/work-trunk/objdir-mingw64-w32/src'
make: *** [all-recursive] Error 1

Discussion

  • This is the libtool invocation that is failing during the build:

    /bin/bash ../libtool --tag=CXX --mode=link i686-w64-mingw32-g++ -no-suppress -save-temps -fverbose-asm -O2 -flto -flto-partition=none -fuse-linker-plugin -flto-report -Wall -Wextra -pedantic -Wstrict-aliasing -Wstrict-overflow -Woverloaded-virtual -Wold-style-cast -Wc++0x-compat -Wundef -Wshadow -Wformat -Wsuggest-attribute=noreturn -Wno-variadic-macros -fvisibility=hidden -no-undefined -version-info 3:0:0 -release 1.1 -Wl,--enable-auto-import -Wl,--enable-runtime-pseudo-reloc -o liblog4cplus.la -rpath /usr/local/lib appenderattachableimpl.lo appender.lo asyncappender.lo clogger.lo configurator.lo consoleappender.lo cygwin-win32.lo env.lo factory.lo fileappender.lo fileinfo.lo filter.lo global-init.lo hierarchy.lo hierarchylocker.lo layout.lo log4judpappender.lo lockfile.lo logger.lo loggerimpl.lo loggingevent.lo loggingmacros.lo loglevel.lo loglog.lo logloguser.lo mdc.lo ndc.lo nullappender.lo nteventlogappender.lo objectregistry.lo patternlayout.lo pointer.lo property.lo queue.lo rootlogger.lo sleep.lo snprintf.lo socketappender.lo socketbuffer.lo socket.lo socket-unix.lo socket-win32.lo stringhelper.lo stringhelper-clocale.lo stringhelper-cxxlocale.lo stringhelper-iconv.lo syncprims.lo syslogappender.lo threads.lo timehelper.lo tls.lo version.lo win32consoleappender.lo win32debugappender.lo -lws2_32 -ladvapi32 -lkernel32

    Moving the syncprims.lo file argument to be the last .lo file on the command line fixes the problem for me. Why? Is this GCC/Mingw-W64 problem or my Autoconf/Libtool problem?