aboutsummaryrefslogtreecommitdiff
path: root/sim/testsuite/lib
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2021-11-11 00:36:52 -0500
committerMike Frysinger <vapier@gentoo.org>2021-11-26 19:51:15 -0500
commit264dcc17cc4d2252d58bda347dfd78c1b78517da (patch)
tree31da57f3638243a7ff8c24c940dcd21e5842d6db /sim/testsuite/lib
parentc0d6a6e5828882040bbb55bafea6b188a18fc000 (diff)
downloadbinutils-264dcc17cc4d2252d58bda347dfd78c1b78517da.zip
binutils-264dcc17cc4d2252d58bda347dfd78c1b78517da.tar.gz
binutils-264dcc17cc4d2252d58bda347dfd78c1b78517da.tar.bz2
sim: testsuite: unify basic C compiler checks
Both bfin & cris ports test the C compiler to see if it works, but in their own way. Unify the checks in the common code so we can leverage them in more ports in the future, and collapse the bfin & cris code.
Diffstat (limited to 'sim/testsuite/lib')
-rw-r--r--sim/testsuite/lib/compilercheck.c5
-rw-r--r--sim/testsuite/lib/sim-defs.exp38
2 files changed, 43 insertions, 0 deletions
diff --git a/sim/testsuite/lib/compilercheck.c b/sim/testsuite/lib/compilercheck.c
new file mode 100644
index 0000000..63a9577
--- /dev/null
+++ b/sim/testsuite/lib/compilercheck.c
@@ -0,0 +1,5 @@
+/* Used by the test harness to verify working compiler & preprocessor. */
+int main()
+{
+ return 0;
+}
diff --git a/sim/testsuite/lib/sim-defs.exp b/sim/testsuite/lib/sim-defs.exp
index 46a8b3f..f399d2f 100644
--- a/sim/testsuite/lib/sim-defs.exp
+++ b/sim/testsuite/lib/sim-defs.exp
@@ -33,11 +33,35 @@ proc sim_init { args } {
# all simulators.
unset_currtarget_info ldscript
+ sim_init_toolchain
+
# Need to return an empty string. This tells dejagnu to *not* re-run us
# with the exact test that we're about to run.
return ""
}
+# Initialize the toolchain settings for this port.
+# Needs to be called once per-port.
+
+proc sim_init_toolchain {} {
+ global objdir
+ global srcdir
+ global global_cpp_works
+ global global_cc_works
+
+ # See if we have a preprocessor available.
+ set result [target_compile $srcdir/lib/compilercheck.c \
+ $objdir/compilercheck.x "preprocess" ""]
+ set global_cpp_works [string equal "" "$result"]
+
+ # See if we have a compiler available.
+ set result [target_compile $srcdir/lib/compilercheck.c \
+ $objdir/compilercheck.x "executable" ""]
+ set global_cc_works [string equal "" "$result"]
+
+ file delete $objdir/compilercheck.x
+}
+
# Print the version of the simulator being tested.
# Required by dejagnu.
@@ -185,6 +209,8 @@ proc run_sim_test { name requested_machs } {
global cpu_option
global cpu_option_sep
global SIMFLAGS_FOR_TARGET
+ global global_cpp_works
+ global global_cc_works
if ![file exists $sim_path] {
unsupported "$name: missing simulator $sim_path"
@@ -327,11 +353,23 @@ proc run_sim_test { name requested_machs } {
}
if [string match "*.c" $sourcefile] {
+ # If we don't have a compiler available, skip tests :(.
+ if { $global_cc_works == 0 } {
+ untested $subdir/$name
+ return
+ }
+
set comp_output [target_compile $sourcefile $objdir/${name}.x "executable" \
[list "incdir=$srcdir/$subdir" "additional_flags=$c_as_options $c_ld_options $opts(cc,$mach)"]]
set method "compiling/linking"
} else {
if [string match "*.S" $sourcefile] {
+ # If we don't have a preprocessor available, skip tests :(.
+ if { $global_cpp_works == 0 } {
+ untested $subdir/$name
+ return
+ }
+
set comp_output [target_compile $sourcefile $objdir/${name}.o "object" \
[list "incdir=$srcdir/$subdir" "additional_flags=$c_as_options"]]
set method "compiling"