Bug 12696 - BFD linker fails GCC LTO tests
Summary: BFD linker fails GCC LTO tests
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:
Blocks:
 
Reported: 2011-04-22 22:30 UTC by H.J. Lu
Modified: 2014-04-07 17:08 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 H.J. Lu 2011-04-22 22:30:51 UTC
BFD linker in CVS trunk failed GCC LTO tests:

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

On Linux/x86, I got

FAIL: g++.dg/lto/20081109-1 cp_lto_20081109-1_0.o-cp_lto_20081109-1_0.o link, -fPIC -flto -flto-partition=1to1
FAIL: g++.dg/lto/20081118 cp_lto_20081118_0.o-cp_lto_20081118_1.o link, -fPIC -flto -flto-partition=1to1 -r -nostdlib
FAIL: g++.dg/lto/20081125 cp_lto_20081125_0.o-cp_lto_20081125_1.o link, -flto -flto-partition=1to1
FAIL: g++.dg/lto/20081204-1 cp_lto_20081204-1_0.o-cp_lto_20081204-1_1.o link, -flto -flto-partition=1to1 -fPIC -r -nostdlib
FAIL: g++.dg/lto/20081219 cp_lto_20081219_0.o-cp_lto_20081219_1.o link, -fPIC -flto -flto-partition=1to1 -O2
FAIL: g++.dg/lto/20090302 cp_lto_20090302_0.o-cp_lto_20090302_1.o link, -fPIC -flto -flto-partition=1to1 -r -nostdlib
FAIL: g++.dg/lto/20091026-1 cp_lto_20091026-1_0.o-cp_lto_20091026-1_1.o link, -O0 -flto -flto-partition=none 
FAIL: g++.dg/lto/20091026-1 cp_lto_20091026-1_0.o-cp_lto_20091026-1_1.o link, -O0 -flto -flto-partition=1to1 
FAIL: g++.dg/lto/20091026-1 cp_lto_20091026-1_0.o-cp_lto_20091026-1_1.o link, -O0 -flto
FAIL: g++.dg/lto/20100724-1 cp_lto_20100724-1_0.o-cp_lto_20100724-1_0.o link, -ftoplevel-reorder -flto -flto-partition=none
FAIL: g++.dg/lto/20100724-1 cp_lto_20100724-1_0.o-cp_lto_20100724-1_0.o link, -ftoplevel-reorder -flto -flto-partition=1to1
FAIL: g++.dg/lto/20081109-1 cp_lto_20081109-1_0.o-cp_lto_20081109-1_0.o link, -fPIC -flto -flto-partition=1to1
FAIL: g++.dg/lto/20081118 cp_lto_20081118_0.o-cp_lto_20081118_1.o link, -fPIC -flto -flto-partition=1to1 -r -nostdlib
FAIL: g++.dg/lto/20081125 cp_lto_20081125_0.o-cp_lto_20081125_1.o link, -flto -flto-partition=1to1
FAIL: g++.dg/lto/20081204-1 cp_lto_20081204-1_0.o-cp_lto_20081204-1_1.o link, -flto -flto-partition=1to1 -fPIC -r -nostdlib
FAIL: g++.dg/lto/20081219 cp_lto_20081219_0.o-cp_lto_20081219_1.o link, -fPIC -flto -flto-partition=1to1 -O2
FAIL: g++.dg/lto/20090302 cp_lto_20090302_0.o-cp_lto_20090302_1.o link, -fPIC -flto -flto-partition=1to1 -r -nostdlib
FAIL: g++.dg/lto/20091026-1 cp_lto_20091026-1_0.o-cp_lto_20091026-1_1.o link, -O0 -flto -flto-partition=none 
FAIL: g++.dg/lto/20091026-1 cp_lto_20091026-1_0.o-cp_lto_20091026-1_1.o link, -O0 -flto -flto-partition=1to1 
FAIL: g++.dg/lto/20091026-1 cp_lto_20091026-1_0.o-cp_lto_20091026-1_1.o link, -O0 -flto
FAIL: g++.dg/lto/20100724-1 cp_lto_20100724-1_0.o-cp_lto_20100724-1_0.o link, -ftoplevel-reorder -flto -flto-partition=none
FAIL: g++.dg/lto/20100724-1 cp_lto_20100724-1_0.o-cp_lto_20100724-1_0.o link, -ftoplevel-reorder -flto -flto-partition=1to1

