Bug 13287 - g++ -Wl,--as-needed -flto doesn't work with the BFD linker, but with gold
Summary: g++ -Wl,--as-needed -flto doesn't work with the BFD linker, but with gold
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on: 13201
Blocks:
  Show dependency treegraph
 
Reported: 2011-10-12 20:31 UTC by Matthias Klose
Modified: 2011-10-25 03:30 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2011-10-12 20:31:11 UTC
seen with the 2.22 branch (and the fix for pr13250 applied), works with gold, gcc is 4.6 from the branch.


$ cat foo.cc 
int main() {}

$ g++ -B/usr/lib/gold-ld/ -Wl,--as-needed -flto foo.cc
ok

$ $ gcc -Wl,--as-needed -flto foo.cc
ok

$ $ g++ -Wl,--as-needed -flto foo.cc
/lib/i386-linux-gnu/libc.so.6: undefined reference to `_dl_argv@GLIBC_PRIVATE'
/lib/i386-linux-gnu/libc.so.6: undefined reference to `__libc_stack_end@GLIBC_2.1'
/lib/i386-linux-gnu/libc.so.6: undefined reference to `__libc_enable_secure@GLIBC_PRIVATE'
/lib/i386-linux-gnu/libc.so.6: undefined reference to `_rtld_global@GLIBC_PRIVATE'
/lib/i386-linux-gnu/libc.so.6: undefined reference to `___tls_get_addr@GLIBC_2.3'
/lib/i386-linux-gnu/libc.so.6: undefined reference to `_rtld_global_ro@GLIBC_PRIVATE'
collect2: ld returned 1 exit status
Comment 1 Matthias Klose 2011-10-17 10:11:26 UTC
also seen on the trunk.

glibc-2.13 or glibc trunk doesn't make a difference
Comment 2 H.J. Lu 2011-10-17 15:41:05 UTC
It is a regression.
Comment 3 H.J. Lu 2011-10-17 15:56:01 UTC
It is caused by

http://sourceware.org/ml/binutils/2011-09/msg00121.html
Comment 4 Sourceware Commits 2011-10-20 09:51:03 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2011-10-20 09:50:59

Modified files:
	ld             : ChangeLog plugin.c plugin.h ldlang.c 

Log message:
	PR ld/13287
	* plugin.c (plugin_should_reload): New function.
	* plugin.h (plugin_should_reload): Declare.
	* ldlang.c (open_input_bfds): Use above function.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2383&r2=1.2384
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.c.diff?cvsroot=src&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.h.diff?cvsroot=src&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&r1=1.378&r2=1.379
Comment 5 Sourceware Commits 2011-10-25 03:15:13 UTC
CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_22-branch
Changes by:	amodra@sourceware.org	2011-10-25 03:15:08

Modified files:
	ld             : ChangeLog ldlang.c plugin.c plugin.h 

Log message:
	PR ld/13287
	2011-10-20  Alan Modra  <amodra@gmail.com>
	* plugin.c (plugin_should_reload): New function.
	* plugin.h (plugin_should_reload): Declare.
	* ldlang.c (open_input_bfds): Use above function.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.2373.2.6&r2=1.2373.2.7
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.378&r2=1.378.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.c.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.40.2.2&r2=1.40.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.h.diff?cvsroot=src&only_with_tag=binutils-2_22-branch&r1=1.9&r2=1.9.2.1
Comment 6 Alan Modra 2011-10-25 03:30:41 UTC
Fixed.