diff options
author | Alan Modra <amodra@gmail.com> | 2021-09-03 16:26:09 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2021-09-03 16:26:09 +0930 |
commit | ad77db1c02a92c912f9719f32e2452890aa738ad (patch) | |
tree | 9ef22e47b0711ae8e490471b38c548fab649e9ff /ld/testsuite/ld-elf | |
parent | 2ea9d33a127c09d9c4df0337981e48fb4b7a236f (diff) | |
download | fsf-binutils-gdb-ad77db1c02a92c912f9719f32e2452890aa738ad.zip fsf-binutils-gdb-ad77db1c02a92c912f9719f32e2452890aa738ad.tar.gz fsf-binutils-gdb-ad77db1c02a92c912f9719f32e2452890aa738ad.tar.bz2 |
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.
Diffstat (limited to 'ld/testsuite/ld-elf')
-rw-r--r-- | ld/testsuite/ld-elf/dwarf.exp | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/indirect.exp | 8 | ||||
-rw-r--r-- | ld/testsuite/ld-elf/shared.exp | 16 |
3 files changed, 16 insertions, 16 deletions
diff --git a/ld/testsuite/ld-elf/dwarf.exp b/ld/testsuite/ld-elf/dwarf.exp index e620651..61973ac 100644 --- a/ld/testsuite/ld-elf/dwarf.exp +++ b/ld/testsuite/ld-elf/dwarf.exp @@ -41,7 +41,7 @@ if { ![check_compiler_available] } { } # 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 } @@ -69,11 +69,11 @@ set run_tests { } # 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 diff --git a/ld/testsuite/ld-elf/indirect.exp b/ld/testsuite/ld-elf/indirect.exp index bd4dab8..c1bf23a 100644 --- a/ld/testsuite/ld-elf/indirect.exp +++ b/ld/testsuite/ld-elf/indirect.exp @@ -38,7 +38,7 @@ if { ![check_compiler_available] } { } # 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 } @@ -59,7 +59,7 @@ proc check_link_message { cmd string testname } { } # Disable LTO for these tests. -set cc_cmd "$CC" +set cc_cmd "$CC_FOR_TARGET" if {[check_lto_available]} { 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" -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 diff --git a/ld/testsuite/ld-elf/shared.exp b/ld/testsuite/ld-elf/shared.exp index 4eb5fba..9224782 100644 --- a/ld/testsuite/ld-elf/shared.exp +++ b/ld/testsuite/ld-elf/shared.exp @@ -1180,36 +1180,36 @@ if [check_libdl_available] { # 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 } { @@ -1217,7 +1217,7 @@ if { [ regexp "undefined reference to `\.?bar'" $exec_output ] } { } # Check to see if the C++ compiler works -if { [which $CXX] == 0 } { +if { [which $CXX_FOR_TARGET] == 0 } { return } |