ld testsuite tidy
authorAlan Modra <amodra@gmail.com>
Fri, 3 Sep 2021 06:56:21 +0000 (16:26 +0930)
committerAlan Modra <amodra@gmail.com>
Fri, 3 Sep 2021 06:56:21 +0000 (16:26 +0930)
Fixes a few issues:
1) If you use "-fsanitize=address,undefined" in CFLAGS, the Makefile
attempt to trim off -fsanitize options left us with ",undefined".
2) ld_compile adds CFLAGS_FOR_TARGET itself, no need to pass it.
3) CFLAGS might be needed linking bootstrap test.

* Makefile.am (CFLAGS_FOR_TARGET, CXXFLAGS_FOR_TARGET): Trim off
all -fsanitize=*.
* Makefile.in: Regenerate.
* testsuite/ld-bootstrap/bootstrap.exp: Use CFLAGS when linking.
* testsuite/ld-cdtest/cdtest.exp: Use CFLAGS_FOR_TARGET when
linking.
* testsuite/ld-auto-import/auto-import.exp: Don't pass
CFLAGS_FOR_TARGET to ld_compile.
* testsuite/ld-cygwin/exe-export.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-pe/pe-compile.exp: Likewise.
* testsuite/ld-pe/pe-run.exp: Likewise.
* testsuite/ld-pe/pe-run2.exp: Likewise.
* testsuite/ld-plugin/plugin.exp: Likewise.
* testsuite/ld-shared/shared.exp: Likewise.
* testsuite/ld-elfcomm/elfcomm.exp: Likewise, and don't allow
nios2 testing to trash CFLAGS_FOR_TARGET.
* testsuite/ld-scripts/crossref.exp: Don't pass options in
CC_FOR_TARGET, do so in CFLAGS_FOR_TARGET instead.
* testsuite/ld-srec/srec.exp: Likewise, and for CXX.

18 files changed:
ld/Makefile.am
ld/Makefile.in
ld/testsuite/ld-auto-import/auto-import.exp
ld/testsuite/ld-bootstrap/bootstrap.exp
ld/testsuite/ld-cdtest/cdtest.exp
ld/testsuite/ld-cygwin/exe-export.exp
ld/testsuite/ld-elfcomm/elfcomm.exp
ld/testsuite/ld-elfvers/vers.exp
ld/testsuite/ld-elfvsb/elfvsb.exp
ld/testsuite/ld-elfweak/elfweak.exp
ld/testsuite/ld-gc/gc.exp
ld/testsuite/ld-pe/pe-compile.exp
ld/testsuite/ld-pe/pe-run.exp
ld/testsuite/ld-pe/pe-run2.exp
ld/testsuite/ld-plugin/plugin.exp
ld/testsuite/ld-scripts/crossref.exp
ld/testsuite/ld-shared/shared.exp
ld/testsuite/ld-srec/srec.exp

index 0345f846ca0aadc44d4ee4247bad313924515801..6cfdfddc5d171e77ef2c6e7aefd0f7e7dddf2342 100644 (file)
@@ -123,8 +123,8 @@ CXX_FOR_TARGET = ` \
   fi`
 
 # Strip out sanitization options as we want to test building binaries without any extra paraphernalia
-CFLAGS_FOR_TARGET = `echo $(CFLAGS) | sed -e 's/-fsanitize=address//g' -e 's/-fsanitize=undefined//g'`
-CXXFLAGS_FOR_TARGET = `echo $(CXXFLAGS) | sed -e 's/-fsanitize=address//g' -e 's/-fsanitize=undefined//g'`
+CFLAGS_FOR_TARGET = `echo $(CFLAGS) | sed -e 's/-fsanitize=[^ ]*//g'`
+CXXFLAGS_FOR_TARGET = `echo $(CXXFLAGS) | sed -e 's/-fsanitize=[^ ]*//g'`
 
 transform = s/^ld-new$$/$(installed_linker)/;@program_transform_name@
 bin_PROGRAMS = ld-new
