summaryrefslogtreecommitdiff
path: root/ld/testsuite/config/default.exp
diff options
context:
space:
mode:
Diffstat (limited to 'ld/testsuite/config/default.exp')
-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 29c020ffa46..1d9728afcae 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -376,3 +376,40 @@ if { ![info exists GNU2_CFLAGS] } then {
set GNU2_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 ""
+ }
+}