Failure looks like

output is:
`_ZTS3Foo' referenced in section `.data.rel.ro._ZTI3Foo[_ZTI3Foo]' of /tmp/ccj4EMTF.ltrans0.ltrans.o: defined in discarded section `.text' of cp_lto_20081109-1_0.o (symbol from plugin)^M 
`_ZTI3Foo' referenced in section `.data.DW.ref._ZTI3Foo[DW.ref._ZTI3Foo]' of /tmp/ccj4EMTF.ltrans0.ltrans.o: defined in discarded section `.text' of cp_lto_20081109-1_0.o (symbol from plugin)^M 
collect2: ld returned 1 exit status^M
Comment 1 Alan Modra 2011-04-23 13:06:00 UTC
I saw the errors too, and wrote them off incorrectly as gcc errors.  When we have a weakly defined symbol in an IR bfd, it isn't overridden by a weakly defined symbol in the real bfd, as per the usual behaviour of weak symbols.  I'm testing a patch to plugin_notice that overcomes this problem (and does away with plugin_multiple and plugin_multiple_common).
Comment 2 H.J. Lu 2011-04-23 14:39:06 UTC
I added a testcase on hjl/lto-test branch at

http://git.kernel.org/?p=devel/binutils/hjl/x86.git;a=summary

With GCC 4.6, I got

FAIL: PR ld/12696
FAIL: ld-plugin/lto-4r-a
FAIL: ld-plugin/lto-4r-b
FAIL: ld-plugin/lto-4r-c
FAIL: ld-plugin/lto-4r-d
FAIL: LTO 4a
FAIL: LTO 4c
FAIL: LTO 4d
FAIL: LTO 10

The other failures are fixed by

http://sourceware.org/ml/binutils/2011-04/msg00295.html
Comment 3 Sourceware Commits 2011-04-24 10:02:19 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2011-04-24 10:02:14

Modified files:
	include        : ChangeLog bfdlink.h 
	bfd            : ChangeLog coff-aux.c linker.c elflink.c 
	ld             : ChangeLog ldmain.c plugin.c 

Log message:
	PR ld/12365
	PR ld/12696
	include/
	* bfdlink.h (ENUM_BITFIELD): Define.
	(struct bfd_link_hash_entry): Make "type" a bitfield.  Add "non_ir_ref".
	(struct bfd_link_callbacks <notice>): Pass bfd_link_hash_entry pointer
	rather than "name".
	bfd/
	* coff-aux.c (coff_m68k_aux_link_add_one_symbol): Update "notice" call.
	* linker.c (_bfd_link_hash_newfunc): Clear bitfields.
	(_bfd_generic_link_add_one_symbol): Update "notice" call.
	* elflink.c (_bfd_elf_merge_symbol): Don't skip weak redefs when
	it is a redef of an IR symbol in a real BFD.
	ld/
	* ldmain.c (notice): Delete "name" param, add "h".
	* plugin.c (plugin_notice): Likewise.  Set non_ir_ref.  Handle
	redefinitions of IR symbols in real BFDs.
	(plugin_multiple_definition, plugin_multiple_common): Delete.
	(non_ironly_hash, init_non_ironly_hash): Delete.
	(is_visible_from_outside): Traverse entry_symbol chain.
	(get_symbols): Use non_ir_ref flag rather than hash lookup.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/ChangeLog.diff?cvsroot=src&r1=1.527&r2=1.528
http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/bfdlink.h.diff?cvsroot=src&r1=1.83&r2=1.84
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5318&r2=1.5319
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/coff-aux.c.diff?cvsroot=src&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/linker.c.diff?cvsroot=src&r1=1.80&r2=1.81
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&r1=1.401&r2=1.402
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2321&r2=1.2322
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldmain.c.diff?cvsroot=src&r1=1.153&r2=1.154
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.c.diff?cvsroot=src&r1=1.32&r2=1.33
Comment 4 Sourceware Commits 2011-04-27 07:17:51 UTC
CVSROOT:	/cvs/src
Module name:	src
Branch: 	binutils-2_21-branch
Changes by:	amodra@sourceware.org	2011-04-27 07:17:45

