public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8732] testsuite, gfortran: Update link flags [PR112862].
@ 2024-02-02  9:01 Iain D Sandoe
  0 siblings, 0 replies; only message in thread
From: Iain D Sandoe @ 2024-02-02  9:01 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e439c7827f5c5723fdd7df9c5fac55319db204af

commit r14-8732-ge439c7827f5c5723fdd7df9c5fac55319db204af
Author: Iain Sandoe <iain@sandoe.co.uk>
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 "
       }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-02  9:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-02  9:01 [gcc r14-8732] testsuite, gfortran: Update link flags [PR112862] Iain D Sandoe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).