Bug 53337 - 4.7.1 lto produces warning: relocation refers to discarded section in linker (gold, binutil 2.22)
Summary: 4.7.1 lto produces warning: relocation refers to discarded section in linker ...
Status: RESOLVED DUPLICATE of bug 53768
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.7.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: lto
Depends on:
Blocks:
 
Reported: 2012-05-13 16:42 UTC by vincenzo Innocente
Modified: 2012-06-29 10:45 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work: 4.8.0
Known to fail:
Last reconfirmed:


Attachments
preprocessed file (for those not having boost) (121.95 KB, application/x-bzip2)
2012-05-14 07:39 UTC, vincenzo Innocente
Details

Note You need to log in before you can comment on or make changes to this bug.
Description vincenzo Innocente 2012-05-13 16:42:02 UTC
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
Comment 1 vincenzo Innocente 2012-05-14 07:39:45 UTC
Created attachment 27397 [details]
preprocessed file (for those not having boost)
Comment 2 H.J. Lu 2012-05-14 13:28:56 UTC
Have you tried gold and ld in binutils trunk?
Comment 3 vincenzo Innocente 2012-05-14 14:08:04 UTC
I will try the trunk go binutils.
Still I confirm that this warning does not appear at all (in real-life code, not just in the attached test case) with gcc 4.8
Comment 4 vincenzo Innocente 2012-05-15 10:19:29 UTC
tested with latest binutil
no change (but nicer error message)

GNU gold (GNU Binutils 2.22.52.20120515) 1.11
/tmp/innocent/ccIKFOKY.ltrans1.ltrans.o:ccIKFOKY.ltrans1.o:function vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::out_of_range> > [clone .local.234]: warning: relocation refers to discarded section
/tmp/innocent/ccIKFOKY.ltrans1.ltrans.o:ccIKFOKY.ltrans1.o:function vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<std::out_of_range> > [clone .local.234]: warning: relocation refers to discarded section
….
Comment 5 vincenzo Innocente 2012-06-29 10:45:05 UTC
get rid of one,  move to 53768

*** This bug has been marked as a duplicate of bug 53768 ***