CC_FOR_TARGET et al

The top level Makefile, the ld Makefile and others, define
CC_FOR_TARGET to be a compiler for the binutils target machine.  This
is the compiler that should be used for almost all tests with C
source.  There are _FOR_TARGET versions of CFLAGS, CXX, and CXXFLAGS
too.  This was all supposed to work with the testsuite .exp files
using CC for the target compiler, and CC_FOR_HOST for the host
compiler, with the makefiles passing CC=$CC_FOR_TARGET and
CC_FOR_HOST=$CC to the runtest invocation.

One exception to the rule of using CC_FOR_TARGET is the native-only ld
bootstrap test, which uses the newly built ld to link a copy of
itself.  Since the files being linked were created with the host
compiler, the boostrap test should use CC and CFLAGS, in case some
host compiler option provides needed libraries automatically.
However, bootstrap.exp used CC where it should have used CC_FOR_HOST.
I set about fixing that problem, then decided that playing games in
the makefiles with CC was a bad idea.  Not only is it confusing, but
other dejagnu code knows about CC_FOR_TARGET.  See dejagnu/target.exp.

So this patch gets rid of the makefile variable renaming and changes
all the .exp files to use the correct _FOR_TARGET variables.
CC_FOR_HOST and CFLAGS_FOR_HOST disappear.  A followup patch will
correct bootstrap.exp to use CFLAGS, and a number of other things I
noticed.

binutils/
	* testsuite/lib/binutils-common.exp (run_dump_test): Use
	CC_FOR_TARGET and CFLAGS_FOR_TARGET rather than CC and CFLAGS.
ld/
	* Makefile.am (check-DEJAGNU): Don't set CC to CC_FOR_TARGET
	and similar.  Pass variables with unchanged names.  Don't set
	CC_FOR_HOST or CFLAGS_FOR_HOST.
	* Makefile.in: Regenerate.
	* testsuite/config/default.exp: Update default CC and similar.
	(compiler_supports, plug_opt): Use CC_FOR_TARGET.
	* testsuite/ld-cdtest/cdtest.exp: Replace all uses of CC with
	CC_FOR_TARGET, and similarly for CFLAGS, CXX and CXXFLAGS.
	* testsuite/ld-auto-import/auto-import.exp: Likewise.
	* testsuite/ld-cygwin/exe-export.exp: Likewise.
	* testsuite/ld-elf/dwarf.exp: Likewise.
	* testsuite/ld-elf/indirect.exp: Likewise.
	* testsuite/ld-elf/shared.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-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-selective/selective.exp: Likewise.
	* testsuite/ld-sh/sh.exp: Likewise.
	* testsuite/ld-shared/shared.exp: Likewise.
	* testsuite/ld-srec/srec.exp: Likewise.
	* testsuite/ld-undefined/undefined.exp: Likewise.
	* testsuite/ld-unique/unique.exp: Likewise.
	* testsuite/ld-x86-64/tls.exp: Likewise.
	* testsuite/lib/ld-lib.exp: Likewise.
libctf/
	* Makefile.am (check-DEJAGNU): Don't set CC to CC_FOR_TARGET.
	Pass CC and CC_FOR_TARGET.  Don't set CC_FOR_HOST.
	* Makefile.in: Regenerate.
	* testsuite/config/default.exp: Update default CC and similar.
	* testsuite/lib/ctf-lib.exp (run_native_host_cmd): Use CC rather
	than CC_FOR_HOST.
	(run_lookup_test): Use CC_FOR_TARGET and CFLAGS_FOR_TARGET.
This commit is contained in:
Alan Modra
2021-09-03 16:26:09 +09:30
parent 2ea9d33a12
commit ad77db1c02
36 changed files with 353 additions and 340 deletions

View File