Modified files:
	bfd            : ChangeLog bfd-in2.h bfd.c coff-aux.c elf-bfd.h 
	                 elf.c elf32-i386.c elf32-ppc.c elf32-sparc.c 
	                 elf64-ppc.c elf64-sparc.c elf64-x86-64.c 
	                 elfcode.h elflink.c linker.c opncls.c plugin.c 
	                 simple.c xcofflink.c 
	gas/testsuite  : ChangeLog 
	gas/testsuite/gas/elf: elf.exp 
	include        : ChangeLog bfdlink.h 
	ld             : ChangeLog ld.texinfo ldfile.c ldlang.c ldlang.h 
	                 ldmain.c lexsup.c plugin.c plugin.h 
	ld/testsuite   : ChangeLog 
	ld/testsuite/ld-plugin: plugin-7.d plugin-8.d plugin.exp 
Added files:
	gas/testsuite/gas/elf: section9.d section9.s 
	ld/testsuite/ld-plugin: plugin-12.d 
	ld/testsuite/ld-unique: unique.exp unique.s unique_empty.s 
	                        unique_shared.s 

Log message:
	PR ld/12696
	PR ld/12672
	PR ld/12507
	PR ld/12365
	PR 10549
	Backport fixes for these PRs.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.5180.2.26&r2=1.5180.2.27
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/bfd-in2.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.522.2.1&r2=1.522.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/bfd.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.114.2.1&r2=1.114.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/coff-aux.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.10&r2=1.10.10.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf-bfd.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.313.2.1&r2=1.313.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.524.2.1&r2=1.524.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-i386.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.241&r2=1.241.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-ppc.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.290.2.2&r2=1.290.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf32-sparc.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.94&r2=1.94.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-ppc.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.339.2.7&r2=1.339.2.8
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-sparc.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.124&r2=1.124.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elf64-x86-64.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.202&r2=1.202.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elfcode.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.103&r2=1.103.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.388.2.1&r2=1.388.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/linker.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.77.2.1&r2=1.77.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/opncls.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.66&r2=1.66.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/plugin.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.9.2.1&r2=1.9.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/simple.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.34&r2=1.34.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/xcofflink.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.76.2.1&r2=1.76.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1802.2.8&r2=1.1802.2.9
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/section9.d.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/section9.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/gas/testsuite/gas/elf/elf.exp.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.69.2.1&r2=1.69.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.510.2.1&r2=1.510.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/include/bfdlink.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.82&r2=1.82.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.2222.2.18&r2=1.2222.2.19
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ld.texinfo.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.267.2.1&r2=1.267.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldfile.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.58.2.1&r2=1.58.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.347.2.2&r2=1.347.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.91.2.1&r2=1.91.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldmain.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.145.2.2&r2=1.145.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/lexsup.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.120.2.1&r2=1.120.2.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.c.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.7.2.3&r2=1.7.2.4
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.h.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.2.2.2&r2=1.2.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1322.2.8&r2=1.1322.2.9
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-12.d.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-7.d.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-8.d.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.1&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin.exp.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=1.5&r2=1.5.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-unique/unique.exp.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-unique/unique.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-unique/unique_empty.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-unique/unique_shared.s.diff?cvsroot=src&only_with_tag=binutils-2_21-branch&r1=NONE&r2=1.1.2.1
Comment 5 Alan Modra 2011-04-27 07:39:35 UTC
fixed
Comment 6 Sourceware Commits 2014-04-07 17:08:46 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  17c34b8f3d79369cfb3a3f9d37109a7051bd8ea4 (commit)
      from  86ad98c392e804eae299eb6226e16732a521a9b4 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=17c34b8f3d79369cfb3a3f9d37109a7051bd8ea4

commit 17c34b8f3d79369cfb3a3f9d37109a7051bd8ea4
Author: Andreas Schwab <schwab@linux-m68k.org>
Date:   Sat Apr 5 22:03:44 2014 +0200

    Fix spurious failures in ld-plugin/lto.exp
    
    * ld-plugin/lto.exp: Make "-Wp," prefix optional when filtering
    out _FORTIFY_SOURCE.
    ("Build libdummy.a 9", "PR ld/12696"): Mark as c++.

-----------------------------------------------------------------------

Summary of changes:
 ld/testsuite/ChangeLog         |    6 ++++++
 ld/testsuite/ld-plugin/lto.exp |    8 ++++----
 2 files changed, 10 insertions(+), 4 deletions(-)