public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug lto/53780] New: [l4.7.1 lto] linker fails with lto and "standard" object file
@ 2012-06-26 15:23 vincenzo.innocente at cern dot ch
  2012-06-28 12:52 ` [Bug lto/53780] " vincenzo.innocente at cern dot ch
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2012-06-26 15:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53780

             Bug #: 53780
           Summary: [l4.7.1 lto] linker fails with lto and "standard"
                    object file
    Classification: Unclassified
           Product: gcc
           Version: 4.7.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: lto
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vincenzo.innocente@cern.ch


here mostly for the record as works with 4.8.0 and it has an easy workaround
it maybe related to PR53337  

either on vanilla fedora 17 
or with
gcc version 4.7.2 20120615 (prerelease) [gcc-4_7-branch revision 188650] (GCC) 
GNU gold (GNU Binutils 2.22.52.20120515) 1.11

linker fails in the following example
c++ -fPIC -std=c++11 -fvisibility-inlines-hidden -O2 -flto -c boostLto.cc
c++ -fPIC -std=c++11 -fvisibility-inlines-hidden -Os  -c boostLto2.cc
echo link ok
c++  -flto -O2 -pthread boostLto2.o boostLto.o  -shared -fPIC -o bha.so
-fvisibility-inlines-hidden -std=c++11
echo link fails
c++  -flto -O2 -pthread boostLto.o boostLto2.o  -shared -fPIC -o bha.so
-fvisibility-inlines-hidden -std=c++11


fedora 17

link ok
link fails
`_ZTIN5boost6detail15sp_counted_baseE' referenced in section
`.data.rel.ro._ZTVN5boost6detail15sp_counted_baseE[_ZTVN5boost6detail15sp_counted_baseE]'
of boostLto2.o: defined in discarded section
`.gnu.linkonce.t._ZTIN5boost6detail15sp_counted_baseE' of boostLto.o (symbol
from plugin)
`_ZThn16_N5boost16exception_detail10clone_implINS0_19error_info_injectorINS_21thread_resource_errorEEEED1Ev'
referenced in section
`.data.rel.ro._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_21thread_resource_errorEEEEE[_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_21thread_resource_errorEEEEE]'
of boostLto2.o: defined in discarded section
`.gnu.linkonce.t._ZN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_21thread_resource_errorEEEED5Ev'
of boostLto.o (symbol from plugin)
`_ZThn16_N5boost16exception_detail10clone_implINS0_19error_info_injectorINS_21thread_resource_errorEEEED0Ev'
referenced in section
`.data.rel.ro._ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_21thread_resource_errorEEEEE[_ZTVN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_21thread_resource_errorEEEEE]'
of boostLto2.o: defined in discarded section
…..
`_ZThn56_N5boost16exception_detail10clone_implINS0_19error_info_injectorINS_21thread_resource_errorEEEED0Ev'
referenced in section `.data.rel.ro' of /tmp/ccnOkzqM.ltrans1.ltrans.o: defined
in discarded section
`.gnu.linkonce.t._ZN5boost16exception_detail10clone_implINS0_19error_info_injectorINS_21thread_resource_errorEEEED0Ev'
of boostLto.o (symbol from plugin)
/bin/ld: bha.so: hidden symbol `.LTHUNK2.3978' isn't defined
/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status


=====================================

with
gcc version 4.7.2 20120615 (prerelease) [gcc-4_7-branch revision 188650] (GCC) 
GNU gold (GNU Binutils 2.22.52.20120515) 1.11

link ok
link fails
boostLto2.o:boostLto2.cc:function vtable for
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::gregorian::bad_day_of_month>
>: warning: relocation refers to discarded section
/afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: error: hidden symbol
'_ZThn16_N5boost16exception_detail10clone_implINS0_19error_info_injectorINS_9gregorian16bad_day_of_monthEEEED1Ev'
is not defined locally
…..
/tmp/innocent/ccZ6RxXH.ltrans1.ltrans.o:ccZ6RxXH.ltrans1.o:function vtable for
boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::gregorian::bad_day_of_year>
> [clone .local.282]: warning: relocation refers to discarded section
/afs/cern.ch/user/i/innocent/w3/gcc47slc5/bin/ld: error: hidden symbol
'_ZThn56_N5boost16exception_detail10clone_implINS0_19error_info_injectorINS_9gregorian15bad_day_of_yearEEEED0Ev'
is not defined locally
collect2: error: ld returned 1 exit status

==================
code
cat boostLto.cc
#include "boost/thread/mutex.hpp"
namespace edm0 {
    boost::mutex* getGlobalMutex();
}

boost::mutex* edm0::getGlobalMutex() { 
    static boost::mutex m_;
    return &m_;
}

[innocent@pcphsftkepler ctest]$ cat boostLto2.cc
#include "boost/thread/mutex.hpp"
namespace edm2 {
    boost::mutex* getGlobalMutex();
}

boost::mutex* edm2::getGlobalMutex() { 
    static boost::mutex m_;
    return &m_;
}

#include "boost/shared_ptr.hpp"
#include "boost/date_time.hpp"
#include "boost/date_time/gregorian/gregorian_types.hpp"
#include "boost/date_time/posix_time/posix_time_types.hpp"
#include "boost/date_time/c_local_time_adjustor.hpp"
typedef boost::posix_time::ptime TimePoint_t;
typedef boost::posix_time::time_duration Duration_t;

#include<string>
#include<sstream>
#include<iomanip>

#include<ctime>

struct A {
  A(){}
  virtual ~A(){}
  A(int j) : i(j){}
int i;
};

struct B {

  A & a() {return *pa;}
  boost::shared_ptr<A> pa;
  int j;

};


boost::shared_ptr<A> make2(int i) {
   return boost::shared_ptr<A>(new A(i));
}


int get2(boost::shared_ptr<A> a) {
  return (*a).i;

}


int get2(B b) {
  return b.a().i; 
}

 std::string dateStamp2(TimePoint_t theTime) {
       typedef boost::date_time::c_local_adjustor<boost::posix_time::ptime>
local_adj;
       tm ptm = boost::posix_time::to_tm( local_adj::utc_to_local(theTime) );
       std::ostringstream dateStampStr;
       dateStampStr << std::setfill('0') << std::setw(4) << ptm.tm_year+1900
                    << std::setfill('0') << std::setw(2) << ptm.tm_mon+1
                    << std::setfill('0') << std::setw(2) << ptm.tm_mday;
       return dateStampStr.str();
}


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-10-11 19:10 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-26 15:23 [Bug lto/53780] New: [l4.7.1 lto] linker fails with lto and "standard" object file vincenzo.innocente at cern dot ch
2012-06-28 12:52 ` [Bug lto/53780] " vincenzo.innocente at cern dot ch
2012-06-29  6:11 ` vincenzo.innocente at cern dot ch
2012-06-29  7:39 ` vincenzo.innocente at cern dot ch
2012-06-29 10:34 ` vincenzo.innocente at cern dot ch
2012-06-29 10:51 ` rguenth at gcc dot gnu.org
2012-06-29 13:20 ` vincenzo.innocente at cern dot ch
2012-06-29 13:46 ` rguenth at gcc dot gnu.org
2012-06-29 15:03 ` vincenzo.innocente at cern dot ch
2012-06-29 15:31 ` vincenzo.innocente at cern dot ch
2012-06-30 15:24 ` vincenzo.innocente at cern dot ch
2012-10-11 19:10 ` matt at use dot net

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).