aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2012-12-07 17:56:09 +0000
committerH.J. Lu <hjl.tools@gmail.com>2012-12-07 17:56:09 +0000
commit3bd58fbe7576a68f9361978288457ab6e0912e3b (patch)
treea219476defefdc2d05e8febbc58208e82ba12775 /ld
parent741e01282880b5fd10c43ad74445bb5825e95197 (diff)
downloadbinutils-3bd58fbe7576a68f9361978288457ab6e0912e3b.zip
binutils-3bd58fbe7576a68f9361978288457ab6e0912e3b.tar.gz
binutils-3bd58fbe7576a68f9361978288457ab6e0912e3b.tar.bz2
Add check_lto_available
* lib/ld-lib.exp (check_lto_available): New. Check if compiler supports LTO.
Diffstat (limited to 'ld')
-rw-r--r--ld/testsuite/ChangeLog5
-rw-r--r--ld/testsuite/lib/ld-lib.exp28
2 files changed, 33 insertions, 0 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 15fb595..c957324 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -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.
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index f08b9bf..5f49e74 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -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 { } {