http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53337
Bug #: 53337 Summary: [4.7.1 lto] produces warning: relocation refers to discarded section in linker (gold, binutil 2.22) Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto AssignedTo: unassig...@gcc.gnu.org ReportedBy: vincenzo.innoce...@cern.ch I get these kind of warnings (from gold) with 4.7.1, not with 4.8 c++ -v Using built-in specs. COLLECT_GCC=c++ COLLECT_LTO_WRAPPER=/build/ge/new-binutils/b/slc5_amd64_gcc470/external/gcc/4.7.0-cms/bin/../libexec/gcc/x86_64-unknown-linux-gnu/4.7.1/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: ../configure --prefix=/build/ge/new-binutils/b/tmp/BUILDROOT/a72d117de7727d2dbd542a4ad4d72e45/opt/cmssw/slc5_amd64_gcc470/external/gcc/4.7.0-cms --disable-multilib --disable-nls --enable-languages=c,c++,fortran --enable-gold=yes --enable-lto --with-gmp=/build/ge/new-binutils/b/tmp/BUILDROOT/a72d117de7727d2dbd542a4ad4d72e45/opt/cmssw/slc5_amd64_gcc470/external/gcc/4.7.0-cms --with-mpfr=/build/ge/new-binutils/b/tmp/BUILDROOT/a72d117de7727d2dbd542a4ad4d72e45/opt/cmssw/slc5_amd64_gcc470/external/gcc/4.7.0-cms --with-mpc=/build/ge/new-binutils/b/tmp/BUILDROOT/a72d117de7727d2dbd542a4ad4d72e45/opt/cmssw/slc5_amd64_gcc470/external/gcc/4.7.0-cms --with-ppl=/build/ge/new-binutils/b/tmp/BUILDROOT/a72d117de7727d2dbd542a4ad4d72e45/opt/cmssw/slc5_amd64_gcc470/external/gcc/4.7.0-cms --with-cloog=/build/ge/new-binutils/b/tmp/BUILDROOT/a72d117de7727d2dbd542a4ad4d72e45/opt/cmssw/slc5_amd64_gcc470/external/gcc/4.7.0-cms --enable-cloog-backend=isl --enable-shared CC='gcc -fPIC' CXX='c++ -fPIC' CPP=cpp CXXCPP='c++ -E' Thread model: posix gcc version 4.7.1 20120510 (prerelease) (GCC) ld -v GNU gold (GNU Binutils 2.22) 1.11 when complied with -flto and -O2 this simple code cat boostLto.cc #include "boost/thread/mutex.hpp" namespace edm { namespace rootfix { boost::mutex* getGlobalMutex(); } } boost::mutex* edm::rootfix::getGlobalMutex() { static boost::mutex m_; return &m_; } produces c++ -O2 -fPIC -shared -o bha.so boostLto.cc -Iboost/1.49.0/include c++ -O2 -flto -fPIC -shared -o bha.so boostLto.cc -Iboost/1.49.0/include /tmp/innocent/ccwLpwep.ltrans1.ltrans.o:ccwLpwep.ltrans1.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorISt12out_of_rangeEEEE.local.234: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans1.ltrans.o:ccwLpwep.ltrans1.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorISt12out_of_rangeEEEE.local.234: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans1.ltrans.o:ccwLpwep.ltrans1.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorISt12out_of_rangeEEEE.local.234: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans1.ltrans.o:ccwLpwep.ltrans1.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorISt12out_of_rangeEEEE.local.234: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans1.ltrans.o:ccwLpwep.ltrans1.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_9gregorian15bad_day_of_yearEEEEE.local.240: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans1.ltrans.o:ccwLpwep.ltrans1.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_9gregorian15bad_day_of_yearEEEEE.local.240: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans1.ltrans.o:ccwLpwep.ltrans1.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_9gregorian15bad_day_of_yearEEEEE.local.240: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans1.ltrans.o:ccwLpwep.ltrans1.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_9gregorian15bad_day_of_yearEEEEE.local.240: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans1.ltrans.o:ccwLpwep.ltrans1.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_9gregorian16bad_day_of_monthEEEEE.local.232: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans1.ltrans.o:ccwLpwep.ltrans1.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_9gregorian16bad_day_of_monthEEEEE.local.232: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans1.ltrans.o:ccwLpwep.ltrans1.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_9gregorian16bad_day_of_monthEEEEE.local.232: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans1.ltrans.o:ccwLpwep.ltrans1.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_9gregorian16bad_day_of_monthEEEEE.local.232: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans2.ltrans.o:ccwLpwep.ltrans2.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_12bad_weak_ptrEEEEE.local.230: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans2.ltrans.o:ccwLpwep.ltrans2.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_12bad_weak_ptrEEEEE.local.230: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans2.ltrans.o:ccwLpwep.ltrans2.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_12bad_weak_ptrEEEEE.local.230: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans2.ltrans.o:ccwLpwep.ltrans2.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_12bad_weak_ptrEEEEE.local.230: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans5.ltrans.o:ccwLpwep.ltrans5.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_9gregorian11bad_weekdayEEEEE.local.246: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans5.ltrans.o:ccwLpwep.ltrans5.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_9gregorian11bad_weekdayEEEEE.local.246: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans5.ltrans.o:ccwLpwep.ltrans5.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_9gregorian11bad_weekdayEEEEE.local.246: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans5.ltrans.o:ccwLpwep.ltrans5.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_9gregorian11bad_weekdayEEEEE.local.246: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans5.ltrans.o:ccwLpwep.ltrans5.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_21thread_resource_errorEEEEE.local.236: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans5.ltrans.o:ccwLpwep.ltrans5.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_21thread_resource_errorEEEEE.local.236: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans5.ltrans.o:ccwLpwep.ltrans5.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_21thread_resource_errorEEEEE.local.236: warning: relocation refers to discarded section /tmp/innocent/ccwLpwep.ltrans5.ltrans.o:ccwLpwep.ltrans5.o:function _ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_21thread_resource_errorEEEEE.local.236: warning: relocation refers to discarded section