Bug 64163 - [5 Regression] r218024 causes qt5 build failure
Summary: [5 Regression] r218024 causes qt5 build failure
Status: RESOLVED DUPLICATE of bug 64612
Alias: None
Product: gcc
Classification: Unclassified
Component: ipa (show other bugs)
Version: 5.0
: P1 normal
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
: 64653 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-12-03 07:57 UTC by Markus Trippelsdorf
Modified: 2015-01-18 09:51 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-12-04 00:00:00


Attachments
unreduced testcase (without ODR violation) (467.91 KB, application/x-bzip)
2014-12-03 08:11 UTC, Markus Trippelsdorf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2014-12-03 07:57:06 UTC
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
Comment 1 Andrew Pinski 2014-12-03 08:00:46 UTC
This reduced testcase is undefined C++ because of One definition rule violation.
Comment 2 Jakub Jelinek 2014-12-03 08:03:47 UTC
And the linker shouldn't crash on any input...
Comment 3 Markus Trippelsdorf 2014-12-03 08:11:52 UTC
Created attachment 34177 [details]
unreduced testcase (without ODR violation)
Comment 4 Markus Trippelsdorf 2014-12-03 08:46:24 UTC
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 %
Comment 5 Markus Trippelsdorf 2014-12-03 16:59:18 UTC
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).
Comment 6 Alan Modra 2014-12-03 22:18:07 UTC
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.
Comment 7 Markus Trippelsdorf 2014-12-04 07:17:14 UTC
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
Comment 8 H.J. Lu 2014-12-04 19:33:23 UTC
(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.
Comment 9 Jan Hubicka 2015-01-16 04:59:10 UTC
this ought to be fixed now (dup pf the profiledbootstrap and chromium issue)
Comment 10 Markus Trippelsdorf 2015-01-16 11:13:25 UTC
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
Comment 11 Markus Trippelsdorf 2015-01-16 11:23:07 UTC

*** This bug has been marked as a duplicate of bug 64612 ***
Comment 12 Markus Trippelsdorf 2015-01-18 09:51:58 UTC
*** Bug 64653 has been marked as a duplicate of this bug. ***