From patchwork Sun Jan 28 15:03:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Iain Sandoe X-Patchwork-Id: 193140 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp84885dyb; Sun, 28 Jan 2024 07:03:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IE4LYKISio/6MPk52w/ct0Kkv2Q3tExGCIkYuU4qORRj0fu1f5EA1I80VIeleLCST4KcdYV X-Received: by 2002:a05:6214:e61:b0:681:8349:5ac5 with SMTP id jz1-20020a0562140e6100b0068183495ac5mr3792428qvb.60.1706454239485; Sun, 28 Jan 2024 07:03:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706454239; cv=pass; d=google.com; s=arc-20160816; b=PFv6zq30TxBpnZpBxq7vzbvYlKba6QvKLMAm2z3GvG7fewuzEau0Hd70bXvVA70mDv zMWONGXYOYY29qVW4X4LMg03SmXjSNgSOSi10Rcf4GFH7hImLAOwUuvW4cvygQFHELBn suC39FUrnr+bxXZ/YOzmImgmuEmoaou0oggz8O4g69fIlYi+dwuIC5637xQ6p1xBXlHs 4CB4w3nydwuZGinxbmuYy7bwqtPY7GMPz8TjN4bB9OF9SSgtOz0brkd7A0GEdy56BhgI WbOa6GGz17YElGSPAkPnGTv8p4LqtozefLuIiKE5ehRkKkeuGsgJGs7zM0nbXnSNOHF8 xbrg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=6FY+jiY4FjlT0iT2rckIZCJ2qB2bSj/8WGBZ6mdmgB0=; fh=HpGyPhETBvl4zejgufl7c2nTNpZufIxjdWMis6jurMQ=; b=SoYjZPGKwwxxAebfApgt5EU71wVfsea0FMKOh9PCihYatgBRxxqMhiLrM4k2mAJzxT iSqjEM4aaecyp4HPDypu8xhvymE48n8EGZZEWu0t8LjavDTIl5X8pnA6V1OoRfiNQOzg aucWUgoW0Yy7mSpTMdkqsI0E/m0uaDP/yeDcJzv24zncHXYEuxJBHN+1DuAk5YR1YKW5 HDiMfFAQtw42OtSGNYtDR44jP+uWmMEsazQM35QG+NyfZRCqOAQbPFsWBq4r1BGB9eOF DUtVFfsmATpt1WenCUQ+0e/JWXXq+WAS/qg7lYKqN+WgwvQVEZHNY7da2NToqkcP7mnf +xzA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=amdG1ckQ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id o2-20020ad45c82000000b00682bfd26b08si6020472qvh.287.2024.01.28.07.03.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Jan 2024 07:03:59 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=amdG1ckQ; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2F72E3858407 for ; Sun, 28 Jan 2024 15:03:59 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id 566563858C39 for ; Sun, 28 Jan 2024 15:03:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 566563858C39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 566563858C39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::332 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706454195; cv=none; b=Q86Evb4PRx56Bn/E+jEOeCycYW6VkjCO/DRwLowqClBoflu2uah6ivjZAd7kNQQ4seTDr28YlOr/gWzBMBcl9Y4ovJsoLNh5nRh601cEW+eb3HWVlUTTztuX/FguPTenY5B15Qgb4zMmF41H1eDnpECue/tQUTRBeFC5IBIU2nI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706454195; c=relaxed/simple; bh=i+GCIT4LwEMJlP7U01M6aag15eVHrn2AhheJFy7BaFI=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=NywMjCJ3L9UjSVKLF+BOEoQFP58lcoSKF6XyeoT053XQpBeAhMBg1JeMQZQg4148dv5Q0ZOjVFfBlOzpj3G8kUXMJqGgu8ARGOnDuaNiS4ISCwU1Ojv0QIAMaQo+TjlCx4mjOg7PGBtCr1dg4sve4pEJARchl1ywvZI3EfnwcZs= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40ef6c471d5so1067265e9.0 for ; Sun, 28 Jan 2024 07:03:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706454190; x=1707058990; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=6FY+jiY4FjlT0iT2rckIZCJ2qB2bSj/8WGBZ6mdmgB0=; b=amdG1ckQw+sUiwKp36pHRvoxbhuahj7LggQgmOP2vvthadOsJS3FrCuAZvaV+StZtj j71Iypyz+F0kr5C1CY8RgimBQwQ6GGYs7QoMPSRcEBHpmFDu3XLJpMPP6xZCE+7iNhro tdjhAa+PmZlPpgGdzcyD3b0/GjeFB8STjGc+S5ih97BIMsWKKsJsF2WzTZ18nQBOupll pJSMhlNYC7+TSnPDjZpDlCPACOHG+cxw+l5K3AKr4lK8lUb2I2QvabiHSBHts57ga7VZ CHgB3JXP5HY9wBdPuvCx0iwlPEpys/SP3/+vZC31q+k8tqOyhQtLA38bZvbdlZOfjH4a 42DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706454190; x=1707058990; h=content-transfer-encoding:mime-version:reply-to:message-id:date :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=6FY+jiY4FjlT0iT2rckIZCJ2qB2bSj/8WGBZ6mdmgB0=; b=dITEnz+Oga4b6ypwl0miUD0Kwi/rudZucsxMZTw5YjJNHxqRxwjhMAAHSGkhpgcgga 4u14MA40unIKnC7ytIDkjlcI992arJnHg7cWZ8bRU9F1n4Lm861pF4Zb+YzHBPG3JllK lGA25nXrFLYKBUdK2p28heMwYZp1+CU6H9W1xJOBTNRAns8XY6eQZxUOaIab/ct7fT4U 9+EcyLaFW/xXkYJaT2nhGf1BYB2gjlacOzYvKQlv4zBJgP+vX0a7fTM6YlDnFHnNAOqR bLdovBZhQAGUm2agt6TUHnVFKFt3xJ2kPy62U2fMaZbffF1axx34XsMyQfAg9FUTFYk+ HL5A== X-Gm-Message-State: AOJu0YwrSfoGLnUc0eYKUsV/ugb2yKi9u87XC9teAXigLWpuguPMZfaJ wt6qm+X9qONGAEIyQmtzXMXZ3H9xeiTZ2DYETCtTK/5QkBBsCvpASBHHjWKu X-Received: by 2002:a05:600c:3585:b0:40e:d32f:8be1 with SMTP id p5-20020a05600c358500b0040ed32f8be1mr3083500wmq.4.1706454190051; Sun, 28 Jan 2024 07:03:10 -0800 (PST) Received: from localhost.localdomain (host81-138-1-83.in-addr.btopenworld.com. [81.138.1.83]) by smtp.gmail.com with ESMTPSA id d20-20020a05600c34d400b0040eeb025d8fsm5023310wmq.30.2024.01.28.07.03.09 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 28 Jan 2024 07:03:09 -0800 (PST) From: Iain Sandoe X-Google-Original-From: Iain Sandoe To: gcc-patches@gcc.gnu.org Cc: ro@CeBiTec.Uni-Bielefeld.DE Subject: [PATCH] testsuite, gfortan: Update link flags [PR112862]. Date: Sun, 28 Jan 2024 15:03:08 +0000 Message-Id: <20240128150308.21141-1-iain@sandoe.co.uk> X-Mailer: git-send-email 2.39.2 (Apple Git-143) MIME-Version: 1.0 X-Spam-Status: No, score=-8.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: iain@sandoe.co.uk Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789346960865255932 X-GMAIL-MSGID: 1789346960865255932 Tested on i686, x86_64, aarch64 Darwin, x86_64, aarch64 Linux, OK for trunk? thanks, Iain --- 8< --- The regressions here are caused by two issues: 1. In some cases there is no generated runpath for libatomic 2. In other cases there are duplicate paths. This patch simplifies the addition of the options in the main gfortran exp and removes the duplicates elewhere. We need to add options to locate libgfortran and the dependent libs libquadmath (supporting REAL*16) and libatomic (supporting operations used by coarrays). Usually '-L' options are added to point to the relevant directories for the uninstalled libraries. In cases where libraries are available as both shared and convenience some additional checks are made. For some targets -static-xxxx options are handled by specs substitution and need a '-B' option rather than '-L'. For Darwin, when embedded runpaths are in use (the default for all versions after macOS 10.11), '-B' is also needed to provide the runpath. When '-B' is used, this results in a '-L' for each path that exists (so that appending a '-L' as well is a needless duplicate). There are also cases where tools warn for duplicates, leading to spurious fails. PR target/112862 gcc/testsuite/ChangeLog: * gfortran.dg/coarray/caf.exp: Remove duplicate additions of libatomic handling. * gfortran.dg/dg.exp: Likewise. * lib/gfortran.exp: Decide on whether to present -B or -L to reference the paths to uninstalled libgfortran, libqadmath and libatomic and use that to generate the link flags. --- gcc/testsuite/gfortran.dg/coarray/caf.exp | 16 +---- gcc/testsuite/gfortran.dg/dg.exp | 20 ------- gcc/testsuite/lib/gfortran.exp | 73 +++++++++++++++-------- 3 files changed, 51 insertions(+), 58 deletions(-) diff --git a/gcc/testsuite/gfortran.dg/coarray/caf.exp b/gcc/testsuite/gfortran.dg/coarray/caf.exp index dae46bd92fa..31c13cd34e5 100644 --- a/gcc/testsuite/gfortran.dg/coarray/caf.exp +++ b/gcc/testsuite/gfortran.dg/coarray/caf.exp @@ -70,18 +70,6 @@ proc dg-compile-aux-modules { args } { } } -# Add -latomic only where supported. Assume built-in support elsewhere. -set maybe_atomic_lib "" -if [check_effective_target_libatomic_available] { - if ![is_remote host] { - if [info exists TOOL_OPTIONS] { - set maybe_atomic_lib "[atomic_link_flags [get_multilibs ${TOOL_OPTIONS}]]" - } else { - set maybe_atomic_lib "[atomic_link_flags [get_multilibs]]" - } - } -} - # Main loop. foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ]] { # If we're only testing specific files and this isn't one of them, skip it. @@ -105,14 +93,14 @@ foreach test [lsort [glob -nocomplain $srcdir/$subdir/*.\[fF\]{,90,95,03,08} ]] foreach flags $option_list { verbose "Testing $nshort (single), $flags" 1 set gfortran_aux_module_flags "-fcoarray=single $flags" - dg-test $test "-fcoarray=single $flags" $maybe_atomic_lib + dg-test $test "-fcoarray=single $flags" {} cleanup-modules "" } foreach flags $option_list { verbose "Testing $nshort (libcaf_single), $flags" 1 set gfortran_aux_module_flags "-fcoarray=lib $flags -lcaf_single" - dg-test $test "-fcoarray=lib $flags -lcaf_single" $maybe_atomic_lib + dg-test $test "-fcoarray=lib $flags -lcaf_single" {} cleanup-modules "" } } diff --git a/gcc/testsuite/gfortran.dg/dg.exp b/gcc/testsuite/gfortran.dg/dg.exp index f936fd38644..7a9cb89c194 100644 --- a/gcc/testsuite/gfortran.dg/dg.exp +++ b/gcc/testsuite/gfortran.dg/dg.exp @@ -54,27 +54,7 @@ proc dg-compile-aux-modules { args } { } } -# coarray tests might need libatomic. Assume that it is either not needed or -# provided by builtins if it's not available. -set maybe_atomic_lib "" -if [check_effective_target_libatomic_available] { - if ![is_remote host] { - if [info exists TOOL_OPTIONS] { - set maybe_atomic_lib "[atomic_link_flags [get_multilibs ${TOOL_OPTIONS}]]" - } else { - set maybe_atomic_lib "[atomic_link_flags [get_multilibs]]" - } - } else { - set maybe_atomic_lib "" - } -} - set all_flags $DEFAULT_FFLAGS -if { $maybe_atomic_lib != "" } { - foreach f $maybe_atomic_lib { - lappend all_flags $f - } -} # Main loop. gfortran-dg-runtest [lsort \ diff --git a/gcc/testsuite/lib/gfortran.exp b/gcc/testsuite/lib/gfortran.exp index c3e258b410b..1ccb81ccec5 100644 --- a/gcc/testsuite/lib/gfortran.exp +++ b/gcc/testsuite/lib/gfortran.exp @@ -79,6 +79,7 @@ proc gfortran_link_flags { paths } { global ld_library_path global GFORTRAN_UNDER_TEST global shlib_ext + global ENABLE_DARWIN_AT_RPATH set gccpath ${paths} set libio_dir "" @@ -87,39 +88,63 @@ proc gfortran_link_flags { paths } { set shlib_ext [get_shlib_extension] verbose "shared lib extension: $shlib_ext" + # We need to add options to locate libgfortran and the dependent libs + # libquadmath (supporting REAL*16) and libatomic (supporting operations + # used by coarrays). Usually '-L' options are added to point to the + # relevant directories for the uninstalled libraries. + + # In cases where libraries are available as both shared and convenience + # some additional checks are made. + + # For some targets -static-xxxx options are handled by specs substitution + # and need a '-B' option rather than '-L'. For Darwin, when embedded + # runpaths are in use (the default for all versions after macOS 10.11), + # '-B' is also needed to provide the runpath. + # When '-B' is used, this results in a '-L' for each path that exists (so + # that appending a '-L' as well is a needless duplicate). There are also + # cases where tools warn for duplicates, leading to spurious fails. + # Therefore the objective of the code below is to add just one '-L' or + # '-B' for each of the libraries. + + set target_wants_B_option 0 + if { [istarget *-*-darwin9* ] || [istarget *-*-darwin\[12\]* ] } { + set target_wants_B_option 1 + } + if { $gccpath != "" } { - if [file exists "${gccpath}/libgfortran/.libs/libgfortran.a"] { - # Some targets use libgfortran.a%s in their specs, so they need a -B option - # for uninstalled testing. - append flags "-B${gccpath}/libgfortran/.libs " - append flags "-L${gccpath}/libgfortran/.libs " - append ld_library_path ":${gccpath}/libgfortran/.libs" - } - if [file exists "${gccpath}/libgfortran/.libs/libgfortran.${shlib_ext}"] { - append flags "-L${gccpath}/libgfortran/.libs " - append ld_library_path ":${gccpath}/libgfortran/.libs" - } if [file exists "${gccpath}/libgfortran/libgforbegin.a"] { append flags "-L${gccpath}/libgfortran " } - if [file exists "${gccpath}/libatomic/.libs/libatomic.${shlib_ext}"] { - append flags "-L${gccpath}/libatomic/.libs " - append ld_library_path ":${gccpath}/libatomic/.libs" + if { [file exists "${gccpath}/libgfortran/.libs/libgfortran.a"] || + [file exists "${gccpath}/libgfortran/.libs/libgfortran.${shlib_ext}"] } { + if { $target_wants_B_option } { + append flags "-B${gccpath}/libgfortran/.libs " + } else { + append flags "-L${gccpath}/libgfortran/.libs " + } + append ld_library_path ":${gccpath}/libgfortran/.libs" } - if [file exists "${gccpath}/libatomic/libatomic.a"] { - append flags "-L${gccpath}/libatomic " + + if { [file exists "${gccpath}/libatomic/.libs/libatomic.a"] || + [file exists "${gccpath}/libatomic/.libs/libatomic.${shlib_ext}"] } { + if { $target_wants_B_option } { + append flags "-B${gccpath}/libatomic/.libs " + } else { + append flags "-L${gccpath}/libatomic/.libs " + } + append ld_library_path ":${gccpath}/libatomic/.libs" } - if [file exists "${gccpath}/libquadmath/.libs/libquadmath.a"] { - # Some targets use libquadmath.a%s in their specs, so they need a -B option - # for uninstalled testing. + + if { [file exists "${gccpath}/libquadmath/.libs/libquadmath.a"] || + [file exists "${gccpath}/libquadmath/.libs/libquadmath.${shlib_ext}"] } { + if { $target_wants_B_option } { append flags "-B${gccpath}/libquadmath/.libs " + } else { append flags "-L${gccpath}/libquadmath/.libs " - append ld_library_path ":${gccpath}/libquadmath/.libs" - } - if [file exists "${gccpath}/libquadmath/.libs/libquadmath.${shlib_ext}"] { - append flags "-L${gccpath}/libquadmath/.libs " - append ld_library_path ":${gccpath}/libquadmath/.libs" + } + append ld_library_path ":${gccpath}/libquadmath/.libs" } + if [file exists "${gccpath}/libiberty/libiberty.a"] { append flags "-L${gccpath}/libiberty " }