lib/ld-lib.exp (check_sysroot_available): New proc.
[deliverable/binutils-gdb.git] / ld / testsuite / lib / ld-lib.exp
index 9f7a414cc99f4bbb352bff7888b4990f32e5c22f..ffdf8051f3191e00433b632810c25f68b3b6494c 100644 (file)
@@ -410,9 +410,9 @@ proc ld_simple_link_defsyms {} {
         append flags " --defsym __gccmain=0"
     }
 
-    # Windows targets need __main, prefixed with underscore.
+    # Windows targets need __main, some prefixed with underscore.
     if {[istarget *-*-cygwin* ] || [istarget *-*-mingw*]} {
-        append flags " --defsym ___main=0"
+        append flags " --defsym __main=0 --defsym ___main=0"
     }
 
     # PowerPC EABI code calls __eabi.
@@ -1424,6 +1424,15 @@ proc run_cc_link_tests { ldtests } {
        set is_unresolved 0
        set failed 0
 
+       #verbose -log "testname  is $testname"
+       #verbose -log "ldflags   is $ldflags"
+       #verbose -log "cflags    is $cflags"
+       #verbose -log "src_files is $src_files"
+       #verbose -log "actions   is $actions"
+       #verbose -log "binfile   is $binfile"
+       #verbose -log "lang      is $lang"
+       #verbose -log "warnings  is $warnings"
+
        # Compile each file in the test.
        foreach src_file $src_files {
            set fileroot "[file rootname [file tail $src_file]]"
@@ -1651,7 +1660,7 @@ proc check_plugin_api_available { } {
     if {![info exists plugin_api_available_saved]} {
        # Check if the ld used by gcc supports --plugin.
        set ld_output [remote_exec host $ld "--help"]
-       if { [ string first "-plugin" $ld_output ] >= 0 } {
+       if { [ string first "-plugin PLUGIN" $ld_output ] >= 0 } {
            set plugin_api_available_saved 1
        } else {
            set plugin_api_available_saved 0
@@ -1660,6 +1669,24 @@ proc check_plugin_api_available { } {
     return $plugin_api_available_saved
 }
 
+# Returns true if the target ld supports sysroot.
+proc check_sysroot_available { } {
+    global ld_sysroot_available_saved
+    global ld
+    if {![info exists ld_sysroot_available_saved]} {
+       # Check if ld supports --sysroot *other* than empty
+       # (non-sysroot linkers don't emit errors for --sysroot="").
+       # The help-text by itself is no indication as it always lists --sysroot.
+       set status [remote_exec host $ld "--sysroot=ldxyzzy --help >/dev/null"]
+       if { [lindex $status 0] != 0 } {
+           set ld_sysroot_available_saved 0
+       } else {
+           set ld_sysroot_available_saved 1
+       }
+    }
+    return $ld_sysroot_available_saved
+}
+
 # Returns true if the target compiler supports LTO
 proc check_lto_available { } {
     global lto_available_saved
@@ -1686,7 +1713,7 @@ proc check_lto_available { } {
        puts $f "int main() { return 0; }"
        close $f
        remote_download host $src
-       set lto_available_saved [run_host_cmd_yesno "$CC" "$flags -flto -ffat-lto-objects -fuse-linker-plugin $src -o $output"]
+       set lto_available_saved [run_host_cmd_yesno "$CC" "$flags -flto -fuse-linker-plugin $src -o $output"]
        remote_file host delete $src
        remote_file host delete $output
        file delete $src
@@ -1694,12 +1721,50 @@ proc check_lto_available { } {
     return $lto_available_saved
 }
 
+# Returns true if the target compiler supports LTO  -ffat-lto-objects
+proc check_lto_fat_available { } {
+    global lto_fat_available_saved
+    global CC
+
+    if {![info exists lto_fat_available_saved]} {
+        if { [which $CC] == 0 } {
+           set lto_fat_available_saved 0
+           return 0
+       }
+       # Check if gcc supports -flto -fuse-linker-plugin
+       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/lto[pid]"
+       set src ${basename}.c
+       set output ${basename}.out
+       set f [open $src "w"]
+       puts $f "int main() { return 0; }"
+       close $f
+       remote_download host $src
+       set lto_fat_available_saved [run_host_cmd_yesno "$CC" "$flags -flto -ffat-lto-objects -fuse-linker-plugin $src -o $output"]
+       remote_file host delete $src
+       remote_file host delete $output
+       file delete $src
+    }
+    return $lto_fat_available_saved
+}
+
 # Returns true if the target compiler supports LTO and -shared
 proc check_lto_shared_available { } {
     global lto_shared_available_saved
     global CC
 
     if {![info exists lto_shared_available_saved]} {
+        if { [which $CC] == 0 } {
+           set lto_shared_available_saved 0
+           return 0
+       }
        # Check if gcc supports -flto -fuse-linker-plugin -shared
        set flags ""
        if [board_info [target_info name] exists cflags] {
This page took 0.025307 seconds and 4 git commands to generate.