From patchwork Fri Sep 30 14:05:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Cl=C3=A9ment_Chigot?= X-Patchwork-Id: 1596 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp503952wrs; Fri, 30 Sep 2022 07:05:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7pc9wg//BpM4PkiEBmdwqmuYrcVH26Fv5ayefACfZH4FuGy1hX0eWH+xWgNSoTc8UBlWeg X-Received: by 2002:a17:907:b04:b0:780:32ea:4fe with SMTP id h4-20020a1709070b0400b0078032ea04femr6556047ejl.452.1664546731550; Fri, 30 Sep 2022 07:05:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664546731; cv=none; d=google.com; s=arc-20160816; b=GZKOSyJMcoD+6TSf7+P26XBz8Uf4oVjhdVYE9Xus6L51hh4KEZlQ4IKvNF3uF1kmvR EHXucrfNyjTEjIJWuzW/cMt6XD9qvVW2oCRjIWhBEH4puHRDxKHs+wjz+UmcT7e8dVxz 0FyEJr2h7X3uMDq/zlY6AIUV7Er4gBWBg40PU3FDZb3zG8t2rMmK6oeow2UnF+OyxT11 cv4tXNVp+RLaALSe933rCte4Cto7aDZ3s5EZ5uyUb34yGQ841ju8hoekmTjIIe5xwQXv st1KVouaAL4EygzJsPRSIh14hhjjsd5j9uCycwDhTSwAtjlOrD0DW5ePBT6WMfdV9RkX yjMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=LwvDBpBZX8MtGm5/OuPvpzp2+h16pyqv5ydmUSu5KoU=; b=vI6PBT5BIMzc0Be1oFJUXYOPPloI5Qy0xMY7lfSKpiB5dYVwr67jVG3eFA4HHfmlfP zm+uZhuc0OCDEVHvaEpMgnlYWYiYxpYtkWa68Nn4td7qOWVCecP7EfEI68ZN0bhQ4GbA ZjmIuf1+PLDzyl9wETIcndOqCQu63B4jtgs/dgiWOggCqzYebxp4UlCoFjA0Qi8ITAJx 7NmphSxSmwaIQ8vQaRy03ngFD/RjiXoTCZl8chIl0lCyJuo1Lj95ncffEZBi7eX9SN43 QXQdXRKW/AERK1FA2cZ/sVCVNXVbvKZdhM5OvrjCgor9FyvIGMhw2jqMlC/amYnrcn1h HDGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=FocvzqEe; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r20-20020a05640251d400b00456e80df51dsi2348456edd.113.2022.09.30.07.05.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 07:05:31 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=FocvzqEe; spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CD0D53854143 for ; Fri, 30 Sep 2022 14:05:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD0D53854143 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1664546727; bh=LwvDBpBZX8MtGm5/OuPvpzp2+h16pyqv5ydmUSu5KoU=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=FocvzqEe/seGcll3rhAv4dr1oEQmPpQcIJ/BkGBGlmlO/9Oq9C7caFRqnmx4dvp0p 7GRSkRUOmoMBYtbIDzbsSvGIE6XCCIG3sJmyT4AXOQsPjXOBfBNGnElOHs5l3CsgOQ MXc7F5WzdqcmHCxaieHqOxQYFeBILHANIiASsybA= X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by sourceware.org (Postfix) with ESMTPS id 1360B3858D1E for ; Fri, 30 Sep 2022 14:05:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1360B3858D1E Received: by mail-wm1-x335.google.com with SMTP id ay7-20020a05600c1e0700b003b49861bf48so4995851wmb.0 for ; Fri, 30 Sep 2022 07:05:17 -0700 (PDT) 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:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date; bh=LwvDBpBZX8MtGm5/OuPvpzp2+h16pyqv5ydmUSu5KoU=; b=veSnsdDP/t+I+DfgO8lY7vYmnFO2E54H/YXZhUwFxquPODtQw4qDcIWG6Fp5SA2inT 3PzkiqL2A9xukRRwIj3y/Oh2qes+xRhNPnA8kH9EXvWIeJzp8GMpHmdbFcLCZsItF4t7 MQMZ8rR9oewF9r0Pf0bZTgucFeK/PKtsR8JN929RI8OEEQ00gG7vXQA3xo6JFph19NMI T11A+tcNL8hqdLdKHL87DZkTwmLVuvGMnUnHooiOOGWBAT18bemrFpGRcFqKDS3mQuLC GOi/gsR1AYyhjh4uXKEsWjGsPgCEHyvIUIvnglJN/LqMNqOk1yTYWDCUBwcBsUIO6YJZ /vfQ== X-Gm-Message-State: ACrzQf3+yYuDe/IcHpiDEKierFdZov+Cb2N3NLyqDei8D65YTZEvfsbc DK4vdX03xbUAAKusMxanQ23wLnIChsprrQ== X-Received: by 2002:a05:600c:354c:b0:3b4:a328:1412 with SMTP id i12-20020a05600c354c00b003b4a3281412mr13770885wmq.145.1664546715217; Fri, 30 Sep 2022 07:05:15 -0700 (PDT) Received: from chigot-Dell.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id e4-20020adfef04000000b0022cdb2950c9sm2118844wro.12.2022.09.30.07.05.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Sep 2022 07:05:14 -0700 (PDT) To: binutils@sourceware.org Subject: [PATCH] ld/testsuite: consistently add board_ldflags when linking with GCC Date: Fri, 30 Sep 2022 16:05:03 +0200 Message-Id: <20220930140503.38233-1-chigot@adacore.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 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 X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Cl=C3=A9ment_Chigot_via_Binutils?= From: =?utf-8?q?Cl=C3=A9ment_Chigot?= Reply-To: =?utf-8?q?Cl=C3=A9ment_Chigot?= Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org Sender: "Binutils" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1745403753907729378?= X-GMAIL-MSGID: =?utf-8?q?1745403753907729378?= 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/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 {