diff mbox

[RFA:] Fix test-suite regressions from PR62250 due to -latomic always added

Message ID 201501080232.t082WFaY030679@ignucius.se.axis.com
State New
Headers show

Commit Message

Hans-Peter Nilsson Jan. 8, 2015, 2:32 a.m. UTC
PR62250 (r219171) was about some fortran tests that used atomic
operations but failing on systems where -latomic is required.
The fix was to always add -latomic.  That caused test-suite
regressions for targets that don't have libatomic, but where the
required operations are built-in (no separate PR entered, the
fix below seemed simple enough).

Here's a fix to that issue, adding a target matcher usable for
individual tests (gfortran.dg/coarray_lib_comm_1.f90) as well as
the grouped tests in gfortran.dg/coarray/caf.exp.  If you
consider using this elsewhere (other languages), there's a
prerequisite that paths have been added to default linker
options to find libatomic; already covered by r219171.  I
considered tweaking that path-adding to instead make use of
lib/atomic-dg.exp, but stopped when noticing that atomic_init
would be required to be called in lib/gfortran.exp and would
always add -latomic and would split up the path-tweaking, doing
differently than the existing tweaking in lib/gfortran.exp.
Other issues likely.  (If there's instead a preference to
strongly depend on libatomic for fortran and forcing targets to
port it, there's some required top-level dependency configury
changes and/or needing to add -latomic to the defaults when
linking with "gfortran" and also I don't want that, seeing this
as the simpler, better fix.  Of course, that also means that the
user has to know to manually add -latomic for *some* fortran
codes for *some* systems.)

Tested to fix the issues for cris-elf (no libatomic, operations
built-in), not having any effect on native
x86_64-unknown-linux-gnu (has libatomic but operations also
built-in) and David says test is in progress for hppa*-*-hpux*
(the cause for PR62250; has libatomic, not all required built-in
operations).

Ok to commit?

(PR marking just to make this show up in the log trail of that
PR as a follow-up to the fix.)

gcc/testsuite:
	PR testsuite/62250
	* lib/target-supports.exp (check_effective_target_libatomic_available):
	New.
	* gfortran.dg/coarray/caf.exp: Only add -latomic for
	targets that match effective-target libatomic_available.
	* gfortran.dg/coarray_lib_comm_1.f90: Similar.


brgds, H-P

Comments

John David Anglin Jan. 8, 2015, 1:36 p.m. UTC | #1
On 2015-01-07, at 9:32 PM, Hans-Peter Nilsson wrote:

> gcc/testsuite:
> 	PR testsuite/62250
> 	* lib/target-supports.exp (check_effective_target_libatomic_available):
> 	New.
> 	* gfortran.dg/coarray/caf.exp: Only add -latomic for
> 	targets that match effective-target libatomic_available.
> 	* gfortran.dg/coarray_lib_comm_1.f90: Similar.

Works for me on hppa64-hp-hpux11.11.

Dave
--
John David Anglin	dave.anglin@bell.net
Mike Stump Jan. 8, 2015, 9:36 p.m. UTC | #2
On Jan 7, 2015, at 6:32 PM, Hans-Peter Nilsson <hans-peter.nilsson@axis.com> wrote:
> PR62250 (r219171) was about some fortran tests that used atomic
> operations but failing on systems where -latomic is required.
> The fix was to always add -latomic.  That caused test-suite
> regressions for targets that don't have libatomic, but where the
> required operations are built-in (no separate PR entered, the
> fix below seemed simple enough).

> Ok to commit?

Ok.
diff mbox

Patch

Index: lib/target-supports.exp
===================================================================
--- lib/target-supports.exp	(revision 219277)
+++ lib/target-supports.exp	(working copy)
@@ -1128,6 +1128,13 @@  proc check_libcilkrts_available { } {
 	} "-fcilkplus -lcilkrts" ]
 }
 
+# Return true if the atomic library is supported on the target.
+proc check_effective_target_libatomic_available { } {
+    return [check_no_compiler_messages libatomic_available executable {
+	int main (void) { return 0; }
+    } "-latomic"]
+}
+
 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
 
 proc check_ascii_locale_available { } {
Index: gfortran.dg/coarray/caf.exp
===================================================================
--- gfortran.dg/coarray/caf.exp	(revision 219277)
+++ gfortran.dg/coarray/caf.exp	(working copy)
@@ -58,6 +58,12 @@  proc dg-compile-aux-modules { args } {
     # cleanup-modules isn't intentionally invoked here.
 }
 
+# Add -latomic only where supported.  Assume built-in support elsewhere.
+set maybe_atomic_lib ""
+if [check_effective_target_libatomic_available] {
+    set maybe_atomic_lib "-latomic"
+}
+
 # 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.
@@ -81,14 +87,14 @@  foreach test [lsort [glob -nocomplain $s
     foreach flags $option_list {
 	verbose "Testing $nshort (single), $flags" 1
         set gfortran_aux_module_flags "-fcoarray=single $flags"
-	dg-test $test "-fcoarray=single $flags -latomic" "" 
+	dg-test $test "-fcoarray=single $flags $maybe_atomic_lib" "" 
 	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 -latomic" ""
+	dg-test $test "-fcoarray=lib $flags -lcaf_single $maybe_atomic_lib" ""
 	cleanup-modules ""
     }
 }
Index: gfortran.dg/coarray_lib_comm_1.f90
===================================================================
--- gfortran.dg/coarray_lib_comm_1.f90	(revision 219277)
+++ gfortran.dg/coarray_lib_comm_1.f90	(working copy)
@@ -1,5 +1,6 @@ 
 ! { dg-do run }
-! { dg-options "-fdump-tree-original -fcoarray=lib -lcaf_single -latomic" }
+! { dg-options "-fdump-tree-original -fcoarray=lib -lcaf_single -latomic" { target libatomic_available } }
+! { dg-options "-fdump-tree-original -fcoarray=lib -lcaf_single" { target { ! libatomic_available } } }
 !
 ! Some dependency-analysis check for coarray communication
 !