From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1135.google.com (mail-yw1-x1135.google.com [IPv6:2607:f8b0:4864:20::1135]) by sourceware.org (Postfix) with ESMTPS id 5AB99385802B for ; Thu, 13 Oct 2022 12:06:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 5AB99385802B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-345528ceb87so15205297b3.11 for ; Thu, 13 Oct 2022 05:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=7LBNaHYLaPy/Uzy6VVcprxliVVQxxjxMu/tCAdvpcJ8=; b=gtVeWS6V2WKLwnEHjIrdO81imopB4EjCzQjuFa2K44cZdWO22WuEG9L8zrFhDNbLB2 Goxhhk29rGWbfHci3FwYRhSHBbED2HtsVwF8J2tMo1D1uuCdKOFk+Bk+2xOIqe7a5Cdu Gos8SjgvCqbe3jJ8OQ2YkDjUUxO64APjHecNeSQTv/sDObSUuOyBZIU7J/tyQX5mhsry S21u/ccp/hlwmylYk0gSPLT5BKlxHyAtv9j8kgF0GSlNVDpoIPMMIF8noJXRVNq4ep4R T4yS6RcbV/wgu3LEgfDE4SUy9/Xvkt0OKM+LGu+c6+M8cXBGbeFimwe6rKEZ8sc5LtSe k0RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7LBNaHYLaPy/Uzy6VVcprxliVVQxxjxMu/tCAdvpcJ8=; b=WyyyxjdLUqFuqmEhWu4IIQbkrYXUbm1SPZO0gZ4FS5hSMd9SjgMoj6pwexoiyxWzdE PS2wHJ/icTTiwuZw/VHApyT4plH5qtO3TC/3lgPfZh5CvO+khRYW7HVnFT+5Vg57swgH 7xHs9nJcIGeNDVsdB+QYeF5sTQ0xUpHT0mk86LWBj6nWQhPvdyfFryzsr3elGzwQAe64 0ni4uoICDUDokmQ/5LSKz6KZst4q9NkK449NPkTpxWO3+LM/n/ld80EA96DlyAwG3/2S WCmw/NlR5SdmcUuj4kKpICLNY3wyixgj0U8akyJAbbo6p9FAiWD3mVHlzhPfYKdriDZt ReFQ== X-Gm-Message-State: ACrzQf1EfiO7+etO57qT9I4THMYMbvxnBXUTtISx3FUgX77bJfC88YKx HBfDD0iycBCFc1aqB849UlhsgckRXZ/KpHWP8Do8tUl7Y9R5Qg== X-Google-Smtp-Source: AMsMyM6V2atEKHv9SNKgcDfO+J4XjXIjjdpZvVz8q6wDjwnzEvzGkc/280vQp+MsdRByI7wzbhLqgkmxacY8gaEgA14= X-Received: by 2002:a81:2513:0:b0:350:5c50:3d9e with SMTP id l19-20020a812513000000b003505c503d9emr32637774ywl.454.1665662765490; Thu, 13 Oct 2022 05:06:05 -0700 (PDT) MIME-Version: 1.0 References: <20220930140503.38233-1-chigot@adacore.com> In-Reply-To: <20220930140503.38233-1-chigot@adacore.com> From: =?UTF-8?Q?Cl=C3=A9ment_Chigot?= Date: Thu, 13 Oct 2022 14:05:53 +0200 Message-ID: Subject: Re: [PATCH] ld/testsuite: consistently add board_ldflags when linking with GCC To: binutils@sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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: Gentle ping Thanks, Cl=C3=A9ment On Fri, Sep 30, 2022 at 4:05 PM Cl=C3=A9ment Chigot wr= ote: > > 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(-) > > diff --git a/ld/testsuite/ld-unique/unique.exp b/ld/testsuite/ld-unique/u= nique.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/uniqu= e_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 cfla= gs 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_o= ptions $objfiles $ld_after "] } { > + && [regexp -- ".* \[-\]+static .*" " $board_cflags $boar= d_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_ldfl= ags -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 $ldfl= ags $objfiles "] } { > + && [regexp -- ".* \[-\]+static .*" " $board_cflags $boar= d_ldflags $ldflags $objfiles "] } { > untested $testname > continue > } > - ld_link $cc_cmd $binfile "$board_cflags -L$srcdir/$subdir $ld= flags $objfiles" > + ld_link $cc_cmd $binfile "$board_cflags $board_ldflags -L$src= dir/$subdir $ldflags $objfiles" > set ld_output "$exec_output" > > if { $check_ld(source) =3D=3D "regexp" } then { > -- > 2.25.1 >