sim/testsuite/cris/c: Use -sim3 but only for newlib targets

Commit a39487c668 "sim: cris: use -sim with C tests for cris-elf
targets" caused " -sim" to be appended to CFLAGS_FOR_TARGET for
cris*-*-elf, where testing had until then relied on
"RUNTESTFLAGS=--target_board=cris-sim" being passed when running "make
check-sim", adding the right options.  While "-sim" happens to work,
the baseboard-file cris-sim.exp uses "-sim3" so for consistency use
that instead.

Then commit b42f20d2ac "sim: testsuite: drop most specific istarget
checks" caused " -sim" to be appended for *all* targets, which just
doesn't work.  For example, for crisv32-linux-gnu, that's not a
recognized option and will cause a dejagnu error and further testing
in c.exp will be aborted.

While cris-sim.exp appends "-static" for *-linux-gnu, further changes
in the test-suite have caused "linux"-specific tests to break, so that
part will be tended to separately.

But, save and restore CFLAGS_FOR_TARGET around the modification and
use where needed, to not have the CRIS-specific modification affect a
continuing test-run (possibly for other targets).

sim/testsuite/cris:
	* c/c.exp (CFLAGS_FOR_TARGET): Replace appended option " -sim"
	with " -sim3", but do it conditionally for newlib targets.  Save
	and restore CFLAGS_FOR_TARGET in saved_CFLAGS_FOR_TARGET such
	that it doesn't affect the value of CFLAGS_FOR_TARGET outside
	c.exp.
This commit is contained in:
Hans-Peter Nilsson 2022-02-14 23:50:36 +01:00 committed by Hans-Peter Nilsson
parent 3e6dc39ed7
commit 56ba3848dc

View File

@ -17,6 +17,9 @@
sim_init sim_init
global global_cc_works
global global_cc_os
set CFLAGS_FOR_TARGET "-O2" set CFLAGS_FOR_TARGET "-O2"
if [istarget cris-*-*] { if [istarget cris-*-*] {
set mach "crisv10" set mach "crisv10"
@ -24,13 +27,16 @@ if [istarget cris-*-*] {
set mach "crisv32" set mach "crisv32"
} }
if [istarget *] { # Make sure we're using the right runtime for simulator runs. If the
append CFLAGS_FOR_TARGET " -sim" # cris-sim dejagnu baseboard is used, -sim3 will be duplicated, but
# that's ok. For e.g. cris*-linux-gnu, neither -sim not -sim3 are
# supported options and likely not other targets too.
set saved_CFLAGS_FOR_TARGET $CFLAGS_FOR_TARGET
if { $global_cc_os == "newlib" } {
append CFLAGS_FOR_TARGET " -sim3"
} }
# Using target_compile, since it is less noisy, # Using target_compile, since it is less noisy,
global global_cc_works
global global_cc_os
if { $global_cc_works == 1 } { if { $global_cc_works == 1 } {
# Now check if we can link a program dynamically, and where # Now check if we can link a program dynamically, and where
# libc.so is located. If it is, we provide a sym link to the # libc.so is located. If it is, we provide a sym link to the
@ -239,3 +245,5 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] {
$status "$mach $testname" $status "$mach $testname"
} }
} }
set CFLAGS_FOR_TARGET $saved_CFLAGS_FOR_TARGET