From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by sourceware.org (Postfix) with ESMTPS id 3D5D53858C83 for ; Tue, 15 Feb 2022 22:49:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3D5D53858C83 From: Hans-Peter Nilsson To: Dimitar Dimitrov CC: In-Reply-To: (message from Dimitar Dimitrov on Tue, 15 Feb 2022 18:43:15 +0100) Subject: Re: [PATCH 04/12] sim/testsuite/cris/c: Use -sim3 but only for newlib targets MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8BIT References: <20220214230255.DC76120439@pchp3.se.axis.com> Message-ID: <20220215224900.A618620426@pchp3.se.axis.com> Date: Tue, 15 Feb 2022 23:49:00 +0100 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_PASS, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Feb 2022 22:49:04 -0000 > From: Dimitar Dimitrov > Date: Tue, 15 Feb 2022 18:43:15 +0100 > On Tue, Feb 15, 2022 at 12:02:55AM +0100, Hans-Peter Nilsson via Gdb-patches wrote: > > 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. > Hi, > > FYI, this change introduces an error for "make check-sim" when configured > for pru-elf target. Error is gone if I revert this commit only. Note > that I don't have cross-CC in my PATH, which judging from sim_init_toolchain > function in sim-defs.exp is supported. > > ERROR: ------------------------------------------- > ERROR: in testcase /home/dinux/projects/pru/testbot-workspace/binutils/sim/testsuite/./cris/c/c.exp > ERROR: can't read "global_cc_os": no such variable > ERROR: tcl error code TCL LOOKUP VARNAME global_cc_os > ERROR: tcl error info: > can't read "global_cc_os": no such variable > while executing > "if { $global_cc_os == "newlib" } { > append CFLAGS_FOR_TARGET " -sim3" > }" > (file "/home/dinux/projects/pru/testbot-workspace/binutils/sim/testsuite/./cris/c/c.exp" line 35) > > > Regards, > Dimitar Please accept my apologies for the breakage and thanks for the report! It was actually the commit preceding the quoted one, that was in error. For that one, I was considering initializing both global_cc_os and global_cc_works as in the patch below, but went for the extant style of setting both in every if-arm. For some reason I missed the if-arm at the top, which pru-dently (sorry) showed the flaw in that style. The following solved the issue, tested by configuring for pru-elf and doing "make check-sim" for a build (with in-tree gas and ld for pru-elf) and observed the breakage in the reported manner before the patch (and gone with it in place). Committed. ---- 8< ---- 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. --- 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 d2750e08b046..5528d64684b3 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 -- 2.30.2