From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by sourceware.org (Postfix) with ESMTPS id 77BD2385701C for ; Mon, 3 Oct 2022 17:10:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 77BD2385701C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=dabbelt.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=dabbelt.com Received: by mail-pj1-x1030.google.com with SMTP id v10-20020a17090a634a00b00205e48cf845so15858312pjs.4 for ; Mon, 03 Oct 2022 10:10:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from :in-reply-to:subject:date:from:to:cc:subject:date; bh=qk6sXG/JBUGg31CbjgnRqGsjxloEQ7Tx5ZsWQL36Cas=; b=7Y0wIazBfAMKO3rDkkoXEo6LdakaM64let7n1AP1l/GVKwWgRw3L0dtORYBYfQJoNu moouzbY0NPYAW+JXkcROpU10RknJFAwmOaW0KWY6KxdwiE6oSQFpoWmRseJFhVJu6zIZ h4acqspDk6whZFVSunGIR1wZJmomhj3x/qUVQdJpJA3TYm2Fu6R0wVBaQbedMxz4Oe/n k+XnOnjgHjnE7jISfli1xzsbG6avZRSYDgXHFlusHW2GmV5/rQ7CZ1XFKSqrlQ9JWHy9 +0eR1Xf6QgdY1Ute8ysCxpgI4KTgAyZfHCIbL6u1ZKfVx7Ve5BGNfDvm8hVdATxQkCX8 S9Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:to:from :in-reply-to:subject:date:x-gm-message-state:from:to:cc:subject:date; bh=qk6sXG/JBUGg31CbjgnRqGsjxloEQ7Tx5ZsWQL36Cas=; b=3Kdol0f6Oap0wJFIDXXyzGRT+01qGEyJW8ezABSBIJsYoqkq0jAU/5M1JqiXvWsA/e FFHxst1OU0EQxK8jOK02mqatWx+h3exlMBkx6bIZSNWie2UXzuxUxOc3qXNYDdYkyPRe iLwAnlB0nMcZoJrYX1TJ0Rm4RmIo0FIvUYjBAxA3rN1rOtm8q9K2pIMNgz9PTI/q6yUi XHTEOHijGXIjYQNvJRQwIXeS9gxybSdO1RtRLndyehFPxSwThf/pdwsz1I5Kc2VBjU9t eCjAa0jb9ygx3YG2mbTYuidqaOgqj9idH+FLCXV1EdsayQ0W9ODCJiz2QH65MvaAfPCi hqIQ== X-Gm-Message-State: ACrzQf3gIhS3cBoXiXfHhEDEpQAM1rWnAT7rPuQAPG82ZeaQktWQbC5h 0xdA1oafYj9EzMG08rj0VUU+QeqIBbHZMv5x X-Google-Smtp-Source: AMsMyM65wQH/vk1SDSzVpBsXkVZT903MVmH1QAbHyZ/EB/sGyVdiqFKtbpseAgsBQNSGtNJZhIBHTg== X-Received: by 2002:a17:90b:1648:b0:203:c8d3:99b0 with SMTP id il8-20020a17090b164800b00203c8d399b0mr13324414pjb.54.1664817043883; Mon, 03 Oct 2022 10:10:43 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id i184-20020a6287c1000000b00537a6b81bb7sm5492465pfe.148.2022.10.03.10.10.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Oct 2022 10:10:43 -0700 (PDT) Date: Mon, 03 Oct 2022 10:10:43 -0700 (PDT) X-Google-Original-Date: Mon, 03 Oct 2022 10:10:35 PDT (-0700) Subject: Re: [PATCH] ld/testsuite: consistently add board_ldflags when linking with GCC In-Reply-To: <20220930140503.38233-1-chigot@adacore.com> From: Palmer Dabbelt To: binutils@sourceware.org, chigot@adacore.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Fri, 30 Sep 2022 07:05:03 PDT (-0700), binutils@sourceware.org wrote: > Currently, the functions checking if the compiler is available or if a > feature is available add both board_cflags and board_ldflags. > However, functions running the tests only retrieve board_cflags. This > can lead to unexpected errors when mandaratory flags are defined in > board_ldflags and not board_cflags. > > ld/ChangeLog: > > * testsuite/ld-unique/unique.exp: Add board_ldflags when > linking with GCC. > * testsuite/lib/ld-lib.exp: Likewise. > --- > ld/testsuite/ld-unique/unique.exp | 8 +++++++- > ld/testsuite/lib/ld-lib.exp | 22 ++++++++++++++++++---- > 2 files changed, 25 insertions(+), 5 deletions(-) Sorry if I'm misunderstanding what's going on here, but with this applied I'm still getting the tests skipped when I just run "check-ld". Running /home/palmer/life/binutils-gdb/ld/testsuite/ld-undefined/undefined.exp ... UNTESTED: undefined UNTESTED: undefined function UNTESTED: undefined line === ld Summary === # of expected passes 797 # of expected failures 8 # of untested testcases 26 # of unsupported tests 175 ./ld-new 2.39.50.20220930 I always kind of end up fumbling my way around these test suite infrastructure things though, so sorry if I'm just lost... > > diff --git a/ld/testsuite/ld-unique/unique.exp b/ld/testsuite/ld-unique/unique.exp > index f3d5a5a6b7d..ab24eef50c3 100644 > --- a/ld/testsuite/ld-unique/unique.exp > +++ b/ld/testsuite/ld-unique/unique.exp > @@ -122,8 +122,14 @@ if [board_info [target_info name] exists cflags] { > set board_cflags "" > } > > +if [board_info [target_info name] exists ldflags] { > + set board_ldflags " [board_info [target_info name] ldflags]" > +} else { > + set board_ldflags "" > +} > + > # Create executable containing unique symbol. > -if ![ld_link "$CC_FOR_TARGET $NOPIE_LDFLAGS $board_cflags" "tmpdir/unique_prog" "tmpdir/unique.o"] { > +if ![ld_link "$CC_FOR_TARGET $NOPIE_LDFLAGS $board_cflags $board_ldflags" "tmpdir/unique_prog" "tmpdir/unique.o"] { > fail "Could not link a unique executable" > set fails [expr $fails + 1] > } > diff --git a/ld/testsuite/lib/ld-lib.exp b/ld/testsuite/lib/ld-lib.exp > index ec27388a72e..2cd840c0169 100644 > --- a/ld/testsuite/lib/ld-lib.exp > +++ b/ld/testsuite/lib/ld-lib.exp > @@ -690,6 +690,7 @@ proc run_ld_link_exec_tests { ldtests args } { > global errcnt > global exec_output > global board_cflags > + global board_ldflags > global STATIC_LDFLAGS > > # When using GCC as the linker driver, we need to specify board cflags when > @@ -702,6 +703,12 @@ proc run_ld_link_exec_tests { ldtests args } { > set board_cflags "" > } > > + if [board_info [target_info name] exists ldflags] { > + set board_ldflags " [board_info [target_info name] ldflags]" > + } else { > + set board_ldflags "" > + } > + > foreach testitem $ldtests { > set testname [lindex $testitem 0] > set ld_options [lindex $testitem 1] > @@ -777,11 +784,11 @@ proc run_ld_link_exec_tests { ldtests args } { > continue; > } else { > if { [string match "" $STATIC_LDFLAGS] \ > - && [regexp -- ".* \[-\]+static .*" " $board_cflags $ld_options $objfiles $ld_after "] } { > + && [regexp -- ".* \[-\]+static .*" " $board_cflags $board_ldflags $ld_options $objfiles $ld_after "] } { > untested $testname > continue > } > - if ![$link_proc $link_cmd $binfile "$board_cflags -L$srcdir/$subdir $ld_options $objfiles $ld_after"] { > + if ![$link_proc $link_cmd $binfile "$board_cflags $board_ldflags -L$srcdir/$subdir $ld_options $objfiles $ld_after"] { > set failed 1 > } > } > @@ -858,6 +865,7 @@ proc run_cc_link_tests { ldtests } { > global ar > global exec_output > global board_cflags > + global board_ldflags > global STATIC_LDFLAGS > > if [board_info [target_info name] exists cflags] { > @@ -866,6 +874,12 @@ proc run_cc_link_tests { ldtests } { > set board_cflags "" > } > > + if [board_info [target_info name] exists ldflags] { > + set board_ldflags " [board_info [target_info name] ldflags]" > + } else { > + set board_ldflags "" > + } > + > foreach testitem $ldtests { > set testname [lindex $testitem 0] > set ldflags [lindex $testitem 1] > @@ -968,11 +982,11 @@ proc run_cc_link_tests { ldtests } { > } > } else { > if { [string match "" $STATIC_LDFLAGS] \ > - && [regexp -- ".* \[-\]+static .*" " $board_cflags $ldflags $objfiles "] } { > + && [regexp -- ".* \[-\]+static .*" " $board_cflags $board_ldflags $ldflags $objfiles "] } { > untested $testname > continue > } > - ld_link $cc_cmd $binfile "$board_cflags -L$srcdir/$subdir $ldflags $objfiles" > + ld_link $cc_cmd $binfile "$board_cflags $board_ldflags -L$srcdir/$subdir $ldflags $objfiles" > set ld_output "$exec_output" > > if { $check_ld(source) == "regexp" } then {