# regexps in FILE.d.
#
proc run_dump_test { name {extra_options {}} } {
- global ADDR2LINE ADDR2LINEFLAGS AS ASFLAGS CC CFLAGS ELFEDIT ELFEDITFLAGS
- global LD LDFLAGS NM NMFLAGS OBJCOPY OBJCOPYFLAGS OBJDUMP OBJDUMPFLAGS
- global READELF READELFFLAGS STRIP STRIPFLAGS
+ global ADDR2LINE ADDR2LINEFLAGS AS ASFLAGS CC_FOR_TARGET CFLAGS_FOR_TARGET
+ global ELFEDIT ELFEDITFLAGS LD LDFLAGS NM NMFLAGS OBJCOPY OBJCOPYFLAGS
+ global OBJDUMP OBJDUMPFLAGS READELF READELFFLAGS STRIP STRIPFLAGS
global copyfile env runtests srcdir subdir verbose
if [string match "*/*" $name] {
# ofile is never absolute, so this always works to protect sfile
# from later absolutization.
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"
set cmdret [remote_exec host [concat sh -c [list "$cmd 2>&1"]] "" "/dev/null" "dump.tmp"]
remote_upload host "dump.tmp"
runtest=$(RUNTEST); \
if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
$$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \
- CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS_FOR_TARGET)" \
- CXX="$(CXX_FOR_TARGET)" CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
- CC_FOR_HOST="$(CC)" CFLAGS_FOR_HOST="$(CFLAGS)" \
+ CC="$(CC)" CFLAGS="$(CFLAGS)" \
+ CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" \
+ 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)" \
LIBIBERTY="$(LIBIBERTY) $(LIBINTL)" LIBS="$(LIBS)" \
DO_COMPARE="`echo '$(do_compare)' | sed -e 's,\\$$,,g'`" \
runtest=$(RUNTEST); \
if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
$$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \
- CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS_FOR_TARGET)" \
- CXX="$(CXX_FOR_TARGET)" CXXFLAGS="$(CXXFLAGS_FOR_TARGET)" \
- CC_FOR_HOST="$(CC)" CFLAGS_FOR_HOST="$(CFLAGS)" \
+ CC="$(CC)" CFLAGS="$(CFLAGS)" \
+ CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" \
+ 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)" \
LIBIBERTY="$(LIBIBERTY) $(LIBINTL)" LIBS="$(LIBS)" \
DO_COMPARE="`echo '$(do_compare)' | sed -e 's,\\$$,,g'`" \
}
}
-# 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]} {
- set CC [find_gcc]
+ set CC gcc
}
if {![info exists CFLAGS]} {
set CFLAGS "-g -O2"
}
-if {![info exists CXX]} {
- set CXX [find_g++]
+if {![info exists CC_FOR_TARGET]} {
+ set CC_FOR_TARGET [find_gcc]
}
-if {![info exists CXXFLAGS]} {
- set CXXFLAGS ""
+if {![info exists CFLAGS_FOR_TARGET]} {
+ 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
# Compiler tests
proc compiler_supports { flag args } {
if { [check_compiler_available] } {
- global CC
+ global CC_FOR_TARGET
set flags ""
if [board_info [target_info name] exists cflags] {
append flags " [board_info [target_info name] cflags]"
}
close $f
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
file delete $fn
return $avail
cyglto_plugin-0.dll
}
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 {
- 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 {
set plug_opt "--plugin $plug_so"
set MYLIBS "-L/usr/lib -lcygwin -L/usr/lib/w32api -lkernel32"
# 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"
}
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"] {
catch "exec ln -fs dll.dll $tmpdir/libsymlinked_dll.dll.a" ln_catch
# 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"
}
return
}
-if { [which $CXX] == 0 } {
+if { [which $CXX_FOR_TARGET] == 0 } {
untested $test1
untested $test2
return
}
-if { ![ld_compile "$CXX $CXXFLAGS -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 $CXXFLAGS -fno-exceptions" $srcdir/$subdir/cdtest-main.cc tmpdir/cdtest-main.o] } {
+if { ![ld_compile "$CXX_FOR_TARGET $CXXFLAGS_FOR_TARGET -fno-exceptions" $srcdir/$subdir/cdtest-foo.cc tmpdir/cdtest-foo.o]
+ || ![ld_compile "$CXX_FOR_TARGET $CXXFLAGS_FOR_TARGET -fno-exceptions" $srcdir/$subdir/cdtest-bar.cc tmpdir/cdtest-bar.o]
+ || ![ld_compile "$CXX_FOR_TARGET $CXXFLAGS_FOR_TARGET -fno-exceptions" $srcdir/$subdir/cdtest-main.cc tmpdir/cdtest-main.o] } {
unsupported $test1
unsupported $test2
return
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
} else {
send_log "tmpdir/cdtest >tmpdir/cdtest.out\n"
if ![ld_relocate $ld tmpdir/cdtest.o {-Ur tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
fail $test2
} else {
- if ![ld_link $CC tmpdir/cdtest tmpdir/cdtest.o] {
+ if ![ld_link $CC_FOR_TARGET tmpdir/cdtest tmpdir/cdtest.o] {
fail $test2
} else {
send_log "tmpdir/cdtest >tmpdir/cdtest.out\n"
} \r
\r
# Compile the executable.\r
-if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/testexe.c $tmpdir/testexe.o] {\r
+if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/testexe.c $tmpdir/testexe.o] {\r
fail "compiling executable"\r
return\r
}\r
\r
-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"] {\r
+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"] {\r
fail "linking executable"\r
return\r
} \r
\r
# Compile the dll.\r
-if ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/testdll.c $tmpdir/testdll.o] {\r
+if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/testdll.c $tmpdir/testdll.o] {\r
fail "compiling shared lib"\r
return\r
}\r
\r
-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"] {\r
+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"] {\r
fail "linking shared lib"\r
return\r
} \r
}
# 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
}
}
# Disable all sanitizers.
-set old_CFLAGS "$CFLAGS"
-append CFLAGS " $NOSANITIZE_CFLAGS"
+set old_CFLAGS "$CFLAGS_FOR_TARGET"
+append CFLAGS_FOR_TARGET " $NOSANITIZE_CFLAGS"
run_cc_link_tests $build_tests
run_ld_link_exec_tests $run_tests
-set CFLAGS "$old_CFLAGS"
+set CFLAGS_FOR_TARGET "$old_CFLAGS"
proc strip_test {} {
global ld
}
# 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
}
}
# Disable LTO for these tests.
-set cc_cmd "$CC"
+set cc_cmd "$CC_FOR_TARGET"
if {[check_lto_available]} {
append cc_cmd " -fno-lto"
}
}
}
-send_log "$CC -fPIE -pie $srcdir/$subdir/main.c -o tmpdir/pie"
-catch "exec $CC -fPIE -pie $srcdir/$subdir/main.c -o tmpdir/pie" exec_output
+send_log "$CC_FOR_TARGET -fPIE -pie $srcdir/$subdir/main.c -o tmpdir/pie"
+catch "exec $CC_FOR_TARGET -fPIE -pie $srcdir/$subdir/main.c -o tmpdir/pie" exec_output
send_log "$exec_output"
if { ! [string match "" $exec_output] } {
return
# XFAIL on NetBSD ELF systems as they do not currently support the .*_array
# sections.
# Disable all sanitizers.
- set old_CFLAGS "$CFLAGS"
- append CFLAGS " $NOSANITIZE_CFLAGS"
+ set old_CFLAGS "$CFLAGS_FOR_TARGET"
+ append CFLAGS_FOR_TARGET " $NOSANITIZE_CFLAGS"
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
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 ] } {
pass $testname
} {
fail $testname
}
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 ] } {
pass $testname
} {
fail $testname
}
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 ] } {
pass $testname
} {
fail $testname
}
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 ] } {
pass $testname
} {
}
# Check to see if the C++ compiler works
-if { [which $CXX] == 0 } {
+if { [which $CXX_FOR_TARGET] == 0 } {
return
}
}
if [istarget nios2*-*-*] {
- set CFLAGS "$CFLAGS -G0"
+ append CFLAGS_FOR_TARGET " -G0"
}
# Explicitly use "-fcommon" so that even if $CFLAGS includes
# "-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]
- || ![ld_compile "$CC $CFLAGS -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] } {
+if { ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -fcommon $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/common1a.c tmpdir/common1a.o]
+ || ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -fcommon $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/common1b.c tmpdir/common1b.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
return
}
# Unfortunately, the gcc argument is -fpic and the cc argument is
# -KPIC. We have to try both.
set picflag "-fpic"
- send_log "$CC $picflag\n"
- verbose "$CC $picflag"
- catch "exec $CC $picflag" exec_output
+ send_log "$CC_FOR_TARGET $picflag\n"
+ verbose "$CC_FOR_TARGET $picflag"
+ catch "exec $CC_FOR_TARGET $picflag" exec_output
send_log "$exec_output\n"
verbose "--" "$exec_output"
if { [string match "*illegal option*" $exec_output]
global as
global as_options
global objdump
- global CC
- global CFLAGS
+ global CC_FOR_TARGET
+ global CFLAGS_FOR_TARGET
global script
global NOSANITIZE_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"
return
}
global as
global as_options
global objdump
- global CC
- global CFLAGS
+ global CC_FOR_TARGET
+ global CFLAGS_FOR_TARGET
global script
if [string match "" $other] then {
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"
return
}
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"
return
}
global subdir
global tmpdir
global as
- global CC
- global CFLAGS
+ global CC_FOR_TARGET
+ global CFLAGS_FOR_TARGET
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"
return
}
global as
global as_options
global objdump
- global CC
- global CFLAGS
+ global CC_FOR_TARGET
+ global CFLAGS_FOR_TARGET
global NOSANITIZE_CFLAGS
global NOLTO_CFLAGS
set script --version-script
# 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]} {
append cc_cmd " -fno-lto"
}
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"
return
}
set file [open $tmpdir/movw-detect.c w]
puts $file "void foo(void) { __asm (\"movw r0, #0\"); }"
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"
}
}
if { [istarget *-*-linux*]
|| [istarget *-*-nacl*]
|| [istarget *-*-gnu*] } {
- if [ld_compile "$CC -g $CFLAGS -DPROTECTED_CHECK" $srcdir/$subdir/main.c $tmpdir/main.o] {
- if [ld_link $CC $tmpdir/main "$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_FOR_TARGET $tmpdir/main "$tmpdir/main.o"] {
catch "exec $tmpdir/main" support_protected
}
}
# The test procedure.
proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
- global CC
+ global CC_FOR_TARGET
global srcdir
global subdir
global exec_output
if { [is_elf_format] && [check_shared_lib_support] } {
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" ]
&& [regexp "undefined reference to \`\.?visibility\'" $link_output]
&& [regexp "undefined reference to \`visibility_var\'" $link_output] } {
# Link against the shared library. Use -rpath so that the
# dynamic linker can locate the shared library at runtime.
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" ]
&& [regexp "undefined reference to \`\.?visibility\'" $link_output]
&& [regexp "undefined reference to \`visibility_var\'" $link_output] } {
}
proc visibility_run {visibility} {
- global CC
- global CFLAGS
+ global CC_FOR_TARGET
+ global CFLAGS_FOR_TARGET
global SHCFLAG
global srcdir
global subdir
} else {
# Compile the main program. Make sure that PLT is used since PLT
# 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)"
} else {
# will need to do more relocation work. However, note that not
# using -fpic will cause some of the tests to return different
# 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]
- || ![ld_compile "$CC -g $NOPIE_CFLAGS $PLT_CFLAGS $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/sh2.c $tmpdir/sh2np.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_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)"
} else {
# SunOS non PIC shared libraries don't permit some cases of
# 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]
- || ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.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_FOR_TARGET -g $CFLAGS_FOR_TARGET $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.o] } {
unsupported "visibility ($visibility)"
} else {
if { [ string match $visibility "protected" ]
# Don't bother.
} else {
# 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)"
} else {
# Unfortunately, the gcc argument is -fpic and the cc argument is
# -KPIC. We have to try both.
set picflag "-fpic"
- send_log "$CC $picflag\n"
- verbose "$CC $picflag"
- catch "exec $CC $picflag" exec_output
+ send_log "$CC_FOR_TARGET $picflag\n"
+ verbose "$CC_FOR_TARGET $picflag"
+ catch "exec $CC_FOR_TARGET $picflag" exec_output
send_log "$exec_output\n"
verbose "--" "$exec_output"
if { [string match "*illegal option*" $exec_output] \
visibility_run protected_weak
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"
} else {
if ![ld_link $ld tmpdir/common "tmpdir/common.o"] {
}
}
-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"
} 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"
} else {
if ![ld_link $ld tmpdir/sh3.so "-shared tmpdir/sh3.o"] {
}
proc build_lib {test libname objs dynsymexp} {
- global CC
+ global CC_FOR_TARGET
global objdump
global tmpdir
global shared
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
return
}
}
proc build_exec { test execname objs flags dat dynsymexp symexp} {
- global CC
+ global CC_FOR_TARGET
global objdump
global tmpdir
global srcdir
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"
return
}
}
# Disable LTO for these tests.
-set cc_cmd "$CC"
+set cc_cmd "$CC_FOR_TARGET"
if {[check_lto_available]} {
append cc_cmd " -fno-lto"
}
# Disable all sanitizers and LTO.
-set saved_CFLAGS "$CFLAGS"
-set CFLAGS "$CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
+set saved_CFLAGS "$CFLAGS_FOR_TARGET"
+append CFLAGS_FOR_TARGET " $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
# Old version of GCC for MIPS default to enabling -fpic
# and get confused if it is used on the command line.
# Unfortunately, the gcc argument is -fpic and the cc argument is
# -KPIC. We have to try both.
set picflag "-fpic"
- send_log "$CC $picflag\n"
- verbose "$CC $picflag"
- catch "exec $CC $picflag" exec_output
+ send_log "$CC_FOR_TARGET $picflag\n"
+ verbose "$CC_FOR_TARGET $picflag"
+ catch "exec $CC_FOR_TARGET $picflag" exec_output
send_log "$exec_output\n"
verbose "--" "$exec_output"
if { [string match "*illegal option*" $exec_output]
}
verbose "Using $picflag to compile PIC code"
-if {![ld_compile "$cc_cmd $CFLAGS $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" $srcdir/$subdir/main.c $tmpdir/main.o]
+if {![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/foo.c $tmpdir/foo.o]
+ || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/bar.c $tmpdir/bar.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_compile "$cc_cmd $CFLAGS $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 $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 $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/foo1a.c $tmpdir/foo1a.o]
+ || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/foo1b.c $tmpdir/foo1b.o]
+ || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/bar1a.c $tmpdir/bar1a.o]
+ || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/bar1b.c $tmpdir/bar1b.o]
+ || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/bar1c.c $tmpdir/bar1c.o]
+ || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/main1.c $tmpdir/main1.o]} then {
unsupported "ELF weak"
} elseif {![ld_link $cc_cmd $tmpdir/libfoo1a.so "$shared $tmpdir/foo1a.o"]
|| ![ld_link $cc_cmd $tmpdir/libfoo1b.so "$shared $tmpdir/foo1b.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 ""
}
-if {![ld_compile "$cc_cmd $CFLAGS $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 $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 {
+if {![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/size_foo.c $tmpdir/size_foo.o]
+ || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/size_bar.c $tmpdir/size_bar_s.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_FOR_TARGET" $srcdir/$subdir/size_main.c $tmpdir/size_main.o]} then {
unsupported "ELF weak (size)"
} else {
build_lib "ELF DSO small bar (size)" libsize_bar_s "size_bar_s.o" ""
verbose "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_compile "$cc_cmd $CFLAGS" $srcdir/$subdir/aliasmain.c $tmpdir/aliasmain.o]
- || ![ld_compile "$cc_cmd $CFLAGS" $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/aliasmain.c $tmpdir/aliasmain.o]
+ || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET" $srcdir/$subdir/weakref1.c $tmpdir/weakref1.o]
+ || ![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET" $srcdir/$subdir/weakref2.c $tmpdir/weakref2.o]} then {
unsupported "ELF weak (alias)"
} else {
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"
}
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} {
if { [istarget "*-*-linux*"]
|| [istarget "*-*-nacl*"]
|| [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_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"
}
}
}
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
}
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
}
if { [check_compiler_available] } {
- ld_compile "$CC $CFLAGS $cflags -O0" $srcdir/$subdir/pr19161-1.c tmpdir/pr19161-1.o
- ld_compile "$CC $CFLAGS $cflags -O0" $srcdir/$subdir/pr19161-2.c tmpdir/pr19161-2.o
+ ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $cflags -O0" $srcdir/$subdir/pr19161-1.c tmpdir/pr19161-1.o
+ ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $cflags -O0" $srcdir/$subdir/pr19161-2.c tmpdir/pr19161-2.o
if [istarget hppa*-*-linux*] {
set symdefs {{ld {--defsym '\$\$dyncall=0'}}}
}
set fails 0
# Disable LTO for these tests.
-set cc_cmd "$CC"
+set cc_cmd "$CC_FOR_TARGET"
if {[check_lto_available]} {
append cc_cmd " -fno-lto"
}
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"
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"
set fails [expr $fails + 1]
}
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"
set fails [expr $fails + 1]
}
fail "Could not link a non-ifunc using static executable"
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"
set fails [expr $fails + 1]
}
run_ld_link_tests $am33_tests
proc i126256-test { } {
- global CC
+ global CC_FOR_TARGET
global ld
global srcdir
global subdir
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
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
return
}
}
proc build_basefile1_o {} {
- global CC
- global CFLAGS
+ global CC_FOR_TARGET
+ global CFLAGS_FOR_TARGET
global srcdir
global subdir
# 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"
}
}
}
proc build_vers_script_dll_o {} {
- global CC
- global CFLAGS
+ global CC_FOR_TARGET
+ global CFLAGS_FOR_TARGET
global srcdir
global subdir
# 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"
}
}
proc run_ver_script_test { testname } {
- global CC
+ global CC_FOR_TARGET
global srcdir
global subdir
global verbose
- if ![ld_link "$CC -shared \
+ if ![ld_link "$CC_FOR_TARGET -shared \
-Wl,--version-script,$srcdir/$subdir/$testname.ver \
-Wl,--output-def,tmpdir/$testname.def" tmpdir/$testname.dll \
"tmpdir/vers-script-dll.o"] {
set tmpdir tmpdir
proc test_direct_link_dll {} {
- global CC
- global CFLAGS
+ global CC_FOR_TARGET
+ global CFLAGS_FOR_TARGET
global srcdir
global subdir
global tmpdir
# 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"
- } 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)"
- } 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)"
} else {
# 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"
} else {
# Check linking directly to direct_dll.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" ] {
pass $msg
} else {
# Check linking directly to direct_dll.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" ] {
pass $msg
} else {
# Create symbolic link.
catch "exec ln -fs direct_dll.dll $tmpdir/libdirect_dll.dll.a" ln_catch
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" ] {
pass $msg
} else {
# Create symbolic link.
catch "exec ln -fs direct_dll.sl $tmpdir/libdirect_sl.dll.a" ln_catch
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" ] {
pass $msg
} else {
set tmpdir tmpdir
proc test_direct2_link_dll {} {
- global CC
- global CFLAGS
+ global CC_FOR_TARGET
+ global CFLAGS_FOR_TARGET
global srcdir
global subdir
global tmpdir
# 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"
- } 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"
- } 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"
} else {
# 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"
} else {
# Check linking directly to direct2_dll.dll.
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" ] {
pass $msg
} else {
# Check linking directly to direct2_dll.sl.
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" ] {
pass $msg
} else {
# Create symbolic link.
catch "exec ln -fs direct2_dll.dll $tmpdir/libdirect2_dll.dll.a" ln_catch
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" ] {
pass $msg
} else {
# Create symbolic link.
catch "exec ln -fs direct2_dll.sl $tmpdir/libdirect2_sl.dll.a" ln_catch
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" ] {
pass $msg
} else {
}
# Check if -pie is supported or not.
-send_log "$CC -fpie -pie $srcdir/$subdir/pie.c -o tmpdir/pie"
-catch "exec $CC -fpie -pie $srcdir/$subdir/pie.c -o tmpdir/pie" exec_output
+send_log "$CC_FOR_TARGET -fpie -pie $srcdir/$subdir/pie.c -o tmpdir/pie"
+catch "exec $CC_FOR_TARGET -fpie -pie $srcdir/$subdir/pie.c -o tmpdir/pie" exec_output
send_log "$exec_output\n"
if { ![string match "" $exec_output] } {
return
# MA 02110-1301, USA.
# 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
}
-set saved_CFLAGS "$CFLAGS"
-set saved_CXXFLAGS "$CXXFLAGS"
-regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CFLAGS "" CFLAGS
-regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CXXFLAGS "" CXXFLAGS
+set saved_CFLAGS "$CFLAGS_FOR_TARGET"
+set saved_CXXFLAGS "$CXXFLAGS_FOR_TARGET"
+regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CFLAGS_FOR_TARGET "" CFLAGS_FOR_TARGET
+regsub -all "(\\-Wp,)?-D_FORTIFY_SOURCE=\[0-9\]+" $CXXFLAGS_FOR_TARGET "" CXXFLAGS_FOR_TARGET
proc restore_notify { } {
global saved_CFLAGS
global saved_CXXFLAGS
- set CFLAGS "$saved_CFLAGS"
- set CXXFLAGS "$saved_CXXFLAGS"
+ global CFLAGS_FOR_TARGET
+ global CXXFLAGS_FOR_TARGET
+ set CFLAGS_FOR_TARGET "$saved_CFLAGS"
+ set CXXFLAGS_FOR_TARGET "$saved_CXXFLAGS"
}
set lto_fat ""
if { [is_elf_format] && [check_lto_shared_available] } {
run_cc_link_tests $lto_link_elf_tests
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 ] } {
pass $testname
} {
fail $testname
}
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 ] } {
pass $testname
} {
fail $testname
}
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 ] } {
pass $testname
} {
set exec_output [run_host_cmd "sh" \
"-c \"ulimit -n 20; \
- $CC -Btmpdir/ld -o tmpdir/pr28138 \
+ $CC_FOR_TARGET -Btmpdir/ld -o tmpdir/pr28138 \
tmpdir/pr28138.o tmpdir/pr28138.a\""]
set exec_output [prune_warnings $exec_output]
if [string match "" $exec_output] then {
|| [istarget "x86_64-*-linux*"]
|| [istarget "amd64-*-linux*"]) } {
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]
if { [ regexp "undefined reference to `my_bcopy'" $exec_output ] } {
# Linker should catch the reference to undefined `my_bcopy'
]
}
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 ] } {
pass $testname
} {
}
proc pr20103 {cflags libs} {
- global CC
+ global CC_FOR_TARGET
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 ] } {
pass "$testname (1)"
} {
set regassilent "-plugin-opt registerallsymbolsreadsilent"
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,
# 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
set failed_compile 0
set _ ""
set plugin_nm_output ""
-set old_CFLAGS "$CFLAGS"
-append CFLAGS " $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
+set old_CFLAGS "$CFLAGS_FOR_TARGET"
+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 && \
- (![ld_compile "$CC $CFLAGS" $srcdir/$subdir/main.c tmpdir/main.o] \
- || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/func.c tmpdir/func.o] \
- || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/text.c tmpdir/text.o] \
- || ![ld_compile "$CC $CFLAGS" $srcdir/$subdir/pr20070a.c tmpdir/pr20070a.o] \
- || ![ld_compile "$CC $CFLAGS" $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/main.c tmpdir/main.o] \
+ || ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/func.c tmpdir/func.o] \
+ || ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/text.c tmpdir/text.o] \
+ || ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/pr20070a.c tmpdir/pr20070a.o] \
+ || ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/dummy.s tmpdir/dummy.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.
set failed_compile 1
}
unsupported [lindex $testitem 0]
}
}
- set CFLAGS "$old_CFLAGS"
+ set CFLAGS_FOR_TARGET "$old_CFLAGS"
return
}
run_ld_link_tests $plugin_tests
if { [is_elf_format] \
- && [ld_compile "$CC $CFLAGS" $srcdir/$subdir/func1p.c tmpdir/func1p.o] \
- && [ld_compile "$CC $CFLAGS" $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/func1p.c tmpdir/func1p.o] \
+ && [ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/func2i.c tmpdir/func2i.o] \
+ && [ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/func3h.c tmpdir/func3h.o] } {
run_ld_link_tests $plugin_extra_elf_tests
}
unsupported "PR ld/20070"
}
-set CFLAGS "$old_CFLAGS"
+set CFLAGS_FOR_TARGET "$old_CFLAGS"
return
}
-set old_CFLAGS "$CFLAGS"
+set old_CFLAGS "$CFLAGS_FOR_TARGET"
# Pass -fplt to CC since -fno-plt doesn't work with NOCROSSREFS tests.
# Also add $NOPIE_CFLAGS since PIE doesn't work NOCROSSREFS tests.
-set old_CC "$CC"
-set CC "$CC $PLT_CFLAGS $NOPIE_CFLAGS"
+set old_CC "$CC_FOR_TARGET"
+append CC_FOR_TARGET " $PLT_CFLAGS $NOPIE_CFLAGS"
# Xtensa targets currently default to putting literal values in a separate
# section and that requires linker script support, so put literals in text.
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
# called __sdabase which will not be defined by our test linker scripts.
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
# linker scripts.
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] \
- || ![ld_compile "$CC $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
+if { ![ld_compile "$CC_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \
+ || ![ld_compile "$CC_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
unsupported $test1
unsupported $test2
- set CFLAGS "$old_CFLAGS"
- set CC "$old_CC"
+ set CFLAGS_FOR_TARGET "$old_CFLAGS"
+ set CC_FOR_TARGET "$old_CC"
return
}
# 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
- set CFLAGS "$old_CFLAGS"
- set CC "$old_CC"
+ set CFLAGS_FOR_TARGET "$old_CFLAGS"
+ set CC_FOR_TARGET "$old_CC"
return
}
# 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
- set CFLAGS "$old_CFLAGS"
- set CC "$old_CC"
+ set CFLAGS_FOR_TARGET "$old_CFLAGS"
+ set CC_FOR_TARGET "$old_CC"
return
}
if ![ld_relocate $ld tmpdir/cross3-partial.o "tmpdir/cross1.o tmpdir/cross4.o"] {
fail $test3
- set CFLAGS "$old_CFLAGS"
- set CC "$old_CC"
+ set CFLAGS_FOR_TARGET "$old_CFLAGS"
+ set CC_FOR_TARGET "$old_CC"
return
}
}
}
-set CFLAGS "$old_CFLAGS"
-set CC "$old_CC"
+set CFLAGS_FOR_TARGET "$old_CFLAGS"
+set CC_FOR_TARGET "$old_CC"
}
# 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 {
untested "[lindex $testitem 0]"
}
# It's either C or C++ at the moment.
if { $testtype == "C++" } {
- set compiler "$CXX"
+ set compiler "$CXX_FOR_TARGET"
# 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.
- set version [remote_exec host "$CXX -dumpversion"]
+ set version [remote_exec host "$CXX_FOR_TARGET -dumpversion"]
set version [lindex $version 1]
if { [regexp "^(\[1-9\]\[0-9\]+|\[4-9\]|3.(\[1-9\]\[0-9\]+))\\." $version] \
|| [regexp "^(\[1-9\]\[0-9\]+|\[4-9\])" $version] } {
}
} else {
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++
}
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 $testjsr
unsupported $testrun
set shared_needs_pic "no"
# Disable all sanitizers.
-set old_CFLAGS "$CFLAGS"
-append CFLAGS " $NOSANITIZE_CFLAGS"
+set old_CFLAGS "$CFLAGS_FOR_TARGET"
+append CFLAGS_FOR_TARGET " $NOSANITIZE_CFLAGS"
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
set file [open $tmpdir/movw-detect.c w]
puts $file "void foo(void) { __asm (\"movw r0, #0\"); }"
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"
}
}
# The test procedure.
proc shared_test { progname testname main sh1 sh2 dat args } {
- global CC
+ global CC_FOR_TARGET
global srcdir
global subdir
global exec_output
if { [is_elf_format] && [check_shared_lib_support] } {
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"
return
}
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
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"
return
}
# Unfortunately, the gcc argument is -fpic and the cc argument is
# -KPIC. We have to try both.
set picflag "-fpic"
- send_log "$CC $picflag\n"
- verbose "$CC $picflag"
- catch "exec $CC $picflag" exec_output
+ send_log "$CC_FOR_TARGET $picflag\n"
+ verbose "$CC_FOR_TARGET $picflag"
+ catch "exec $CC_FOR_TARGET $picflag" exec_output
send_log "$exec_output\n"
verbose "--" "$exec_output"
if { [string match "*illegal option*" $exec_output] \
verbose "Using $picflag to compile PIC code"
# 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"
} else {
# using -fpic will cause some of the tests to return different
# results. Make sure that PLT is used since PLT is expected.
global PLT_CFLAGS NOPIE_CFLAGS
- if { ![ld_compile "$CC $PLT_CFLAGS $NOPIE_CFLAGS $CFLAGS $SHCFLAG" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o]
- || ![ld_compile "$CC $PLT_CFLAGS $CFLAGS $SHCFLAG" $srcdir/$subdir/sh2.c $tmpdir/sh2np.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_FOR_TARGET $PLT_CFLAGS $CFLAGS_FOR_TARGET $SHCFLAG" $srcdir/$subdir/sh2.c $tmpdir/sh2np.o] } {
unsupported "shared (non PIC)"
} else { if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
shared_test shnp "shared (nonPIC)" mainnp.o sh1np.o sh2np.o xcoff
# Now compile the code using -fpic.
- if { ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o]
- || ![ld_compile "$CC $CFLAGS $SHCFLAG $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.o] } {
+ if { ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o]
+ || ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.o] } {
unsupported "shared"
} else {
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
shared_test shp "shared" mainnp.o sh1p.o sh2p.o xcoff
} else {
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 $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" $srcdir/$subdir/main.c $tmpdir/mainnp.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"
- ld_compile "$CC $CFLAGS $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" $srcdir/$subdir/main.c $tmpdir/mainnp.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.
-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)"
} else {
}
}
-set CFLAGS "$old_CFLAGS"
+set CFLAGS_FOR_TARGET "$old_CFLAGS"
if { [istarget rs6000*-*-aix*] || [istarget powerpc*-*-aix*] } {
# Remove the temporary directory.
# tests. Also add $NOPIE_CFLAGS and $NOPIE_LDFLAGS if PIE doesn't work
# with S-records. Also add $NOCF_PROTECTION_CFLAGS for S-records.
# Also add $NOSANITIZE_CFLAGS for S-records.
-set old_CC "$CC"
-set CC "$CC $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
-set old_CXX "$CXX"
-set old_CXXFLAGS "$CXXFLAGS"
-set CXXFLAGS "$CXXFLAGS $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
+set old_CC "$CC_FOR_TARGET"
+append CC_FOR_TARGET " $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
+set old_CXX "$CXX_FOR_TARGET"
+set old_CXXFLAGS "$CXXFLAGS_FOR_TARGET"
+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.
if { [is_elf_format] \
&& ([istarget "i?86-*-*"] || [istarget "x86_64-*-*"]) } {
- set CC "$CC -Wa,-mx86-used-note=no"
- set CXX "$CXX -Wa,-mx86-used-note=no"
+ append CC_FOR_TARGET " -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] \
- || ![ld_compile $CC $srcdir/$subdir/sr2.c tmpdir/sr2.o] } {
+if { ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/sr1.c tmpdir/sr1.o] \
+ || ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/sr2.c tmpdir/sr2.o] } {
unsupported $test1
unsupported $test2
- set CC "$old_CC"
- set CXX "$old_CXX"
- set CXXFLAGS "$old_CXXFLAGS"
+ set CC_FOR_TARGET "$old_CC"
+ set CXX_FOR_TARGET "$old_CXX"
+ set CXXFLAGS_FOR_TARGET "$old_CXXFLAGS"
return
}
# destructors. Note that since we are not linking against any
# 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
- set CC "$old_CC"
- set CXX "$old_CXX"
- set CXXFLAGS "$old_CXXFLAGS"
+ set CC_FOR_TARGET "$old_CC"
+ set CXX_FOR_TARGET "$old_CXX"
+ set CXXFLAGS_FOR_TARGET "$old_CXXFLAGS"
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
- set CC "$old_CC"
- set CXX "$old_CXX"
- set CXXFLAGS "$old_CXXFLAGS"
+ set CC_FOR_TARGET "$old_CC"
+ set CXX_FOR_TARGET "$old_CXX"
+ set CXXFLAGS_FOR_TARGET "$old_CXXFLAGS"
return
}
run_srec_test $test2 "tmpdir/sr3.o"
-set CC "$old_CC"
-set CXX "$old_CXX"
-set CXXFLAGS "$old_CXXFLAGS"
+set CC_FOR_TARGET "$old_CC"
+set CXX_FOR_TARGET "$old_CXX"
+set CXXFLAGS_FOR_TARGET "$old_CXXFLAGS"
untested $testund
untested $testfn
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
unsupported $testund
unsupported $testfn
set fails 0
# 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"
set fails [expr $fails + 1]
}
# 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"
set fails [expr $fails + 1]
}
}
# 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"
set fails [expr $fails + 1]
}
}
# 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"
set fails [expr $fails + 1]
}
}
# 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"
set fails [expr $fails + 1]
}
]
# 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
}
# Returns 0 otherwise.
#
proc at_least_gcc_version { major minor } {
- global CC
+ global CC_FOR_TARGET
- if {![info exists CC]} {
- set CC [find_gcc]
+ if {![info exists CC_FOR_TARGET]} {
+ set CC_FOR_TARGET [find_gcc]
}
- if { $CC == "" } {
+ if { $CC_FOR_TARGET == "" } {
return 0
}
# 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]
if { [lindex $state 0] != 0 } {
return 0;
# Compile an object using cc.
#
proc default_ld_compile { cc source object } {
- global CFLAGS
- global CXXFLAGS
+ global CFLAGS_FOR_TARGET
+ global CXXFLAGS_FOR_TARGET
global srcdir
global subdir
global host_triplet
set ccexe [string replace $ccexe 0 [string last "/" $ccexe] ""]
if {[string match "*++*" $ccexe]} {
- append flags " $CXXFLAGS"
+ append flags " $CXXFLAGS_FOR_TARGET"
} else {
- append flags " $CFLAGS"
+ append flags " $CFLAGS_FOR_TARGET"
}
if [board_info [target_info name] exists cflags] {
global srcdir
global subdir
global env
- global CC
- global CFLAGS
+ global CC_FOR_TARGET
+ global CFLAGS_FOR_TARGET
global runtests
global exec_output
set objfile "tmpdir/$fileroot.o"
if { [file extension $src_file] == ".c" } {
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
break
}
global srcdir
global subdir
global env
- global CC
- global CXX
- global CFLAGS
- global CXXFLAGS
+ global CC_FOR_TARGET
+ global CXX_FOR_TARGET
+ global CFLAGS_FOR_TARGET
+ global CXXFLAGS_FOR_TARGET
global errcnt
global exec_output
global board_cflags
lappend objfiles $objfile
if { [ string match "c++" $lang ] } {
- set cmd "$CXX -c $CXXFLAGS $cflags"
+ set cmd "$CXX_FOR_TARGET -c $CXXFLAGS_FOR_TARGET $cflags"
} 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] {
set failed 1
set link_cmd $ld
} elseif { [ string match "c++" $lang ] } {
set link_proc ld_link
- set link_cmd $CXX
+ set link_cmd $CXX_FOR_TARGET
} else {
set link_proc ld_link
- set link_cmd $CC
+ set link_cmd $CC_FOR_TARGET
}
if { $binfile eq "tmpdir/" } {
global srcdir
global subdir
global env
- global CC
- global CXX
- global CFLAGS
- global CXXFLAGS
+ global CC_FOR_TARGET
+ global CXX_FOR_TARGET
+ global CFLAGS_FOR_TARGET
+ global CXXFLAGS_FOR_TARGET
global ar
global exec_output
global board_cflags
lappend objfiles $objfile
if { [ string match "c++" $lang ] } {
- set cmd "$CXX -c $CXXFLAGS $cflags"
+ set cmd "$CXX_FOR_TARGET -c $CXXFLAGS_FOR_TARGET $cflags"
} 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] {
set failed 1
reset_vars
if { [ string match "c++" $lang ] } {
- set cc_cmd $CXX
+ set cc_cmd $CXX_FOR_TARGET
} else {
- set cc_cmd $CC
+ set cc_cmd $CC_FOR_TARGET
}
if { $binfile eq "tmpdir/" } {
proc check_compiler_available { } {
global compiler_available_saved
- global CC
+ global CC_FOR_TARGET
if {![info exists compiler_available_saved]} {
- if { [which $CC] == 0 } {
+ if { [which $CC_FOR_TARGET] == 0 } {
set compiler_available_saved 0
return 0
}
if [is_remote host] {
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 $output
file delete $src
# Returns 1 if plugin is enabled in gcc. Returns 0 otherwise.
proc check_gcc_plugin_enabled { } {
- global CC
+ global CC_FOR_TARGET
- if {![info exists CC]} {
- set CC [find_gcc]
+ if {![info exists CC_FOR_TARGET]} {
+ set CC_FOR_TARGET [find_gcc]
}
- if { $CC == ""} {
+ if { $CC_FOR_TARGET == ""} {
return 0
}
# 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]
if { [lindex $state 0] != 0 } {
return 0;
# Returns true if the target compiler supports LTO
proc check_lto_available { } {
global lto_available_saved
- global CC
+ global CC_FOR_TARGET
if {![info exists lto_available_saved]} {
if { ![check_gcc_plugin_enabled] } {
if [is_remote host] {
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 $output
file delete $src
# Returns true if the target compiler supports LTO -ffat-lto-objects
proc check_lto_fat_available { } {
global lto_fat_available_saved
- global CC
+ global CC_FOR_TARGET
if {![info exists lto_fat_available_saved]} {
if { ![check_gcc_plugin_enabled] } {
if [is_remote host] {
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 $output
file delete $src
# Returns true if the target compiler supports LTO and -shared
proc check_lto_shared_available { } {
global lto_shared_available_saved
- global CC
+ global CC_FOR_TARGET
if {![info exists lto_shared_available_saved]} {
if { ![check_gcc_plugin_enabled] } {
if [is_remote host] {
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 $output
file delete $src
proc check_ifunc_available { } {
global ifunc_available_saved
- global CC
+ global CC_FOR_TARGET
if {![info exists ifunc_available_saved]} {
if { ![check_compiler_available] } {
if [is_remote host] {
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 } {
set ifunc_available_saved [run_host_cmd_yesno "$output" ""]
}
proc check_ifunc_attribute_available { } {
global ifunc_attribute_available_saved
- global CC
+ global CC_FOR_TARGET
if {![info exists ifunc_attribute_available_saved]} {
if { ![check_compiler_available] } {
if [is_remote host] {
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 } {
set ifunc_attribute_available_saved [run_host_cmd_yesno "$output" ""]
}
proc check_libdl_available { } {
global libdl_available_saved
- global CC
+ global CC_FOR_TARGET
if {![info exists libdl_available_saved]} {
if { ![check_compiler_available] } {
if [is_remote host] {
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 $output
file delete $src
proc check_gnu2_tls_available { } {
global gnu2_tls_available_saved
- global CC
+ global CC_FOR_TARGET
global GNU2_CFLAGS
if {![info exists gnu2_tls_available_saved]} {
if [is_remote host] {
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 } {
- 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 } {
set gnu2_tls_available_saved [run_host_cmd_yesno "$output2" ""]
}
# Compile a C source file, with the specified additional_flags.
proc compile_one_cc { src output additional_flags } {
- global CC
- global CFLAGS
+ global CC_FOR_TARGET
+ global CFLAGS_FOR_TARGET
set flags ""
if [board_info [target_info name] exists cflags] {
if [is_remote host] {
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
runtest=$(RUNTEST); \
if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
$$runtest --tool $(DEJATOOL) --srcdir $${srcroot}/testsuite \
- CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS) -I$(INCDIR) -I$(srcdir) -I$(builddir) -I$(builddir)/../bfd $(ZLIBINC)" \
- CC_FOR_HOST="$(CC)" LIBS="$(libctf_nobfd_la_LIBADD) $(LIBS)" $(RUNTESTFLAGS); \
+ CC="$(CC)" CC_FOR_TARGET="$(CC_FOR_TARGET)" \
+ 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; :;\
fi
@TCL_TRY_TRUE@ runtest=$(RUNTEST); \
@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@ CC="$(CC_FOR_TARGET)" CFLAGS="$(CFLAGS) -I$(INCDIR) -I$(srcdir) -I$(builddir) -I$(builddir)/../bfd $(ZLIBINC)" \
-@TCL_TRY_TRUE@ CC_FOR_HOST="$(CC)" LIBS="$(libctf_nobfd_la_LIBADD) $(LIBS)" $(RUNTESTFLAGS); \
+@TCL_TRY_TRUE@ CC="$(CC)" CC_FOR_TARGET="$(CC_FOR_TARGET)" \
+@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@ fi
set gcc_B_opt "-B[pwd]/tmpdir/libctf/"
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]} {
- set CC [find_gcc]
-}
-if {![info exists CC_FOR_HOST]} {
- set CC_FOR_HOST $CC
+ set CC gcc
}
if {![info exists CFLAGS]} {
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_lib ctf-lib.exp
# Compile and link a C source file for execution on the host.
proc compile_link_one_host_cc { src output additional_args } {
- global CC_FOR_HOST
+ global CC
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
# regexps in FILE.d.
#
proc run_lookup_test { name } {
- global CC CFLAGS LIBS
+ global CC_FOR_TARGET CFLAGS_FOR_TARGET LIBS
global copyfile env runtests srcdir subdir verbose
if ![runtest_file_p $runtests $name] then {
}
}
- 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 != ""} {
send_log "compilation of CTF program [concat $src] failed with <$comp_output>"