index 366d03489dfda9df1f77587b2df36b65bbb681f8..30fa918dfc878167b008994dade728544afedefb 100644 (file)
@@ -619,8 +619,8 @@ CXX_FOR_TARGET = ` \
 
 
 # Strip out sanitization options as we want to test building binaries without any extra paraphernalia
-CFLAGS_FOR_TARGET = `echo $(CFLAGS) | sed -e 's/-fsanitize=address//g' -e 's/-fsanitize=undefined//g'`
-CXXFLAGS_FOR_TARGET = `echo $(CXXFLAGS) | sed -e 's/-fsanitize=address//g' -e 's/-fsanitize=undefined//g'`
+CFLAGS_FOR_TARGET = `echo $(CFLAGS) | sed -e 's/-fsanitize=[^ ]*//g'`
+CXXFLAGS_FOR_TARGET = `echo $(CXXFLAGS) | sed -e 's/-fsanitize=[^ ]*//g'`
 info_TEXINFOS = ld.texi
 ld_TEXINFOS = configdoc.texi
 noinst_TEXINFOS = ldint.texi
index 74e8db293ae507208946fd36d42665e30133e6e4..dfbd911c15fa725dd525c218f05df0b149e07637 100644 (file)
@@ -118,7 +118,7 @@ if [istarget *-pc-cygwin] {
     set MYLIBS "-L/usr/lib -lcygwin -L/usr/lib/w32api -lkernel32"
     
     # Compile the dll.
-    if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG" $srcdir/$subdir/dll.c $tmpdir/dll.o] {
+    if ![ld_compile "$CC_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"] {
@@ -129,7 +129,7 @@ if [istarget *-pc-cygwin] {
     catch "exec ln -fs dll.dll $tmpdir/libsymlinked_dll.dll.a" ln_catch
 
     # Compile and link the client program.
-    if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG" $srcdir/$subdir/client.c $tmpdir/client.o] {
+    if ![ld_compile "$CC_FOR_TARGET $SHCFLAG" $srcdir/$subdir/client.c $tmpdir/client.o] {
         fail "compiling client"
     }
 
index 74582392010e5a368fff81e6d213e06b4f7d1891..e323b42868834bdd9298d0b9d429c6c5e50f3f78 100644 (file)
@@ -168,7 +168,7 @@ foreach flags $test_flags {
        setup_xfail "mips*-*-irix5*"
     }
 
-    if ![ld_link $CC tmpdir/ld1 "$flags tmpdir/ld-partial.o $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
+    if ![ld_link $CC tmpdir/ld1 "$CFLAGS $flags tmpdir/ld-partial.o $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
        fail $testname
        continue
     }
@@ -185,13 +185,13 @@ foreach flags $test_flags {
     }
 
     regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld1/ gcc_B_opt
-    if ![ld_link $CC tmpdir/ld2 "$flags $OFILES $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
+    if ![ld_link $CC tmpdir/ld2 "$CFLAGS $flags $OFILES $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
        fail $testname
        continue
     }
 
     regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld2/ gcc_B_opt
-    if ![ld_link $CC tmpdir/ld3 "$flags $OFILES $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
+    if ![ld_link $CC tmpdir/ld3 "$CFLAGS $flags $OFILES $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
        fail $testname
        continue
     }
@@ -204,7 +204,7 @@ foreach flags $test_flags {
        # generated by different linkers, tmpdir/ld1 and tmpdir/ld2.
        # So we rebuild tmpdir/ld2 with tmpdir/ld3.
        regsub /tmpdir/ld/ $gcc_B_opt_save /tmpdir/gccld3/ gcc_B_opt
-       if ![ld_link $CC tmpdir/ld2 "$flags $OFILES $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
+       if ![ld_link $CC tmpdir/ld2 "$CFLAGS $flags $OFILES $CTFLIB $BFDLIB $LIBIBERTY $extralibs"] {
            fail $testname
            continue
        }
index 50f6ff1e40b1f29a3f638b0000bf7449223cc3e0..9bd8ba76d81bf399f47223caedea7c7110face9b 100644 (file)
@@ -48,7 +48,7 @@ if {   ![ld_compile "$CXX_FOR_TARGET $CXXFLAGS_FOR_TARGET -fno-exceptions" $srcd
 
 set expected_output "$srcdir/$subdir/cdtest.dat"
 
-if ![ld_link $CC_FOR_TARGET tmpdir/cdtest {tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o}] {
+if ![ld_link $CC_FOR_TARGET tmpdir/cdtest "$CFLAGS_FOR_TARGET tmpdir/cdtest-foo.o tmpdir/cdtest-bar.o tmpdir/cdtest-main.o"] {
     fail $test1
 } else {
     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}] {
     fail $test2
 } else {
-    if ![ld_link $CC_FOR_TARGET tmpdir/cdtest tmpdir/cdtest.o] {
+    if ![ld_link $CC_FOR_TARGET tmpdir/cdtest "$CFLAGS_FOR_TARGET tmpdir/cdtest.o"] {
        fail $test2
     } else {
        send_log   "tmpdir/cdtest >tmpdir/cdtest.out\n"
index 1e5b93c51ceec744f38a628bb82f415bb3465b84..741d2a9a932cf6a253df6476d3d1d030b66794f2 100644 (file)
@@ -113,7 +113,7 @@ if ![run_dlltool $tmpdir/testdll.lib $srcdir/$subdir/testdll.def] {
 } \r
 \r
 # Compile the executable.\r
-if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/testexe.c $tmpdir/testexe.o] {\r
+if ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/testexe.c $tmpdir/testexe.o] {\r
     fail "compiling executable"\r
     return\r
 }\r
@@ -124,7 +124,7 @@ if ![ld_special_link "$CC_FOR_TARGET $LDFLAGS $MYLDFLAGS -e _testexe_main@16" $t
 } \r
 \r
 # Compile the dll.\r
-if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/testdll.c $tmpdir/testdll.o] {\r
+if ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/testdll.c $tmpdir/testdll.o] {\r
     fail "compiling shared lib"\r
     return\r
 }\r
index b74910440aea9f04db092797d737ad05467fcc5b..bed4e8c173a8950e72e42429eb56471ec928e2b8 100644 (file)
@@ -163,15 +163,15 @@ proc stt_common_test { options testname } {
     return 1
 }
 
-if [istarget nios2*-*-*] {
-    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_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] } {
+set options "-fcommon $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
+if [istarget nios2*-*-*] {
+    append options " -G0"
+}
+if {   ![ld_compile "$CC_FOR_TARGET $options" $srcdir/$subdir/common1a.c tmpdir/common1a.o]
+    || ![ld_compile "$CC_FOR_TARGET $options" $srcdir/$subdir/common1b.c tmpdir/common1b.o]
+    || ![ld_compile "$CC_FOR_TARGET $options -Wa,--elf-stt-common=yes" $srcdir/$subdir/common1b.c tmpdir/common1c.o] } {
     unsupported $test1
     return
 }
index b97da8014e9a90764ac9976f77d08cfcfb7a3712..1557f3f28deb5325e60a2386cbadb31aa937baa2 100644 (file)
@@ -487,12 +487,11 @@ proc build_binary { shared pic test source libname other mapfile verexp versymex
     global as_options
     global objdump
     global CC_FOR_TARGET
-    global CFLAGS_FOR_TARGET
     global script
     global NOSANITIZE_CFLAGS
     global NOLTO_CFLAGS
 
-    if ![ld_compile "$CC_FOR_TARGET -S $pic $CFLAGS_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/$source $tmpdir/$libname.s]     {
+    if ![ld_compile "$CC_FOR_TARGET -S $pic $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/$source $tmpdir/$libname.s]     {
        unsupported "$test"
        return
     }
@@ -579,7 +578,6 @@ proc test_ldfail { test flag source execname other mapfile whyfail } {
     global as_options
     global objdump
     global CC_FOR_TARGET
-    global CFLAGS_FOR_TARGET
     global script
 
     if [string match "" $other] then {
@@ -588,7 +586,7 @@ proc test_ldfail { test flag source execname other mapfile whyfail } {
        set other_lib $tmpdir/$other
     }
 
-    if ![ld_compile "$CC_FOR_TARGET -S $flag $CFLAGS_FOR_TARGET" $srcdir/$subdir/$source $tmpdir/$execname.s]     {
+    if ![ld_compile "$CC_FOR_TARGET -S $flag" $srcdir/$subdir/$source $tmpdir/$execname.s]     {
        unsupported "$test"
        return
     }
@@ -619,10 +617,9 @@ proc test_asfail { test flag source execname whyfail } {
     global tmpdir
     global as
     global CC_FOR_TARGET
-    global CFLAGS_FOR_TARGET
     global NOLTO_CFLAGS
 
-    if ![ld_compile "$CC_FOR_TARGET -S $flag $CFLAGS_FOR_TARGET $NOLTO_CFLAGS" $srcdir/$subdir/$source $tmpdir/$execname.s]     {
+    if ![ld_compile "$CC_FOR_TARGET -S $flag $NOLTO_CFLAGS" $srcdir/$subdir/$source $tmpdir/$execname.s]     {
        unsupported "$test"
        return
     }
@@ -689,7 +686,6 @@ proc build_exec { test source execname flags solibname verexp versymexp symexp }
     global as_options
     global objdump
     global CC_FOR_TARGET
-    global CFLAGS_FOR_TARGET
     global NOSANITIZE_CFLAGS
     global NOLTO_CFLAGS
 
@@ -697,7 +693,7 @@ proc build_exec { test source execname flags solibname verexp versymexp symexp }
     set script --version-script
 
     # Disable LTO for these tests.
-    set cc_cmd "$CC_FOR_TARGET -S $CFLAGS_FOR_TARGET"
+    set cc_cmd "$CC_FOR_TARGET -S"
     if {[check_lto_available]} {
        append cc_cmd " -fno-lto"
     }
index 3c0826161cb222528ec211c6486ccf1cd3239596..1866be5e66d65a537b068411d3fb43a6aa56a719 100644 (file)
@@ -87,7 +87,7 @@ set support_protected "no"
 if { [istarget *-*-linux*]
      || [istarget *-*-nacl*]
      || [istarget *-*-gnu*] } {
-    if [ld_compile "$CC_FOR_TARGET -g $CFLAGS_FOR_TARGET -DPROTECTED_CHECK" $srcdir/$subdir/main.c $tmpdir/main.o] {
+    if [ld_compile "$CC_FOR_TARGET -g -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
       }
@@ -185,7 +185,6 @@ proc visibility_test { visibility progname testname main sh1 sh2 dat args } {
 
 proc visibility_run {visibility} {
     global CC_FOR_TARGET
-    global CFLAGS_FOR_TARGET
     global SHCFLAG
     global srcdir
     global subdir
@@ -237,7 +236,7 @@ proc visibility_run {visibility} {
     } else {
     # Compile the main program.  Make sure that PLT is used since PLT
     # is expected.
-    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] {
+    if ![ld_compile "$CC_FOR_TARGET -g $PLT_CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
        unsupported "visibility ($visibility) (non PIC)"
        unsupported "visibility ($visibility)"
     } else {
@@ -247,8 +246,8 @@ proc visibility_run {visibility} {
        # 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_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] } {
+       if { ![ld_compile "$CC_FOR_TARGET -g $NOPIE_CFLAGS $PLT_CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o]
+            || ![ld_compile "$CC_FOR_TARGET -g $NOPIE_CFLAGS $PLT_CFLAGS $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
@@ -336,8 +335,8 @@ proc visibility_run {visibility} {
 
        # Now compile the code using -fpic.
 
-       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] } {
+       if { ![ld_compile "$CC_FOR_TARGET -g $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o]
+           || ![ld_compile "$CC_FOR_TARGET -g $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.o] } {
            unsupported "visibility ($visibility)"
        } else {
            if { [ string match $visibility "protected" ]
@@ -354,7 +353,7 @@ proc visibility_run {visibility} {
        # Don't bother.
     } else {
     # Now do the same tests again, but this time compile main.c PIC.
-    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] {
+    if ![ld_compile "$CC_FOR_TARGET -g $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 {
@@ -446,7 +445,7 @@ visibility_run protected_undef_def
 visibility_run protected_weak
 visibility_run normal
 
-if { ![ld_compile "$CC_FOR_TARGET -g $CFLAGS_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/common.c tmpdir/common.o] } {
+if { ![ld_compile "$CC_FOR_TARGET -g $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"] {
@@ -456,10 +455,10 @@ if { ![ld_compile "$CC_FOR_TARGET -g $CFLAGS_FOR_TARGET $NOSANITIZE_CFLAGS $NOLT
     }
 }
 
-if { ![ld_compile "$CC_FOR_TARGET -g $CFLAGS_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/test.c tmpdir/test.o] } {
+if { ![ld_compile "$CC_FOR_TARGET -g $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/test.c tmpdir/test.o] } {
     unsupported "weak hidden symbol"
 } else {
-   if { ![ld_compile "$CC_FOR_TARGET -g $CFLAGS_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh3.c tmpdir/sh3.o] } {
+   if { ![ld_compile "$CC_FOR_TARGET -g $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"] {
index 762b214ab686dbb68ca418c58ccf1f4d66471264..d7ee9361135bb3a225914af044597488365cd189 100644 (file)
@@ -384,16 +384,16 @@ if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then {
 }
 verbose "Using $picflag to compile PIC code"
 
-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]
+if {![ld_compile "$cc_cmd $picflag" $srcdir/$subdir/foo.c $tmpdir/foo.o]
+    || ![ld_compile "$cc_cmd $picflag" $srcdir/$subdir/bar.c $tmpdir/bar.o]
+    || ![ld_compile "$cc_cmd" $srcdir/$subdir/main.c $tmpdir/main.o]
     || ![ld_link $cc_cmd $tmpdir/libbar.so "$shared $tmpdir/bar.o"]
-    || ![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 {
+    || ![ld_compile "$cc_cmd $picflag" $srcdir/$subdir/foo1a.c $tmpdir/foo1a.o]
+    || ![ld_compile "$cc_cmd $picflag" $srcdir/$subdir/foo1b.c $tmpdir/foo1b.o]
+    || ![ld_compile "$cc_cmd $picflag" $srcdir/$subdir/bar1a.c $tmpdir/bar1a.o]
+    || ![ld_compile "$cc_cmd $picflag" $srcdir/$subdir/bar1b.c $tmpdir/bar1b.o]
+    || ![ld_compile "$cc_cmd $picflag" $srcdir/$subdir/bar1c.c $tmpdir/bar1c.o]
+    || ![ld_compile "$cc_cmd $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"]
@@ -424,10 +424,10 @@ if {![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/foo.c $tm
     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_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 {
+if {![ld_compile "$cc_cmd $picflag" $srcdir/$subdir/size_foo.c $tmpdir/size_foo.o]
+    || ![ld_compile "$cc_cmd $picflag" $srcdir/$subdir/size_bar.c $tmpdir/size_bar_s.o]
+    || ![ld_compile "$cc_cmd $picflag -DSIZE_BIG" $srcdir/$subdir/size_bar.c $tmpdir/size_bar.o]
+    || ![ld_compile "$cc_cmd" $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" ""
@@ -439,11 +439,11 @@ if {![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/size_foo.
 verbose "size2"
 run_dump_test $srcdir/$subdir/size2
 
-if {![ld_compile "$cc_cmd $CFLAGS_FOR_TARGET $picflag" $srcdir/$subdir/alias.c $tmpdir/alias.o]
+if {![ld_compile "$cc_cmd $picflag" $srcdir/$subdir/alias.c $tmpdir/alias.o]
     || ![ld_link $cc_cmd $tmpdir/alias.so "$shared $tmpdir/alias.o"]
-    || ![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 {
+    || ![ld_compile $cc_cmd $srcdir/$subdir/aliasmain.c $tmpdir/aliasmain.o]
+    || ![ld_compile $cc_cmd $srcdir/$subdir/weakref1.c $tmpdir/weakref1.o]
+    || ![ld_compile $cc_cmd $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 "" ""
index 60491fe0f8082b1a38ecdca64c3cdd8911a7c949..8071222d2f4bd23fee640d255389fc203dc5d54e 100644 (file)
@@ -37,7 +37,7 @@ if { [istarget m681*-*-*] || [istarget m68hc1*-*-*] } {
 }
 
 if { [check_compiler_available] } {
-    ld_compile "$CC_FOR_TARGET -c $CFLAGS_FOR_TARGET $cflags" $srcdir/$subdir/gc.c $objfile
+    ld_compile "$CC_FOR_TARGET -c $cflags" $srcdir/$subdir/gc.c $objfile
 }
 
 proc test_gc { testname filename linker ldflags} {
@@ -144,9 +144,9 @@ if { [check_compiler_available] } {
     if { [istarget "*-*-linux*"]
         || [istarget "*-*-nacl*"]
         || [istarget "*-*-gnu*"] } {
-       ld_compile "$CC_FOR_TARGET -fPIC $CFLAGS_FOR_TARGET $cflags" $srcdir/$subdir/pr11218-1.c tmpdir/pr11218-1.o
+       ld_compile "$CC_FOR_TARGET -fPIC $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_FOR_TARGET -c $CFLAGS_FOR_TARGET $cflags" $srcdir/$subdir/pr11218-2.c tmpdir/pr11218-2.o
+       ld_compile "$CC_FOR_TARGET -c $cflags" $srcdir/$subdir/pr11218-2.c tmpdir/pr11218-2.o
        run_dump_test "pr11218"
     }
 }
@@ -157,18 +157,18 @@ if [is_pecoff_format] {
 }
 
 if { [check_compiler_available] } {
-    ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $cflags" $srcdir/$subdir/pr13683.c tmpdir/pr13683.o
+    ld_compile "$CC_FOR_TARGET $cflags" $srcdir/$subdir/pr13683.c tmpdir/pr13683.o
     run_dump_test "pr13683" $symdefs
 }
 
 if { [check_compiler_available] } {
-    ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $cflags $NOPIE_CFLAGS" $srcdir/$subdir/pr14265.c tmpdir/pr14265.o
+    ld_compile "$CC_FOR_TARGET $cflags $NOPIE_CFLAGS" $srcdir/$subdir/pr14265.c tmpdir/pr14265.o
     run_dump_test "pr14265" $symdefs
 }
 
 if { [check_compiler_available] } {
-    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
+    ld_compile "$CC_FOR_TARGET $cflags -O0" $srcdir/$subdir/pr19161-1.c tmpdir/pr19161-1.o
+    ld_compile "$CC_FOR_TARGET $cflags -O0" $srcdir/$subdir/pr19161-2.c tmpdir/pr19161-2.o
     if [istarget hppa*-*-linux*] {
        set symdefs {{ld {--defsym '\$\$dyncall=0'}}}
     }
index 5282cfdb0a1075fbebd1604f9c8d2372ea84dd26..3ffb3f2af0da42a8e55e830adff69ad71de09815 100644 (file)
@@ -35,12 +35,11 @@ if { ![check_compiler_available] } {
 
 proc build_basefile1_o {} {
     global CC_FOR_TARGET
-    global CFLAGS_FOR_TARGET
     global srcdir
     global subdir
 
     # Compile the object file.
-    if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/basefile1.s tmpdir/basefile1.o] {
+    if ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/basefile1.s tmpdir/basefile1.o] {
        fail "compiling basefile1 object"
     }
 }
@@ -76,12 +75,11 @@ proc run_basefile_test { testname } {
 
 proc build_vers_script_dll_o {} {
     global CC_FOR_TARGET
-    global CFLAGS_FOR_TARGET
     global srcdir
     global subdir
 
     # Compile the object file.
-    if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET -shared" $srcdir/$subdir/vers-script-dll.c tmpdir/vers-script-dll.o] {
+    if ![ld_compile "$CC_FOR_TARGET -shared" $srcdir/$subdir/vers-script-dll.c tmpdir/vers-script-dll.o] {
        fail "compiling shared lib object"
     }
 }
index a26644cc367ff3e0382551d4c93ad5728666f786..99a397957a25c68385b05de5536b00c2f1729f98 100644 (file)
@@ -63,13 +63,12 @@ set tmpdir tmpdir
 
 proc test_direct_link_dll {} {
     global CC_FOR_TARGET
-    global CFLAGS_FOR_TARGET
     global srcdir
     global subdir
     global tmpdir
 
     # Compile the dll.
-    if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/direct_dll.c $tmpdir/direct_dll.o ] {
+    if ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/direct_dll.c $tmpdir/direct_dll.o ] {
        fail "compiling shared lib"
     } elseif ![ld_link "$CC_FOR_TARGET -shared" $tmpdir/direct_dll.dll "$tmpdir/direct_dll.o" ] {
        fail "linking shared lib (.dll)"
@@ -77,7 +76,7 @@ proc test_direct_link_dll {} {
        fail "linking shared lib (.sl)"
     } else {
        # Compile and link the client program.
-       if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/direct_client.c $tmpdir/direct_client.o ] {
+       if ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/direct_client.c $tmpdir/direct_client.o ] {
            fail "compiling client"
        } else {
            # Check linking directly to direct_dll.dll.
index b4b4e785bb8d2aed5ddb88de7c0f0500ecb757fc..45a08ef2a5239316dfd2a7356d6b79548939e5b6 100644 (file)
@@ -71,7 +71,7 @@ proc test_direct2_link_dll {} {
     global tmpdir
 
     # Compile the dll.
-    if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/direct2_dll.c $tmpdir/direct2_dll.o ] {
+    if ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/direct2_dll.c $tmpdir/direct2_dll.o ] {
        fail "compiling shared lib fastcall/stdcall"
     } 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"
@@ -79,7 +79,7 @@ proc test_direct2_link_dll {} {
        fail "linking shared lib (.sl) fastcall/stdcall"
     } else {
        # Compile and link the client program.
-       if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET" $srcdir/$subdir/direct2_client.c $tmpdir/direct2_client.o ] {
+       if ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/direct2_client.c $tmpdir/direct2_client.o ] {
            fail "compiling client fastcall/stdcall"
        } else {
            # Check linking directly to direct2_dll.dll.
index 2652a8d3ed152fe0f8b3b90f3ff33b156d986fa4..8fac94113d0358fc2472f35fa11842eb14fef47e 100644 (file)
@@ -95,12 +95,12 @@ if { [istarget m681*-*-*] || [istarget m68hc1*-*-*] || [istarget m9s12x*-*-*] }
 }
 
 if { $can_compile && \
-       (![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]) } {
+       (![ld_compile $CC_FOR_TARGET $srcdir/$subdir/main.c tmpdir/main.o] \
+       || ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/func.c tmpdir/func.o] \
+       || ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/text.c tmpdir/text.o] \
+       || ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/pr20070a.c tmpdir/pr20070a.o] \
+       || ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/dummy.s tmpdir/dummy.o] \
+       || ![ld_compile $CC_FOR_TARGET $srcdir/$subdir/pr17973.s tmpdir/pr17973.o]) } {
     # Defer fail until we have list of tests set.
     set failed_compile 1
 }
@@ -298,9 +298,9 @@ if { !$can_compile || $failed_compile } {
 run_ld_link_tests $plugin_tests
 
 if { [is_elf_format] \
-     && [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] } {
+     && [ld_compile $CC_FOR_TARGET $srcdir/$subdir/func1p.c tmpdir/func1p.o] \
+     && [ld_compile $CC_FOR_TARGET $srcdir/$subdir/func2i.c tmpdir/func2i.o] \
+     && [ld_compile $CC_FOR_TARGET $srcdir/$subdir/func3h.c tmpdir/func3h.o] } {
     run_ld_link_tests $plugin_extra_elf_tests
 }
 
index 42ce87ffababe8124c8fc02cd0e194bc368ecb14..ff185a747d7083ccc7c8f7f73b995d0ce7598e04 100644 (file)
@@ -38,12 +38,10 @@ if { ![check_compiler_available] } {
     return
 }
 
-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_FOR_TARGET"
-append CC_FOR_TARGET " $PLT_CFLAGS $NOPIE_CFLAGS"
+set old_CFLAGS "$CFLAGS_FOR_TARGET"
+append CFLAGS_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.
@@ -68,7 +66,6 @@ if { ![ld_compile "$CC_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$su
     unsupported $test1
     unsupported $test2
     set CFLAGS_FOR_TARGET "$old_CFLAGS"
-    set CC_FOR_TARGET "$old_CC"
     return
 }
 
@@ -105,7 +102,6 @@ if [string match "" $exec_output] then {
 if { ![ld_compile "$CC_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
     unsupported $test2
     set CFLAGS_FOR_TARGET "$old_CFLAGS"
-    set CC_FOR_TARGET "$old_CC"
     return
 }
 
@@ -130,14 +126,12 @@ if [string match "" $exec_output] then {
 if { ![ld_compile "$CC_FOR_TARGET $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross4.c" tmpdir/cross4.o] } {
     unsupported $test3
     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_FOR_TARGET "$old_CFLAGS"
-    set CC_FOR_TARGET "$old_CC"
     return
 }
 
@@ -211,4 +205,3 @@ if [string match "" $exec_output] then {
 }
 
 set CFLAGS_FOR_TARGET "$old_CFLAGS"
-set CC_FOR_TARGET "$old_CC"
index d191e316e4690058f3407ab9e846eeddd6d3577f..655a56da99c1e5de4d3ee0321055a72b622a2381 100644 (file)
@@ -212,7 +212,7 @@ if { [istarget mips*-*-*] && ! [at_least_gcc_version 4 3] } then {
 verbose "Using $picflag to compile PIC code"
 
 # Compile the main program.
-if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
+if ![ld_compile "$CC_FOR_TARGET $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
     unsupported "shared (non PIC)"
     unsupported "shared"
 } else {
@@ -223,8 +223,8 @@ if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG" $srcdir/$subdir/mai
     # 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_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] } {
+    if { ![ld_compile "$CC_FOR_TARGET $PLT_CFLAGS $NOPIE_CFLAGS $SHCFLAG" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o]
+        || ![ld_compile "$CC_FOR_TARGET $PLT_CFLAGS $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
@@ -284,25 +284,25 @@ if ![ld_compile "$CC_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG" $srcdir/$subdir/mai
 
     # Now compile the code using -fpic.
 
-    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] } {
+    if { ![ld_compile "$CC_FOR_TARGET $SHCFLAG $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o]
+        || ![ld_compile "$CC_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_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
+           ld_compile "$CC_FOR_TARGET -DSYMBOLIC_TEST -DXCOFF_TEST $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o
+           ld_compile "$CC_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_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
+           ld_compile "$CC_FOR_TARGET $SHCFLAG" $srcdir/$subdir/main.c $tmpdir/mainnp.o
+           ld_compile "$CC_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_FOR_TARGET $CFLAGS_FOR_TARGET $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdir/mainp.o] {
+if ![ld_compile "$CC_FOR_TARGET $SHCFLAG $picflag" $srcdir/$subdir/main.c $tmpdir/mainp.o] {
     unsupported "shared (PIC main, non PIC so)"
     unsupported "shared (PIC main)"
 } else {
index 20472afcfc7340b8b1ac3b28b668f3c7d1b423a8..57380ca31464a50d18176094736667ac1b4f5564 100644 (file)
@@ -355,25 +355,23 @@ if { ![check_compiler_available] } {
 # 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_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_CFLAGS "$CFLAGS_FOR_TARGET"
+append CFLAGS_FOR_TARGET " $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
 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-*-*"]) } {
-    append CC_FOR_TARGET " -Wa,-mx86-used-note=no"
-    append CXX_FOR_TARGET " -Wa,-mx86-used-note=no"
+    append CFLAGS_FOR_TARGET " -Wa,-mx86-used-note=no"
+    append CXXFLAGS_FOR_TARGET " -Wa,-mx86-used-note=no"
 }
 
 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_FOR_TARGET "$old_CC"
-    set CXX_FOR_TARGET "$old_CXX"
+    set CFLAGS_FOR_TARGET "$old_CFLAGS"
     set CXXFLAGS_FOR_TARGET "$old_CXXFLAGS"
     return
 }
@@ -446,16 +444,14 @@ run_srec_test $test1 "tmpdir/sr1.o tmpdir/sr2.o"
 
 if { ![is_remote host] && [which $CXX_FOR_TARGET] == 0 } {
     untested $test2
-    set CC_FOR_TARGET "$old_CC"
-    set CXX_FOR_TARGET "$old_CXX"
+    set CFLAGS_FOR_TARGET "$old_CFLAGS"
     set CXXFLAGS_FOR_TARGET "$old_CXXFLAGS"
     return
 }
 
-if ![ld_compile "$CXX_FOR_TARGET $CXXFLAGS_FOR_TARGET -fno-exceptions" $srcdir/$subdir/sr3.cc tmpdir/sr3.o] {
+if ![ld_compile "$CXX_FOR_TARGET -fno-exceptions" $srcdir/$subdir/sr3.cc tmpdir/sr3.o] {
     unsupported $test2
-    set CC_FOR_TARGET "$old_CC"
-    set CXX_FOR_TARGET "$old_CXX"
+    set CFLAGS_FOR_TARGET "$old_CFLAGS"
     set CXXFLAGS_FOR_TARGET "$old_CXXFLAGS"
     return
 }
@@ -482,6 +478,5 @@ setup_xfail "bpf-*-*"
 
 run_srec_test $test2 "tmpdir/sr3.o"
 
-set CC_FOR_TARGET "$old_CC"
-set CXX_FOR_TARGET "$old_CXX"
+set CFLAGS_FOR_TARGET "$old_CFLAGS"
 set CXXFLAGS_FOR_TARGET "$old_CXXFLAGS"