sim: testsuite: add dedicated flag for init toolchain tests
authorMike Frysinger <vapier@gentoo.org>
Sat, 27 Nov 2021 08:09:57 +0000 (03:09 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 27 Nov 2021 08:09:57 +0000 (03:09 -0500)
As we setup more reliable CC_FOR_TARGET variables for each target, the
bfin way of overriding it to stuff custom CFLAGS doesn't scale well.
Add a dedicated CFLAGS_FOR_TARGET_init setting that each set of tests
can setup if they want to add custom options.

sim/testsuite/bfin/allinsn.exp
sim/testsuite/lib/sim-defs.exp

index a9dc08457b2689c38137c80cf6cfa0ad05e72edd..2be369dc9383ad2a8714cd9d3bf6692e49d14c63 100644 (file)
@@ -2,9 +2,9 @@
 
 # Set a default CPU to satisfy bfin-elf-gcc requirements.  BF537 should work
 # with all standard Blackfin toolchains.
-set CC_FOR_TARGET "[find_gcc] -mcpu=bf537"
+global CFLAGS_FOR_TARGET_init
+set CFLAGS_FOR_TARGET_init "-mcpu=bf537"
 sim_init
-unset CC_FOR_TARGET
 
 if [istarget bfin-*-elf] {
     # all machines
index fca66af26a86d19b6b4d7f25985b30f402e5a753..cd16bbb13b9681079dee38d187e4a78f12ef57ed 100644 (file)
@@ -55,6 +55,7 @@ proc sim_init_toolchain {} {
     global global_cpp_works
     global global_cc_works
     global global_cc_os
+    global CFLAGS_FOR_TARGET_init
 
     # Reset all the toolchain settings.  This provides a clean slate when
     # starting the next set of tests.
@@ -64,24 +65,30 @@ proc sim_init_toolchain {} {
     set SIMFLAGS_FOR_TARGET ""
     unset -nocomplain cpu_option cpu_option_sep
 
+    # Merge per-test settings if available.
+    if ![info exists CFLAGS_FOR_TARGET_init] {
+       set CFLAGS_FOR_TARGET_init ""
+    }
+    set cc_options [list "additional_flags=$CFLAGS_FOR_TARGET_init"]
+
     # See if we have a preprocessor available.
     set result [target_compile $srcdir/lib/compilercheck.c \
-               $objdir/compilercheck.x "preprocess" ""]
+               $objdir/compilercheck.x "preprocess" $cc_options]
     set global_cpp_works [string equal "" "$result"]
 
     # See if we have a compiler available, and which environment it's targeting.
     if { [target_compile $srcdir/lib/newlibcheck.c \
-         $objdir/compilercheck.x "executable" ""] == "" } {
+         $objdir/compilercheck.x "executable" $cc_options] == "" } {
        verbose -log "Found newlib C compiler"
        set global_cc_works 1
        set global_cc_os "newlib"
     } elseif { [target_compile $srcdir/lib/linuxcheck.c \
-               $objdir/compilercheck.x "executable" ""] == "" } {
+               $objdir/compilercheck.x "executable" $cc_options] == "" } {
        verbose -log "Found Linux C compiler"
        set global_cc_works 1
        set global_cc_os "linux"
     } elseif { [target_compile $srcdir/lib/compilercheck.c \
-               $objdir/compilercheck.x "executable" ""] == "" } {
+               $objdir/compilercheck.x "executable" $cc_options] == "" } {
        verbose -log "Found C compiler, but unknown OS"
        set global_cc_works 1
        set global_cc_os ""
@@ -91,6 +98,8 @@ proc sim_init_toolchain {} {
     }
 
     file delete $objdir/compilercheck.x
+
+    unset CFLAGS_FOR_TARGET_init
 }
 
 # Print the version of the simulator being tested.