@ -851,9 +851,9 @@ if ![string length [info proc prune_warnings]] {
# regexps in FILE.d. # regexps in FILE.d.
# #
proc run_dump_test { name {extra_options {}} } { proc run_dump_test { name {extra_options {}} } {
global ADDR2LINE ADDR2LINEFLAGS AS ASFLAGS CC CFLAGS ELFEDIT ELFEDITFLAGS global ADDR2LINE ADDR2LINEFLAGS AS ASFLAGS CC_FOR_TARGET CFLAGS_FOR_TARGET
global LD LDFLAGS NM NMFLAGS OBJCOPY OBJCOPYFLAGS OBJDUMP OBJDUMPFLAGS global ELFEDIT ELFEDITFLAGS LD LDFLAGS NM NMFLAGS OBJCOPY OBJCOPYFLAGS
global READELF READELFFLAGS STRIP STRIPFLAGS global OBJDUMP OBJDUMPFLAGS READELF READELFFLAGS STRIP STRIPFLAGS
global copyfile env runtests srcdir subdir verbose global copyfile env runtests srcdir subdir verbose
if [string match "*/*" $name] { if [string match "*/*" $name] {
@ -1159,7 +1159,7 @@ proc run_dump_test { name {extra_options {}} } {
# ofile is never absolute, so this always works to protect sfile # ofile is never absolute, so this always works to protect sfile
# from later absolutization. # from later absolutization.
set sfile "./[file rootname $ofile].s" set sfile "./[file rootname $ofile].s"
set cmd "$CC $CFLAGS -S $opts(cc) -o $sfile $cfile" set cmd "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -S $opts(cc) -o $sfile $cfile"
send_log "$cmd\n" send_log "$cmd\n"
set cmdret [remote_exec host [concat sh -c [list "$cmd 2>&1"]] "" "/dev/null" "dump.tmp"] set cmdret [remote_exec host [concat sh -c [list "$cmd 2>&1"]] "" "/dev/null" "dump.tmp"]
remote_upload host "dump.tmp" remote_upload host "dump.tmp"

View File

@ -980,9 +980,12 @@ check-DEJAGNU: site.exp
runtest=$(RUNTEST); \ runtest=$(RUNTEST); \
if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
$$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \ $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \
CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS_FOR_TARGET)" \ CC="$(CC)" CFLAGS="$(CFLAGS)" \
CXX="$(CXX_FOR_TARGET)" CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \ CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" \
CC_FOR_HOST="$(CC)" CFLAGS_FOR_HOST="$(CFLAGS)" \ CC_FOR_TARGET="$(CC_FOR_TARGET)" \
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXX_FOR_TARGET="$(CXX_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
OFILES="$(OFILES)" BFDLIB="$(TESTBFDLIB)" CTFLIB="$(TESTCTFLIB) $(ZLIB)" \ OFILES="$(OFILES)" BFDLIB="$(TESTBFDLIB)" CTFLIB="$(TESTCTFLIB) $(ZLIB)" \
LIBIBERTY="$(LIBIBERTY) $(LIBINTL)" LIBS="$(LIBS)" \ LIBIBERTY="$(LIBIBERTY) $(LIBINTL)" LIBS="$(LIBS)" \
DO_COMPARE="`echo '$(do_compare)' | sed -e 's,\\$$,,g'`" \ DO_COMPARE="`echo '$(do_compare)' | sed -e 's,\\$$,,g'`" \

View File

@ -2625,9 +2625,12 @@ check-DEJAGNU: site.exp
runtest=$(RUNTEST); \ runtest=$(RUNTEST); \
if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
$$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \ $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \
CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS_FOR_TARGET)" \ CC="$(CC)" CFLAGS="$(CFLAGS)" \
CXX="$(CXX_FOR_TARGET)" CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \ CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" \
CC_FOR_HOST="$(CC)" CFLAGS_FOR_HOST="$(CFLAGS)" \ CC_FOR_TARGET="$(CC_FOR_TARGET)" \
CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)" \
CXX_FOR_TARGET="$(CXX_FOR_TARGET)" \
CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)" \
OFILES="$(OFILES)" BFDLIB="$(TESTBFDLIB)" CTFLIB="$(TESTCTFLIB) $(ZLIB)" \ OFILES="$(OFILES)" BFDLIB="$(TESTBFDLIB)" CTFLIB="$(TESTCTFLIB) $(ZLIB)" \
LIBIBERTY="$(LIBIBERTY) $(LIBINTL)" LIBS="$(LIBS)" \ LIBIBERTY="$(LIBIBERTY) $(LIBINTL)" LIBS="$(LIBS)" \
DO_COMPARE="`echo '$(do_compare)' | sed -e 's,\\$$,,g'`" \ DO_COMPARE="`echo '$(do_compare)' | sed -e 's,\\$$,,g'`" \

View File

@ -76,20 +76,23 @@ if {[file exists tmpdir/libpath.exp]} {
} }
} }
# The "make check" target in the Makefile passes in
# "CC=$(CC_FOR_TARGET)". But, if the user invokes runtest directly
# (as when testing an installed linker), these flags may not be set.
if {![info exists CC]} { if {![info exists CC]} {
set CC [find_gcc] set CC gcc
} }
if {![info exists CFLAGS]} { if {![info exists CFLAGS]} {
set CFLAGS "-g -O2" set CFLAGS "-g -O2"
} }
if {![info exists CXX]} { if {![info exists CC_FOR_TARGET]} {
set CXX [find_g++] set CC_FOR_TARGET [find_gcc]
} }
if {![info exists CXXFLAGS]} { if {![info exists CFLAGS_FOR_TARGET]} {
set CXXFLAGS "" set CFLAGS_FOR_TARGET "-g -O2"
}
if {![info exists CXX_FOR_TARGET]} {
set CXX_FOR_TARGET [find_g++]
}
if {![info exists CXXFLAGS_FOR_TARGET]} {
set CXXFLAGS_FOR_TARGET ""
} }
# This allows us to run the linker testsuite with clang as the compilation # This allows us to run the linker testsuite with clang as the compilation
@ -324,7 +327,7 @@ if { ![info exists LD_CLASS] } then {
# Compiler tests # Compiler tests
proc compiler_supports { flag args } { proc compiler_supports { flag args } {
if { [check_compiler_available] } { if { [check_compiler_available] } {
global CC global CC_FOR_TARGET
set flags "" set flags ""
if [board_info [target_info name] exists cflags] { if [board_info [target_info name] exists cflags] {
append flags " [board_info [target_info name] cflags]" append flags " [board_info [target_info name] cflags]"
@ -341,7 +344,7 @@ proc compiler_supports { flag args } {
} }
close $f close $f
set rfn [remote_download host $fn] set rfn [remote_download host $fn]
set avail [run_host_cmd_yesno "$CC" "$flags $flag $rfn -o /dev/null"] set avail [run_host_cmd_yesno "$CC_FOR_TARGET" "$flags $flag $rfn -o /dev/null"]
remote_file host delete $rfn remote_file host delete $rfn
file delete $fn file delete $fn
return $avail return $avail
@ -442,9 +445,9 @@ if { [check_compiler_available] } {
cyglto_plugin-0.dll cyglto_plugin-0.dll
} }
foreach plug $plugin_names { foreach plug $plugin_names {
set plug_so [run_host_cmd $CC "--print-prog-name $plug"] set plug_so [run_host_cmd $CC_FOR_TARGET "--print-prog-name $plug"]
if { $plug_so eq $plug } then { if { $plug_so eq $plug } then {
set plug_so [run_host_cmd $CC "--print-file-name $plug"] set plug_so [run_host_cmd $CC_FOR_TARGET "--print-file-name $plug"]
} }
if { $plug_so ne $plug } then { if { $plug_so ne $plug } then {
set plug_opt "--plugin $plug_so" set plug_opt "--plugin $plug_so"

View File

@ -118,7 +118,7 @@ if [istarget *-pc-cygwin] {
set MYLIBS "-L/usr/lib -lcygwin -L/usr/lib/w32api -lkernel32" set MYLIBS "-L/usr/lib -lcygwin -L/usr/lib/w32api -lkernel32"
# Compile the dll. # Compile the dll.
if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/dll.c $tmpdir/dll.o] { if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG" $srcdir/$subdir/dll.c $tmpdir/dll.o] {
fail "compiling shared lib" fail "compiling shared lib"
} }
if ![ld_special_link "$ld -shared --enable-auto-import -e __cygwin_dll_entry@12 --out-implib=$tmpdir/libstandard.dll.a" $tmpdir/dll.dll "$tmpdir/dll.o $MYLIBS"] { if ![ld_special_link "$ld -shared --enable-auto-import -e __cygwin_dll_entry@12 --out-implib=$tmpdir/libstandard.dll.a" $tmpdir/dll.dll "$tmpdir/dll.o $MYLIBS"] {
@ -129,7 +129,7 @@ if [istarget *-pc-cygwin] {
catch "exec ln -fs dll.dll $tmpdir/libsymlinked_dll.dll.a" ln_catch catch "exec ln -fs dll.dll $tmpdir/libsymlinked_dll.dll.a" ln_catch
# Compile and link the client program. # Compile and link the client program.
if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/client.c $tmpdir/client.o] { if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG" $srcdir/$subdir/client.c $tmpdir/client.o] {
fail "compiling client" fail "compiling client"
} }

View File

@ -32,15 +32,15 @@ if ![isnative] {
return return
} }
if { [which $CXX] == 0 } { if { [which $CXX_FOR_TARGET] == 0 } {
untested $test1 untested $test1
untested $test2 untested $test2
return return
} }
if { ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-foo.cc tmpdir/cdtest-foo.o] if { ![ld_compile "$CXX_FOR_TARGET $CXXFLAGS_FOR_TARGET -fno-exceptions" $srcdir/$subdir/cdtest-foo.cc tmpdir/cdtest-foo.o]
|| ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-bar.cc tmpdir/cdtest-bar.o] || ![ld_compile "$CXX_FOR_TARGET $CXXFLAGS_FOR_TARGET -fno-exceptions" $srcdir/$subdir/cdtest-bar.cc tmpdir/cdtest-bar.o]
|| ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-main.cc tmpdir/cdtest-main.o] } { || ![ld_compile "$CXX_FOR_TARGET $CXXFLAGS_FOR_TARGET -fno-exceptions" $srcdir/$subdir/cdtest-main.cc tmpdir/cdtest-main.o] } {
unsupported $test1 unsupported $test1
unsupported $test2 unsupported $test2
return return
@ -48,7 +48,7 @@ if { ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-foo.
set expected_output "$srcdir/$subdir/cdtest.dat" set expected_output "$srcdir/$subdir/cdtest.dat"
if ![ld_link $CC tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] { if ![ld_link $CC_FOR_TARGET tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
fail $test1 fail $test1
} else { } else {
send_log "tmpdir/cdtest >tmpdir/cdtest.out\n" send_log "tmpdir/cdtest >tmpdir/cdtest.out\n"
@ -100,7 +100,7 @@ if [is_pecoff_format] {
if ![ld_relocate $ld tmpdir/cdtest.o {-Ur tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] { if ![ld_relocate $ld tmpdir/cdtest.o {-Ur tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
fail $test2 fail $test2
} else { } else {
if ![ld_link $CC tmpdir/cdtest tmpdir/cdtest.o] { if ![ld_link $CC_FOR_TARGET tmpdir/cdtest tmpdir/cdtest.o] {
fail $test2 fail $test2
} else { } else {
send_log "tmpdir/cdtest >tmpdir/cdtest.out\n" send_log "tmpdir/cdtest >tmpdir/cdtest.out\n"

View File

@ -113,23 +113,23 @@ if ![run_dlltool $tmpdir/testdll.lib $srcdir/$subdir/testdll.def] {
} }
# Compile the executable. # Compile the executable.
if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/testexe.c $tmpdir/testexe.o] { if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/testexe.c $tmpdir/testexe.o] {
fail "compiling executable" fail "compiling executable"
return return
} }
if ![ld_special_link "$CC $LDFLAGS $MYLDFLAGS -e _testexe_main@16" $tmpdir/testexe.exe "$tmpdir/testexe.o $srcdir/$subdir/testexe.def $tmpdir/testdll.lib -lkernel32"] { if ![ld_special_link "$CC_FOR_TARGET $LDFLAGS $MYLDFLAGS -e _testexe_main@16" $tmpdir/testexe.exe "$tmpdir/testexe.o $srcdir/$subdir/testexe.def $tmpdir/testdll.lib -lkernel32"] {
fail "linking executable" fail "linking executable"
return return
} }
# Compile the dll. # Compile the dll.
if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/testdll.c $tmpdir/testdll.o] { if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/testdll.c $tmpdir/testdll.o] {
fail "compiling shared lib" fail "compiling shared lib"
return return
} }
if ![ld_special_link "$CC $LDFLAGS -nostartfiles -nostdlib -e _testdll_main@12" $tmpdir/testdll.dll "$tmpdir/testdll.o $srcdir/$subdir/testdll.def $tmpdir/testexe.lib"] { if ![ld_special_link "$CC_FOR_TARGET $LDFLAGS -nostartfiles -nostdlib -e _testdll_main@12" $tmpdir/testdll.dll "$tmpdir/testdll.o $srcdir/$subdir/testdll.def $tmpdir/testexe.lib"] {
fail "linking shared lib" fail "linking shared lib"
return return
} }

View File

@ -41,7 +41,7 @@ if { ![check_compiler_available] } {
} }
# Skip if -feliminate-dwarf2-dups isn't supported. # Skip if -feliminate-dwarf2-dups isn't supported.
if ![ld_compile "$CC -g -feliminate-dwarf2-dups" $srcdir/$subdir/dummy.c tmpdir/dummy.o] { if ![ld_compile "$CC_FOR_TARGET -g -feliminate-dwarf2-dups" $srcdir/$subdir/dummy.c tmpdir/dummy.o] {
return return
} }
@ -69,11 +69,11 @@ set run_tests {
} }
# Disable all sanitizers. # Disable all sanitizers.
set old_CFLAGS "$CFLAGS" set old_CFLAGS "$CFLAGS_FOR_TARGET"
append CFLAGS " $NOSANITIZE_CFLAGS" append CFLAGS_FOR_TARGET " $NOSANITIZE_CFLAGS"
run_cc_link_tests $build_tests run_cc_link_tests $build_tests
run_ld_link_exec_tests $run_tests run_ld_link_exec_tests $run_tests
set CFLAGS "$old_CFLAGS" set CFLAGS_FOR_TARGET "$old_CFLAGS"
proc strip_test {} { proc strip_test {} {
global ld global ld

View File

@ -38,7 +38,7 @@ if { ![check_compiler_available] } {
} }
# Some bare-metal targets don't support shared libs or PIC. # Some bare-metal targets don't support shared libs or PIC.
if { ![run_host_cmd_yesno $CC "-shared -fPIC $srcdir/$subdir/dummy.c -o tmpdir/t.so"] } { if { ![run_host_cmd_yesno $CC_FOR_TARGET "-shared -fPIC $srcdir/$subdir/dummy.c -o tmpdir/t.so"] } {
return return
} }
@ -59,7 +59,7 @@ proc check_link_message { cmd string testname } {
} }
# Disable LTO for these tests. # Disable LTO for these tests.
set cc_cmd "$CC" set cc_cmd "$CC_FOR_TARGET"
if {[check_lto_available]} { if {[check_lto_available]} {
append cc_cmd " -fno-lto" append cc_cmd " -fno-lto"
} }
@ -226,8 +226,8 @@ foreach t [list indirect5a indirect5b indirect6a indirect6b] {
} }
} }
send_log "$CC -fPIE -pie $srcdir/$subdir/main.c -o tmpdir/pie" send_log "$CC_FOR_TARGET -fPIE -pie $srcdir/$subdir/main.c -o tmpdir/pie"
catch "exec $CC -fPIE -pie $srcdir/$subdir/main.c -o tmpdir/pie" exec_output catch "exec $CC_FOR_TARGET -fPIE -pie $srcdir/$subdir/main.c -o tmpdir/pie" exec_output
send_log "$exec_output" send_log "$exec_output"
if { ! [string match "" $exec_output] } { if { ! [string match "" $exec_output] } {
return return

View File

@ -1180,36 +1180,36 @@ if [check_libdl_available] {
# XFAIL on NetBSD ELF systems as they do not currently support the .*_array # XFAIL on NetBSD ELF systems as they do not currently support the .*_array
# sections. # sections.
# Disable all sanitizers. # Disable all sanitizers.
set old_CFLAGS "$CFLAGS" set old_CFLAGS "$CFLAGS_FOR_TARGET"
append CFLAGS " $NOSANITIZE_CFLAGS" append CFLAGS_FOR_TARGET " $NOSANITIZE_CFLAGS"
run_ld_link_exec_tests $dlopen_run_tests "*-*-netbsd*" run_ld_link_exec_tests $dlopen_run_tests "*-*-netbsd*"
set CFLAGS "$old_CFLAGS" set CFLAGS_FOR_TARGET "$old_CFLAGS"
} }
# Check --no-add-needed and --no-copy-dt-needed-entries # Check --no-add-needed and --no-copy-dt-needed-entries
set testname "--no-add-needed" set testname "--no-add-needed"
set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"] set exec_output [run_host_cmd "$CC_FOR_TARGET" "tmpdir/libneeded1c.o -Wl,--no-add-needed,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } { if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } {
pass $testname pass $testname
} { } {
fail $testname fail $testname
} }
set testname "--no-copy-dt-needed-entries" set testname "--no-copy-dt-needed-entries"
set exec_output [run_host_cmd "$CC" "tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"] set exec_output [run_host_cmd "$CC_FOR_TARGET" "tmpdir/libneeded1c.o -Wl,--no-copy-dt-needed-entries,-rpath-link=tmpdir -Ltmpdir -lneeded1a"]
if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } { if { [ regexp "tmpdir/libneeded1b.so: .*: DSO missing" $exec_output ] } {
pass $testname pass $testname
} { } {
fail $testname fail $testname
} }
set testname "--no-add-needed -shared" set testname "--no-add-needed -shared"
set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-add-needed,-z,defs -Ltmpdir -lneeded1a"] set exec_output [run_host_cmd "$CC_FOR_TARGET" "-shared tmpdir/libneeded1pic.o -Wl,--no-add-needed,-z,defs -Ltmpdir -lneeded1a"]
if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } { if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } {
pass $testname pass $testname
} { } {
fail $testname fail $testname
} }
set testname "--no-copy-dt-needed-entries -shared" set testname "--no-copy-dt-needed-entries -shared"
set exec_output [run_host_cmd "$CC" "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries,-z,defs -Ltmpdir -lneeded1a"] set exec_output [run_host_cmd "$CC_FOR_TARGET" "-shared tmpdir/libneeded1pic.o -Wl,--no-copy-dt-needed-entries,-z,defs -Ltmpdir -lneeded1a"]
if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } { if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } {
pass $testname pass $testname
} { } {
@ -1217,7 +1217,7 @@ if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } {
} }
# Check to see if the C++ compiler works # Check to see if the C++ compiler works
if { [which $CXX] == 0 } { if { [which $CXX_FOR_TARGET] == 0 } {
return return
} }

View File

@ -164,14 +164,14 @@ proc stt_common_test { options testname } {
} }
if [istarget nios2*-*-*] { if [istarget nios2*-*-*] {
set CFLAGS "$CFLAGS -G0" append CFLAGS_FOR_TARGET " -G0"
} }
# Explicitly use "-fcommon" so that even if $CFLAGS includes # Explicitly use "-fcommon" so that even if $CFLAGS includes
# "-fno-common", these tests are compiled as expected. # "-fno-common", these tests are compiled as expected.
if { ![ld_compile "$CC $CFLAGS -fcommon $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/common1a.c tmpdir/common1a.o] if { ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -fcommon $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/common1a.c tmpdir/common1a.o]
|| ![ld_compile "$CC $CFLAGS -fcommon $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/common1b.c tmpdir/common1b.o] || ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -fcommon $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/common1b.c tmpdir/common1b.o]
|| ![ld_compile "$CC $CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -Wa,--elf-stt-common=yes -fcommon" $srcdir/$subdir/common1b.c tmpdir/common1c.o] } { || ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -Wa,--elf-stt-common=yes -fcommon" $srcdir/$subdir/common1b.c tmpdir/common1c.o] } {
unsupported $test1 unsupported $test1
return return
} }

View File

@ -73,9 +73,9 @@ if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then {
# Unfortunately, the gcc argument is -fpic and the cc argument is # Unfortunately, the gcc argument is -fpic and the cc argument is
# -KPIC. We have to try both. # -KPIC. We have to try both.
set picflag "-fpic" set picflag "-fpic"
send_log "$CC $picflag\n" send_log "$CC_FOR_TARGET $picflag\n"
verbose "$CC $picflag" verbose "$CC_FOR_TARGET $picflag"
catch "exec $CC $picflag" exec_output catch "exec $CC_FOR_TARGET $picflag" exec_output
send_log "$exec_output\n" send_log "$exec_output\n"
verbose "--" "$exec_output" verbose "--" "$exec_output"
if { [string match "*illegal option*" $exec_output] if { [string match "*illegal option*" $exec_output]
@ -486,13 +486,13 @@ proc build_binary { shared pic test source libname other mapfile verexp versymex
global as global as
global as_options global as_options
global objdump global objdump
global CC global CC_FOR_TARGET
global CFLAGS global CFLAGS_FOR_TARGET
global script global script
global NOSANITIZE_CFLAGS global NOSANITIZE_CFLAGS
global NOLTO_CFLAGS global NOLTO_CFLAGS
if ![ld_compile "$CC -S $pic $CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/$source $tmpdir/$libname.s] { if ![ld_compile "$CC_FOR_TARGET -S $pic $CFLAGS_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/$source $tmpdir/$libname.s] {
unsupported "$test" unsupported "$test"
return return
} }
@ -578,8 +578,8 @@ proc test_ldfail { test flag source execname other mapfile whyfail } {
global as global as
global as_options global as_options
global objdump global objdump
global CC global CC_FOR_TARGET
global CFLAGS global CFLAGS_FOR_TARGET
global script global script
if [string match "" $other] then { if [string match "" $other] then {
@ -588,7 +588,7 @@ proc test_ldfail { test flag source execname other mapfile whyfail } {
set other_lib $tmpdir/$other set other_lib $tmpdir/$other
} }
if ![ld_compile "$CC -S $flag $CFLAGS" $srcdir/$subdir/$source $tmpdir/$execname.s] { if ![ld_compile "$CC_FOR_TARGET -S $flag $CFLAGS_FOR_TARGET" $srcdir/$subdir/$source $tmpdir/$execname.s] {
unsupported "$test" unsupported "$test"
return return
} }
@ -606,7 +606,7 @@ proc test_ldfail { test flag source execname other mapfile whyfail } {
set script_arg "-Wl,$script $srcdir/$subdir/$mapfile" set script_arg "-Wl,$script $srcdir/$subdir/$mapfile"
} }
if {![ld_link $CC $tmpdir/$execname "$tmpdir/$execname.o $other_lib $script_arg"]} { if {![ld_link $CC_FOR_TARGET $tmpdir/$execname "$tmpdir/$execname.o $other_lib $script_arg"]} {
pass "$test" pass "$test"
return return
} }
@ -618,11 +618,11 @@ proc test_asfail { test flag source execname whyfail } {
global subdir global subdir
global tmpdir global tmpdir
global as global as
global CC global CC_FOR_TARGET
global CFLAGS global CFLAGS_FOR_TARGET
global NOLTO_CFLAGS global NOLTO_CFLAGS
if ![ld_compile "$CC -S $flag $CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/$source $tmpdir/$execname.s] { if ![ld_compile "$CC_FOR_TARGET -S $flag $CFLAGS_FOR_TARGET $NOLTO_CFLAGS" $srcdir/$subdir/$source $tmpdir/$execname.s] {
unsupported "$test" unsupported "$test"
return return
} }
@ -688,8 +688,8 @@ proc build_exec { test source execname flags solibname verexp versymexp symexp }
global as global as
global as_options global as_options
global objdump global objdump
global CC global CC_FOR_TARGET
global CFLAGS global CFLAGS_FOR_TARGET
global NOSANITIZE_CFLAGS global NOSANITIZE_CFLAGS
global NOLTO_CFLAGS global NOLTO_CFLAGS
@ -697,7 +697,7 @@ proc build_exec { test source execname flags solibname verexp versymexp symexp }
set script --version-script set script --version-script
# Disable LTO for these tests. # Disable LTO for these tests.
set cc_cmd "$CC -S $CFLAGS" set cc_cmd "$CC_FOR_TARGET -S $CFLAGS_FOR_TARGET"
if {[check_lto_available]} { if {[check_lto_available]} {
append cc_cmd " -fno-lto" append cc_cmd " -fno-lto"
} }
@ -721,7 +721,7 @@ proc build_exec { test source execname flags solibname verexp versymexp symexp }
set solibname_lib $tmpdir/$solibname set solibname_lib $tmpdir/$solibname
} }
if {![ld_link $CC $tmpdir/$execname "$flags $tmpdir/$execname.o $solibname_lib"]} { if {![ld_link $CC_FOR_TARGET $tmpdir/$execname "$flags $tmpdir/$execname.o $solibname_lib"]} {
fail "$test" fail "$test"
return return
} }

View File

@ -76,7 +76,7 @@ if [istarget arm*-*-linux*] {
set file [open $tmpdir/movw-detect.c w] set file [open $tmpdir/movw-detect.c w]
puts $file "void foo(void) { __asm (\"movw r0, #0\"); }" puts $file "void foo(void) { __asm (\"movw r0, #0\"); }"
close $file close $file
if [run_host_cmd_yesno "$CC" "$CFLAGS -c $tmpdir/movw-detect.c -o $tmpdir/movw-detect.o"] { if [run_host_cmd_yesno "$CC_FOR_TARGET" "$CFLAGS_FOR_TARGET -c $tmpdir/movw-detect.c -o $tmpdir/movw-detect.o"] {
set shared_needs_pic "yes" set shared_needs_pic "yes"
} }
} }
@ -87,8 +87,8 @@ set support_protected "no"
if { [istarget *-*-linux*] if { [istarget *-*-linux*]
|| [istarget *-*-nacl*] || [istarget *-*-nacl*]
|| [istarget *-*-gnu*] } { || [istarget *-*-gnu*] } {
if [ld_compile "$CC -g $CFLAGS -DPROTECTED_CHECK" $srcdir/$subdir/main.c $tmpdir/main.o] { if [ld_compile "$CC_FOR_TARGET -g $CFLAGS_FOR_TARGET -DPROTECTED_CHECK" $srcdir/$subdir/main.c $tmpdir/main.o] {
if [ld_link $CC $tmpdir/main "$tmpdir/main.o"] { if [ld_link $CC_FOR_TARGET $tmpdir/main "$tmpdir/main.o"] {
catch "exec $tmpdir/main" support_protected catch "exec $tmpdir/main" support_protected
} }
} }
@ -96,7 +96,7 @@ if { [istarget *-*-linux*]
# The test procedure. # The test procedure.
proc visibility_test { visibility progname testname main sh1 sh2 dat args } { proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
global CC global CC_FOR_TARGET
global srcdir global srcdir
global subdir global subdir
global exec_output global exec_output
@ -111,7 +111,7 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
if { [is_elf_format] && [check_shared_lib_support] } { if { [is_elf_format] && [check_shared_lib_support] } {
append shared " -Wl,-z,notext" append shared " -Wl,-z,notext"
} }
if {![ld_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} { if {![ld_link $CC_FOR_TARGET $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
if { [ string match $visibility "hidden_undef" ] if { [ string match $visibility "hidden_undef" ]
&& [regexp "undefined reference to \`\.?visibility\'" $link_output] && [regexp "undefined reference to \`\.?visibility\'" $link_output]
&& [regexp "undefined reference to \`visibility_var\'" $link_output] } { && [regexp "undefined reference to \`visibility_var\'" $link_output] } {
@ -129,7 +129,7 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
# Link against the shared library. Use -rpath so that the # Link against the shared library. Use -rpath so that the
# dynamic linker can locate the shared library at runtime. # dynamic linker can locate the shared library at runtime.
set rpath $tmpdir set rpath $tmpdir
if ![ld_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] { if ![ld_link $CC_FOR_TARGET $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] {
if { [ string match $visibility "hidden" ] if { [ string match $visibility "hidden" ]
&& [regexp "undefined reference to \`\.?visibility\'" $link_output] && [regexp "undefined reference to \`\.?visibility\'" $link_output]
&& [regexp "undefined reference to \`visibility_var\'" $link_output] } { && [regexp "undefined reference to \`visibility_var\'" $link_output] } {
@ -184,8 +184,8 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
} }
proc visibility_run {visibility} { proc visibility_run {visibility} {
global CC global CC_FOR_TARGET
global CFLAGS global CFLAGS_FOR_TARGET
global SHCFLAG global SHCFLAG
global srcdir global srcdir
global subdir global subdir
@ -237,7 +237,7 @@ proc visibility_run {visibility} {
} else { } else {
# Compile the main program. Make sure that PLT is used since PLT # Compile the main program. Make sure that PLT is used since PLT
# is expected. # is expected.
if ![ld_compile "$CC -g $PLT_CFLAGS $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/main.c $tmpdir/mainnp.o] { if ![ld_compile "$CC_FOR_TARGET -g $PLT_CFLAGS $CFLAGS_FOR_TARGET $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
unsupported "visibility ($visibility) (non PIC)" unsupported "visibility ($visibility) (non PIC)"
unsupported "visibility ($visibility)" unsupported "visibility ($visibility)"
} else { } else {
@ -247,8 +247,8 @@ proc visibility_run {visibility} {
# will need to do more relocation work. However, note that not # will need to do more relocation work. However, note that not
# using -fpic will cause some of the tests to return different # using -fpic will cause some of the tests to return different
# results. Make sure that PLT is used since PLT is expected. # results. Make sure that PLT is used since PLT is expected.
if { ![ld_compile "$CC -g $NOPIE_CFLAGS $PLT_CFLAGS $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o] if { ![ld_compile "$CC_FOR_TARGET -g $NOPIE_CFLAGS $PLT_CFLAGS $CFLAGS_FOR_TARGET $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o]
|| ![ld_compile "$CC -g $NOPIE_CFLAGS $PLT_CFLAGS $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/sh2.c $tmpdir/sh2np.o] } { || ![ld_compile "$CC_FOR_TARGET -g $NOPIE_CFLAGS $PLT_CFLAGS $CFLAGS_FOR_TARGET $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/sh2.c $tmpdir/sh2np.o] } {
unsupported "visibility ($visibility) (non PIC)" unsupported "visibility ($visibility) (non PIC)"
} else { } else {
# SunOS non PIC shared libraries don't permit some cases of # SunOS non PIC shared libraries don't permit some cases of
@ -336,8 +336,8 @@ proc visibility_run {visibility} {
# Now compile the code using -fpic. # Now compile the code using -fpic.
if { ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o] if { ![ld_compile "$CC_FOR_TARGET -g $CFLAGS_FOR_TARGET $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o]
|| ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.o] } { || ![ld_compile "$CC_FOR_TARGET -g $CFLAGS_FOR_TARGET $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.o] } {
unsupported "visibility ($visibility)" unsupported "visibility ($visibility)"
} else { } else {
if { [ string match $visibility "protected" ] if { [ string match $visibility "protected" ]
@ -354,7 +354,7 @@ proc visibility_run {visibility} {
# Don't bother. # Don't bother.
} else { } else {
# Now do the same tests again, but this time compile main.c PIC. # Now do the same tests again, but this time compile main.c PIC.
if ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/main.c $tmpdir/mainp.o] { if ![ld_compile "$CC_FOR_TARGET -g $CFLAGS_FOR_TARGET $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/main.c $tmpdir/mainp.o] {
unsupported "visibility ($visibility) (PIC main, non PIC so)" unsupported "visibility ($visibility) (PIC main, non PIC so)"
unsupported "visibility ($visibility) (PIC main)" unsupported "visibility ($visibility) (PIC main)"
} else { } else {
@ -421,9 +421,9 @@ if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then {
# Unfortunately, the gcc argument is -fpic and the cc argument is # Unfortunately, the gcc argument is -fpic and the cc argument is
# -KPIC. We have to try both. # -KPIC. We have to try both.
set picflag "-fpic" set picflag "-fpic"
send_log "$CC $picflag\n" send_log "$CC_FOR_TARGET $picflag\n"
verbose "$CC $picflag" verbose "$CC_FOR_TARGET $picflag"
catch "exec $CC $picflag" exec_output catch "exec $CC_FOR_TARGET $picflag" exec_output
send_log "$exec_output\n" send_log "$exec_output\n"
verbose "--" "$exec_output" verbose "--" "$exec_output"
if { [string match "*illegal option*" $exec_output] \ if { [string match "*illegal option*" $exec_output] \
@ -446,7 +446,7 @@ visibility_run protected_undef_def
visibility_run protected_weak visibility_run protected_weak
visibility_run normal visibility_run normal
if { ![ld_compile "$CC -g $CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/common.c tmpdir/common.o] } { if { ![ld_compile "$CC_FOR_TARGET -g $CFLAGS_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/common.c tmpdir/common.o] } {
unsupported "common hidden symbol" unsupported "common hidden symbol"
} else { } else {
if ![ld_link $ld tmpdir/common "tmpdir/common.o"] { if ![ld_link $ld tmpdir/common "tmpdir/common.o"] {
@ -456,10 +456,10 @@ if { ![ld_compile "$CC -g $CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$sub
} }
} }
if { ![ld_compile "$CC -g $CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/test.c tmpdir/test.o] } { if { ![ld_compile "$CC_FOR_TARGET -g $CFLAGS_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/test.c tmpdir/test.o] } {
unsupported "weak hidden symbol" unsupported "weak hidden symbol"
} else { } else {
if { ![ld_compile "$CC -g $CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh3.c tmpdir/sh3.o] } { if { ![ld_compile "$CC_FOR_TARGET -g $CFLAGS_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh3.c tmpdir/sh3.o] } {
unsupported "weak hidden symbol" unsupported "weak hidden symbol"
} else { } else {
if ![ld_link $ld tmpdir/sh3.so "-shared tmpdir/sh3.o"] { if ![ld_link $ld tmpdir/sh3.so "-shared tmpdir/sh3.o"] {

View File

@ -261,7 +261,7 @@ proc objdump_dynsymstuff { objdump object expectfile } {
} }
proc build_lib {test libname objs dynsymexp} { proc build_lib {test libname objs dynsymexp} {
global CC global CC_FOR_TARGET
global objdump global objdump
global tmpdir global tmpdir
global shared global shared
@ -275,7 +275,7 @@ proc build_lib {test libname objs dynsymexp} {
set files "$files $tmpdir/$obj" set files "$files $tmpdir/$obj"
} }
if {![ld_link "$CC $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $tmpdir/$libname.so "$shared $files"]} { if {![ld_link "$CC_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $tmpdir/$libname.so "$shared $files"]} {
fail $test fail $test
return return
} }
@ -289,7 +289,7 @@ proc build_lib {test libname objs dynsymexp} {
} }
proc build_exec { test execname objs flags dat dynsymexp symexp} { proc build_exec { test execname objs flags dat dynsymexp symexp} {
global CC global CC_FOR_TARGET
global objdump global objdump
global tmpdir global tmpdir
global srcdir global srcdir
@ -303,7 +303,7 @@ proc build_exec { test execname objs flags dat dynsymexp symexp} {
set files "$files $tmpdir/$obj" set files "$files $tmpdir/$obj"
} }
if {![ld_link $CC $tmpdir/$execname "$flags $NOSANITIZE_CFLAGS $NOLTO_CFLAGS $files"]} { if {![ld_link $CC_FOR_TARGET $tmpdir/$execname "$flags $NOSANITIZE_CFLAGS $NOLTO_CFLAGS $files"]} {
fail "$test" fail "$test"
return return
} }
@ -353,14 +353,14 @@ proc build_exec { test execname objs flags dat dynsymexp symexp} {
} }
# Disable LTO for these tests. # Disable LTO for these tests.
set cc_cmd "$CC" set cc_cmd "$CC_FOR_TARGET"
if {[check_lto_available]} { if {[check_lto_available]} {
append cc_cmd " -fno-lto" append cc_cmd " -fno-lto"
} }
# Disable all sanitizers and LTO. # Disable all sanitizers and LTO.
set saved_CFLAGS "$CFLAGS" set saved_CFLAGS "$CFLAGS_FOR_TARGET"
set CFLAGS "$CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" append CFLAGS_FOR_TARGET " $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
# Old version of GCC for MIPS default to enabling -fpic # Old version of GCC for MIPS default to enabling -fpic
# and get confused if it is used on the command line. # and get confused if it is used on the command line.
@ -370,9 +370,9 @@ if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then {
# Unfortunately, the gcc argument is -fpic and the cc argument is # Unfortunately, the gcc argument is -fpic and the cc argument is
# -KPIC. We have to try both. # -KPIC. We have to try both.
set picflag "-fpic" set picflag "-fpic"
send_log "$CC $picflag\n" send_log "$CC_FOR_TARGET $picflag\n"
verbose "$CC $picflag" verbose "$CC_FOR_TARGET $picflag"
catch "exec $CC $picflag" exec_output catch "exec $CC_FOR_TARGET $picflag" exec_output
send_log "$exec_output\n" send_log "$exec_output\n"
verbose "--" "$exec_output" verbose "--" "$exec_output"
if { [string match "*illegal option*" $exec_output] if { [string match "*illegal option*" $exec_output]
@ -384,16 +384,16 @@ if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then {
} }
verbose "Using $picflag to compile PIC code" verbose "Using $picflag to compile PIC code"
if {![ld_compile "$cc_cmd $CFLAGS $picflag" $srcdir/$subdir/foo.c $tmpdir/foo.o] if {![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/foo.c $tmpdir/foo.o]
|| ![ld_compile "$cc_cmd $CFLAGS $picflag" $srcdir/$subdir/bar.c $tmpdir/bar.o] || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/bar.c $tmpdir/bar.o]
|| ![ld_compile "$cc_cmd $CFLAGS" $srcdir/$subdir/main.c $tmpdir/main.o] || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET" $srcdir/$subdir/main.c $tmpdir/main.o]
|| ![ld_link $cc_cmd $tmpdir/libbar.so "$shared $tmpdir/bar.o"] || ![ld_link $cc_cmd $tmpdir/libbar.so "$shared $tmpdir/bar.o"]
|| ![ld_compile "$cc_cmd $CFLAGS $picflag" $srcdir/$subdir/foo1a.c $tmpdir/foo1a.o] || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/foo1a.c $tmpdir/foo1a.o]
|| ![ld_compile "$cc_cmd $CFLAGS $picflag" $srcdir/$subdir/foo1b.c $tmpdir/foo1b.o] || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/foo1b.c $tmpdir/foo1b.o]
|| ![ld_compile "$cc_cmd $CFLAGS $picflag" $srcdir/$subdir/bar1a.c $tmpdir/bar1a.o] || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/bar1a.c $tmpdir/bar1a.o]
|| ![ld_compile "$cc_cmd $CFLAGS $picflag" $srcdir/$subdir/bar1b.c $tmpdir/bar1b.o] || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/bar1b.c $tmpdir/bar1b.o]
|| ![ld_compile "$cc_cmd $CFLAGS $picflag" $srcdir/$subdir/bar1c.c $tmpdir/bar1c.o] || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/bar1c.c $tmpdir/bar1c.o]
|| ![ld_compile "$cc_cmd $CFLAGS $picflag" $srcdir/$subdir/main1.c $tmpdir/main1.o]} then { || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/main1.c $tmpdir/main1.o]} then {
unsupported "ELF weak" unsupported "ELF weak"
} elseif {![ld_link $cc_cmd $tmpdir/libfoo1a.so "$shared $tmpdir/foo1a.o"] } elseif {![ld_link $cc_cmd $tmpdir/libfoo1a.so "$shared $tmpdir/foo1a.o"]
|| ![ld_link $cc_cmd $tmpdir/libfoo1b.so "$shared $tmpdir/foo1b.o"] || ![ld_link $cc_cmd $tmpdir/libfoo1b.so "$shared $tmpdir/foo1b.o"]
@ -424,10 +424,10 @@ if {![ld_compile "$cc_cmd $CFLAGS $picflag" $srcdir/$subdir/foo.c $tmpdir/foo.o]
build_exec "ELF weak data last DSO common" foo "libfoo1b.so main1.o libbar1a.so" "-Wl,--no-as-needed,-rpath,.,-rpath-link,." weakdata weakdata.dsym "" build_exec "ELF weak data last DSO common" foo "libfoo1b.so main1.o libbar1a.so" "-Wl,--no-as-needed,-rpath,.,-rpath-link,." weakdata weakdata.dsym ""
} }
if {![ld_compile "$cc_cmd $CFLAGS $picflag" $srcdir/$subdir/size_foo.c $tmpdir/size_foo.o] if {![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/size_foo.c $tmpdir/size_foo.o]
|| ![ld_compile "$cc_cmd $CFLAGS $picflag" $srcdir/$subdir/size_bar.c $tmpdir/size_bar_s.o] || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/size_bar.c $tmpdir/size_bar_s.o]
|| ![ld_compile "$cc_cmd $CFLAGS $picflag -DSIZE_BIG" $srcdir/$subdir/size_bar.c $tmpdir/size_bar.o] || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag -DSIZE_BIG" $srcdir/$subdir/size_bar.c $tmpdir/size_bar.o]
|| ![ld_compile "$cc_cmd $CFLAGS" $srcdir/$subdir/size_main.c $tmpdir/size_main.o]} then { || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET" $srcdir/$subdir/size_main.c $tmpdir/size_main.o]} then {
unsupported "ELF weak (size)" unsupported "ELF weak (size)"
} else { } else {
build_lib "ELF DSO small bar (size)" libsize_bar_s "size_bar_s.o" "" build_lib "ELF DSO small bar (size)" libsize_bar_s "size_bar_s.o" ""
@ -439,14 +439,14 @@ if {![ld_compile "$cc_cmd $CFLAGS $picflag" $srcdir/$subdir/size_foo.c $tmpdir/s
verbose "size2" verbose "size2"
run_dump_test $srcdir/$subdir/size2 run_dump_test $srcdir/$subdir/size2
if {![ld_compile "$cc_cmd $CFLAGS $picflag" $srcdir/$subdir/alias.c $tmpdir/alias.o] if {![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/alias.c $tmpdir/alias.o]
|| ![ld_link $cc_cmd $tmpdir/alias.so "$shared $tmpdir/alias.o"] || ![ld_link $cc_cmd $tmpdir/alias.so "$shared $tmpdir/alias.o"]
|| ![ld_compile "$cc_cmd $CFLAGS" $srcdir/$subdir/aliasmain.c $tmpdir/aliasmain.o] || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET" $srcdir/$subdir/aliasmain.c $tmpdir/aliasmain.o]
|| ![ld_compile "$cc_cmd $CFLAGS" $srcdir/$subdir/weakref1.c $tmpdir/weakref1.o] || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET" $srcdir/$subdir/weakref1.c $tmpdir/weakref1.o]
|| ![ld_compile "$cc_cmd $CFLAGS" $srcdir/$subdir/weakref2.c $tmpdir/weakref2.o]} then { || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET" $srcdir/$subdir/weakref2.c $tmpdir/weakref2.o]} then {
unsupported "ELF weak (alias)" unsupported "ELF weak (alias)"
} else { } else {
build_exec "ELF weak (alias)" alias "aliasmain.o weakref1.o weakref2.o alias.so" "-Wl,-rpath=.,--no-as-needed" alias "" "" build_exec "ELF weak (alias)" alias "aliasmain.o weakref1.o weakref2.o alias.so" "-Wl,-rpath=.,--no-as-needed" alias "" ""
} }
set CFLAGS "$saved_CFLAGS" set CFLAGS_FOR_TARGET "$saved_CFLAGS"

View File

@ -37,7 +37,7 @@ if { [istarget m681*-*-*] || [istarget m68hc1*-*-*] } {
} }
if { [check_compiler_available] } { if { [check_compiler_available] } {
ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/gc.c $objfile ld_compile "$CC_FOR_TARGET -c $CFLAGS_FOR_TARGET $cflags" $srcdir/$subdir/gc.c $objfile
} }
proc test_gc { testname filename linker ldflags} { proc test_gc { testname filename linker ldflags} {
@ -144,9 +144,9 @@ if { [check_compiler_available] } {
if { [istarget "*-*-linux*"] if { [istarget "*-*-linux*"]
|| [istarget "*-*-nacl*"] || [istarget "*-*-nacl*"]
|| [istarget "*-*-gnu*"] } { || [istarget "*-*-gnu*"] } {
ld_compile "$CC -fPIC $CFLAGS $cflags" $srcdir/$subdir/pr11218-1.c tmpdir/pr11218-1.o ld_compile "$CC_FOR_TARGET -fPIC $CFLAGS_FOR_TARGET $cflags" $srcdir/$subdir/pr11218-1.c tmpdir/pr11218-1.o
ld_link $ld tmpdir/pr11218-1.so "-shared tmpdir/pr11218-1.o" ld_link $ld tmpdir/pr11218-1.so "-shared tmpdir/pr11218-1.o"
ld_compile "$CC -c $CFLAGS $cflags" $srcdir/$subdir/pr11218-2.c tmpdir/pr11218-2.o ld_compile "$CC_FOR_TARGET -c $CFLAGS_FOR_TARGET $cflags" $srcdir/$subdir/pr11218-2.c tmpdir/pr11218-2.o
run_dump_test "pr11218" run_dump_test "pr11218"
} }
} }
@ -157,18 +157,18 @@ if [is_pecoff_format] {
} }
if { [check_compiler_available] } { if { [check_compiler_available] } {
ld_compile "$CC $CFLAGS $cflags" $srcdir/$subdir/pr13683.c tmpdir/pr13683.o ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $cflags" $srcdir/$subdir/pr13683.c tmpdir/pr13683.o
run_dump_test "pr13683" $symdefs run_dump_test "pr13683" $symdefs
} }
if { [check_compiler_available] } { if { [check_compiler_available] } {
ld_compile "$CC $CFLAGS $cflags $NOPIE_CFLAGS" $srcdir/$subdir/pr14265.c tmpdir/pr14265.o ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $cflags $NOPIE_CFLAGS" $srcdir/$subdir/pr14265.c tmpdir/pr14265.o
run_dump_test "pr14265" $symdefs run_dump_test "pr14265" $symdefs
} }
if { [check_compiler_available] } { if { [check_compiler_available] } {
ld_compile "$CC $CFLAGS $cflags -O0" $srcdir/$subdir/pr19161-1.c tmpdir/pr19161-1.o ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $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 ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $cflags -O0" $srcdir/$subdir/pr19161-2.c tmpdir/pr19161-2.o
if [istarget hppa*-*-linux*] { if [istarget hppa*-*-linux*] {
set symdefs {{ld {--defsym '\$\$dyncall=0'}}} set symdefs {{ld {--defsym '\$\$dyncall=0'}}}
} }

View File

@ -182,7 +182,7 @@ proc contains_ifunc_reloc { binary_file } {
set fails 0 set fails 0
# Disable LTO for these tests. # Disable LTO for these tests.
set cc_cmd "$CC" set cc_cmd "$CC_FOR_TARGET"
if {[check_lto_available]} { if {[check_lto_available]} {
append cc_cmd " -fno-lto" append cc_cmd " -fno-lto"
} }
@ -238,16 +238,16 @@ if { $fails != 0 } {
return return
} }
if ![ld_link $CC "tmpdir/dynamic_prog" "-Wl,--no-as-needed,-rpath=./tmpdir,-Bdynamic -Ltmpdir tmpdir/shared_prog.o -lshared_ifunc"] { if ![ld_link $CC_FOR_TARGET "tmpdir/dynamic_prog" "-Wl,--no-as-needed,-rpath=./tmpdir,-Bdynamic -Ltmpdir tmpdir/shared_prog.o -lshared_ifunc"] {
fail "Could not link a dynamic executable" fail "Could not link a dynamic executable"
set fails [expr $fails + 1] set fails [expr $fails + 1]
} }
if ![ld_link $CC "tmpdir/local_prog" "$NOPIE_LDFLAGS -Wl,--no-as-needed,-rpath=./tmpdir -Ltmpdir tmpdir/static_prog.o -lifunc"] { if ![ld_link $CC_FOR_TARGET "tmpdir/local_prog" "$NOPIE_LDFLAGS -Wl,--no-as-needed,-rpath=./tmpdir -Ltmpdir tmpdir/static_prog.o -lifunc"] {
fail "Could not link a dynamic executable using local ifunc" fail "Could not link a dynamic executable using local ifunc"
set fails [expr $fails + 1] set fails [expr $fails + 1]
} }
if ![string match "" $STATIC_LDFLAGS] { if ![string match "" $STATIC_LDFLAGS] {
if ![ld_link $CC "tmpdir/static_prog" "-static -Ltmpdir tmpdir/static_prog.o -lifunc"] { if ![ld_link $CC_FOR_TARGET "tmpdir/static_prog" "-static -Ltmpdir tmpdir/static_prog.o -lifunc"] {
fail "Could not link a static executable" fail "Could not link a static executable"
set fails [expr $fails + 1] set fails [expr $fails + 1]
} }
@ -256,7 +256,7 @@ if ![ld_link $ld "tmpdir/static_nonifunc_prog" "-static tmpdir/empty.o"] {
fail "Could not link a non-ifunc using static executable" fail "Could not link a non-ifunc using static executable"
set fails [expr $fails + 1] set fails [expr $fails + 1]
} }
if ![ld_link $CC "tmpdir/test-1" "-Wl,--no-as-needed,-rpath=./tmpdir tmpdir/test-1.o tmpdir/libshared_ifunc.so"] { if ![ld_link $CC_FOR_TARGET "tmpdir/test-1" "-Wl,--no-as-needed,-rpath=./tmpdir tmpdir/test-1.o tmpdir/libshared_ifunc.so"] {
fail "Could not link test-1" fail "Could not link test-1"
set fails [expr $fails + 1] set fails [expr $fails + 1]
} }

View File

@ -126,7 +126,7 @@ set am33_tests {
run_ld_link_tests $am33_tests run_ld_link_tests $am33_tests
proc i126256-test { } { proc i126256-test { } {
global CC global CC_FOR_TARGET
global ld global ld
global srcdir global srcdir
global subdir global subdir
@ -138,12 +138,12 @@ proc i126256-test { } {
return return
} }
if { ![ld_compile "$CC -mrelax -fPIC" $srcdir/$subdir/i126256-1.c $tmpdir/i126256-1.o] } { if { ![ld_compile "$CC_FOR_TARGET -mrelax -fPIC" $srcdir/$subdir/i126256-1.c $tmpdir/i126256-1.o] } {
unsupported $testname unsupported $testname
return return
} }
if { ![ld_compile "$CC -mrelax -fPIC" $srcdir/$subdir/i126256-2.c $tmpdir/i126256-2.o] } { if { ![ld_compile "$CC_FOR_TARGET -mrelax -fPIC" $srcdir/$subdir/i126256-2.c $tmpdir/i126256-2.o] } {
unsupported $testname unsupported $testname
return return
} }

View File

@ -34,13 +34,13 @@ if { ![check_compiler_available] } {
} }
proc build_basefile1_o {} { proc build_basefile1_o {} {
global CC global CC_FOR_TARGET
global CFLAGS global CFLAGS_FOR_TARGET
global srcdir global srcdir
global subdir global subdir
# Compile the object file. # Compile the object file.
if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/basefile1.s tmpdir/basefile1.o] { if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/basefile1.s tmpdir/basefile1.o] {
fail "compiling basefile1 object" fail "compiling basefile1 object"
} }
} }
@ -75,24 +75,24 @@ proc run_basefile_test { testname } {
} }
proc build_vers_script_dll_o {} { proc build_vers_script_dll_o {} {
global CC global CC_FOR_TARGET
global CFLAGS global CFLAGS_FOR_TARGET
global srcdir global srcdir
global subdir global subdir
# Compile the object file. # Compile the object file.
if ![ld_compile "$CC $CFLAGS -shared" $srcdir/$subdir/vers-script-dll.c tmpdir/vers-script-dll.o] { if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -shared" $srcdir/$subdir/vers-script-dll.c tmpdir/vers-script-dll.o] {
fail "compiling shared lib object" fail "compiling shared lib object"
} }
} }
proc run_ver_script_test { testname } { proc run_ver_script_test { testname } {
global CC global CC_FOR_TARGET
global srcdir global srcdir
global subdir global subdir
global verbose global verbose
if ![ld_link "$CC -shared \ if ![ld_link "$CC_FOR_TARGET -shared \
-Wl,--version-script,$srcdir/$subdir/$testname.ver \ -Wl,--version-script,$srcdir/$subdir/$testname.ver \
-Wl,--output-def,tmpdir/$testname.def" tmpdir/$testname.dll \ -Wl,--output-def,tmpdir/$testname.def" tmpdir/$testname.dll \
"tmpdir/vers-script-dll.o"] { "tmpdir/vers-script-dll.o"] {

View File

@ -62,27 +62,27 @@ if { ![check_compiler_available] } {
set tmpdir tmpdir set tmpdir tmpdir
proc test_direct_link_dll {} { proc test_direct_link_dll {} {
global CC global CC_FOR_TARGET
global CFLAGS global CFLAGS_FOR_TARGET
global srcdir global srcdir
global subdir global subdir
global tmpdir global tmpdir
# Compile the dll. # Compile the dll.
if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/direct_dll.c $tmpdir/direct_dll.o ] { if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/direct_dll.c $tmpdir/direct_dll.o ] {
fail "compiling shared lib" fail "compiling shared lib"
} elseif ![ld_link "$CC -shared" $tmpdir/direct_dll.dll "$tmpdir/direct_dll.o" ] { } elseif ![ld_link "$CC_FOR_TARGET -shared" $tmpdir/direct_dll.dll "$tmpdir/direct_dll.o" ] {
fail "linking shared lib (.dll)" fail "linking shared lib (.dll)"
} elseif ![ld_link "$CC -shared" $tmpdir/direct_dll.sl "$tmpdir/direct_dll.o" ] { } elseif ![ld_link "$CC_FOR_TARGET -shared" $tmpdir/direct_dll.sl "$tmpdir/direct_dll.o" ] {
fail "linking shared lib (.sl)" fail "linking shared lib (.sl)"
} else { } else {
# Compile and link the client program. # Compile and link the client program.
if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/direct_client.c $tmpdir/direct_client.o ] { if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/direct_client.c $tmpdir/direct_client.o ] {
fail "compiling client" fail "compiling client"
} else { } else {
# Check linking directly to direct_dll.dll. # Check linking directly to direct_dll.dll.
set msg "linking client (.dll)" set msg "linking client (.dll)"
if [ld_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_dll.exe \ if [ld_link "$CC_FOR_TARGET -Wl,--enable-auto-import" $tmpdir/direct_client_dll.exe \
"$tmpdir/direct_client.o $tmpdir/direct_dll.dll" ] { "$tmpdir/direct_client.o $tmpdir/direct_dll.dll" ] {
pass $msg pass $msg
} else { } else {
@ -91,7 +91,7 @@ proc test_direct_link_dll {} {
# Check linking directly to direct_dll.sl. # Check linking directly to direct_dll.sl.
set msg "linking client (.sl)" set msg "linking client (.sl)"
if [ld_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_sl.exe \ if [ld_link "$CC_FOR_TARGET -Wl,--enable-auto-import" $tmpdir/direct_client_sl.exe \
"$tmpdir/direct_client.o $tmpdir/direct_dll.sl" ] { "$tmpdir/direct_client.o $tmpdir/direct_dll.sl" ] {
pass $msg pass $msg
} else { } else {
@ -102,7 +102,7 @@ proc test_direct_link_dll {} {
# Create symbolic link. # Create symbolic link.
catch "exec ln -fs direct_dll.dll $tmpdir/libdirect_dll.dll.a" ln_catch catch "exec ln -fs direct_dll.dll $tmpdir/libdirect_dll.dll.a" ln_catch
set msg "linking client (symlink -> .dll)" set msg "linking client (symlink -> .dll)"
if [ld_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_symlink_dll.exe \ if [ld_link "$CC_FOR_TARGET -Wl,--enable-auto-import" $tmpdir/direct_client_symlink_dll.exe \
"$tmpdir/direct_client.o $tmpdir/libdirect_dll.dll.a" ] { "$tmpdir/direct_client.o $tmpdir/libdirect_dll.dll.a" ] {
pass $msg pass $msg
} else { } else {
@ -113,7 +113,7 @@ proc test_direct_link_dll {} {
# Create symbolic link. # Create symbolic link.
catch "exec ln -fs direct_dll.sl $tmpdir/libdirect_sl.dll.a" ln_catch catch "exec ln -fs direct_dll.sl $tmpdir/libdirect_sl.dll.a" ln_catch
set msg "linking client (symlink -> .sl)" set msg "linking client (symlink -> .sl)"
if [ld_link "$CC -Wl,--enable-auto-import" $tmpdir/direct_client_symlink_sl.exe \ if [ld_link "$CC_FOR_TARGET -Wl,--enable-auto-import" $tmpdir/direct_client_symlink_sl.exe \
"$tmpdir/direct_client.o $tmpdir/libdirect_sl.dll.a" ] { "$tmpdir/direct_client.o $tmpdir/libdirect_sl.dll.a" ] {
pass $msg pass $msg
} else { } else {

View File

@ -64,27 +64,27 @@ if { ![check_compiler_available] } {
set tmpdir tmpdir set tmpdir tmpdir
proc test_direct2_link_dll {} { proc test_direct2_link_dll {} {
global CC global CC_FOR_TARGET
global CFLAGS global CFLAGS_FOR_TARGET
global srcdir global srcdir
global subdir global subdir
global tmpdir global tmpdir
# Compile the dll. # Compile the dll.
if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/direct2_dll.c $tmpdir/direct2_dll.o ] { if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/direct2_dll.c $tmpdir/direct2_dll.o ] {
fail "compiling shared lib fastcall/stdcall" fail "compiling shared lib fastcall/stdcall"
} elseif ![ld_link "$CC -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.dll "$tmpdir/direct2_dll.o" ] { } elseif ![ld_link "$CC_FOR_TARGET -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.dll "$tmpdir/direct2_dll.o" ] {
fail "linking shared lib (.dll) fastcall/stdcall" fail "linking shared lib (.dll) fastcall/stdcall"
} elseif ![ld_link "$CC -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.sl "$tmpdir/direct2_dll.o" ] { } elseif ![ld_link "$CC_FOR_TARGET -shared -Wl,--enable-stdcall-fixup -Wl,--kill-at " $tmpdir/direct2_dll.sl "$tmpdir/direct2_dll.o" ] {
fail "linking shared lib (.sl) fastcall/stdcall" fail "linking shared lib (.sl) fastcall/stdcall"
} else { } else {
# Compile and link the client program. # Compile and link the client program.
if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/direct2_client.c $tmpdir/direct2_client.o ] { if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/direct2_client.c $tmpdir/direct2_client.o ] {
fail "compiling client fastcall/stdcall" fail "compiling client fastcall/stdcall"
} else { } else {
# Check linking directly to direct2_dll.dll. # Check linking directly to direct2_dll.dll.
set msg "linking client (.dll) fastcall/stdcall" set msg "linking client (.dll) fastcall/stdcall"
if [ld_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_dll.exe \ if [ld_link "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_dll.exe \
"$tmpdir/direct2_client.o $tmpdir/direct2_dll.dll" ] { "$tmpdir/direct2_client.o $tmpdir/direct2_dll.dll" ] {
pass $msg pass $msg
} else { } else {
@ -93,7 +93,7 @@ proc test_direct2_link_dll {} {
# Check linking directly to direct2_dll.sl. # Check linking directly to direct2_dll.sl.
set msg "linking client (.sl) fastcall/stdcall" set msg "linking client (.sl) fastcall/stdcall"
if [ld_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_sl.exe \ if [ld_link "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_sl.exe \
"$tmpdir/direct2_client.o $tmpdir/direct2_dll.sl" ] { "$tmpdir/direct2_client.o $tmpdir/direct2_dll.sl" ] {
pass $msg pass $msg
} else { } else {
@ -104,7 +104,7 @@ proc test_direct2_link_dll {} {
# Create symbolic link. # Create symbolic link.
catch "exec ln -fs direct2_dll.dll $tmpdir/libdirect2_dll.dll.a" ln_catch catch "exec ln -fs direct2_dll.dll $tmpdir/libdirect2_dll.dll.a" ln_catch
set msg "linking client (symlink -> .dll) fastcall/stdcall" set msg "linking client (symlink -> .dll) fastcall/stdcall"
if [ld_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_dll.exe \ if [ld_link "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_dll.exe \
"$tmpdir/direct2_client.o $tmpdir/libdirect2_dll.dll.a" ] { "$tmpdir/direct2_client.o $tmpdir/libdirect2_dll.dll.a" ] {
pass $msg pass $msg
} else { } else {
@ -115,7 +115,7 @@ proc test_direct2_link_dll {} {
# Create symbolic link. # Create symbolic link.
catch "exec ln -fs direct2_dll.sl $tmpdir/libdirect2_sl.dll.a" ln_catch catch "exec ln -fs direct2_dll.sl $tmpdir/libdirect2_sl.dll.a" ln_catch
set msg "linking client (symlink -> .sl) fastcall/stdcall" set msg "linking client (symlink -> .sl) fastcall/stdcall"
if [ld_link "$CC $CFLAGS -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_sl.exe \ if [ld_link "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -Wl,--enable-stdcall-fixup -Wl,--enable-auto-import" $tmpdir/direct2_client_symlink_sl.exe \
"$tmpdir/direct2_client.o $tmpdir/libdirect2_sl.dll.a" ] { "$tmpdir/direct2_client.o $tmpdir/libdirect2_sl.dll.a" ] {
pass $msg pass $msg
} else { } else {

View File

@ -31,8 +31,8 @@ if { ![check_compiler_available] } {
} }
# Check if -pie is supported or not. # Check if -pie is supported or not.
send_log "$CC -fpie -pie $srcdir/$subdir/pie.c -o tmpdir/pie" send_log "$CC_FOR_TARGET -fpie -pie $srcdir/$subdir/pie.c -o tmpdir/pie"
catch "exec $CC -fpie -pie $srcdir/$subdir/pie.c -o tmpdir/pie" exec_output catch "exec $CC_FOR_TARGET -fpie -pie $srcdir/$subdir/pie.c -o tmpdir/pie" exec_output
send_log "$exec_output\n" send_log "$exec_output\n"
if { ![string match "" $exec_output] } { if { ![string match "" $exec_output] } {
return return

View File

@ -19,7 +19,7 @@
# MA 02110-1301, USA. # MA 02110-1301, USA.
# Check to see if the C and C++ compilers work # Check to see if the C and C++ compilers work
if { ![check_compiler_available] || [which $CXX] == 0 } { if { ![check_compiler_available] || [which $CXX_FOR_TARGET] == 0 } {
return return
} }
@ -29,16 +29,18 @@ if { ![check_plugin_api_available]
return return
} }
set saved_CFLAGS "$CFLAGS" set saved_CFLAGS "$CFLAGS_FOR_TARGET"
set saved_CXXFLAGS "$CXXFLAGS" set saved_CXXFLAGS "$CXXFLAGS_FOR_TARGET"
regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CFLAGS "" CFLAGS regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CFLAGS_FOR_TARGET "" CFLAGS_FOR_TARGET
regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CXXFLAGS "" CXXFLAGS regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CXXFLAGS_FOR_TARGET "" CXXFLAGS_FOR_TARGET
proc restore_notify { } { proc restore_notify { } {
global saved_CFLAGS global saved_CFLAGS
global saved_CXXFLAGS global saved_CXXFLAGS
set CFLAGS "$saved_CFLAGS" global CFLAGS_FOR_TARGET
set CXXFLAGS "$saved_CXXFLAGS" global CXXFLAGS_FOR_TARGET
set CFLAGS_FOR_TARGET "$saved_CFLAGS"
set CXXFLAGS_FOR_TARGET "$saved_CXXFLAGS"
} }
set lto_fat "" set lto_fat ""
@ -674,21 +676,21 @@ run_cc_link_tests $lto_compile_elf_tests
if { [is_elf_format] && [check_lto_shared_available] } { if { [is_elf_format] && [check_lto_shared_available] } {
run_cc_link_tests $lto_link_elf_tests run_cc_link_tests $lto_link_elf_tests
set testname "PR ld/15146 (2)" set testname "PR ld/15146 (2)"
set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146d.o tmpdir/pr15146c.so"] set exec_output [run_host_cmd "$CC_FOR_TARGET" "-O2 -flto -fuse-linker-plugin -Wl,-rpath-link,. -Wl,--no-copy-dt-needed-entries -Wl,--no-as-needed tmpdir/pr15146d.o tmpdir/pr15146c.so"]
if { [ regexp "undefined reference to symbol '\\.?xxx'" $exec_output ] } { if { [ regexp "undefined reference to symbol '\\.?xxx'" $exec_output ] } {
pass $testname pass $testname
} { } {
fail $testname fail $testname
} }
set testname "PR ld/16746 (3)" set testname "PR ld/16746 (3)"
set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746b.o tmpdir/pr16746d.o"] set exec_output [run_host_cmd "$CC_FOR_TARGET" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746b.o tmpdir/pr16746d.o"]
if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } { if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
pass $testname pass $testname
} { } {
fail $testname fail $testname
} }
set testname "PR ld/16746 (4)" set testname "PR ld/16746 (4)"
set exec_output [run_host_cmd "$CC" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746d.o tmpdir/pr16746b.o"] set exec_output [run_host_cmd "$CC_FOR_TARGET" "-O2 -flto -fuse-linker-plugin tmpdir/pr16746d.o tmpdir/pr16746b.o"]
if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } { if { [ regexp "warning: \\.?foobar" $exec_output ] && ![ regexp "symbol from plugin" $exec_output ] } {
pass $testname pass $testname
} { } {
@ -712,7 +714,7 @@ run_cc_link_tests [list \
set exec_output [run_host_cmd "sh" \ set exec_output [run_host_cmd "sh" \
"-c \"ulimit -n 20; \ "-c \"ulimit -n 20; \
$CC -Btmpdir/ld -o tmpdir/pr28138 \ $CC_FOR_TARGET -Btmpdir/ld -o tmpdir/pr28138 \
tmpdir/pr28138.o tmpdir/pr28138.a\""] tmpdir/pr28138.o tmpdir/pr28138.a\""]
set exec_output [prune_warnings $exec_output] set exec_output [prune_warnings $exec_output]
if [string match "" $exec_output] then { if [string match "" $exec_output] then {
@ -749,7 +751,7 @@ if { [at_least_gcc_version 4 7] } {
|| [istarget "x86_64-*-linux*"] || [istarget "x86_64-*-linux*"]
|| [istarget "amd64-*-linux*"]) } { || [istarget "amd64-*-linux*"]) } {
set testname "PR ld/12365" set testname "PR ld/12365"
set exec_output [run_host_cmd "$CC" "-O2 -flto -flto-partition=none -fuse-linker-plugin -o tmpdir/pr12365 tmpdir/pr12365a.o tmpdir/pr12365b.o tmpdir/pr12365c.o"] set exec_output [run_host_cmd "$CC_FOR_TARGET" "-O2 -flto -flto-partition=none -fuse-linker-plugin -o tmpdir/pr12365 tmpdir/pr12365a.o tmpdir/pr12365b.o tmpdir/pr12365c.o"]
set exec_output [prune_warnings $exec_output] set exec_output [prune_warnings $exec_output]
if { [ regexp "undefined reference to `my_bcopy'" $exec_output ] } { if { [ regexp "undefined reference to `my_bcopy'" $exec_output ] } {
# Linker should catch the reference to undefined `my_bcopy' # Linker should catch the reference to undefined `my_bcopy'
@ -797,7 +799,7 @@ if { [at_least_gcc_version 4 7] } {
] ]
} }
set testname "PR ld/12942 (3)" set testname "PR ld/12942 (3)"
set exec_output [run_host_cmd "$CXX" "-O2 -flto -fuse-linker-plugin tmpdir/pr12942b.o tmpdir/pr12942a.o"] set exec_output [run_host_cmd "$CXX_FOR_TARGET" "-O2 -flto -fuse-linker-plugin tmpdir/pr12942b.o tmpdir/pr12942a.o"]
if { [ regexp "undefined reference to `\\.?link_error\\(\\)'" $exec_output ] } { if { [ regexp "undefined reference to `\\.?link_error\\(\\)'" $exec_output ] } {
pass $testname pass $testname
} { } {
@ -889,10 +891,10 @@ if { [is_elf_format] && [check_lto_shared_available] } {
} }
proc pr20103 {cflags libs} { proc pr20103 {cflags libs} {
global CC global CC_FOR_TARGET
set testname "PR ld/20103 ($cflags $libs)" set testname "PR ld/20103 ($cflags $libs)"
set exec_output [run_host_cmd "$CC" "$cflags $libs"] set exec_output [run_host_cmd "$CC_FOR_TARGET" "$cflags $libs"]
if { [ regexp "undefined reference to `\\.?dead'" $exec_output ] } { if { [ regexp "undefined reference to `\\.?dead'" $exec_output ] } {
pass "$testname (1)" pass "$testname (1)"
} { } {

View File

@ -77,10 +77,6 @@ set regas "-plugin-opt registerallsymbolsread"
set regassilent "-plugin-opt registerallsymbolsreadsilent" set regassilent "-plugin-opt registerallsymbolsreadsilent"
set regcln "-plugin-opt registercleanup" set regcln "-plugin-opt registercleanup"
if { [istarget m681*-*-*] || [istarget m68hc1*-*-*] || [istarget m9s12x*-*-*] } {
# otherwise get FAILS due to _.frame
set CFLAGS "$CFLAGS -fomit-frame-pointer"
}
# In order to define symbols in plugin options in the list of tests below, # In order to define symbols in plugin options in the list of tests below,
# we need to know if the platform prepends an underscore to C symbols, # we need to know if the platform prepends an underscore to C symbols,
# which we find out by compiling the test objects now. If there is any # which we find out by compiling the test objects now. If there is any
@ -91,16 +87,20 @@ if { [istarget m681*-*-*] || [istarget m68hc1*-*-*] || [istarget m9s12x*-*-*] }
set failed_compile 0 set failed_compile 0
set _ "" set _ ""
set plugin_nm_output "" set plugin_nm_output ""
set old_CFLAGS "$CFLAGS" set old_CFLAGS "$CFLAGS_FOR_TARGET"
append CFLAGS " $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" append CFLAGS_FOR_TARGET " $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
if { [istarget m681*-*-*] || [istarget m68hc1*-*-*] || [istarget m9s12x*-*-*] } {
# otherwise get FAILS due to _.frame
append CFLAGS_FOR_TARGET " -fomit-frame-pointer"
}
if { $can_compile && \ if { $can_compile && \
(![ld_compile "$CC $CFLAGS" $srcdir/$subdir/main.c tmpdir/main.o] \ (![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/main.c tmpdir/main.o] \
|| ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/func.c tmpdir/func.o] \ || ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/func.c tmpdir/func.o] \
|| ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/text.c tmpdir/text.o] \ || ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/text.c tmpdir/text.o] \
|| ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/pr20070a.c tmpdir/pr20070a.o] \ || ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/pr20070a.c tmpdir/pr20070a.o] \
|| ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/dummy.s tmpdir/dummy.o] \ || ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/dummy.s tmpdir/dummy.o] \
|| ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/pr17973.s tmpdir/pr17973.o]) } { || ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/pr17973.s tmpdir/pr17973.o]) } {
# Defer fail until we have list of tests set. # Defer fail until we have list of tests set.
set failed_compile 1 set failed_compile 1
} }
@ -291,16 +291,16 @@ if { !$can_compile || $failed_compile } {
unsupported [lindex $testitem 0] unsupported [lindex $testitem 0]
} }
} }
set CFLAGS "$old_CFLAGS" set CFLAGS_FOR_TARGET "$old_CFLAGS"
return return
} }
run_ld_link_tests $plugin_tests run_ld_link_tests $plugin_tests
if { [is_elf_format] \ if { [is_elf_format] \
&& [ld_compile "$CC $CFLAGS" $srcdir/$subdir/func1p.c tmpdir/func1p.o] \ && [ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/func1p.c tmpdir/func1p.o] \
&& [ld_compile "$CC $CFLAGS" $srcdir/$subdir/func2i.c tmpdir/func2i.o] \ && [ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/func2i.c tmpdir/func2i.o] \
&& [ld_compile "$CC $CFLAGS" $srcdir/$subdir/func3h.c tmpdir/func3h.o] } { && [ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/func3h.c tmpdir/func3h.o] } {
run_ld_link_tests $plugin_extra_elf_tests run_ld_link_tests $plugin_extra_elf_tests
} }
@ -394,4 +394,4 @@ if [ar_simple_create $ar "--plugin $plugin4_path" "tmpdir/libpr20070.a" \
unsupported "PR ld/20070" unsupported "PR ld/20070"
} }
set CFLAGS "$old_CFLAGS" set CFLAGS_FOR_TARGET "$old_CFLAGS"

View File

@ -38,37 +38,37 @@ if { ![check_compiler_available] } {
return return
} }
set old_CFLAGS "$CFLAGS" set old_CFLAGS "$CFLAGS_FOR_TARGET"
# Pass -fplt to CC since -fno-plt doesn't work with NOCROSSREFS tests. # Pass -fplt to CC since -fno-plt doesn't work with NOCROSSREFS tests.
# Also add $NOPIE_CFLAGS since PIE doesn't work NOCROSSREFS tests. # Also add $NOPIE_CFLAGS since PIE doesn't work NOCROSSREFS tests.
set old_CC "$CC" set old_CC "$CC_FOR_TARGET"
set CC "$CC $PLT_CFLAGS $NOPIE_CFLAGS" append CC_FOR_TARGET " $PLT_CFLAGS $NOPIE_CFLAGS"
# Xtensa targets currently default to putting literal values in a separate # Xtensa targets currently default to putting literal values in a separate
# section and that requires linker script support, so put literals in text. # section and that requires linker script support, so put literals in text.
if [istarget xtensa*-*-*] { if [istarget xtensa*-*-*] {
set CFLAGS "$CFLAGS -mtext-section-literals" append CFLAGS_FOR_TARGET " -mtext-section-literals"
} }
# Prevent the use of the MeP's small data area which references a symbol # Prevent the use of the MeP's small data area which references a symbol
# called __sdabase which will not be defined by our test linker scripts. # called __sdabase which will not be defined by our test linker scripts.
if [istarget mep*-*-elf] { if [istarget mep*-*-elf] {
set CFLAGS "-mtiny=0" append CFLAGS_FOR_TARGET " -mtiny=0"
} }
# The .dsbt section and __c6xabi_DSBT_BASE are not defined in our test # The .dsbt section and __c6xabi_DSBT_BASE are not defined in our test
# linker scripts. # linker scripts.
if [istarget tic6x*-*-*] { if [istarget tic6x*-*-*] {
set CFLAGS "-mno-dsbt -msdata=none" append CFLAGS_FOR_TARGET " -mno-dsbt -msdata=none"
} }
if { ![ld_compile "$CC $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \ if { ![ld_compile "$CC_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \
|| ![ld_compile "$CC $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } { || ![ld_compile "$CC_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
unsupported $test1 unsupported $test1
unsupported $test2 unsupported $test2
set CFLAGS "$old_CFLAGS" set CFLAGS_FOR_TARGET "$old_CFLAGS"
set CC "$old_CC" set CC_FOR_TARGET "$old_CC"
return return
} }
@ -102,10 +102,10 @@ if [string match "" $exec_output] then {
# Check cross references within a single object. # Check cross references within a single object.
if { ![ld_compile "$CC $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } { if { ![ld_compile "$CC_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
unsupported $test2 unsupported $test2
set CFLAGS "$old_CFLAGS" set CFLAGS_FOR_TARGET "$old_CFLAGS"
set CC "$old_CC" set CC_FOR_TARGET "$old_CC"
return return
} }
@ -127,17 +127,17 @@ if [string match "" $exec_output] then {
# Check cross references for ld -r # Check cross references for ld -r
if { ![ld_compile "$CC $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross4.c" tmpdir/cross4.o] } { if { ![ld_compile "$CC_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross4.c" tmpdir/cross4.o] } {
unsupported $test3 unsupported $test3
set CFLAGS "$old_CFLAGS" set CFLAGS_FOR_TARGET "$old_CFLAGS"
set CC "$old_CC" set CC_FOR_TARGET "$old_CC"
return return
} }
if ![ld_relocate $ld tmpdir/cross3-partial.o "tmpdir/cross1.o tmpdir/cross4.o"] { if ![ld_relocate $ld tmpdir/cross3-partial.o "tmpdir/cross1.o tmpdir/cross4.o"] {
fail $test3 fail $test3
set CFLAGS "$old_CFLAGS" set CFLAGS_FOR_TARGET "$old_CFLAGS"
set CC "$old_CC" set CC_FOR_TARGET "$old_CC"
return return
} }
@ -210,5 +210,5 @@ if [string match "" $exec_output] then {
} }
} }
set CFLAGS "$old_CFLAGS" set CFLAGS_FOR_TARGET "$old_CFLAGS"
set CC "$old_CC" set CC_FOR_TARGET "$old_CC"

View File

@ -64,7 +64,7 @@ if [istarget avr-*-*] {
} }
# If we don't have g++ for the target, mark all tests as untested. # If we don't have g++ for the target, mark all tests as untested.
if { ![is_remote host] && [which $CXX] == 0 } { if { ![is_remote host] && [which $CXX_FOR_TARGET] == 0 } {
foreach testitem $seltests { foreach testitem $seltests {
untested "[lindex $testitem 0]" untested "[lindex $testitem 0]"
} }
@ -90,10 +90,10 @@ foreach testitem $seltests {
# It's either C or C++ at the moment. # It's either C or C++ at the moment.
if { $testtype == "C++" } { if { $testtype == "C++" } {
set compiler "$CXX" set compiler "$CXX_FOR_TARGET"
# Starting with 3.4.0, -fvtable-gc is no longer supported and thus # Starting with 3.4.0, -fvtable-gc is no longer supported and thus
# the functionality we try to test for cannot be expected to work. # the functionality we try to test for cannot be expected to work.
set version [remote_exec host "$CXX -dumpversion"] set version [remote_exec host "$CXX_FOR_TARGET -dumpversion"]
set version [lindex $version 1] set version [lindex $version 1]
if { [regexp "^(\[1-9\]\[0-9\]+|\[4-9\]|3.(\[1-9\]\[0-9\]+))\\." $version] \ if { [regexp "^(\[1-9\]\[0-9\]+|\[4-9\]|3.(\[1-9\]\[0-9\]+))\\." $version] \
|| [regexp "^(\[1-9\]\[0-9\]+|\[4-9\])" $version] } { || [regexp "^(\[1-9\]\[0-9\]+|\[4-9\])" $version] } {
@ -104,7 +104,7 @@ foreach testitem $seltests {
} }
} else { } else {
set testflags "$cflags" set testflags "$cflags"
set compiler "$CC" set compiler "$CC_FOR_TARGET"
} }
# Note that we do not actually *use* CXX; we just add cxxflags for C++ # Note that we do not actually *use* CXX; we just add cxxflags for C++

View File

@ -144,7 +144,7 @@ if [istarget sh*-*linux*] {
} }
if {![ld_assemble $as "-relax tmpdir/start.s" tmpdir/start.o] \ if {![ld_assemble $as "-relax tmpdir/start.s" tmpdir/start.o] \
|| ![ld_compile $CC "-O -mrelax -foptimize-sibling-calls $srcdir/$subdir/sh2.c" tmpdir/sh2.o]} { || ![ld_compile $CC_FOR_TARGET "-O -mrelax -foptimize-sibling-calls $srcdir/$subdir/sh2.c" tmpdir/sh2.o]} {
unsupported $testlink unsupported $testlink
unsupported $testjsr unsupported $testjsr
unsupported $testrun unsupported $testrun

View File

@ -66,8 +66,8 @@ set SHCFLAG ""
set shared_needs_pic "no" set shared_needs_pic "no"
# Disable all sanitizers. # Disable all sanitizers.
set old_CFLAGS "$CFLAGS" set old_CFLAGS "$CFLAGS_FOR_TARGET"
append CFLAGS " $NOSANITIZE_CFLAGS" append CFLAGS_FOR_TARGET " $NOSANITIZE_CFLAGS"
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
@ -114,7 +114,7 @@ if [istarget arm*-*-linux*] {
set file [open $tmpdir/movw-detect.c w] set file [open $tmpdir/movw-detect.c w]
puts $file "void foo(void) { __asm (\"movw r0, #0\"); }" puts $file "void foo(void) { __asm (\"movw r0, #0\"); }"
close $file close $file
if [run_host_cmd_yesno "$CC" "$CFLAGS -c $tmpdir/movw-detect.c -o $tmpdir/movw-detect.o"] { if [run_host_cmd_yesno "$CC_FOR_TARGET" "$CFLAGS_FOR_TARGET -c $tmpdir/movw-detect.c -o $tmpdir/movw-detect.o"] {
set shared_needs_pic "yes" set shared_needs_pic "yes"
} }
} }
@ -122,7 +122,7 @@ if [istarget arm*-*-linux*] {
# The test procedure. # The test procedure.
proc shared_test { progname testname main sh1 sh2 dat args } { proc shared_test { progname testname main sh1 sh2 dat args } {
global CC global CC_FOR_TARGET
global srcdir global srcdir
global subdir global subdir
global exec_output global exec_output
@ -140,7 +140,7 @@ proc shared_test { progname testname main sh1 sh2 dat args } {
if { [is_elf_format] && [check_shared_lib_support] } { if { [is_elf_format] && [check_shared_lib_support] } {
append shared " -Wl,-z,notext" append shared " -Wl,-z,notext"
} }
if {![ld_link $CC $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} { if {![ld_link $CC_FOR_TARGET $tmpdir/$progname.so "$shared $shldflags $tmpdir/$sh1 $tmpdir/$sh2"]} {
fail "$testname" fail "$testname"
return return
} }
@ -153,7 +153,7 @@ proc shared_test { progname testname main sh1 sh2 dat args } {
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
set rpath /lib:$tmpdir set rpath /lib:$tmpdir
} }
if ![ld_link $CC $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] { if ![ld_link $CC_FOR_TARGET $tmpdir/$progname "-Wl,-rpath,$rpath $tmpdir/$main $tmpdir/$progname.so"] {
fail "$testname" fail "$testname"
return return
} }
@ -197,9 +197,9 @@ if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then {
# Unfortunately, the gcc argument is -fpic and the cc argument is # Unfortunately, the gcc argument is -fpic and the cc argument is
# -KPIC. We have to try both. # -KPIC. We have to try both.
set picflag "-fpic" set picflag "-fpic"
send_log "$CC $picflag\n" send_log "$CC_FOR_TARGET $picflag\n"
verbose "$CC $picflag" verbose "$CC_FOR_TARGET $picflag"
catch "exec $CC $picflag" exec_output catch "exec $CC_FOR_TARGET $picflag" exec_output
send_log "$exec_output\n" send_log "$exec_output\n"
verbose "--" "$exec_output" verbose "--" "$exec_output"
if { [string match "*illegal option*" $exec_output] \ if { [string match "*illegal option*" $exec_output] \
@ -212,7 +212,7 @@ if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then {
verbose "Using $picflag to compile PIC code" verbose "Using $picflag to compile PIC code"
# Compile the main program. # Compile the main program.
if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o] { if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
unsupported "shared (non PIC)" unsupported "shared (non PIC)"
unsupported "shared" unsupported "shared"
} else { } else {
@ -223,8 +223,8 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o]
# using -fpic will cause some of the tests to return different # using -fpic will cause some of the tests to return different
# results. Make sure that PLT is used since PLT is expected. # results. Make sure that PLT is used since PLT is expected.
global PLT_CFLAGS NOPIE_CFLAGS global PLT_CFLAGS NOPIE_CFLAGS
if { ![ld_compile "$CC $PLT_CFLAGS $NOPIE_CFLAGS $CFLAGS $SHCFLAG" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o] if { ![ld_compile "$CC_FOR_TARGET $PLT_CFLAGS $NOPIE_CFLAGS $CFLAGS_FOR_TARGET $SHCFLAG" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o]
|| ![ld_compile "$CC $PLT_CFLAGS $CFLAGS $SHCFLAG" $srcdir/$subdir/sh2.c $tmpdir/sh2np.o] } { || ![ld_compile "$CC_FOR_TARGET $PLT_CFLAGS $CFLAGS_FOR_TARGET $SHCFLAG" $srcdir/$subdir/sh2.c $tmpdir/sh2np.o] } {
unsupported "shared (non PIC)" unsupported "shared (non PIC)"
} else { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } { } else { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
shared_test shnp "shared (nonPIC)" mainnp.o sh1np.o sh2np.o xcoff shared_test shnp "shared (nonPIC)" mainnp.o sh1np.o sh2np.o xcoff
@ -284,25 +284,25 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o]
# Now compile the code using -fpic. # Now compile the code using -fpic.
if { ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o] if { ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o]
|| ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.o] } { || ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.o] } {
unsupported "shared" unsupported "shared"
} else { } else {
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
shared_test shp "shared" mainnp.o sh1p.o sh2p.o xcoff shared_test shp "shared" mainnp.o sh1p.o sh2p.o xcoff
} else { } else {
shared_test shp "shared" mainnp.o sh1p.o sh2p.o shared shared_test shp "shared" mainnp.o sh1p.o sh2p.o shared
ld_compile "$CC $CFLAGS -DSYMBOLIC_TEST -DXCOFF_TEST $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -DSYMBOLIC_TEST -DXCOFF_TEST $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o
ld_compile "$CC $CFLAGS -DSYMBOLIC_TEST -DXCOFF_TEST $SHCFLAG $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -DSYMBOLIC_TEST -DXCOFF_TEST $SHCFLAG $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o
shared_test shp "shared -Bsymbolic" mainnp.o sh1p.o sh2p.o symbolic "-Bsymbolic" shared_test shp "shared -Bsymbolic" mainnp.o sh1p.o sh2p.o symbolic "-Bsymbolic"
ld_compile "$CC $CFLAGS $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o
ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o
} }
} }
} }
# Now do the same tests again, but this time compile main.c PIC. # Now do the same tests again, but this time compile main.c PIC.
if ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdir/mainp.o] { if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdir/mainp.o] {
unsupported "shared (PIC main, non PIC so)" unsupported "shared (PIC main, non PIC so)"
unsupported "shared (PIC main)" unsupported "shared (PIC main)"
} else { } else {
@ -347,7 +347,7 @@ if ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdir/m
} }
} }
set CFLAGS "$old_CFLAGS" set CFLAGS_FOR_TARGET "$old_CFLAGS"
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
# Remove the temporary directory. # Remove the temporary directory.

View File

@ -355,26 +355,26 @@ if { ![check_compiler_available] } {
# tests. Also add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if PIE doesn't work # tests. Also add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if PIE doesn't work
# with S-records. Also add $NOCF_PROTECTION_CFLAGS for S-records. # with S-records. Also add $NOCF_PROTECTION_CFLAGS for S-records.
# Also add $NOSANITIZE_CFLAGS for S-records. # Also add $NOSANITIZE_CFLAGS for S-records.
set old_CC "$CC" set old_CC "$CC_FOR_TARGET"
set CC "$CC $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" append CC_FOR_TARGET " $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
set old_CXX "$CXX" set old_CXX "$CXX_FOR_TARGET"
set old_CXXFLAGS "$CXXFLAGS" set old_CXXFLAGS "$CXXFLAGS_FOR_TARGET"
set CXXFLAGS "$CXXFLAGS $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" append CXXFLAGS_FOR_TARGET " $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
# S-records can't handle .note.gnu.property sections. # S-records can't handle .note.gnu.property sections.
if { [is_elf_format] \ if { [is_elf_format] \
&& ([istarget "i?86-*-*"] || [istarget "x86_64-*-*"]) } { && ([istarget "i?86-*-*"] || [istarget "x86_64-*-*"]) } {
set CC "$CC -Wa,-mx86-used-note=no" append CC_FOR_TARGET " -Wa,-mx86-used-note=no"
set CXX "$CXX -Wa,-mx86-used-note=no" append CXX_FOR_TARGET " -Wa,-mx86-used-note=no"
} }
if { ![ld_compile $CC $srcdir/$subdir/sr1.c tmpdir/sr1.o] \ if { ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/sr1.c tmpdir/sr1.o] \
|| ![ld_compile $CC $srcdir/$subdir/sr2.c tmpdir/sr2.o] } { || ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/sr2.c tmpdir/sr2.o] } {
unsupported $test1 unsupported $test1
unsupported $test2 unsupported $test2
set CC "$old_CC" set CC_FOR_TARGET "$old_CC"
set CXX "$old_CXX" set CXX_FOR_TARGET "$old_CXX"
set CXXFLAGS "$old_CXXFLAGS" set CXXFLAGS_FOR_TARGET "$old_CXXFLAGS"
return return
} }
@ -444,19 +444,19 @@ run_srec_test $test1 "tmpdir/sr1.o tmpdir/sr2.o"
# destructors. Note that since we are not linking against any # destructors. Note that since we are not linking against any
# libraries, this program won't actually work or anything. # libraries, this program won't actually work or anything.
if { ![is_remote host] && [which $CXX] == 0 } { if { ![is_remote host] && [which $CXX_FOR_TARGET] == 0 } {
untested $test2 untested $test2
set CC "$old_CC" set CC_FOR_TARGET "$old_CC"
set CXX "$old_CXX" set CXX_FOR_TARGET "$old_CXX"
set CXXFLAGS "$old_CXXFLAGS" set CXXFLAGS_FOR_TARGET "$old_CXXFLAGS"
return return
} }
if ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/sr3.cc tmpdir/sr3.o] { if ![ld_compile "$CXX_FOR_TARGET $CXXFLAGS_FOR_TARGET -fno-exceptions" $srcdir/$subdir/sr3.cc tmpdir/sr3.o] {
unsupported $test2 unsupported $test2
set CC "$old_CC" set CC_FOR_TARGET "$old_CC"
set CXX "$old_CXX" set CXX_FOR_TARGET "$old_CXX"
set CXXFLAGS "$old_CXXFLAGS" set CXXFLAGS_FOR_TARGET "$old_CXXFLAGS"
return return
} }
@ -482,6 +482,6 @@ setup_xfail "bpf-*-*"
run_srec_test $test2 "tmpdir/sr3.o" run_srec_test $test2 "tmpdir/sr3.o"
set CC "$old_CC" set CC_FOR_TARGET "$old_CC"
set CXX "$old_CXX" set CXX_FOR_TARGET "$old_CXX"
set CXXFLAGS "$old_CXXFLAGS" set CXXFLAGS_FOR_TARGET "$old_CXXFLAGS"

View File

@ -29,7 +29,7 @@ if { ![check_compiler_available] } {
untested $testund untested $testund
untested $testfn untested $testfn
untested $testline untested $testline
} elseif { ![ld_compile "$CC -g $NOLTO_CFLAGS" $srcdir/$subdir/undefined.c tmpdir/undefined.o] } { } elseif { ![ld_compile "$CC_FOR_TARGET -g $NOLTO_CFLAGS" $srcdir/$subdir/undefined.c tmpdir/undefined.o] } {
verbose "Unable to compile test file!" 1 verbose "Unable to compile test file!" 1
unsupported $testund unsupported $testund
unsupported $testfn unsupported $testfn

View File

@ -102,13 +102,13 @@ proc contains_unique_symbol { binary_file } {
set fails 0 set fails 0
# Create object file containing unique symbol. # Create object file containing unique symbol.
if ![ld_compile "$CC -c" "$srcdir/$subdir/unique.s" "tmpdir/unique.o"] { if ![ld_compile "$CC_FOR_TARGET -c" "$srcdir/$subdir/unique.s" "tmpdir/unique.o"] {
fail "Could not create a unique object" fail "Could not create a unique object"
set fails [expr $fails + 1] set fails [expr $fails + 1]
} }
# Create object file NOT containing unique symbol. # Create object file NOT containing unique symbol.
if ![ld_compile "$CC -c" "$srcdir/$subdir/unique_empty.s" "tmpdir/unique_empty.o"] { if ![ld_compile "$CC_FOR_TARGET -c" "$srcdir/$subdir/unique_empty.s" "tmpdir/unique_empty.o"] {
fail "Could not create a non-unique object" fail "Could not create a non-unique object"
set fails [expr $fails + 1] set fails [expr $fails + 1]
} }
@ -123,7 +123,7 @@ if [board_info [target_info name] exists cflags] {
} }
# Create executable containing unique symbol. # Create executable containing unique symbol.
if ![ld_link "$CC $NOPIE_LDFLAGS $board_cflags" "tmpdir/unique_prog" "tmpdir/unique.o"] { if ![ld_link "$CC_FOR_TARGET $NOPIE_LDFLAGS $board_cflags" "tmpdir/unique_prog" "tmpdir/unique.o"] {
fail "Could not link a unique executable" fail "Could not link a unique executable"
set fails [expr $fails + 1] set fails [expr $fails + 1]
} }
@ -190,7 +190,7 @@ if { ![check_shared_lib_support] } {
} }
# Create pic object file containing unique symbol. # Create pic object file containing unique symbol.
if {![ld_compile "$CC -c -fPIC" "$srcdir/$subdir/unique_shared.s" "tmpdir/unique_shared.o"] } { if {![ld_compile "$CC_FOR_TARGET -c -fPIC" "$srcdir/$subdir/unique_shared.s" "tmpdir/unique_shared.o"] } {
fail "Could not create a pic unique object" fail "Could not create a pic unique object"
set fails [expr $fails + 1] set fails [expr $fails + 1]
} }
@ -202,7 +202,7 @@ if {![ld_link $ld "tmpdir/libunique_shared.so" "-shared tmpdir/unique_shared.o"]
} }
# Create executable NOT containing unique symbol linked against library. # Create executable NOT containing unique symbol linked against library.
if {![ld_link "$CC $NOPIE_LDFLAGS $board_cflags" "tmpdir/unique_shared_prog" "-Ltmpdir tmpdir/unique_empty.o -Wl,-Bdynamic,-rpath=./tmpdir -lunique_shared"] } { if {![ld_link "$CC_FOR_TARGET $NOPIE_LDFLAGS $board_cflags" "tmpdir/unique_shared_prog" "-Ltmpdir tmpdir/unique_empty.o -Wl,-Bdynamic,-rpath=./tmpdir -lunique_shared"] } {
fail "Could not link a dynamic executable" fail "Could not link a dynamic executable"
set fails [expr $fails + 1] set fails [expr $fails + 1]
} }

View File

@ -178,7 +178,7 @@ run_ld_link_exec_tests [list \
] ]
# Skip if -mtls-dialect=gnu2 doesn't work. # Skip if -mtls-dialect=gnu2 doesn't work.
if { ![run_host_cmd_yesno $CC "-c -O2 -fPIC $GNU2_CFLAGS $srcdir/$subdir/tlsdesc1b.c -o tmpdir/tlsdesc1b.o"] } { if { ![run_host_cmd_yesno $CC_FOR_TARGET "-c -O2 -fPIC $GNU2_CFLAGS $srcdir/$subdir/tlsdesc1b.c -o tmpdir/tlsdesc1b.o"] } {
return return
} }

View File

@ -24,16 +24,16 @@ load_file $srcdir/../../binutils/testsuite/lib/binutils-common.exp
# Returns 0 otherwise. # Returns 0 otherwise.
# #
proc at_least_gcc_version { major minor } { proc at_least_gcc_version { major minor } {
global CC global CC_FOR_TARGET
if {![info exists CC]} { if {![info exists CC_FOR_TARGET]} {
set CC [find_gcc] set CC_FOR_TARGET [find_gcc]
} }
if { $CC == "" } { if { $CC_FOR_TARGET == "" } {
return 0 return 0
} }
# Filter out -Wl, options. # Filter out -Wl, options.
regsub -all -- "-Wl,\[^ ^\t\]+" $CC "" cc_cmd regsub -all -- "-Wl,\[^ ^\t\]+" $CC_FOR_TARGET "" cc_cmd
set state [remote_exec host $cc_cmd --version] set state [remote_exec host $cc_cmd --version]
if { [lindex $state 0] != 0 } { if { [lindex $state 0] != 0 } {
return 0; return 0;
@ -216,8 +216,8 @@ proc default_ld_link { ld target objects } {
# Compile an object using cc. # Compile an object using cc.
# #
proc default_ld_compile { cc source object } { proc default_ld_compile { cc source object } {
global CFLAGS global CFLAGS_FOR_TARGET
global CXXFLAGS global CXXFLAGS_FOR_TARGET
global srcdir global srcdir
global subdir global subdir
global host_triplet global host_triplet
@ -252,9 +252,9 @@ proc default_ld_compile { cc source object } {
set ccexe [string replace $ccexe 0 [string last "/" $ccexe] ""] set ccexe [string replace $ccexe 0 [string last "/" $ccexe] ""]
if {[string match "*++*" $ccexe]} { if {[string match "*++*" $ccexe]} {
append flags " $CXXFLAGS" append flags " $CXXFLAGS_FOR_TARGET"
} else { } else {
append flags " $CFLAGS" append flags " $CFLAGS_FOR_TARGET"
} }
if [board_info [target_info name] exists cflags] { if [board_info [target_info name] exists cflags] {
@ -466,8 +466,8 @@ proc run_ld_link_tests { ldtests args } {
global srcdir global srcdir
global subdir global subdir
global env global env
global CC global CC_FOR_TARGET
global CFLAGS global CFLAGS_FOR_TARGET
global runtests global runtests
global exec_output global exec_output
@ -534,7 +534,7 @@ proc run_ld_link_tests { ldtests args } {
set objfile "tmpdir/$fileroot.o" set objfile "tmpdir/$fileroot.o"
if { [file extension $src_file] == ".c" } { if { [file extension $src_file] == ".c" } {
set as_file "tmpdir/$fileroot.s" set as_file "tmpdir/$fileroot.s"
if ![ld_compile "$CC -S $CFLAGS $cflags" $srcdir/$subdir/$src_file $as_file] { if ![ld_compile "$CC_FOR_TARGET -S $CFLAGS_FOR_TARGET $cflags" $srcdir/$subdir/$src_file $as_file] {
set is_unsupported 1 set is_unsupported 1
break break
} }
@ -683,10 +683,10 @@ proc run_ld_link_exec_tests { ldtests args } {
global srcdir global srcdir
global subdir global subdir
global env global env
global CC global CC_FOR_TARGET
global CXX global CXX_FOR_TARGET
global CFLAGS global CFLAGS_FOR_TARGET
global CXXFLAGS global CXXFLAGS_FOR_TARGET
global errcnt global errcnt
global exec_output global exec_output
global board_cflags global board_cflags
@ -746,9 +746,9 @@ proc run_ld_link_exec_tests { ldtests args } {
lappend objfiles $objfile lappend objfiles $objfile
if { [ string match "c++" $lang ] } { if { [ string match "c++" $lang ] } {
set cmd "$CXX -c $CXXFLAGS $cflags" set cmd "$CXX_FOR_TARGET -c $CXXFLAGS_FOR_TARGET $cflags"
} else { } else {
set cmd "$CC -c $CFLAGS $cflags" set cmd "$CC_FOR_TARGET -c $CFLAGS_FOR_TARGET $cflags"
} }
if ![ld_compile $cmd $srcdir/$subdir/$src_file $objfile] { if ![ld_compile $cmd $srcdir/$subdir/$src_file $objfile] {
set failed 1 set failed 1
@ -765,10 +765,10 @@ proc run_ld_link_exec_tests { ldtests args } {
set link_cmd $ld set link_cmd $ld
} elseif { [ string match "c++" $lang ] } { } elseif { [ string match "c++" $lang ] } {
set link_proc ld_link set link_proc ld_link
set link_cmd $CXX set link_cmd $CXX_FOR_TARGET
} else { } else {
set link_proc ld_link set link_proc ld_link
set link_cmd $CC set link_cmd $CC_FOR_TARGET
} }
if { $binfile eq "tmpdir/" } { if { $binfile eq "tmpdir/" } {
@ -851,10 +851,10 @@ proc run_cc_link_tests { ldtests } {
global srcdir global srcdir
global subdir global subdir
global env global env
global CC global CC_FOR_TARGET
global CXX global CXX_FOR_TARGET
global CFLAGS global CFLAGS_FOR_TARGET
global CXXFLAGS global CXXFLAGS_FOR_TARGET
global ar global ar
global exec_output global exec_output
global board_cflags global board_cflags
@ -936,9 +936,9 @@ proc run_cc_link_tests { ldtests } {
lappend objfiles $objfile lappend objfiles $objfile
if { [ string match "c++" $lang ] } { if { [ string match "c++" $lang ] } {
set cmd "$CXX -c $CXXFLAGS $cflags" set cmd "$CXX_FOR_TARGET -c $CXXFLAGS_FOR_TARGET $cflags"
} else { } else {
set cmd "$CC -c $CFLAGS $cflags" set cmd "$CC_FOR_TARGET -c $CFLAGS_FOR_TARGET $cflags"
} }
if ![ld_compile $cmd $srcdir/$subdir/$src_file $objfile] { if ![ld_compile $cmd $srcdir/$subdir/$src_file $objfile] {
set failed 1 set failed 1
@ -954,9 +954,9 @@ proc run_cc_link_tests { ldtests } {
reset_vars reset_vars
if { [ string match "c++" $lang ] } { if { [ string match "c++" $lang ] } {
set cc_cmd $CXX set cc_cmd $CXX_FOR_TARGET
} else { } else {
set cc_cmd $CC set cc_cmd $CC_FOR_TARGET
} }
if { $binfile eq "tmpdir/" } { if { $binfile eq "tmpdir/" } {
@ -1200,10 +1200,10 @@ proc check_sysroot_available { } {
proc check_compiler_available { } { proc check_compiler_available { } {
global compiler_available_saved global compiler_available_saved
global CC global CC_FOR_TARGET
if {![info exists compiler_available_saved]} { if {![info exists compiler_available_saved]} {
if { [which $CC] == 0 } { if { [which $CC_FOR_TARGET] == 0 } {
set compiler_available_saved 0 set compiler_available_saved 0
return 0 return 0
} }
@ -1228,7 +1228,7 @@ proc check_compiler_available { } {
if [is_remote host] { if [is_remote host] {
set src [remote_download host $src] set src [remote_download host $src]
} }
set compiler_available_saved [run_host_cmd_yesno "$CC" "$flags $src -o $output"] set compiler_available_saved [run_host_cmd_yesno "$CC_FOR_TARGET" "$flags $src -o $output"]
remote_file host delete $src remote_file host delete $src
remote_file host delete $output remote_file host delete $output
file delete $src file delete $src
@ -1238,16 +1238,16 @@ proc check_compiler_available { } {
# Returns 1 if plugin is enabled in gcc. Returns 0 otherwise. # Returns 1 if plugin is enabled in gcc. Returns 0 otherwise.
proc check_gcc_plugin_enabled { } { proc check_gcc_plugin_enabled { } {
global CC global CC_FOR_TARGET
if {![info exists CC]} { if {![info exists CC_FOR_TARGET]} {
set CC [find_gcc] set CC_FOR_TARGET [find_gcc]
} }
if { $CC == ""} { if { $CC_FOR_TARGET == ""} {
return 0 return 0
} }
# Filter out -Wl, options. # Filter out -Wl, options.
regsub -all -- "-Wl,\[^ ^\t\]+" $CC "" cc_cmd regsub -all -- "-Wl,\[^ ^\t\]+" $CC_FOR_TARGET "" cc_cmd
set state [remote_exec host $cc_cmd -v] set state [remote_exec host $cc_cmd -v]
if { [lindex $state 0] != 0 } { if { [lindex $state 0] != 0 } {
return 0; return 0;
@ -1266,7 +1266,7 @@ proc check_gcc_plugin_enabled { } {
# Returns true if the target compiler supports LTO # Returns true if the target compiler supports LTO
proc check_lto_available { } { proc check_lto_available { } {
global lto_available_saved global lto_available_saved
global CC global CC_FOR_TARGET
if {![info exists lto_available_saved]} { if {![info exists lto_available_saved]} {
if { ![check_gcc_plugin_enabled] } { if { ![check_gcc_plugin_enabled] } {
@ -1298,7 +1298,7 @@ proc check_lto_available { } {
if [is_remote host] { if [is_remote host] {
set src [remote_download host $src] set src [remote_download host $src]
} }
set lto_available_saved [run_host_cmd_yesno "$CC" "$flags -flto -fuse-linker-plugin $src -o $output"] set lto_available_saved [run_host_cmd_yesno "$CC_FOR_TARGET" "$flags -flto -fuse-linker-plugin $src -o $output"]
remote_file host delete $src remote_file host delete $src
remote_file host delete $output remote_file host delete $output
file delete $src file delete $src
@ -1309,7 +1309,7 @@ proc check_lto_available { } {
# Returns true if the target compiler supports LTO -ffat-lto-objects # Returns true if the target compiler supports LTO -ffat-lto-objects
proc check_lto_fat_available { } { proc check_lto_fat_available { } {
global lto_fat_available_saved global lto_fat_available_saved
global CC global CC_FOR_TARGET
if {![info exists lto_fat_available_saved]} { if {![info exists lto_fat_available_saved]} {
if { ![check_gcc_plugin_enabled] } { if { ![check_gcc_plugin_enabled] } {
@ -1341,7 +1341,7 @@ proc check_lto_fat_available { } {
if [is_remote host] { if [is_remote host] {
set src [remote_download host $src] set src [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"] set lto_fat_available_saved [run_host_cmd_yesno "$CC_FOR_TARGET" "$flags -flto -ffat-lto-objects -fuse-linker-plugin $src -o $output"]
remote_file host delete $src remote_file host delete $src
remote_file host delete $output remote_file host delete $output
file delete $src file delete $src
@ -1352,7 +1352,7 @@ proc check_lto_fat_available { } {
# Returns true if the target compiler supports LTO and -shared # Returns true if the target compiler supports LTO and -shared
proc check_lto_shared_available { } { proc check_lto_shared_available { } {
global lto_shared_available_saved global lto_shared_available_saved
global CC global CC_FOR_TARGET
if {![info exists lto_shared_available_saved]} { if {![info exists lto_shared_available_saved]} {
if { ![check_gcc_plugin_enabled] } { if { ![check_gcc_plugin_enabled] } {
@ -1384,7 +1384,7 @@ proc check_lto_shared_available { } {
if [is_remote host] { if [is_remote host] {
set src [remote_download host $src] set src [remote_download host $src]
} }
set lto_shared_available_saved [run_host_cmd_yesno "$CC" "$flags -shared -fPIC -flto -fuse-linker-plugin $src -o $output"] set lto_shared_available_saved [run_host_cmd_yesno "$CC_FOR_TARGET" "$flags -shared -fPIC -flto -fuse-linker-plugin $src -o $output"]
remote_file host delete $src remote_file host delete $src
remote_file host delete $output remote_file host delete $output
file delete $src file delete $src
@ -1418,7 +1418,7 @@ proc check_as_cfi { } {
proc check_ifunc_available { } { proc check_ifunc_available { } {
global ifunc_available_saved global ifunc_available_saved
global CC global CC_FOR_TARGET
if {![info exists ifunc_available_saved]} { if {![info exists ifunc_available_saved]} {
if { ![check_compiler_available] } { if { ![check_compiler_available] } {
@ -1452,7 +1452,7 @@ proc check_ifunc_available { } {
if [is_remote host] { if [is_remote host] {
set src [remote_download host $src] set src [remote_download host $src]
} }
set ifunc_available_saved [run_host_cmd_yesno "$CC" "$flags $src -o $output"] set ifunc_available_saved [run_host_cmd_yesno "$CC_FOR_TARGET" "$flags $src -o $output"]
if { [isnative] && $ifunc_available_saved == 1 } { if { [isnative] && $ifunc_available_saved == 1 } {
set ifunc_available_saved [run_host_cmd_yesno "$output" ""] set ifunc_available_saved [run_host_cmd_yesno "$output" ""]
} }
@ -1467,7 +1467,7 @@ proc check_ifunc_available { } {
proc check_ifunc_attribute_available { } { proc check_ifunc_attribute_available { } {
global ifunc_attribute_available_saved global ifunc_attribute_available_saved
global CC global CC_FOR_TARGET
if {![info exists ifunc_attribute_available_saved]} { if {![info exists ifunc_attribute_available_saved]} {
if { ![check_compiler_available] } { if { ![check_compiler_available] } {
@ -1499,7 +1499,7 @@ proc check_ifunc_attribute_available { } {
if [is_remote host] { if [is_remote host] {
set src [remote_download host $src] set src [remote_download host $src]
} }
set ifunc_attribute_available_saved [run_host_cmd_yesno "$CC" "$flags $src -o $output"] set ifunc_attribute_available_saved [run_host_cmd_yesno "$CC_FOR_TARGET" "$flags $src -o $output"]
if { [isnative] && $ifunc_attribute_available_saved == 1 } { if { [isnative] && $ifunc_attribute_available_saved == 1 } {
set ifunc_attribute_available_saved [run_host_cmd_yesno "$output" ""] set ifunc_attribute_available_saved [run_host_cmd_yesno "$output" ""]
} }
@ -1514,7 +1514,7 @@ proc check_ifunc_attribute_available { } {
proc check_libdl_available { } { proc check_libdl_available { } {
global libdl_available_saved global libdl_available_saved
global CC global CC_FOR_TARGET
if {![info exists libdl_available_saved]} { if {![info exists libdl_available_saved]} {
if { ![check_compiler_available] } { if { ![check_compiler_available] } {
@ -1537,7 +1537,7 @@ proc check_libdl_available { } {
if [is_remote host] { if [is_remote host] {
set src [remote_download host $src] set src [remote_download host $src]
} }
set libdl_available_saved [run_host_cmd_yesno "$CC" "$src -o $output -ldl"] set libdl_available_saved [run_host_cmd_yesno "$CC_FOR_TARGET" "$src -o $output -ldl"]
remote_file host delete $src remote_file host delete $src
remote_file host delete $output remote_file host delete $output
file delete $src file delete $src
@ -1549,7 +1549,7 @@ proc check_libdl_available { } {
proc check_gnu2_tls_available { } { proc check_gnu2_tls_available { } {
global gnu2_tls_available_saved global gnu2_tls_available_saved
global CC global CC_FOR_TARGET
global GNU2_CFLAGS global GNU2_CFLAGS
if {![info exists gnu2_tls_available_saved]} { if {![info exists gnu2_tls_available_saved]} {
@ -1593,9 +1593,9 @@ proc check_gnu2_tls_available { } {
if [is_remote host] { if [is_remote host] {
set src2 [remote_download host $src2] set src2 [remote_download host $src2]
} }
set gnu2_tls_available_saved [run_host_cmd_yesno "$CC" "-fPIC -shared $flags $src1 -o $output1"] set gnu2_tls_available_saved [run_host_cmd_yesno "$CC_FOR_TARGET" "-fPIC -shared $flags $src1 -o $output1"]
if { $gnu2_tls_available_saved == 1 } { if { $gnu2_tls_available_saved == 1 } {
set gnu2_tls_available_saved [run_host_cmd_yesno "$CC" "$flags $src2 $output1 -o $output2"] set gnu2_tls_available_saved [run_host_cmd_yesno "$CC_FOR_TARGET" "$flags $src2 $output1 -o $output2"]
if { $gnu2_tls_available_saved == 1 } { if { $gnu2_tls_available_saved == 1 } {
set gnu2_tls_available_saved [run_host_cmd_yesno "$output2" ""] set gnu2_tls_available_saved [run_host_cmd_yesno "$output2" ""]
} }
@ -1611,8 +1611,8 @@ proc check_gnu2_tls_available { } {
# Compile a C source file, with the specified additional_flags. # Compile a C source file, with the specified additional_flags.
proc compile_one_cc { src output additional_flags } { proc compile_one_cc { src output additional_flags } {
global CC global CC_FOR_TARGET
global CFLAGS global CFLAGS_FOR_TARGET
set flags "" set flags ""
if [board_info [target_info name] exists cflags] { if [board_info [target_info name] exists cflags] {
@ -1625,7 +1625,7 @@ proc compile_one_cc { src output additional_flags } {
if [is_remote host] { if [is_remote host] {
set src [remote_download host $src] set src [remote_download host $src]
} }
return [run_host_cmd_yesno "$CC" "$flags $CFLAGS $additional_flags $src -o $output"] return [run_host_cmd_yesno "$CC_FOR_TARGET" "$flags $CFLAGS_FOR_TARGET $additional_flags $src -o $output"]
} }
# Returns true if the target compiler supports -gctf # Returns true if the target compiler supports -gctf

View File

@ -86,8 +86,9 @@ check-DEJAGNU: site.exp development.exp
runtest=$(RUNTEST); \ runtest=$(RUNTEST); \
if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
$$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \ $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \
CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS) -I$(INCDIR) -I$(srcdir) -I$(builddir) -I$(builddir)/../bfd $(ZLIBINC)" \ CC="$(CC)" CC_FOR_TARGET="$(CC_FOR_TARGET)" \
CC_FOR_HOST="$(CC)" LIBS="$(libctf_nobfd_la_LIBADD) $(LIBS)" $(RUNTESTFLAGS); \ CFLAGS="$(CFLAGS) -I$(INCDIR) -I$(srcdir) -I$(builddir) -I$(builddir)/../bfd $(ZLIBINC)" \
LIBS="$(libctf_nobfd_la_LIBADD) $(LIBS)" $(RUNTESTFLAGS); \
else echo "WARNING: could not find \`runtest'" 1>&2; :;\ else echo "WARNING: could not find \`runtest'" 1>&2; :;\
fi fi

View File

@ -1374,8 +1374,9 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES
@TCL_TRY_TRUE@ runtest=$(RUNTEST); \ @TCL_TRY_TRUE@ runtest=$(RUNTEST); \
@TCL_TRY_TRUE@ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ @TCL_TRY_TRUE@ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
@TCL_TRY_TRUE@ $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \ @TCL_TRY_TRUE@ $$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \
@TCL_TRY_TRUE@ CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS) -I$(INCDIR) -I$(srcdir) -I$(builddir) -I$(builddir)/../bfd $(ZLIBINC)" \ @TCL_TRY_TRUE@ CC="$(CC)" CC_FOR_TARGET="$(CC_FOR_TARGET)" \
@TCL_TRY_TRUE@ CC_FOR_HOST="$(CC)" LIBS="$(libctf_nobfd_la_LIBADD) $(LIBS)" $(RUNTESTFLAGS); \ @TCL_TRY_TRUE@ CFLAGS="$(CFLAGS) -I$(INCDIR) -I$(srcdir) -I$(builddir) -I$(builddir)/../bfd $(ZLIBINC)" \
@TCL_TRY_TRUE@ LIBS="$(libctf_nobfd_la_LIBADD) $(LIBS)" $(RUNTESTFLAGS); \
@TCL_TRY_TRUE@ else echo "WARNING: could not find \`runtest'" 1>&2; :;\ @TCL_TRY_TRUE@ else echo "WARNING: could not find \`runtest'" 1>&2; :;\
@TCL_TRY_TRUE@ fi @TCL_TRY_TRUE@ fi

View File

@ -43,18 +43,18 @@ if {![file isdirectory tmpdir/libctf]} then {
set gcc_B_opt "-B[pwd]/tmpdir/libctf/" set gcc_B_opt "-B[pwd]/tmpdir/libctf/"
set ld_L_opt "" set ld_L_opt ""
# The "make check" target in the Makefile passes in
# "CC=$(CC_FOR_TARGET)". But, if the user invokes runtest directly,
# these flags may not be set.
if {![info exists CC]} { if {![info exists CC]} {
set CC [find_gcc] set CC gcc
}
if {![info exists CC_FOR_HOST]} {
set CC_FOR_HOST $CC
} }
if {![info exists CFLAGS]} { if {![info exists CFLAGS]} {
set CFLAGS "-g -O2" set CFLAGS "-g -O2"
} }
if {![info exists CC_FOR_TARGET]} {
set CC_FOR_TARGET [find_gcc]
}
if {![info exists CFLAGS_FOR_TARGET]} {
set CFLAGS_FOR_TARGET $CFLAGS
}
# load the utility procedures # load the utility procedures
load_lib ctf-lib.exp load_lib ctf-lib.exp

View File

@ -48,10 +48,10 @@ proc run_native_host_cmd { command } {
# Compile and link a C source file for execution on the host. # Compile and link a C source file for execution on the host.
proc compile_link_one_host_cc { src output additional_args } { proc compile_link_one_host_cc { src output additional_args } {
global CC_FOR_HOST global CC
global CFLAGS global CFLAGS
return [run_native_host_cmd "./libtool --quiet --tag=CC --mode=link $CC_FOR_HOST $CFLAGS $src -o $output $additional_args" ] return [run_native_host_cmd "./libtool --quiet --tag=CC --mode=link $CC $CFLAGS $src -o $output $additional_args" ]
} }
# run_lookup_test FILE # run_lookup_test FILE
@ -110,7 +110,7 @@ proc compile_link_one_host_cc { src output additional_args } {
# regexps in FILE.d. # regexps in FILE.d.
# #
proc run_lookup_test { name } { proc run_lookup_test { name } {
global CC CFLAGS LIBS global CC_FOR_TARGET CFLAGS_FOR_TARGET LIBS
global copyfile env runtests srcdir subdir verbose global copyfile env runtests srcdir subdir verbose
if ![runtest_file_p $runtests $name] then { if ![runtest_file_p $runtests $name] then {
@ -217,7 +217,7 @@ proc run_lookup_test { name } {
} }
} }
set comp_output [run_host_cmd "$CC" "$CFLAGS $lookup_flags [concat $src] -o $lookup_output"] set comp_output [run_host_cmd "$CC_FOR_TARGET" "$CFLAGS_FOR_TARGET $lookup_flags [concat $src] -o $lookup_output"]
if { $comp_output != ""} { if { $comp_output != ""} {
send_log "compilation of CTF program [concat $src] failed with <$comp_output>" send_log "compilation of CTF program [concat $src] failed with <$comp_output>"