Using gold on ppc64, qt5 doesn't build because of r218024. See https://sourceware.org/bugzilla/show_bug.cgi?id=17670 for further analysis by Alan. trippels@gcc2-power8 corelib % cat qmimeglobpattern.ii class G; class A { public: A (G); }; class B { public: int m_fn1 (); }; class QString; struct C { B ref; }; template <typename> class QList { C d; public: ~QList (); void m_fn2 (); void m_fn3 (); }; class G : public QList<QString> { }; struct D { void m_fn4 (const QString &&); G m_matchingMimeTypes; }; class F { G m_fn5 (const QString &) const; }; template <typename T> QList<T>::~QList () { if (d.ref.m_fn1 ()) m_fn3 (); } template <typename T> void QList<T>::m_fn2 () { QList (); } void D::m_fn4 (const QString &&) { m_matchingMimeTypes.m_fn2 (); } G F::m_fn5 (const QString &) const { G a; for (A b (a);;) ; } trippels@gcc2-power8 corelib % cat qmimeprovider.ii class A { public: int m_fn1 (); }; class QString { public: static QString m_fn2 (char *); }; struct B { A ref; }; template <typename> class QList { B d; public: ~QList (); class const_iterator { }; const_iterator m_fn3 (); void m_fn4 (); }; class C { QList<QString> c; QList<QString>::const_iterator i; public: C (QList<QString>) : i (c.m_fn3 ()) {} }; class D { public: enum StandardLocation { GenericDataLocation }; static QList<QString> m_fn5 (StandardLocation, QString); }; QList<QString> a = D::m_fn5 (D::GenericDataLocation, QString::m_fn2 ("")); template <typename T> QList<T>::~QList () { if (d.ref.m_fn1 ()) m_fn4 (); } void fn1 () { C b (a); } trippels@gcc2-power8 corelib % g++ -shared -w -O3 -fvisibility=hidden -std=c++0x qmimeglobpattern.ii qmimeprovider.ii /home/trippels/bin/ld: internal error in symval_for_branch, at powerpc.cc:6755
This reduced testcase is undefined C++ because of One definition rule violation.
And the linker shouldn't crash on any input...
Created attachment 34177 [details] unreduced testcase (without ODR violation)
With the unreduced testcase this issue also happens on x86_64 with gold: markus@x4 /tmp % g++ -w -shared -fPIC -O2 -fvisibility=hidden -std=c++0x qmimeglobpattern.ii qmimeprovider.ii markus@x4 /tmp % g++ -w -shared -fPIC -O3 -fvisibility=hidden -std=c++0x qmimeglobpattern.ii qmimeprovider.ii /usr/bin/ld: error: /tmp/ccpdsACp.o: requires dynamic R_X86_64_PC32 reloc against '_ZN5QListI7QStringED1Ev' which may overflow at runtime; recompile with -fPIC /tmp/ccpdsACp.o:qmimeprovider.cpp:function QMimeXMLProvider::ensureLoaded(): warning: relocation refers to discarded section /tmp/ccpdsACp.o:qmimeprovider.cpp:function QMimeXMLProvider::listAliases(QString const&): warning: relocation refers to discarded section /tmp/ccpdsACp.o:qmimeprovider.cpp:function QMimeXMLProvider::listAliases(QString const&): warning: relocation refers to discarded section /tmp/ccpdsACp.o:qmimeprovider.cpp:function QMimeBinaryProvider::checkCache(): warning: relocation refers to discarded section /tmp/ccpdsACp.o:qmimeprovider.cpp:function QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate&): warning: relocation refers to discarded section /tmp/ccpdsACp.o:qmimeprovider.cpp:function QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate&): warning: relocation refers to discarded section /tmp/ccpdsACp.o:qmimeprovider.cpp:function QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate&): warning: relocation refers to discarded section collect2: error: ld returned 1 exit status (ld.bfd is fine:) markus@x4 /tmp % g++ -w -shared -fPIC -O3 -fvisibility=hidden -std=c++0x qmimeglobpattern.ii qmimeprovider.ii markus@x4 /tmp %
Honza, this might well be another gold bug (on x86_64). With Alan's gold fix the unreduced testcase now compiles fine on ppc64 (with a few "relocation refers to discarded section" warnings).
No, this is not a gold bug on x86_64. ld.bfd may link without complaint, but the resulting shared library will crash, I think. There are calls to _ZN5QListI7QStringED1Ev which resolve to 0 (ie. the ELF header in the shared lib). This seems to be a fairly recent bug. On x86_64, 20141126 and 20141203 miscompile the unreduced testcase while 20141111 looks to be OK. You can easily see whether there is a problme by running nm *.o | grep _ZN5QListI7QStringED 0000000000000000 W _ZN5QListI7QStringED2Ev 0000000000000000 n _ZN5QListI7QStringED5Ev 0000000000000000 W _ZN5QListI7QStringED1Ev 0000000000000000 W _ZN5QListI7QStringED2Ev 0000000000000000 n _ZN5QListI7QStringED5Ev If as above you see only one copy of _ZN5QListI7QStringED1Ev, then only one of the two comdat groups define that symbol.
Here is another reduced testcase. This time hopefully without and ODR issues. % cat qmimeglobpattern.ii class A { public: bool deref (); }; class QString; struct B { A ref; }; template <typename> class QList { B d; public: ~QList (); class const_iterator { }; const_iterator constBegin (); void clear (); void dealloc (); }; template <typename T> QList<T>::~QList () { if (d.ref.deref ()) dealloc (); } template <typename T> void QList<T>::clear () { QList (); } class A1 : public QList<QString> { }; class B1 { public: B1 (A1); }; struct F { void addMatch (const QString &&); A1 m_matchingMimeTypes; }; class G { A1 matchingGlobs (const QString &) const; }; void F::addMatch (const QString &&) { m_matchingMimeTypes.clear (); } A1 G::matchingGlobs (const QString &) const { A1 a; for (B1 b (a);;) ; } % cat qmimeprovider.ii class A { public: bool deref (); }; class QString; struct B { A ref; }; template <typename> class QList { B d; public: ~QList (); class const_iterator { }; const_iterator constBegin (); void clear (); void dealloc (); }; class C { QList<QString> c; QList<QString>::const_iterator i; public: C (QList<QString>) : i (c.constBegin ()) {} }; template <typename T> QList<T>::~QList () { if (d.ref.deref ()) dealloc (); } void fn1 () { QList<QString> a; C b (a); } % g++ -fuse-ld=bfd -shared -fPIC -O3 -fvisibility=hidden -std=c++0x qmimeglobpattern.ii qmimeprovider.ii % g++ -fuse-ld=gold -shared -fPIC -O3 -fvisibility=hidden -std=c++0x qmimeglobpattern.ii qmimeprovider.ii /usr/bin/ld.gold: error: /tmp/ccRfiSrB.o: requires dynamic R_X86_64_PC32 reloc against '_ZN5QListI7QStringED1Ev' which may overflow at runtime; recompile with -fPIC /tmp/ccRfiSrB.o:qmimeprovider.ii:function fn1(): warning: relocation refers to discarded section /tmp/ccRfiSrB.o:qmimeprovider.ii:function fn1(): warning: relocation refers to discarded section /tmp/ccRfiSrB.o:qmimeprovider.ii:function fn1(): warning: relocation refers to discarded section collect2: error: ld returned 1 exit status
(In reply to Markus Trippelsdorf from comment #7) > Here is another reduced testcase. This time hopefully without and ODR issues. > > % cat qmimeglobpattern.ii > class A > { > public: > bool deref (); > }; > class QString; > struct B > { > A ref; > }; > template <typename> class QList > { > B d; > public: > ~QList (); > class const_iterator > { > }; > const_iterator constBegin (); > void clear (); > void dealloc (); > }; > template <typename T> QList<T>::~QList () > { > if (d.ref.deref ()) > dealloc (); > } > template <typename T> > void > QList<T>::clear () > { > QList (); > } > class A1 : public QList<QString> > { > }; > class B1 > { > public: > B1 (A1); > }; > struct F > { > void addMatch (const QString &&); > A1 m_matchingMimeTypes; > }; > class G > { > A1 matchingGlobs (const QString &) const; > }; > void > F::addMatch (const QString &&) > { > m_matchingMimeTypes.clear (); > } > A1 > G::matchingGlobs (const QString &) const > { > A1 a; > for (B1 b (a);;) > ; > } > > % cat qmimeprovider.ii > class A > { > public: > bool deref (); > }; > class QString; > struct B > { > A ref; > }; > template <typename> class QList > { > B d; > public: > ~QList (); > class const_iterator > { > }; > const_iterator constBegin (); > void clear (); > void dealloc (); > }; > > class C > { > QList<QString> c; > QList<QString>::const_iterator i; > > public: > C (QList<QString>) : i (c.constBegin ()) {} > }; > template <typename T> QList<T>::~QList () > { > if (d.ref.deref ()) > dealloc (); > } > > void > fn1 () > { > QList<QString> a; > C b (a); > } > > % g++ -fuse-ld=bfd -shared -fPIC -O3 -fvisibility=hidden -std=c++0x > qmimeglobpattern.ii qmimeprovider.ii > % g++ -fuse-ld=gold -shared -fPIC -O3 -fvisibility=hidden -std=c++0x > qmimeglobpattern.ii qmimeprovider.ii > /usr/bin/ld.gold: error: /tmp/ccRfiSrB.o: requires dynamic R_X86_64_PC32 > reloc against '_ZN5QListI7QStringED1Ev' which may overflow at runtime; > recompile with -fPIC > /tmp/ccRfiSrB.o:qmimeprovider.ii:function fn1(): warning: relocation refers > to discarded section > /tmp/ccRfiSrB.o:qmimeprovider.ii:function fn1(): warning: relocation refers > to discarded section > /tmp/ccRfiSrB.o:qmimeprovider.ii:function fn1(): warning: relocation refers > to discarded section > collect2: error: ld returned 1 exit status This is caused by r218024.
this ought to be fixed now (dup pf the profiledbootstrap and chromium issue)
Author: trippels Date: Fri Jan 16 11:12:52 2015 New Revision: 219721 URL: https://gcc.gnu.org/viewcvs?rev=219721&root=gcc&view=rev Log: g++.dg/ipa/pr64612.C: New test. 2015-01-16 Markus Trippelsdorf <markus@trippelsdorf.de> PR ipa/64163 PR ipa/64612 * g++.dg/ipa/pr64612.C: New test. Added: trunk/gcc/testsuite/g++.dg/ipa/pr64612.C Modified: trunk/gcc/testsuite/ChangeLog
*** This bug has been marked as a duplicate of bug 64612 ***
*** Bug 64653 has been marked as a duplicate of this bug. ***