From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from moene.org (84-86-97-173.fixed.kpn.net [84.86.97.173]) by sourceware.org (Postfix) with ESMTPS id 12CC63858D20 for ; Sun, 28 Jan 2024 15:22:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 12CC63858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=moene.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=moene.org ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 12CC63858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=84.86.97.173 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706455359; cv=none; b=foPrIMY9x+UO9dLQOdPqwNCAI3Ium/nBD5fYJizIQ5E/pEbsjSdY2DCt9Y5jyLDTeNyOqKE2MfjH9izTVxhtgT2dlhsmSqRDWo6UfkoobSUBNY30OPEvdbXTXzLgYpcNv0iC3HJP+4+YWo61mVey/Uciwn3bMqysDOtZYvf7E0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706455359; c=relaxed/simple; bh=ecwDiY+cV0Gh8FWz75kutLUqd6YmVivhYj41BjPkxzQ=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=q7WGOZNg858jJde485UNYR4IuPN8Z2nTdmjvy/2m21i1Vxo6mpJM0Npimd67JKpncMDUCcmwz8kk7b0pUIABA8+y9kekczCLVWOfjATeeTLcY8i65VP0EF+nhMtqIC6ZL/bRE5dddS4fhUqf7f9K2fmy8MqoA+AR/X9DsBlms3g= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=moene.org; s=key; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:From:To: References:Subject:MIME-Version:Date:Message-ID:Sender:Reply-To:Cc:Content-ID :Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To: Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe :List-Post:List-Owner:List-Archive; bh=6/B9C7pl8YTHDjSdUm0zii2Lxi/T8NzW1Sqtnx3p9yk=; b=QpWtYNMvYz65GnQcuQdr0onYwY 557rptWeeBfvVpOyiqITQw98mMdjMgoBa9n01aDur0leMgxw7KhaD0nrg4UEQAwAlTQyuWsKLEDDD jjdJAZUKLgWj7DP55LZKbDeOQMgd+ljAbC3mS/Eh1lBaM9M32NZCo/xPimtZy50hbXetGmVG3h6pi i6t42TGTQUCJjQBgUGbEAvRu9Y1jY3WA/VFKCdUNwHPLk/KHz7tV/MNERcZ9G9wHoy+Th5TSgW6Wf kEFXeTT7MyYGDvIeEE8Ni2zW+Ze52eDs4dhGpzYXGOmZCeEGQlXlshT4WW6eZ2VTDZpj4zQV9eOd2 rl8R7mUQ==; Received: from localhost ([127.0.0.1]) by moene.org with esmtp (Exim 4.97) (envelope-from ) id 1rU6zT-00000003Ief-3ZIe for fortran@gcc.gnu.org; Sun, 28 Jan 2024 16:22:35 +0100 Message-ID: Date: Sun, 28 Jan 2024 16:22:35 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Fwd: [PATCH] testsuite, gfortan: Update link flags [PR112862]. References: <20240128150308.21141-1-iain@sandoe.co.uk> Content-Language: en-US To: gfortran From: Toon Moene Organization: Moene Computational Physics, Maartensdijk, The Netherlands In-Reply-To: <20240128150308.21141-1-iain@sandoe.co.uk> X-Forwarded-Message-Id: <20240128150308.21141-1-iain@sandoe.co.uk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_NONE,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 List-Id: -------- Forwarded Message -------- Subject: [PATCH] testsuite, gfortan: Update link flags [PR112862]. Date: Sun, 28 Jan 2024 15:03:08 +0000 From: Iain Sandoe Reply-To: iain@sandoe.co.uk To: gcc-patches@gcc.gnu.org CC: ro@CeBiTec.Uni-Bielefeld.DE 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 " } -- 2.39.2 (Apple Git-143)