public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Run ar with --plugin for LTO 11 test
@ 2014-07-05  3:18 Alan Modra
  2014-07-07 17:05 ` H.J. Lu
  0 siblings, 1 reply; 2+ messages in thread
From: Alan Modra @ 2014-07-05  3:18 UTC (permalink / raw)
  To: binutils; +Cc: H.J. Lu

Objects built with -fno-fat-lto-objects (the default for gcc-4.9) have
no normal symbols, except things like __gnu_lto_slim.  These useless
symbols are the ones put into the archive index, and of course nothing
references them so no objects are extracted by the linker.  Running
ar with --plugin changes ar behaviour to put the lto symbols into the
archive index.

I tried first to use gcc-ar, but that is decidedly useless when trying
to run the binutils test using a not-yet-installed gcc.

alan@bubble:~/build/gcc-current$ gcc/gcc-ar 
gcc/gcc-ar: Cannot find plugin 'liblto_plugin.so'
alan@bubble:~/build/gcc-current$ ls -l gcc/liblto_plugin.so
lrwxrwxrwx 1 alan alan 22 Jul  5 09:51 gcc/liblto_plugin.so -> liblto_plugin.so.0.0.0

Huh?  gcc-ar can't even find the plugin in the same dir?

HJ, does this look OK to you?  I'm not at all sure of the intent of
the LTO 11 test..  Another easy option is to compile the relevant
objects with -ffat-lto-objects.

	PR 17112
	* ld-plugin/lto.exp: When building liblti-11.a, pass
	--plugin path_to_gcc/liblto_plugin.so to ar.

diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 6ff474e..9bc0217 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -324,7 +324,20 @@ if { [is_elf_format] && [check_lto_shared_available] } {
 
 set testname "Build liblto-11.a"
 remote_file host delete "tmpdir/liblto-11.a"
-set catch_output [run_host_cmd "$ar" "rc tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
+set plugin_names {
+    liblto_plugin.so
+    liblto_plugin-0.dll
+    cyglto_plugin-0.dll
+}
+set plug_opt ""
+foreach plug $plugin_names {
+    set plug_so [run_host_cmd $CC "--print-prog-name $plug"]
+    if { $plug_so ne $plug } then {
+	set plug_opt "--plugin $plug_so"
+	break
+    }
+}
+set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
 if {![string match "" $catch_output]} {
     unresolved $testname
     restore_notify

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Run ar with --plugin for LTO 11 test
  2014-07-05  3:18 Run ar with --plugin for LTO 11 test Alan Modra
@ 2014-07-07 17:05 ` H.J. Lu
  0 siblings, 0 replies; 2+ messages in thread
From: H.J. Lu @ 2014-07-07 17:05 UTC (permalink / raw)
  To: Binutils

On Fri, Jul 4, 2014 at 8:18 PM, Alan Modra <amodra@gmail.com> wrote:
> Objects built with -fno-fat-lto-objects (the default for gcc-4.9) have
> no normal symbols, except things like __gnu_lto_slim.  These useless
> symbols are the ones put into the archive index, and of course nothing
> references them so no objects are extracted by the linker.  Running
> ar with --plugin changes ar behaviour to put the lto symbols into the
> archive index.
>
> I tried first to use gcc-ar, but that is decidedly useless when trying
> to run the binutils test using a not-yet-installed gcc.
>
> alan@bubble:~/build/gcc-current$ gcc/gcc-ar
> gcc/gcc-ar: Cannot find plugin 'liblto_plugin.so'
> alan@bubble:~/build/gcc-current$ ls -l gcc/liblto_plugin.so
> lrwxrwxrwx 1 alan alan 22 Jul  5 09:51 gcc/liblto_plugin.so -> liblto_plugin.so.0.0.0
>
> Huh?  gcc-ar can't even find the plugin in the same dir?
>
> HJ, does this look OK to you?  I'm not at all sure of the intent of
> the LTO 11 test..  Another easy option is to compile the relevant
> objects with -ffat-lto-objects.
>
>         PR 17112
>         * ld-plugin/lto.exp: When building liblti-11.a, pass
>         --plugin path_to_gcc/liblto_plugin.so to ar.
>
> diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
> index 6ff474e..9bc0217 100644
> --- a/ld/testsuite/ld-plugin/lto.exp
> +++ b/ld/testsuite/ld-plugin/lto.exp
> @@ -324,7 +324,20 @@ if { [is_elf_format] && [check_lto_shared_available] } {
>
>  set testname "Build liblto-11.a"
>  remote_file host delete "tmpdir/liblto-11.a"
> -set catch_output [run_host_cmd "$ar" "rc tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
> +set plugin_names {
> +    liblto_plugin.so
> +    liblto_plugin-0.dll
> +    cyglto_plugin-0.dll
> +}
> +set plug_opt ""
> +foreach plug $plugin_names {
> +    set plug_so [run_host_cmd $CC "--print-prog-name $plug"]
> +    if { $plug_so ne $plug } then {
> +       set plug_opt "--plugin $plug_so"
> +       break
> +    }
> +}
> +set catch_output [run_host_cmd "$ar" "rc $plug_opt tmpdir/liblto-11.a tmpdir/lto-11a.o tmpdir/lto-11b.o tmpdir/lto-11c.o"]
>  if {![string match "" $catch_output]} {
>      unresolved $testname
>      restore_notify
>
> --
> Alan Modra
> Australia Development Lab, IBM

It looks good to me.

Thanks.

-- 
H.J.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-07-07 17:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-05  3:18 Run ar with --plugin for LTO 11 test Alan Modra
2014-07-07 17:05 ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).