Bug 12672 - LTO on powerpc will not work with static libraries
Summary: LTO on powerpc will not work with static libraries
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.22
: P2 critical
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-13 21:22 UTC by Michael Meissner
Modified: 2011-04-27 07:41 UTC (History)
3 users (show)

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


Attachments
Tar file to show the problem (1.83 KB, application/x-bzip2)
2011-04-13 21:22 UTC, Michael Meissner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Meissner 2011-04-13 21:22:37 UTC
Created attachment 5670 [details]
Tar file to show the problem

I built binutils for powerpc64-linux that was the top of the tree from April 12th, adding the --enable-plugins

I then built a GCC compiler that was top of the tree from April 13ths, using that binutils for the target assembler, linker, etc.  I added the options: --with-plugin-ld=<path> --enable-plugin and --enable-lto to enable LTO.

I then tried a case where I was enabling vectorization of the math functions on power7 with -ffast-math -mcpu=power7 -mveclibabi=mass, and I get undefined errors (the MASS library is only available as static archives).  If I extract the objects and put them on the link line manually, it works fine.  If I create a shared library with these objects and use that, it also works.  However, if I use a static library, I get undefined errors.

I built a sample test case to try this out that is the attachment.  In this case, when linking test-lto1-static, I get:

-igoo-> make clean; make CC=/home/meissner/fsf-install-ppc64/trunk/bin/gcc all
rm -f *.[osia] *.so *.so.1 test-lto1-shared test-lto1-static all
/home/meissner/fsf-install-ppc64/trunk/bin/gcc -O3 -mcpu=power7 -mveclibabi=mass -ffast-math -flto -fwhole-program -fuse-linker-plugin -c test-lto1-a.c
/home/meissner/fsf-install-ppc64/trunk/bin/gcc -O3 -mcpu=power7 -mveclibabi=mass -ffast-math -flto -fwhole-program -fuse-linker-plugin -c test-lto1-b.c
/home/meissner/fsf-install-ppc64/trunk/bin/gcc -O3 -mcpu=power7 -mveclibabi=mass -ffast-math -flto -fwhole-program -fuse-linker-plugin -fpic -c test-lto1-c.c
rm -f liblto1-shared.so.1
/home/meissner/fsf-install-ppc64/trunk/bin/gcc -shared -o liblto1-shared.so.1 -Wl,-soname,liblto1-shared.so.1 test-lto1-c.o
rm -f liblto1-shared.so
ln -s liblto1-shared.so.1 liblto1-shared.so
/home/meissner/fsf-install-ppc64/trunk/bin/gcc -o test-lto1-shared -O3 -mcpu=power7 -mveclibabi=mass -ffast-math -flto -fwhole-program -fuse-linker-plugin  test-lto1-a.o test-lto1-b.o -L . -Wl,-rpath,$(pwd) -llto1-shared -lm
rm -f liblto1-static.a
ar cq liblto1-static.a test-lto1-c.o
ranlib liblto1-static.a
/home/meissner/fsf-install-ppc64/trunk/bin/gcc -o test-lto1-static -O3 -mcpu=power7 -mveclibabi=mass -ffast-math -flto -fwhole-program -fuse-linker-plugin  test-lto1-a.o test-lto1-b.o -L . -llto1-static -lm
/tmp/ccLckNND.ltrans0.ltrans.o:(.text.startup+0xc4): undefined reference to `sind2'
collect2: ld returned 1 exit status
make: *** [test-lto1-static] Error 1
Comment 1 Michael Meissner 2011-04-13 21:25:10 UTC
Ian Taylor has said that gold fixes this problem.  Unfortunately, gold does not work for powerpc64-linux.

http://sourceware.org/ml/binutils/2011-01/msg00270.html
Comment 2 H.J. Lu 2011-04-14 17:30:10 UTC
You can try hjl/lto-mixed branch at

http://git.kernel.org/?p=devel/binutils/hjl/x86.git;a=summary
Comment 3 Alan Modra 2011-04-15 00:34:53 UTC
I have implemented archive rescan for ld.  In the process of testing
Comment 4 cvs-commit@gcc.gnu.org 2011-04-15 03:47:34 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2011-04-15 03:47:30

Modified files:
	ld             : ChangeLog ldlang.c 

Log message:
	PR ld/12672
	* ldlang.c (enum open_bfd_mode): New.
	(open_input_bfds): Replace "force" param with "mode".  Reload
	archives for rescan.  Update all callers.
	(lang_process): Make another open_input_bfds pass for plugins.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2311&r2=1.2312
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&r1=1.364&r2=1.365
Comment 5 cvs-commit@gcc.gnu.org 2011-04-17 23:15:18 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2011-04-17 23:15:13

Modified files:
	bfd            : bfd.c bfd-in2.h elflink.c opncls.c 
	ld             : ldfile.c ldmain.c ldlang.c plugin.h plugin.c 
	ld/testsuite/ld-plugin: plugin-7.d plugin-8.d plugin.exp 
Added files:
	ld/testsuite/ld-plugin: plugin-12.d 

Log message:
	PR ld/12365
	PR ld/12672
	bfd/
	* bfd.c (BFD_PLUGIN): Define.
	(BFD_FLAGS_SAVED, BFD_FLAGS_FOR_BFD_USE_MASK): Add BFD_PLUGIN.
	* bfd-in2.h: Regenerate.
	* elflink.c (elf_link_output_extsym): Strip undefined plugin syms.
	* opncls.c (bfd_make_readable): Don't lose original bfd flags.
	ld/
	* ldfile.c (ldfile_try_open_bfd): Don't attempt any plugin action
	when no_more_claiming.
	* ldmain.c (add_archive_element): Likewise.
	(multiple_definition): Remove plugin_multiple_definition call.
	(notice): Remove plugin_notice call.
	* ldlang.c (lang_list_insert_after, void lang_list_remove_tail): Move.
	Delete prototype.
	(plugin_insert): New static var.
	(open_input_bfds): Only rescan libs after plugin insert point.
	(lang_gc_sections): Omit plugin claimed files.
	(lang_process): Set plugin_insert.  Only rescan when plugin adds
	objects.
	* plugin.h (no_more_claiming): Declare.
	(plugin_notice, plugin_multiple_definition): Don't declare.
	* plugin.c: Formatting.
	(orig_notice_all, orig_allow_multiple_defs, orig_callbacks,
	plugin_callbacks): New static vars.
	(no_more_claiming): Make global.
	(plugin_cached_allow_multiple_defs): Delete.
	(plugin_get_ir_dummy_bfd): Set SEC_EXCLUDE on dummy .text section,
	use newer bfd_make_section variant.  Make COMMON section too.
	Error handling.  Correct setting of gp size.
	(asymbol_from_plugin_symbol): Properly cast last arg of concat.
	(message): Likewise for ACONCAT.
	(asymbol_from_plugin_symbol): Use our COMMON section.
	(get_symbols): When report_plugin_symbols, show visibility too.
	(init_non_ironly_hash): Move.  Don't test non_ironly_hash.
	(plugin_load_plugins): Save state of linker callbacks, set up to
	call plugin_notice instead.  Call init_non_ironly_hash here.
	(plugin_call_all_symbols_read): Set plugin_multiple_definition in
	plugin callbacks.
	(plugin_notice): Rewrite.
	(plugin_multiple_definition): Make static, call original callback.
	ld/testsuite/
	* ld-plugin/plugin-7.d: Adjust for plugin changes.
	* ld-plugin/plugin-8.d: Likewise.
	* ld-plugin/plugin.exp: Pass --verbose=2 for visibility test, and
	compare ld output to..
	* ld-plugin/plugin-12.d: New.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/bfd.c.diff?cvsroot=src&r1=1.115&r2=1.116
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/bfd-in2.h.diff?cvsroot=src&r1=1.532&r2=1.533
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/elflink.c.diff?cvsroot=src&r1=1.396&r2=1.397
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/opncls.c.diff?cvsroot=src&r1=1.66&r2=1.67
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldfile.c.diff?cvsroot=src&r1=1.61&r2=1.62
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldmain.c.diff?cvsroot=src&r1=1.150&r2=1.151
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ldlang.c.diff?cvsroot=src&r1=1.365&r2=1.366
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.h.diff?cvsroot=src&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/plugin.c.diff?cvsroot=src&r1=1.29&r2=1.30
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-12.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-7.d.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin-8.d.diff?cvsroot=src&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-plugin/plugin.exp.diff?cvsroot=src&r1=1.6&r2=1.7
Comment 6 cvs-commit@gcc.gnu.org 2011-04-17 23:18:27 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	amodra@sourceware.org	2011-04-17 23:18:24

Modified files:
	bfd            : ChangeLog 
	ld             : ChangeLog 
	ld/testsuite   : ChangeLog 

Log message:
	PR ld/12365
	PR ld/12672
	missing changelog entries

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.5306&r2=1.5307
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/ChangeLog.diff?cvsroot=src&r1=1.2312&r2=1.2313
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1387&r2=1.1388
Comment 7 cvs-commit@gcc.gnu.org 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 8 Alan Modra 2011-04-27 07:41:30 UTC
fixed