From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1698) id B26FB3858022; Fri, 2 Feb 2024 09:01:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B26FB3858022 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706864470; bh=8b0ArSPGm2Xg6s3lvPMOQptE2LGb+18BZxO1SVy62EE=; h=From:To:Subject:Date:From; b=niy6U2F7bYwE6JwD1sABN+Owr49HVu9DAVVuJlHKnouKjjTb1Afq1RPOWpTz9GaP5 2pmq8p0Ap69jWaV9OAZLqvxsW49Ru2jsGVm+i5+z69rZG3zrc5WxQLEz6Qqpg2tAL5 J/6J/ZseEyj1VFRS6dswnVNH2gYDcXdo2hY+19bw= MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="utf-8" From: Iain D Sandoe To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8732] testsuite, gfortran: Update link flags [PR112862]. X-Act-Checkin: gcc X-Git-Author: Iain Sandoe X-Git-Refname: refs/heads/master X-Git-Oldrev: 74489c19070703361acc20bc172f304cae845a96 X-Git-Newrev: e439c7827f5c5723fdd7df9c5fac55319db204af Message-Id: <20240202090110.B26FB3858022@sourceware.org> Date: Fri, 2 Feb 2024 09:01:10 +0000 (GMT) List-Id: https://gcc.gnu.org/g:e439c7827f5c5723fdd7df9c5fac55319db204af commit r14-8732-ge439c7827f5c5723fdd7df9c5fac55319db204af Author: Iain Sandoe Date: Wed Jan 24 08:05:30 2024 +0000 testsuite, gfortran: Update link flags [PR112862]. 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. Diff: --- 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 dae46bd92fad..31c13cd34e5e 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 f936fd386442..7a9cb89c1949 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 c3e258b410b9..1ccb81ccec5a 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 " }