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: 1891908 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=amdG1ckQ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TNF7C5vBKz23fD for ; Mon, 29 Jan 2024 02:03:35 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D00DD385840E for ; Sun, 28 Jan 2024 15:03:33 +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-Google-Smtp-Source: AGHT+IFXxm6d3TEex7fNxLq7C/K4Kzp0IMobBIG1dMU0B7HtNdjfjSOp7OyaVxdO9QmcTxfo/64kFg== 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+incoming=patchwork.ozlabs.org@gcc.gnu.org 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 " }