This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: Add check_lto_available
- From: Richard Earnshaw <rearnsha at arm dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Fri, 11 Oct 2013 13:36:30 +0100
- Subject: Re: PATCH: Add check_lto_available
- Authentication-results: sourceware.org; auth=none
- References: <20121207175814 dot GC13783 at intel dot com>
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 { } {
>