summaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2020-10-22 06:04:21 -0700
committerH.J. Lu <hjl.tools@gmail.com>2020-10-22 06:04:36 -0700
commitc6d47bff77db79b1ad99cd7911f7e1807874be55 (patch)
treebc57be9e8e0f4e3e660b455411c5fecdae6401b5 /ld
parent63aa0ac0fd8f4d46507a12c1a38217f8d7d1ee33 (diff)
ld: Pass -fno-lto to non LTO tests
* testsuite/config/default.exp (NOLTO_CFLAGS): New. * ld/testsuite/ld-elfcomm/elfcomm.exp: Add $NOLTO_CFLAGS to CC. * testsuite/ld-elfvers/vers.exp: Likewise. * testsuite/ld-elfvsb/elfvsb.exp: Likewise. * testsuite/ld-gc/gc.exp: Likewise. * testsuite/ld-plugin/plugin.exp: Likewise. * testsuite/ld-scripts/crossref.exp: Likewise. * testsuite/ld-selective/selective.exp: Likewise. * testsuite/ld-undefined/undefined.exp: Likewise. * testsuite/ld-srec/srec.exp: Add $NOLTO_CFLAGS to CC. Override CXXFLAGS. * testsuite/lib/ld-lib.exp (run_ld_link_tests): Prepend -fno-lto to cflags.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog16
-rw-r--r--ld/testsuite/config/default.exp7
-rw-r--r--ld/testsuite/ld-elfcomm/elfcomm.exp6
-rw-r--r--ld/testsuite/ld-elfvers/vers.exp11
-rw-r--r--ld/testsuite/ld-elfvsb/elfvsb.exp19
-rw-r--r--ld/testsuite/ld-gc/gc.exp2
-rw-r--r--ld/testsuite/ld-plugin/plugin.exp2
-rw-r--r--ld/testsuite/ld-scripts/crossref.exp8
-rw-r--r--ld/testsuite/ld-selective/selective.exp4
-rw-r--r--ld/testsuite/ld-srec/srec.exp9
-rw-r--r--ld/testsuite/ld-undefined/undefined.exp2
-rw-r--r--ld/testsuite/lib/ld-lib.exp5
12 files changed, 64 insertions, 27 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 8d5fb456e4..2e6cfd4a8b 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,19 @@
+2020-10-22 H.J. Lu <hongjiu.lu@intel.com>
+
+ * testsuite/config/default.exp (NOLTO_CFLAGS): New.
+ * ld/testsuite/ld-elfcomm/elfcomm.exp: Add $NOLTO_CFLAGS to CC.
+ * testsuite/ld-elfvers/vers.exp: Likewise.
+ * testsuite/ld-elfvsb/elfvsb.exp: Likewise.
+ * testsuite/ld-gc/gc.exp: Likewise.
+ * testsuite/ld-plugin/plugin.exp: Likewise.
+ * testsuite/ld-scripts/crossref.exp: Likewise.
+ * testsuite/ld-selective/selective.exp: Likewise.
+ * testsuite/ld-undefined/undefined.exp: Likewise.
+ * testsuite/ld-srec/srec.exp: Add $NOLTO_CFLAGS to CC. Override
+ CXXFLAGS.
+ * testsuite/lib/ld-lib.exp (run_ld_link_tests): Prepend -fno-lto
+ to cflags.
+
2020-10-19 Alan Modra <amodra@gmail.com>
* testsuite/config/default.exp: Provide dummy libraries for
diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
index dfb633406d..e5730ff565 100644
--- a/ld/testsuite/config/default.exp
+++ b/ld/testsuite/config/default.exp
@@ -398,6 +398,13 @@ if { ![info exists NOSANITIZE_CFLAGS] } then {
}
}
+if { ![info exists NOLTO_CFLAGS] } then {
+ set NOLTO_CFLAGS ""
+ if [compiler_supports "-fno-lto"] {
+ set NOLTO_CFLAGS "-fno-lto"
+ }
+}
+
# Provide dummy libraries that alpha-vms-ld always loads
if { [istarget alpha*-*-*vms*] } {
set src tmpdir/empty.s
diff --git a/ld/testsuite/ld-elfcomm/elfcomm.exp b/ld/testsuite/ld-elfcomm/elfcomm.exp
index c4836d9c46..856a6db5c6 100644
--- a/ld/testsuite/ld-elfcomm/elfcomm.exp
+++ b/ld/testsuite/ld-elfcomm/elfcomm.exp
@@ -169,9 +169,9 @@ if [istarget nios2*-*-*] {
# 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" $srcdir/$subdir/common1a.c tmpdir/common1a.o]
- || ![ld_compile "$CC $CFLAGS -fcommon $NOSANITIZE_CFLAGS" $srcdir/$subdir/common1b.c tmpdir/common1b.o]
- || ![ld_compile "$CC $CFLAGS $NOSANITIZE_CFLAGS -Wa,--elf-stt-common=yes -fcommon" $srcdir/$subdir/common1b.c tmpdir/common1c.o] } {
+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] } {
unresolved $test1
unresolved $test1
return
diff --git a/ld/testsuite/ld-elfvers/vers.exp b/ld/testsuite/ld-elfvers/vers.exp
index 91ff8f1448..817e8be6d4 100644
--- a/ld/testsuite/ld-elfvers/vers.exp
+++ b/ld/testsuite/ld-elfvers/vers.exp
@@ -490,8 +490,9 @@ proc build_binary { shared pic test source libname other mapfile verexp versymex
global CFLAGS
global script
global NOSANITIZE_CFLAGS
+ global NOLTO_CFLAGS
- if ![ld_compile "$CC -S $pic $CFLAGS $NOSANITIZE_CFLAGS" $srcdir/$subdir/$source $tmpdir/$libname.s] {
+ if ![ld_compile "$CC -S $pic $CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/$source $tmpdir/$libname.s] {
unresolved "$test"
return
}
@@ -619,8 +620,9 @@ proc test_asfail { test flag source execname whyfail } {
global as
global CC
global CFLAGS
+ global NOLTO_CFLAGS
- if ![ld_compile "$CC -S $flag $CFLAGS" $srcdir/$subdir/$source $tmpdir/$execname.s] {
+ if ![ld_compile "$CC -S $flag $CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/$source $tmpdir/$execname.s] {
unresolved "$test"
return
}
@@ -689,6 +691,7 @@ proc build_exec { test source execname flags solibname verexp versymexp symexp }
global CC
global CFLAGS
global NOSANITIZE_CFLAGS
+ global NOLTO_CFLAGS
set shared "--shared --no-undefined-version"
set script --version-script
@@ -699,8 +702,8 @@ proc build_exec { test source execname flags solibname verexp versymexp symexp }
append cc_cmd " -fno-lto"
}
- # Disable all sanitizers.
- append cc_cmd " $NOSANITIZE_CFLAGS"
+ # Disable all sanitizers and LTO.
+ append cc_cmd " $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
if ![ld_compile $cc_cmd $srcdir/$subdir/$source $tmpdir/$execname.s] {
unresolved "$test"
diff --git a/ld/testsuite/ld-elfvsb/elfvsb.exp b/ld/testsuite/ld-elfvsb/elfvsb.exp
index 05052cc3ba..a729df3f01 100644
--- a/ld/testsuite/ld-elfvsb/elfvsb.exp
+++ b/ld/testsuite/ld-elfvsb/elfvsb.exp
@@ -198,6 +198,7 @@ proc visibility_run {visibility} {
global NOPIE_CFLAGS
global COMPRESS_LDFLAG
global NOSANITIZE_CFLAGS
+ global NOLTO_CFLAGS
if [ string match $visibility "hidden" ] {
set VSBCFLAG "-DHIDDEN_TEST"
@@ -236,7 +237,7 @@ proc visibility_run {visibility} {
} 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" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
+ if ![ld_compile "$CC -g $PLT_CFLAGS $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/main.c $tmpdir/mainnp.o] {
unresolved "visibility ($visibility) (non PIC)"
unresolved "visibility ($visibility)"
} else {
@@ -246,8 +247,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 -g $NOPIE_CFLAGS $PLT_CFLAGS $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS" $srcdir/$subdir/sh1.c $tmpdir/sh1np.o]
- || ![ld_compile "$CC -g $NOPIE_CFLAGS $PLT_CFLAGS $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS" $srcdir/$subdir/sh2.c $tmpdir/sh2np.o] } {
+ 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] } {
unresolved "visibility ($visibility) (non PIC)"
} else {
# SunOS non PIC shared libraries don't permit some cases of
@@ -335,8 +336,8 @@ proc visibility_run {visibility} {
# Now compile the code using -fpic.
- if { ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh1.c $tmpdir/sh1p.o]
- || ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh2.c $tmpdir/sh2p.o] } {
+ 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] } {
unresolved "visibility ($visibility)"
} else {
if { [ string match $visibility "protected" ]
@@ -353,7 +354,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 -g $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS -DSHARED $picflag" $srcdir/$subdir/main.c $tmpdir/mainp.o] {
+ if ![ld_compile "$CC -g $CFLAGS $SHCFLAG $VSBCFLAG $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/main.c $tmpdir/mainp.o] {
unresolved "visibility ($visibility) (PIC main, non PIC so)"
unresolved "visibility ($visibility) (PIC main)"
} else {
@@ -445,7 +446,7 @@ visibility_run protected_undef_def
visibility_run protected_weak
visibility_run normal
-if { ![ld_compile "$CC -g $CFLAGS $NOSANITIZE_CFLAGS" $srcdir/$subdir/common.c tmpdir/common.o] } {
+if { ![ld_compile "$CC -g $CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/common.c tmpdir/common.o] } {
unresolved "common hidden symbol"
} else {
if ![ld_link $ld tmpdir/common "tmpdir/common.o"] {
@@ -455,10 +456,10 @@ if { ![ld_compile "$CC -g $CFLAGS $NOSANITIZE_CFLAGS" $srcdir/$subdir/common.c t
}
}
-if { ![ld_compile "$CC -g $CFLAGS $NOSANITIZE_CFLAGS" $srcdir/$subdir/test.c tmpdir/test.o] } {
+if { ![ld_compile "$CC -g $CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" $srcdir/$subdir/test.c tmpdir/test.o] } {
unresolved "weak hidden symbol"
} else {
- if { ![ld_compile "$CC -g $CFLAGS $NOSANITIZE_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh3.c tmpdir/sh3.o] } {
+ if { ![ld_compile "$CC -g $CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS -DSHARED $picflag" $srcdir/$subdir/sh3.c tmpdir/sh3.o] } {
unresolved "weak hidden symbol"
} else {
if ![ld_link $ld tmpdir/sh3.so "-shared tmpdir/sh3.o"] {
diff --git a/ld/testsuite/ld-gc/gc.exp b/ld/testsuite/ld-gc/gc.exp
index 02da44f27a..aa01523736 100644
--- a/ld/testsuite/ld-gc/gc.exp
+++ b/ld/testsuite/ld-gc/gc.exp
@@ -23,7 +23,7 @@ if ![check_gc_sections_available] {
return
}
-set cflags "-ffunction-sections -fdata-sections $NOSANITIZE_CFLAGS"
+set cflags "-ffunction-sections -fdata-sections $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
set objfile "tmpdir/gc.o"
if { [istarget powerpc*-*-*] && ![istarget powerpc64*-*-*] } {
diff --git a/ld/testsuite/ld-plugin/plugin.exp b/ld/testsuite/ld-plugin/plugin.exp
index b30b05f144..4b6b2fc7cd 100644
--- a/ld/testsuite/ld-plugin/plugin.exp
+++ b/ld/testsuite/ld-plugin/plugin.exp
@@ -94,7 +94,7 @@ set failed_compile 0
set _ ""
set plugin_nm_output ""
set old_CFLAGS "$CFLAGS"
-append CFLAGS " $NOSANITIZE_CFLAGS"
+append CFLAGS " $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
if { $can_compile && \
(![ld_compile "$CC $CFLAGS" $srcdir/$subdir/main.c tmpdir/main.o] \
diff --git a/ld/testsuite/ld-scripts/crossref.exp b/ld/testsuite/ld-scripts/crossref.exp
index 94452f7479..d5cd5079c8 100644
--- a/ld/testsuite/ld-scripts/crossref.exp
+++ b/ld/testsuite/ld-scripts/crossref.exp
@@ -63,8 +63,8 @@ if [istarget tic6x*-*-*] {
set CFLAGS "-mno-dsbt -msdata=none"
}
-if { ![ld_compile "$CC $NOSANITIZE_CFLAGS" "$srcdir/$subdir/cross1.c" tmpdir/cross1.o] \
- || ![ld_compile "$CC $NOSANITIZE_CFLAGS" "$srcdir/$subdir/cross2.c" tmpdir/cross2.o] } {
+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] } {
unresolved $test1
unresolved $test2
set CFLAGS "$old_CFLAGS"
@@ -101,7 +101,7 @@ if [string match "" $exec_output] then {
# Check cross references within a single object.
-if { ![ld_compile "$CC $NOSANITIZE_CFLAGS" "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
+if { ![ld_compile "$CC $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross3.c" tmpdir/cross3.o] } {
unresolved $test2
set CFLAGS "$old_CFLAGS"
set CC "$old_CC"
@@ -126,7 +126,7 @@ if [string match "" $exec_output] then {
# Check cross references for ld -r
-if { ![ld_compile "$CC $NOSANITIZE_CFLAGS" "$srcdir/$subdir/cross4.c" tmpdir/cross4.o] } {
+if { ![ld_compile "$CC $NOSANITIZE_CFLAGS $NOLTO_CFLAGS" "$srcdir/$subdir/cross4.c" tmpdir/cross4.o] } {
unresolved $test3
set CFLAGS "$old_CFLAGS"
set CC "$old_CC"
diff --git a/ld/testsuite/ld-selective/selective.exp b/ld/testsuite/ld-selective/selective.exp
index f8c143fa15..8c34699203 100644
--- a/ld/testsuite/ld-selective/selective.exp
+++ b/ld/testsuite/ld-selective/selective.exp
@@ -46,8 +46,8 @@ set seltests {
{A::foo() B::foo() dropme1() dropme2()} {*-*-*}}
}
-set cflags "-w -O -ffunction-sections -fdata-sections $NOSANITIZE_CFLAGS"
-set cxxflags "-fno-exceptions -fno-rtti $NOSANITIZE_CFLAGS"
+set cflags "-w -O -ffunction-sections -fdata-sections $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
+set cxxflags "-fno-exceptions -fno-rtti $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
set ldflags "--gc-sections -Bstatic"
if [istarget mips*-*] {
diff --git a/ld/testsuite/ld-srec/srec.exp b/ld/testsuite/ld-srec/srec.exp
index 3b279fe805..1842f35bfa 100644
--- a/ld/testsuite/ld-srec/srec.exp
+++ b/ld/testsuite/ld-srec/srec.exp
@@ -353,9 +353,10 @@ if { ![check_compiler_available] } {
# 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"
+set CC "$CC $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANITIZE_CFLAGS $NOLTO_CFLAGS"
set old_CXX "$CXX"
-set CXX "$CXX $PLT_CFLAGS $NOPIE_CFLAGS $NOPIE_LDFLAGS $NOCF_PROTECTION_CFLAGS $NOSANITIZE_CFLAGS"
+set old_CXXFLAGS "$CXXFLAGS"
+set CXXFLAGS "$CXXFLAGS $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] \
@@ -370,6 +371,7 @@ if { ![ld_compile $CC $srcdir/$subdir/sr1.c tmpdir/sr1.o] \
unresolved $test2
set CC "$old_CC"
set CXX "$old_CXX"
+ set CXXFLAGS "$old_CXXFLAGS"
return
}
@@ -443,6 +445,7 @@ if { ![is_remote host] && [which $CXX] == 0 } {
untested $test2
set CC "$old_CC"
set CXX "$old_CXX"
+ set CXXFLAGS "$old_CXXFLAGS"
return
}
@@ -450,6 +453,7 @@ if ![ld_compile "$CXX $CXXFLAGS -fno-exceptions" $srcdir/$subdir/sr3.cc tmpdir/s
unresolved $test2
set CC "$old_CC"
set CXX "$old_CXX"
+ set CXXFLAGS "$old_CXXFLAGS"
return
}
@@ -477,3 +481,4 @@ run_srec_test $test2 "tmpdir/sr3.o"
set CC "$old_CC"
set CXX "$old_CXX"
+set CXXFLAGS "$old_CXXFLAGS"
diff --git a/ld/testsuite/ld-undefined/undefined.exp b/ld/testsuite/ld-undefined/undefined.exp
index b1b39ea360..ea7172a7ec 100644
--- a/ld/testsuite/ld-undefined/undefined.exp
+++ b/ld/testsuite/ld-undefined/undefined.exp
@@ -29,7 +29,7 @@ if { ![check_compiler_available] } {
untested $testund
untested $testfn
untested $testline
-} elseif { ![ld_compile "$CC -g" $srcdir/$subdir/undefined.c tmpdir/undefined.o] } {
+} elseif { ![ld_compile "$CC -g $NOLTO_CFLAGS" $srcdir/$subdir/undefined.c tmpdir/undefined.o] } {
verbose "Unable to compile test file!" 1
unresolved $testund
unresolved $testfn
diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp
index c026407619..1aa614fa36 100644
--- a/ld/testsuite/lib/ld-lib.exp
+++ b/ld/testsuite/lib/ld-lib.exp
@@ -499,6 +499,11 @@ proc run_ld_link_tests { ldtests args } {
set maybe_failed 0
set ld_output ""
+ # Add -fno-lto. LTO should be tested explicitly by $cflags.
+ if {[check_lto_available]} {
+ set cflags "-fno-lto $cflags"
+ }
+
# verbose -log "Testname is $testname"
# verbose -log "ld_options is $ld_options"
# verbose -log "ld_after is $ld_after"