diff options
Diffstat (limited to 'ld')
41 files changed, 155 insertions, 55 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 4b4956e..a62a6c5 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,50 @@ +2019-04-24 Sandra Loosemore <sandra@codesourcery.com> + + * testsuite/config/default.exp: Use [check_compiler_available] + instead of [which $CC]. + * testsuite/ld-auto-import/auto-import.exp: Likewise. + * testsuite/ld-cygwin/exe-export.exp: Likewise. + * testsuite/ld-elf/audit.exp: Likewise. + * testsuite/ld-elf/compress.exp: Likewise. + * testsuite/ld-elf/dwarf.exp: Likewise. + * testsuite/ld-elf/elf.exp: Likewise. + * testsuite/ld-elf/indirect.exp: Likewise. + * testsuite/ld-elf/linux-x86.exp: Likewise. + * testsuite/ld-elf/shared.exp: Likewise. + * testsuite/ld-elf/tls.exp: Likewise. + * testsuite/ld-elf/wrap.exp: Likewise. + * testsuite/ld-elfcomm/elfcomm.exp: Likewise. + * testsuite/ld-elfvers/vers.exp: Likewise. + * testsuite/ld-elfvsb/elfvsb.exp: Likewise. + * testsuite/ld-elfweak/elfweak.exp: Likewise. + * testsuite/ld-gc/gc.exp: Likewise. + * testsuite/ld-i386/i386.exp: Likewise. + * testsuite/ld-i386/no-plt.exp: Likewise. + * testsuite/ld-i386/tls.exp: Likewise. + * testsuite/ld-ifunc/ifunc.exp: Likewise. + * testsuite/ld-mn10300/mn10300.exp: Likewise. + * testsuite/ld-pe/pe-compile.exp: Likewise. + * testsuite/ld-pe/pe-run.exp: Likewise. + * testsuite/ld-pe/pe-run2.exp: Likewise. + * testsuite/ld-pie/pie.exp: Likewise. + * testsuite/ld-plugin/lto.exp: Likewise. + * testsuite/ld-plugin/plugin.exp: Likewise. + * testsuite/ld-scripts/crossref.exp: Likewise. + * testsuite/ld-sh/sh.exp: Likewise. + * testsuite/ld-shared/shared.exp: Likewise. + * testsuite/ld-size/size.exp: Likewise. + * testsuite/ld-srec/srec.exp: Likewise. + * testsuite/ld-undefined/undefined.exp: Likewise. + * testsuite/ld-unique/unique.exp: Likewise. + * testsuite/ld-x86-64/mpx.exp: Likewise. + * testsuite/ld-x86-64/no-plt.exp: Likewise. + * testsuite/ld-x86-64/tls.exp: Likewise. + * testsuite/ld-x86-64/x86-64.exp: Likewise. + * testsuite/lib/ld-lib.exp (run_ld_link_exec_tests): Call + check_compiler_available before trying to use the compiler. + (run_cc_link_tests): Likewise. + (check_compiler_available): New. Use it instead of [which $CC]. + 2019-04-23 Alan Modra <amodra@gmail.com> * Makefile.am (GENDEPDIR): New var, used.. diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp index 5acab06..ce52919 100644 --- a/ld/testsuite/config/default.exp +++ b/ld/testsuite/config/default.exp @@ -269,7 +269,7 @@ if { ![info exists LD_CLASS] } then { # Set PLT_CFLAGS to "-fplt" if target compiler supports it. if { ![info exists PLT_CFLAGS] } then { - if { [which $CC] != 0 } { + if { [check_compiler_available] } { # Check if gcc supports -fplt set flags "" if [board_info [target_info name] exists cflags] { @@ -307,7 +307,7 @@ if { ![info exists PLT_CFLAGS] } then { # target compiler supports them. if { ![info exists NOPIE_CFLAGS] || ![info exists NOPIE_LDFLAGS] } then { - if { [which $CC] != 0 } { + if { [check_compiler_available] } { # Check if gcc supports -fno-PIE -no-pie. set flags "" if [board_info [target_info name] exists cflags] { @@ -347,7 +347,7 @@ if { ![info exists NOPIE_CFLAGS] || ![info exists NOPIE_LDFLAGS] } then { # Set GNU2_CFLAGS to "-mtls-dialect=gnu2" if target compiler supports it. if { ![info exists GNU2_CFLAGS] } then { - if { [which $CC] != 0 } { + if { [check_compiler_available] } { # Check if gcc supports -mtls-dialect=gnu2 set flags "" if [board_info [target_info name] exists cflags] { @@ -384,7 +384,7 @@ if { ![info exists GNU2_CFLAGS] } then { # Set INT128_CFLAGS to "-DHAS_INT128" if target compiler supports __int128. if { ![info exists INT128_CFLAGS] } then { - if { [which $CC] != 0 } { + if { [check_compiler_available] } { # Check if gcc supports __int128. set flags "" if [board_info [target_info name] exists cflags] { @@ -421,7 +421,7 @@ if { ![info exists INT128_CFLAGS] } then { # Set STATIC_LDFLAGS to "-static" if target compiler supports it. if { ![info exists STATIC_LDFLAGS] } then { - if { [which $CC] != 0 } { + if { [check_compiler_available] } { # Check if gcc supports -static. set flags "" if [board_info [target_info name] exists cflags] { @@ -458,7 +458,7 @@ if { ![info exists STATIC_LDFLAGS] } then { # Set STATIC_PIE_LDFLAGS to "-static-pie" if target compiler supports it. if { ![info exists STATIC_PIE_LDFLAGS] } then { - if { [which $CC] != 0 } { + if { [check_compiler_available] } { # Check if gcc supports -static-pie. set flags "" if [board_info [target_info name] exists cflags] { diff --git a/ld/testsuite/ld-auto-import/auto-import.exp b/ld/testsuite/ld-auto-import/auto-import.exp index d9ac6cf..d5a0dcc 100644 --- a/ld/testsuite/ld-auto-import/auto-import.exp +++ b/ld/testsuite/ld-auto-import/auto-import.exp @@ -67,7 +67,7 @@ if [istarget *-pc-mingw*] { } # No compiler, no test. -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { untested "Auto import test (compiler not found)" return } diff --git a/ld/testsuite/ld-cygwin/exe-export.exp b/ld/testsuite/ld-cygwin/exe-export.exp index 258949e..5436332 100644 --- a/ld/testsuite/ld-cygwin/exe-export.exp +++ b/ld/testsuite/ld-cygwin/exe-export.exp @@ -29,7 +29,7 @@ if {![istarget *-pc-cygwin]} { }
# No compiler, no test.
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
untested "Exe export test (no compiler available)"
return
}
diff --git a/ld/testsuite/ld-elf/audit.exp b/ld/testsuite/ld-elf/audit.exp index 3514176..5cc044b 100644 --- a/ld/testsuite/ld-elf/audit.exp +++ b/ld/testsuite/ld-elf/audit.exp @@ -32,7 +32,7 @@ if ![check_shared_lib_support] { } # Check if compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-elf/compress.exp b/ld/testsuite/ld-elf/compress.exp index 6bdc921..90b6c6e 100644 --- a/ld/testsuite/ld-elf/compress.exp +++ b/ld/testsuite/ld-elf/compress.exp @@ -32,7 +32,7 @@ if ![check_shared_lib_support] { } # Check if compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-elf/dwarf.exp b/ld/testsuite/ld-elf/dwarf.exp index bc3cbb2..233a2a8 100644 --- a/ld/testsuite/ld-elf/dwarf.exp +++ b/ld/testsuite/ld-elf/dwarf.exp @@ -36,7 +36,7 @@ if ![check_shared_lib_support] { } # Check if compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-elf/elf.exp b/ld/testsuite/ld-elf/elf.exp index 4686870..9121936 100644 --- a/ld/testsuite/ld-elf/elf.exp +++ b/ld/testsuite/ld-elf/elf.exp @@ -182,7 +182,7 @@ set LDFLAGS $old_ldflags set ASFLAGS $old_asflags # Check to see if the C compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-elf/indirect.exp b/ld/testsuite/ld-elf/indirect.exp index b1a2c6c..1acb556 100644 --- a/ld/testsuite/ld-elf/indirect.exp +++ b/ld/testsuite/ld-elf/indirect.exp @@ -33,7 +33,7 @@ if ![check_shared_lib_support] { } # Check if compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-elf/linux-x86.exp b/ld/testsuite/ld-elf/linux-x86.exp index b1cad61..6b0f23f 100644 --- a/ld/testsuite/ld-elf/linux-x86.exp +++ b/ld/testsuite/ld-elf/linux-x86.exp @@ -20,7 +20,7 @@ # # Test very simple native Linux/x86 programs with linux-x86.S. -if { ![isnative] || [which $CC] == 0 \ +if { ![isnative] || ![check_compiler_available] \ || (![istarget "i?86-*-linux*"] \ && ![istarget "x86_64-*-linux*"] \ && ![istarget "amd64-*-linux*"]) } { diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp index b5a01c9..f27fa24 100644 --- a/ld/testsuite/ld-elf/shared.exp +++ b/ld/testsuite/ld-elf/shared.exp @@ -498,7 +498,7 @@ if { [istarget *-*-linux*] } # Check to see if the C compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-elf/tls.exp b/ld/testsuite/ld-elf/tls.exp index 1b26f8b..4daddc7 100644 --- a/ld/testsuite/ld-elf/tls.exp +++ b/ld/testsuite/ld-elf/tls.exp @@ -29,7 +29,7 @@ if { ![istarget *-*-linux*] } # Check to see if the C compiler works. -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-elf/wrap.exp b/ld/testsuite/ld-elf/wrap.exp index 3293231..1a9fa7c 100644 --- a/ld/testsuite/ld-elf/wrap.exp +++ b/ld/testsuite/ld-elf/wrap.exp @@ -32,7 +32,7 @@ if ![check_shared_lib_support] { } # Check if compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-elfcomm/elfcomm.exp b/ld/testsuite/ld-elfcomm/elfcomm.exp index 69eb0bc..6052e8f 100644 --- a/ld/testsuite/ld-elfcomm/elfcomm.exp +++ b/ld/testsuite/ld-elfcomm/elfcomm.exp @@ -107,7 +107,7 @@ set test1w2 "$test1 (warning 2)" set test1c1 "$test1 (change 1)" set test1c2 "$test1 (change 2)" -if { ![is_remote host] && [which $CC] == 0 } { +if { ![check_compiler_available] } { untested $test1w1 untested $test1w2 untested $test1c1 diff --git a/ld/testsuite/ld-elfvers/vers.exp b/ld/testsuite/ld-elfvers/vers.exp index 83b23a7..ebaaa78 100644 --- a/ld/testsuite/ld-elfvers/vers.exp +++ b/ld/testsuite/ld-elfvers/vers.exp @@ -23,7 +23,7 @@ # # Check to see if the C compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-elfvsb/elfvsb.exp b/ld/testsuite/ld-elfvsb/elfvsb.exp index 0c1e962..bf0747a 100644 --- a/ld/testsuite/ld-elfvsb/elfvsb.exp +++ b/ld/testsuite/ld-elfvsb/elfvsb.exp @@ -25,7 +25,7 @@ # Make sure that ld can generate ELF shared libraries with visibility. # Check to see if the C compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-elfweak/elfweak.exp b/ld/testsuite/ld-elfweak/elfweak.exp index 4bc27ca..183f190 100644 --- a/ld/testsuite/ld-elfweak/elfweak.exp +++ b/ld/testsuite/ld-elfweak/elfweak.exp @@ -23,7 +23,7 @@ # # Check to see if the C compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp index 422c3c3..fe50f31 100644 --- a/ld/testsuite/ld-gc/gc.exp +++ b/ld/testsuite/ld-gc/gc.exp @@ -39,7 +39,7 @@ if { [istarget m681*-*-*] || [istarget m68hc1*-*-*] } { set cflags "$cflags -fomit-frame-pointer -mshort" } -if { [is_remote host] || [which $CC] != 0 } { +if { [check_compiler_available] } { ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/gc.c $objfile } @@ -130,7 +130,7 @@ if { [is_elf_format] && [check_shared_lib_support] } then { set LDFLAGS $old_ldflags } -if { [is_remote host] || [which $CC] != 0 } { +if { [check_compiler_available] } { if { [istarget "*-*-linux*"] || [istarget "*-*-nacl*"] || [istarget "*-*-gnu*"] } { @@ -141,24 +141,24 @@ if { [is_remote host] || [which $CC] != 0 } { } } -if { [is_remote host] || [which $CC] != 0 } { +if { [check_compiler_available] } { ld_compile "$CC $CFLAGS $cflags" $srcdir/$subdir/pr13683.c tmpdir/pr13683.o run_dump_test "pr13683" } -if { [is_remote host] || [which $CC] != 0 } { +if { [check_compiler_available] } { ld_compile "$CC $CFLAGS $cflags $NOPIE_CFLAGS" $srcdir/$subdir/pr14265.c tmpdir/pr14265.o run_dump_test "pr14265" } -if { [is_remote host] || [which $CC] != 0 } { +if { [check_compiler_available] } { ld_compile "$CC $CFLAGS $cflags -O0" $srcdir/$subdir/pr19161-1.c tmpdir/pr19161-1.o ld_compile "$CC $CFLAGS $cflags -O0" $srcdir/$subdir/pr19161-2.c tmpdir/pr19161-2.o run_dump_test "pr19161" } if { [is_elf_format] && [check_shared_lib_support] \ - && ([is_remote host] || [which $CC] != 0) } { + && [check_compiler_available] } { run_cc_link_tests [list \ [list \ "Build libpr20306.so" \ diff --git a/ld/testsuite/ld-i386/i386.exp b/ld/testsuite/ld-i386/i386.exp index 9579df6..3a1fd8b 100644 --- a/ld/testsuite/ld-i386/i386.exp +++ b/ld/testsuite/ld-i386/i386.exp @@ -581,7 +581,7 @@ global PLT_CFLAGS # Must be Linux native with the C compiler if { [isnative] && [istarget "i?86-*-linux*"] - && [which $CC] != 0 } { + && [check_compiler_available] } { run_cc_link_tests [list \ [list \ "Build plt-lib.so" \ @@ -1193,7 +1193,7 @@ global NOPIE_CFLAGS NOPIE_LDFLAGS if { [isnative] && [check_ifunc_available] && [istarget "i?86-*-*"] - && [which $CC] != 0 } { + && [check_compiler_available] } { run_cc_link_tests [list \ [list \ "Build ifunc-1a.o ifunc-1b.o ifunc-1c.o ifunc-1d.o" \ @@ -1310,7 +1310,7 @@ if { [isnative] # Must be native with the C compiler. if { [isnative] && [istarget "i?86-*-*"] - && [which $CC] != 0 } { + && [check_compiler_available] } { run_cc_link_tests [list \ [list \ "Build pr22001-1.so" \ diff --git a/ld/testsuite/ld-i386/no-plt.exp b/ld/testsuite/ld-i386/no-plt.exp index 21040a1..6a75a04 100644 --- a/ld/testsuite/ld-i386/no-plt.exp +++ b/ld/testsuite/ld-i386/no-plt.exp @@ -35,7 +35,7 @@ if ![istarget "i?86-*-*"] { } # Check to see if the C compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-i386/tls.exp b/ld/testsuite/ld-i386/tls.exp index 79c6d9a..1587de6 100644 --- a/ld/testsuite/ld-i386/tls.exp +++ b/ld/testsuite/ld-i386/tls.exp @@ -32,7 +32,7 @@ if ![istarget "i?86-*-linux*"] { } # Check to see if the C compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-ifunc/ifunc.exp b/ld/testsuite/ld-ifunc/ifunc.exp index e13b561..3fd616a 100644 --- a/ld/testsuite/ld-ifunc/ifunc.exp +++ b/ld/testsuite/ld-ifunc/ifunc.exp @@ -63,7 +63,7 @@ foreach t $test_list { # We need a working compiler. (Strictly speaking this is # not true, we could use target specific assembler files). -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { verbose "IFUNC tests not run - no compiler available" return } diff --git a/ld/testsuite/ld-mn10300/mn10300.exp b/ld/testsuite/ld-mn10300/mn10300.exp index d7c6c45..b78ef55 100644 --- a/ld/testsuite/ld-mn10300/mn10300.exp +++ b/ld/testsuite/ld-mn10300/mn10300.exp @@ -134,7 +134,7 @@ proc i126256-test { } { set tmpdir tmpdir set testname "Seg fault whilst linking one shared library into another when relaxation is enabled." - if {![is_remote host] && [which $CC] == 0} then { + if { ![check_compiler_available] } then { return } diff --git a/ld/testsuite/ld-pe/pe-compile.exp b/ld/testsuite/ld-pe/pe-compile.exp index e6154c5..84098f6 100644 --- a/ld/testsuite/ld-pe/pe-compile.exp +++ b/ld/testsuite/ld-pe/pe-compile.exp @@ -26,7 +26,7 @@ if {![is_pecoff_format]} { } # No compiler, no test. -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { untested "PE version scripts" untested "aligned common tests" # Add more "untested" directives here when adding more tests below. diff --git a/ld/testsuite/ld-pe/pe-run.exp b/ld/testsuite/ld-pe/pe-run.exp index 1f06b7a..ae91b61 100644 --- a/ld/testsuite/ld-pe/pe-run.exp +++ b/ld/testsuite/ld-pe/pe-run.exp @@ -54,7 +54,7 @@ if {![is_pecoff_format]} { } # No compiler, no test. -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { untested "Direct linking to dll test" return } diff --git a/ld/testsuite/ld-pe/pe-run2.exp b/ld/testsuite/ld-pe/pe-run2.exp index af45915..4ae239f 100644 --- a/ld/testsuite/ld-pe/pe-run2.exp +++ b/ld/testsuite/ld-pe/pe-run2.exp @@ -56,7 +56,7 @@ if {![is_pecoff_format]} { } # No compiler, no test. -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { untested "Direct linking to dll fastcall/stdcall test" return } diff --git a/ld/testsuite/ld-pie/pie.exp b/ld/testsuite/ld-pie/pie.exp index 778a944..39c7205 100644 --- a/ld/testsuite/ld-pie/pie.exp +++ b/ld/testsuite/ld-pie/pie.exp @@ -26,7 +26,7 @@ if { ![istarget *-*-linux*] } # Check to see if the C compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-plugin/lto.exp b/ld/testsuite/ld-plugin/lto.exp index d097f06..3449a07 100644 --- a/ld/testsuite/ld-plugin/lto.exp +++ b/ld/testsuite/ld-plugin/lto.exp @@ -19,7 +19,7 @@ # MA 02110-1301, USA. # Check to see if the C and C++ compilers work -if { [which $CC] == 0 || [which $CXX] == 0 } { +if { ![check_compiler_available] || [which $CXX] == 0 } { return } diff --git a/ld/testsuite/ld-plugin/plugin.exp b/ld/testsuite/ld-plugin/plugin.exp index 8b0ea9c..ee193e9 100644 --- a/ld/testsuite/ld-plugin/plugin.exp +++ b/ld/testsuite/ld-plugin/plugin.exp @@ -26,7 +26,7 @@ if ![check_plugin_api_available] { # And a compiler to be available. set can_compile 1 set failure_kind "unresolved" -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { # Don't fail immediately, set can_compile 0 set failure_kind "unsupported" diff --git a/ld/testsuite/ld-scripts/crossref.exp b/ld/testsuite/ld-scripts/crossref.exp index 9aa216e..35573cd 100644 --- a/ld/testsuite/ld-scripts/crossref.exp +++ b/ld/testsuite/ld-scripts/crossref.exp @@ -27,7 +27,7 @@ set test5 "NOCROSSREFS_TO 2" set test6 "NOCROSSREFS_TO 3" set test7 "NOCROSSREFS_TO 4" -if { ![is_remote host] && [which $CC] == 0 } { +if { ![check_compiler_available] } { untested $test1 untested $test2 untested $test3 diff --git a/ld/testsuite/ld-sh/sh.exp b/ld/testsuite/ld-sh/sh.exp index 09263bb..1fca64d 100644 --- a/ld/testsuite/ld-sh/sh.exp +++ b/ld/testsuite/ld-sh/sh.exp @@ -129,7 +129,7 @@ set testlink "SH relaxing" set testjsr "SH confirm relaxing" set testrun "SH relaxing execution" -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { untested $testlink untested $testjsr untested $testrun diff --git a/ld/testsuite/ld-shared/shared.exp b/ld/testsuite/ld-shared/shared.exp index 0e3d75e..ed17b93 100644 --- a/ld/testsuite/ld-shared/shared.exp +++ b/ld/testsuite/ld-shared/shared.exp @@ -26,7 +26,7 @@ # bootstrap test. # Check to see if the C compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-size/size.exp b/ld/testsuite/ld-size/size.exp index 804ae11..c3493d2 100644 --- a/ld/testsuite/ld-size/size.exp +++ b/ld/testsuite/ld-size/size.exp @@ -48,7 +48,7 @@ foreach t $test_list { } # We need a working compiler. -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { verbose "Native size relocation tests not run - no compiler available" return } diff --git a/ld/testsuite/ld-srec/srec.exp b/ld/testsuite/ld-srec/srec.exp index afb1729..944e0a7 100644 --- a/ld/testsuite/ld-srec/srec.exp +++ b/ld/testsuite/ld-srec/srec.exp @@ -342,7 +342,7 @@ set sizeof_headers [string match "*SIZEOF_HEADERS*" $exec_output] # directly to the S-record format, and require that the two files # contain the same data. -if { ![is_remote host] && [which $CC] == 0 } { +if { ![check_compiler_available] } { untested $test1 untested $test2 return diff --git a/ld/testsuite/ld-undefined/undefined.exp b/ld/testsuite/ld-undefined/undefined.exp index 83433f3..8a8e865 100644 --- a/ld/testsuite/ld-undefined/undefined.exp +++ b/ld/testsuite/ld-undefined/undefined.exp @@ -24,7 +24,7 @@ set testund "undefined" set testfn "undefined function" set testline "undefined line" -if { ![is_remote host] && [which $CC] == 0 } { +if { ![check_compiler_available] } { verbose "Could not find C compiler!" 1 untested $testund untested $testfn diff --git a/ld/testsuite/ld-unique/unique.exp b/ld/testsuite/ld-unique/unique.exp index 2cda133..eb21108 100644 --- a/ld/testsuite/ld-unique/unique.exp +++ b/ld/testsuite/ld-unique/unique.exp @@ -44,7 +44,7 @@ foreach t $test_list { # We need a working compiler. (Strictly speaking this is # not true, we could use target specific assembler files). -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { verbose "UNIQUE compiled tests not run - no compiler available" return } diff --git a/ld/testsuite/ld-x86-64/mpx.exp b/ld/testsuite/ld-x86-64/mpx.exp index 6474084..4e63039 100644 --- a/ld/testsuite/ld-x86-64/mpx.exp +++ b/ld/testsuite/ld-x86-64/mpx.exp @@ -32,7 +32,7 @@ if ![istarget "x86_64-*-linux*"] { } # Check to see if the C compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-x86-64/no-plt.exp b/ld/testsuite/ld-x86-64/no-plt.exp index 77c90b1..7409345 100644 --- a/ld/testsuite/ld-x86-64/no-plt.exp +++ b/ld/testsuite/ld-x86-64/no-plt.exp @@ -35,7 +35,7 @@ if ![istarget "x86_64-*-*"] { } # Check to see if the C compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-x86-64/tls.exp b/ld/testsuite/ld-x86-64/tls.exp index b3b8a83..0b9f5c5 100644 --- a/ld/testsuite/ld-x86-64/tls.exp +++ b/ld/testsuite/ld-x86-64/tls.exp @@ -32,7 +32,7 @@ if ![istarget "x86_64-*-linux*"] { } # Check to see if the C compiler works -if { [which $CC] == 0 } { +if { ![check_compiler_available] } { return } diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp index 98aa4b0..23f2020 100644 --- a/ld/testsuite/ld-x86-64/x86-64.exp +++ b/ld/testsuite/ld-x86-64/x86-64.exp @@ -731,7 +731,7 @@ global PLT_CFLAGS global NOPIE_CFLAGS NOPIE_LDFLAGS # Must be native with the C compiler -if { [isnative] && [which $CC] != 0 } { +if { [isnative] && [check_compiler_available] } { run_cc_link_tests { {"Helper X32 DSO from x86-64 object" "" "-m64 -fPIC -g" {simple.c} {} "libsimple.a"} diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp index dc55dc8..0ff51c9 100644 --- a/ld/testsuite/lib/ld-lib.exp +++ b/ld/testsuite/lib/ld-lib.exp @@ -688,6 +688,11 @@ proc run_ld_link_exec_tests { ldtests args } { set objfiles {} set failed 0 + if { ![check_compiler_available] } { + unsupported $testname + continue + } + # verbose -log "Testname is $testname" # verbose -log "ld_options is $ld_options" # verbose -log "as_options is $as_options" @@ -840,6 +845,11 @@ proc run_cc_link_tests { ldtests } { set check_ld(terminal) 0 set check_ld(source) "" + if { ![check_compiler_available] } { + unsupported $testname + continue + } + #verbose -log "testname is $testname" #verbose -log "ldflags is $ldflags" #verbose -log "cflags is $cflags" @@ -1140,6 +1150,49 @@ proc check_sysroot_available { } { return $ld_sysroot_available_saved } +# Return true if we can build a program with the compiler. +# On some targets, CC might be defined, but libraries and startup +# code might be missing or require special options that the ld test +# harness doesn't know about. + +proc check_compiler_available { } { + global compiler_available_saved + global CC + + if {![info exists compiler_available_saved]} { + if { [which $CC] == 0 } { + set compiler_available_saved 0 + return 0 + } + + 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/compiler[pid]" + set src ${basename}.c + set output ${basename}.out + set f [open $src "w"] + puts $f "int main (void)" + puts $f "{" + puts $f " return 0; " + puts $f "}" + close $f + if [is_remote host] { + set src [remote_download host $src] + } + set compiler_available_saved [run_host_cmd_yesno "$CC" "$flags $src -o $output"] + remote_file host delete $src + remote_file host delete $output + file delete $src + } + return $compiler_available_saved +} + # Returns 1 if plugin is enabled in gcc. Returns 0 otherwise. proc check_gcc_plugin_enabled { } { global CC @@ -1327,7 +1380,7 @@ proc check_ifunc_available { } { global CC if {![info exists ifunc_available_saved]} { - if { [which $CC] == 0 } { + if { ![check_compiler_available] } { set ifunc_available_saved 0 return 0 } @@ -1376,7 +1429,7 @@ proc check_ifunc_attribute_available { } { global CC if {![info exists ifunc_attribute_available_saved]} { - if { [which $CC] == 0 } { + if { ![check_compiler_available] } { set ifunc_attribute_available_saved 0 return 0 } @@ -1423,7 +1476,7 @@ proc check_libdl_available { } { global CC if {![info exists libdl_available_saved]} { - if { [which $CC] == 0 } { + if { ![check_compiler_available] } { set libdl_available_saved 0 return 0 } @@ -1459,7 +1512,7 @@ proc check_gnu2_tls_available { } { global GNU2_CFLAGS if {![info exists gnu2_tls_available_saved]} { - if { [which $CC] == 0 || "$GNU2_CFLAGS" == "" } { + if { ![check_compiler_available] || "$GNU2_CFLAGS" == "" } { set gnu2_tls_available_saved 0 return 0 } |