public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* 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

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).