* PATCH: Add check_lto_available
@ 2012-12-07 17:58 H.J. Lu
2013-10-11 12:36 ` Richard Earnshaw
0 siblings, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2012-12-07 17:58 UTC (permalink / raw)
To: binutils
Hi,
I checked in this patch to add check_lto_available to check if
compiler supports LTO.
H.J.
---
Index: ChangeLog
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ChangeLog,v
retrieving revision 1.1637
diff -u -p -r1.1637 ChangeLog
--- ChangeLog 7 Dec 2012 17:53:03 -0000 1.1637
+++ ChangeLog 7 Dec 2012 17:55:20 -0000
@@ -1,5 +1,10 @@
2012-12-07 H.J. Lu <hongjiu.lu@intel.com>
+ * lib/ld-lib.exp (check_lto_available): New. Check if compiler
+ supports LTO.
+
+2012-12-07 H.J. Lu <hongjiu.lu@intel.com>
+
* lib/ld-lib.exp (run_cc_link_tests): Properly check linker
warnings.
Index: lib/ld-lib.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/lib/ld-lib.exp,v
retrieving revision 1.99
diff -u -p -r1.99 ld-lib.exp
--- lib/ld-lib.exp 7 Dec 2012 17:53:04 -0000 1.99
+++ lib/ld-lib.exp 7 Dec 2012 17:55:20 -0000
@@ -1614,6 +1614,34 @@ proc check_plugin_api_available { } {
return $plugin_api_available_saved
}
+# Returns true if the target compiler supports LTO
+proc check_lto_available { } {
+ global lto_available_saved
+ global CC
+ if {![info exists lto_available_saved]} {
+ # Check if gcc supports -flto -fuse-linker-plugin
+ if { [which $CC] == 0 } {
+ set lto_available_saved 0
+ return 0
+ }
+ set basename "lto"
+ set src ${basename}[pid].c
+ set output ${basename}[pid].so
+ set f [open $src "w"]
+ puts $f ""
+ close $f
+ set status [remote_exec host $CC "-shared -B[pwd]/tmpdir/ld/ -flto -fuse-linker-plugin $src -o $output"]
+ if { [lindex $status 0] == 0 } {
+ set lto_available_saved 1
+ } else {
+ set lto_available_saved 0
+ }
+ file delete $src
+ file delete $output
+ }
+ return $lto_available_saved
+}
+
# Check if the assembler supports CFI statements.
proc check_as_cfi { } {
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: Add check_lto_available
2012-12-07 17:58 PATCH: Add check_lto_available H.J. Lu
@ 2013-10-11 12:36 ` Richard Earnshaw
2013-10-11 17:09 ` H.J. Lu
0 siblings, 1 reply; 4+ messages in thread
From: Richard Earnshaw @ 2013-10-11 12:36 UTC (permalink / raw)
To: H.J. Lu; +Cc: binutils
HJ,
Why does this patch try to produce a shared object as part of
determining whether LTO works? If you have LTO but not shared object
support in a toolchain this means we don't test LTO properly.
R.
On 07/12/12 17:58, H.J. Lu wrote:
> Hi,
>
> I checked in this patch to add check_lto_available to check if
> compiler supports LTO.
>
>
> H.J.
> ---
> Index: ChangeLog
> ===================================================================
> RCS file: /cvs/src/src/ld/testsuite/ChangeLog,v
> retrieving revision 1.1637
> diff -u -p -r1.1637 ChangeLog
> --- ChangeLog 7 Dec 2012 17:53:03 -0000 1.1637
> +++ ChangeLog 7 Dec 2012 17:55:20 -0000
> @@ -1,5 +1,10 @@
> 2012-12-07 H.J. Lu <hongjiu.lu@intel.com>
>
> + * lib/ld-lib.exp (check_lto_available): New. Check if compiler
> + supports LTO.
> +
> +2012-12-07 H.J. Lu <hongjiu.lu@intel.com>
> +
> * lib/ld-lib.exp (run_cc_link_tests): Properly check linker
> warnings.
>
> Index: lib/ld-lib.exp
> ===================================================================
> RCS file: /cvs/src/src/ld/testsuite/lib/ld-lib.exp,v
> retrieving revision 1.99
> diff -u -p -r1.99 ld-lib.exp
> --- lib/ld-lib.exp 7 Dec 2012 17:53:04 -0000 1.99
> +++ lib/ld-lib.exp 7 Dec 2012 17:55:20 -0000
> @@ -1614,6 +1614,34 @@ proc check_plugin_api_available { } {
> return $plugin_api_available_saved
> }
>
> +# Returns true if the target compiler supports LTO
> +proc check_lto_available { } {
> + global lto_available_saved
> + global CC
> + if {![info exists lto_available_saved]} {
> + # Check if gcc supports -flto -fuse-linker-plugin
> + if { [which $CC] == 0 } {
> + set lto_available_saved 0
> + return 0
> + }
> + set basename "lto"
> + set src ${basename}[pid].c
> + set output ${basename}[pid].so
> + set f [open $src "w"]
> + puts $f ""
> + close $f
> + set status [remote_exec host $CC "-shared -B[pwd]/tmpdir/ld/ -flto -fuse-linker-plugin $src -o $output"]
> + if { [lindex $status 0] == 0 } {
> + set lto_available_saved 1
> + } else {
> + set lto_available_saved 0
> + }
> + file delete $src
> + file delete $output
> + }
> + return $lto_available_saved
> +}
> +
> # Check if the assembler supports CFI statements.
>
> proc check_as_cfi { } {
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: Add check_lto_available
2013-10-11 12:36 ` Richard Earnshaw
@ 2013-10-11 17:09 ` H.J. Lu
2013-10-14 10:16 ` Vidya Praveen
0 siblings, 1 reply; 4+ messages in thread
From: H.J. Lu @ 2013-10-11 17:09 UTC (permalink / raw)
To: Richard Earnshaw; +Cc: Binutils
On Fri, Oct 11, 2013 at 5:36 AM, Richard Earnshaw <rearnsha@arm.com> wrote:
> HJ,
>
> Why does this patch try to produce a shared object as part of
> determining whether LTO works? If you have LTO but not shared object
> support in a toolchain this means we don't test LTO properly.
>
LTO tests also check if shared library works correctly with LTO.
--
H.J.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: Add check_lto_available
2013-10-11 17:09 ` H.J. Lu
@ 2013-10-14 10:16 ` Vidya Praveen
0 siblings, 0 replies; 4+ messages in thread
From: Vidya Praveen @ 2013-10-14 10:16 UTC (permalink / raw)
To: H.J. Lu; +Cc: Richard Earnshaw, Binutils
On Fri, Oct 11, 2013 at 06:09:43PM +0100, H.J. Lu wrote:
> On Fri, Oct 11, 2013 at 5:36 AM, Richard Earnshaw <rearnsha@arm.com> wrote:
> > HJ,
> >
> > Why does this patch try to produce a shared object as part of
> > determining whether LTO works? If you have LTO but not shared object
> > support in a toolchain this means we don't test LTO properly.
> >
>
> LTO tests also check if shared library works correctly with LTO.
lto.exp does hav a condition to guard those:
303 if { [is_elf_format]
304 && [run_host_cmd_yesno $CC "-shared -fPIC $srcdir/$subdir/dummy.c -o tmpdir/t.so"] } {
305 run_cc_link_tests $lto_link_elf_tests
....
313 }
Since the other tests seem valid for toolchains that doesn't support shared
library, Shouldn't check_lto_availble have a check that doesn't use -shared ?
VP
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-10-14 10:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-07 17:58 PATCH: Add check_lto_available H.J. Lu
2013-10-11 12:36 ` Richard Earnshaw
2013-10-11 17:09 ` H.J. Lu
2013-10-14 10:16 ` Vidya Praveen
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).