+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..
# 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] {
# 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] {
# 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] {
# 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] {
# 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] {
# 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] {
}
# No compiler, no test.
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
untested "Auto import test (compiler not found)"
return
}
}\r
\r
# No compiler, no test.\r
-if { [which $CC] == 0 } {\r
+if { ![check_compiler_available] } {\r
untested "Exe export test (no compiler available)"\r
return\r
}\r
}
# Check if compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
}
# Check if compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
}
# Check if compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
set ASFLAGS $old_asflags
# Check to see if the C compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
}
# Check if compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
#
# 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*"]) } {
}
# Check to see if the C compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
}
# Check to see if the C compiler works.
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
}
# Check if compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
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
#
# Check to see if the C compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
# 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
}
#
# Check to see if the C compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
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
}
set LDFLAGS $old_ldflags
}
-if { [is_remote host] || [which $CC] != 0 } {
+if { [check_compiler_available] } {
if { [istarget "*-*-linux*"]
|| [istarget "*-*-nacl*"]
|| [istarget "*-*-gnu*"] } {
}
}
-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" \
# 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" \
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" \
# 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" \
}
# Check to see if the C compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
}
# Check to see if the C compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
# 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
}
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
}
}
# 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.
}
# No compiler, no test.
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
untested "Direct linking to dll test"
return
}
}
# No compiler, no test.
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
untested "Direct linking to dll fastcall/stdcall test"
return
}
}
# Check to see if the C compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
# 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
}
# 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"
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
set testjsr "SH confirm relaxing"
set testrun "SH relaxing execution"
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
untested $testlink
untested $testjsr
untested $testrun
# bootstrap test.
# Check to see if the C compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
}
# We need a working compiler.
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
verbose "Native size relocation tests not run - no compiler available"
return
}
# 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
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
# 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
}
}
# Check to see if the C compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
}
# Check to see if the C compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
}
# Check to see if the C compiler works
-if { [which $CC] == 0 } {
+if { ![check_compiler_available] } {
return
}
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"}
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"
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"
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
global CC
if {![info exists ifunc_available_saved]} {
- if { [which $CC] == 0 } {
+ if { ![check_compiler_available] } {
set ifunc_available_saved 0
return 0
}
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
}
global CC
if {![info exists libdl_available_saved]} {
- if { [which $CC] == 0 } {
+ if { ![check_compiler_available] } {
set libdl_available_saved 0
return 0
}
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
}