aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2014-01-09 09:01:53 -0800
committerH.J. Lu <hjl.tools@gmail.com>2014-01-09 09:01:53 -0800
commit92c09111f34c464c3dd2b0cfbfa13c3b6c74c3e5 (patch)
treeb2a7f2670a76ec18668f470d5242db16abb73eb0
parent09bf66a8e8f7e62f6e842b42b048721abef49904 (diff)
downloadgdb-92c09111f34c464c3dd2b0cfbfa13c3b6c74c3e5.zip
gdb-92c09111f34c464c3dd2b0cfbfa13c3b6c74c3e5.tar.gz
gdb-92c09111f34c464c3dd2b0cfbfa13c3b6c74c3e5.tar.bz2
Add and use check_lto_shared_available
2014-01-09 Vidya Praveen <vidyapraveen@arm.com> * lib/ld-lib.exp (check_lto_shared_available): New check. * ld-plugin/lto.exp: Use check_lto_shared_available.
-rw-r--r--ld/testsuite/ChangeLog5
-rw-r--r--ld/testsuite/ld-plugin/lto.exp3
-rw-r--r--ld/testsuite/lib/ld-lib.exp39
3 files changed, 45 insertions, 2 deletions
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 8d32d28..df2e1b8 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2014-01-09 Vidya Praveen <vidyapraveen@arm.com>
+
+ * lib/ld-lib.exp (check_lto_shared_available): New check.
+ * ld-plugin/lto.exp: Use check_lto_shared_available.
+
2014-01-08 H.J. Lu <hongjiu.lu@intel.com>
PR ld/14207
diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp
index 69946de..d55dca4 100644
--- a/ld/testsuite/ld-plugin/lto.exp
+++ b/ld/testsuite/ld-plugin/lto.exp
@@ -300,8 +300,7 @@ set lto_run_elf_tests {
run_cc_link_tests $lto_link_tests
# Restrict these to ELF targets that support shared libs and PIC.
-if { [is_elf_format]
- && [run_host_cmd_yesno $CC "-shared -fPIC $srcdir/$subdir/dummy.c -o tmpdir/t.so"] } {
+if { [is_elf_format] && [check_lto_shared_available] } {
run_cc_link_tests $lto_link_elf_tests
set testname "PR ld/15146 (2)"
set exec_output [run_host_cmd "$CC" "$gcc_gas_flag $gcc_ld_flag -O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146d.o tmpdir/pr15146c.so"]
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index c04b56f..54b617f 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -1679,6 +1679,45 @@ proc check_lto_available { } {
return $lto_available_saved
}
+# Returns true if the target compiler supports LTO and -shared
+proc check_lto_shared_available { } {
+ global lto_shared_available_saved
+ global CC
+
+ set flags ""
+
+ if [board_info [target_info name] exists cflags] {
+ append flags " [board_info [target_info name] cflags]"
+ }
+
+ if [board_info [target_info name] exists ldflags] {
+ append flags " [board_info [target_info name] ldflags]"
+ }
+
+ if {![info exists lto_shared_available_saved]} {
+ # Check if gcc supports -flto -fuse-linker-plugin -shared
+ if { [which $CC] == 0 } {
+ set lto_shared_available_saved 0
+ return 0
+ }
+ set basename "lto_shared"
+ 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 "$flags -shared -fPIC -B[pwd]/tmpdir/ld/ -flto -fuse-linker-plugin $src -o $output"]
+ if { [lindex $status 0] == 0 } {
+ set lto_shared_available_saved 1
+ } else {
+ set lto_shared_available_saved 0
+ }
+ file delete $src
+ file delete $output
+ }
+ return $lto_shared_available_saved
+}
+
# Check if the assembler supports CFI statements.
proc check_as_cfi { } {