http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52405
Bug #: 52405 Summary: undefined references in shared library when linking the shared library with -flto Classification: Unclassified Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto AssignedTo: unassig...@gcc.gnu.org ReportedBy: d...@gcc.gnu.org seen with the 4.6 branch, and 4.7 20120223. The object files are built with -flto as well. Linking the shared library with -flto results in unresolved symbols when linking against the share library. Not building the shared library with -flto lets the launcher link succeed. the object files (x86_64-linux-gnu) including the build script build.sh can be found at http://people.debian.org/~doko/tmp/hs.tar.xz The undefined symbols come from inline template definitions in a header file. gcc-4.7 -m64 -fpic -fno-rtti -fno-exceptions -fcheck-new -fvisibility=hidden -m64 -flto -g -O3 -fno-strict-aliasing -fno-omit-frame-pointer -fuse-linker-plugin -Xlinker -O1 -Wl,-Bsymbolic-functions -Xlinker -z -Xlinker noexecstack -m64 -Xlinker -export-dynamic -L `pwd` -o gamma launcher/java_md.o launcher/wildcard.o launcher/java.o launcher/jli_util.o -ljvm -lm -ldl -lpthread /home/packages/openjdk/7/openjdk-7-7~u3-2.1/build/openjdk.build-boot/hotspot/outputdir/linux_amd64_compiler2/product/libjvm.so: undefined reference to `void G1ParPushHeapRSClosure::do_oop_nv<oopDesc*>(oopDesc**)' /home/packages/openjdk/7/openjdk-7-7~u3-2.1/build/openjdk.build-boot/hotspot/outputdir/linux_amd64_compiler2/product/libjvm.so: undefined reference to `void FilterIntoCSClosure::do_oop_nv<oopDesc*>(oopDesc**)' /home/packages/openjdk/7/openjdk-7-7~u3-2.1/build/openjdk.build-boot/hotspot/outputdir/linux_amd64_compiler2/product/libjvm.so: undefined reference to `void G1ParPushHeapRSClosure::do_oop_nv<unsigned int>(unsigned int*)' collect2: error: ld returned 1 exit status make[8]: *** [gamma] Error 1