Bug 25797

Summary: [4.2 Regression] almost all libstdc++ tests fail
Product: gcc Reporter: Andrew Pinski <pinskia>
Component: libstdc++Assignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: normal CC: bkoz, gcc-bugs, hjl.tools, sje
Priority: P3 Keywords: link-failure
Version: 4.2.0   
Target Milestone: 4.2.0   
Host: Target: x86_64-unknown-linux-gnu
Build: Known to work:
Known to fail: Last reconfirmed:
Attachments: correct configure test

Description Andrew Pinski 2006-01-15 17:21:32 UTC
FAIL: 21_strings/basic_string/cons/char/6.cc (test for excess errors)
Excess errors:
/usr/bin/ld: testsuite_abi.o(.text._ZNSs12_S_constructIPcEES0_T_S1_RKSaIcESt20forward_iterator_tag[char* std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_construct<char*>(char*, char*, std::allocator<char> const&, std::forward_iterator_tag)]+0x91): unresolvable relocation against symbol `std::__throw_logic_error(char const*)@@GLIBCXX_3.4'


Seen also on ia64-linux-gnu:
http://gcc.gnu.org/ml/gcc-testresults/2006-01/msg00765.html

I have no idea what is going on here so I filed the bug.
Comment 1 Andrew Pinski 2006-01-15 17:22:18 UTC
Oh and also on powerpc64-linux-gnu:
http://gcc.gnu.org/ml/gcc-testresults/2006-01/msg00755.html
Comment 2 Andrew Pinski 2006-01-15 17:23:09 UTC
This worked with rev 109555.
Comment 3 Paolo Carlini 2006-01-15 18:09:51 UTC
I know what's going on, I saw this with stock binutils 2.16.1 on x86-linux. See:

  http://gcc.gnu.org/ml/libstdc++/2006-01/msg00051.html

And, there is also another issue with --gc-sections, this one:

  http://gcc.gnu.org/ml/libstdc++/2006-01/msg00077.html

which other people are also seeing. Really, I think we have to renounce to the idea, for the time being.
  
Comment 4 Benjamin Kosnik 2006-01-16 22:11:09 UTC
I'm on it. This patch should be a step to fixing this.
Comment 5 Benjamin Kosnik 2006-01-16 22:12:11 UTC
Created attachment 10655 [details]
correct configure test
Comment 6 H.J. Lu 2006-01-17 20:58:55 UTC
The patch doesn't work on Linux/ia64. --gc-sections is ignored on Linux/ia64:

[hjl@gnu-12 tmp]$ gcc -Wl,--gc-sections x.c
/usr/local/bin/ld: Warning: gc-sections option ignored

I got many

/usr/local/bin/ld: Warning: gc-sections option ignored^M
output is:
/usr/local/bin/ld: Warning: gc-sections option ignored^M

FAIL: 17_intro/header_cassert.cc (test for excess errors)
Excess errors:
Comment 7 Benjamin Kosnik 2006-01-19 22:32:25 UTC
paolo I can reproduce this on x86/linux with binutils 2.16.1

                === libstdc++ Summary ===

# of expected passes            3837
# of unexpected failures        134
# of unexpected successes       1
# of expected failures          12
Comment 8 hjl@gcc.gnu.org 2006-01-19 22:36:49 UTC
Subject: Bug 25797

Author: hjl
Date: Thu Jan 19 22:36:41 2006
New Revision: 109985

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=109985
Log:
2006-01-19  H.J. Lu  <hongjiu.lu@intel.com>

	PR libstdc++/25797
	* acinclude.m4 (GLIBCXX_CHECK_LINKER_FEATURES): Remove -Werror
	from CFLAGS.  Check if linker really supports --gc-sections.
	* configure: Regenerated.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/acinclude.m4
    trunk/libstdc++-v3/configure

Comment 9 Benjamin Kosnik 2006-01-20 00:23:06 UTC
H.J, are you seeing this kind of additional symptom with binutils-2.16.1:

FAIL: 21_strings/basic_string/cons/char/6.cc (test for excess errors)
Excess errors:
/mnt/hd/bld/H-x86-binutils-2.16.1/bin/ld: testsuite_abi.o(.text._ZNSs12_S_constructIPcEES0_T_S1_RKSaIcESt20forward_iterator_tag[char* std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_S_construct<char*>(char*, char*, std::allocator<char> const&, std::forward_iterator_tag)]+0x8b): unresolvable relocation against symbol `std::__throw_logic_error(char const*)@@GLIBCXX_3.4'
/mnt/hd/bld/H-x86-binutils-2.16.1/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status

I don't understand how to test for this "unresolvable relocation against symbol" stuff... I see this bug report about this error in another context:

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

I've tried to narrow this down. Indeed, if the compile line for the above error removes -Wl,--gc-sections, the link is fine. So, it appears as if it does do something different.

To make a small case, (ie, so we can then make an autoconf test...). I tried to make a two part test, where you take one file, use all the relevant flags, and make a shared object, which you then compile with some more flags to create an executable. 

However, I cannot reproduce it. 

Any insights? This seems like more your area.

My other thought is to just black-list --gc-sections for binutils pre 2.16.2. It's not a great solution, but I think it will work.

If there is no better idea by tomorrow this is what I'll check in.

-benjamin
Comment 10 H.J. Lu 2006-01-20 01:02:42 UTC
Binutils 2.16.1 is too old. There are so many bug fixes since it was released.
People can try the current Linux binutils at

http://www.kernel.org/pub/linux/devel/binutils/

or get the binutils from CVS.
Comment 11 Andrew Pinski 2006-01-23 15:29:49 UTC
Fixed.