===================================================================
@@ -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 { } {
===================================================================
@@ -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 ""
}
}
===================================================================
@@ -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
!