[binutils-gdb] sim/testsuite: Default global_cc_os and global_cc_works properly

Hans-Peter Nilsson hp@sourceware.org
Tue Feb 15 22:36:28 GMT 2022


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=e63f65fea9e87ba2d4daa78fb4c82c631c103f02

commit e63f65fea9e87ba2d4daa78fb4c82c631c103f02
Author: Hans-Peter Nilsson <hp@axis.com>
Date:   Tue Feb 15 23:29:07 2022 +0100

    sim/testsuite: Default global_cc_os and global_cc_works properly
    
    There was an omission on 3e6dc39ed7a8 "sim/testsuite: Set
    global_cc_os also when no compiler is found"; global_cc_os
    wasn't set for other than the primary target, which means
    that the "unguarded" use of global_cc_os in
    testsuite/cris/c/c.exp caused the dreaded "ERROR: can't read
    "global_cc_os": no such variable" when e.g. configuring for
    pru-elf and doing "make check-sim".  Better initializing
    both variables at the top to default values, rather than
    adding another single 'set global_cc_os ""', to reduce the
    risk of not setting them properly if or when that
    if-statement-chain is made longer.
    
    sim/testsuite:
            * lib/sim-defs.exp (sim_init_toolchain): Default
            global_cc_os and global_cc_works properly, before if-chain.

Diff:
---
 sim/testsuite/lib/sim-defs.exp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/sim/testsuite/lib/sim-defs.exp b/sim/testsuite/lib/sim-defs.exp
index d2750e08b04..5528d64684b 100644
--- a/sim/testsuite/lib/sim-defs.exp
+++ b/sim/testsuite/lib/sim-defs.exp
@@ -121,9 +121,10 @@ proc sim_init_toolchain {} {
     set global_cpp_works [string equal "" "$result"]
 
     # See if we have a compiler available, and which environment it's targeting.
+    set global_cc_os ""
+    set global_cc_works 0
     if { $arch != $SIM_PRIMARY_TARGET && $CC_FOR_TARGET == "false" } {
 	verbose -log "Can't find a compatible C compiler"
-	set global_cc_works 0
     } elseif { [target_compile $srcdir/lib/newlibcheck.c \
 		$objdir/compilercheck.x "executable" $cc_options] == "" } {
 	verbose -log "Found newlib C compiler"
@@ -138,11 +139,8 @@ proc sim_init_toolchain {} {
 		$objdir/compilercheck.x "executable" $cc_options] == "" } {
 	verbose -log "Found C compiler, but unknown OS"
 	set global_cc_works 1
-	set global_cc_os ""
     } {
 	verbose -log "Can't execute C compiler"
-	set global_cc_works 0
-	set global_cc_os ""
     }
 
     file delete $objdir/compilercheck.x


More information about the Gdb-cvs mailing list