diff options
Diffstat (limited to 'ld/testsuite/config/default.exp')
-rw-r--r-- | ld/testsuite/config/default.exp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp index 899943c..f5cb188 100644 --- a/ld/testsuite/config/default.exp +++ b/ld/testsuite/config/default.exp @@ -328,3 +328,40 @@ if { ![info exists NOPIE_CFLAGS] || ![info exists NOPIE_LDFLAGS] } then { set NOPIE_LDFLAGS "" } } + +# Set GNU2_CFLAGS to "-mtls-dialect=gnu2" if target compiler supports it. + +if { ![info exists GNU2_CFLAGS] } then { + if { [which $CC] != 0 } { + # Check if gcc supports -mtls-dialect=gnu2 + 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/gnu2[pid]" + set src ${basename}.c + set output ${basename}.o + set f [open $src "w"] + puts $f "__thread int yyy = 100;" + close $f + if [is_remote host] { + set src [remote_download host $src] + } + set gnu2_available [run_host_cmd_yesno "$CC" "$flags -c -mtls-dialect=gnu2 $src -o $output"] + remote_file host delete $src + remote_file host delete $output + file delete $src + + if { $gnu2_available == 1 } then { + set GNU2_CFLAGS "-mtls-dialect=gnu2" + } else { + set GNU2_CFLAGS "" + } + } else { + set GNU2_CFLAGS "" + } +} |