public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hongjiu.lu@intel.com>
To: binutils@sourceware.org
Subject: PATCH: Add check_lto_available
Date: Fri, 07 Dec 2012 17:58:00 -0000	[thread overview]
Message-ID: <20121207175814.GC13783@intel.com> (raw)

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 { } {

             reply	other threads:[~2012-12-07 17:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-07 17:58 H.J. Lu [this message]
2013-10-11 12:36 ` Richard Earnshaw
2013-10-11 17:09   ` H.J. Lu
2013-10-14 10:16     ` Vidya Praveen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121207175814.GC13783@intel.com \
    --to=hongjiu.lu@intel.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).