summaryrefslogtreecommitdiff
path: root/ld/testsuite/config
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2018-01-29 04:54:57 -0800
committerH.J. Lu <hjl.tools@gmail.com>2018-01-29 04:55:23 -0800
commit98d72909f8f216fb9fc4d7c2c8e48dbe2823cd0b (patch)
treee357718d8f39db126db36a047097f42c3467f68a /ld/testsuite/config
parenteb77f6a4621795367a39cdd30957903af9dbb815 (diff)
downloadbinutils-gdb-98d72909f8f216fb9fc4d7c2c8e48dbe2823cd0b.tar.gz
ld: Skip unsupported static executable tests
Skip static executable tests if static executable is unsupported. Tested on Linux/x86 without libc.a. PR ld/22732 * testsuite/config/default.exp (STATIC_LDFLAGS): New. Set to "-static" if target compiler supports it. * testsuite/ld-bootstrap/bootstrap.exp: Skip static executable tests if target compiler doesn't support it. * testsuite/ld-ifunc/ifunc.exp: Likewise. * testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Likewise. (run_cc_link_tests): Likewise.
Diffstat (limited to 'ld/testsuite/config')
-rw-r--r--ld/testsuite/config/default.exp37
1 files changed, 37 insertions, 0 deletions
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index fe3bd3204aa..704ac300e40 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -413,3 +413,40 @@ if { ![info exists INT128_CFLAGS] } then {
set INT128_CFLAGS ""
}
}
+
+# Set STATIC_LDFLAGS to "-static" if target compiler supports it.
+
+if { ![info exists STATIC_LDFLAGS] } then {
+ if { [which $CC] != 0 } {
+ # Check if gcc supports -static.
+ 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]"
+ }
+
+ set basename "tmpdir/static[pid]"
+ set src ${basename}.c
+ set output ${basename}
+ set f [open $src "w"]
+ puts $f "int main (void) { return 0; }"
+ close $f
+ if [is_remote host] {
+ set src [remote_download host $src]
+ }
+ set static_available [run_host_cmd_yesno "$CC" "-static $flags $src -o $output"]
+ remote_file host delete $src
+ remote_file host delete $output
+ file delete $src
+
+ if { $static_available == 1 } then {
+ set STATIC_LDFLAGS "-static"
+ } else {
+ set STATIC_LDFLAGS ""
+ }
+ } else {
+ set STATIC_LDFLAGS ""
+ }
+}