On 04/04/2010 11:54 AM, Ralf Wildenhues wrote: > * Ralf Wildenhues wrote on Sun, Mar 28, 2010 at 05:33:44PM CEST: >> I'm still working on a patch to support -flto in libtool, it needs >> changes in several places. > > I have a preliminary(!) patch set here for LTO support in libtool.
Hi, Thanks a lot for the patches, they worked fine so far! I'd have one more request: please add "-use-gold-plugin" to the list of flags passed through to support LLVM's LTO described here: http://llvm.org/docs/GoldPlugin.html I've applied your patches, re-autoconfed ClamAV, and tested a GCC build with -flto: ./configure CFLAGS="-flto -O2" CXXFLAGS="-flto -O2" CC=gcc-4.5 CXX=g++-4.5 Everything worked fine, and make check passed too! (Now of course it didn't LTO the entire program because -fuse-linker-plugin triggers PR41584) If I edit libtool and add -use-gold-plugin (after -fuse-linker-plugin), then I can build ClamAV with llvm2.7[*] without using the workarounds described on that page, by simply doing this: ./configure CC=/home/edwin/llvm2.7/llvm-gcc-4.2-2.7-x86_64-linux/bin/llvm-gcc CXX=/home/edwin/llvm2.7/llvm-gcc-4.2-2.7-x86_64-linux/bin/llvm-g++ CFLAGS="-O4 -use-gold-plugin" CXXFLAGS="-O4 -use-gold-plugin" ac_cv_c_fpu_bigendian=no This worked too (with less optimizations): ./configure CC=/home/edwin/llvm2.7/llvm-gcc-4.2-2.7-x86_64-linux/bin/llvm-gcc CXX=/home/edwin/llvm2.7/llvm-gcc-4.2-2.7-x86_64-linux/bin/llvm-g++ CFLAGS="-flto -use-gold-plugin" CXXFLAGS="-flto -use-gold-plugin" ac_cv_c_fpu_bigendian=no I also had to add a symlink to system's libstdc++.so (the llvm-gcc binary ships with a libstdc++.la, and a libstdc++.a which break linking LTO programs, because they are not PIC). [*] After copying libLLVMgold.so as described in http://llvm.org/docs/GoldPlugin.html#lto_autotools > DO NOT submit this to your favorite distribution, it is not ready > for general consumption yet. > > Several upstream issues to fix here: > > - gold bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42757 > (common symbols not emitted with -fuse-linker-plugin) > - GCC bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43576 > (ICE w/ partial linking) > - GCC bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43542 > (segfault if __gnu_lto_v1 is referenced) > - gold bug http://sourceware.org/bugzilla/show_bug.cgi?id=11182 > (names in linker scripts in subdirs are relative to subdir) > - GCC bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41584 > (-fwhopr ICE with TU that contains no function) Yep, I'm hitting this one, so I can't test -fuse-linker-plugin. Best regards, --Edwin