diff mbox series

libstdc++: testsuite: Skip atomics test if there's no -latomic

Message ID 20240618182201.3518098-1-thiago.bauermann@linaro.org
State New
Headers show
Series libstdc++: testsuite: Skip atomics test if there's no -latomic | expand

Commit Message

Thiago Jung Bauermann June 18, 2024, 6:22 p.m. UTC
On arm-none-eabi, 29_atomics/atomic_float/compare_exchange_padding.cc
fails to build:

FAIL: 29_atomics/atomic_float/compare_exchange_padding.cc  -std=gnu++20 (test for excess errors)
Excess errors:
/home/bauermann/.cache/builds/combined-tree-thumb-m55-hard-eabi/ld/.libs/ld-new: cannot find -latomic: No such file or directory
collect2: error: ld returned 1 exit status

UNRESOLVED: 29_atomics/atomic_float/compare_exchange_padding.cc  -std=gnu++20 compilation failed to produce executable

This test should be skipped if libatomic is not available for the
target.  To that end, add dg-require-libatomic-available and use it in
29_atomics/atomic_float/compare_exchange_padding.cc.

Also, check_effective_target_libatomic_available is fixed to use
atomic_link_flags to properly compile the test executable.

Tested on:
- Host x86_64-linux-gnu, target arm-unknown-eabi
- Native aarch64-linux-gnu
- Native x86_64-linux-gnu

gcc/testsuite/
	* lib/target-supports-dg.exp (dg-require-libatomic-available):
	New procedure.
	* lib/target-supports.exp (check_effective_target_libatomic_available):
	Use atomic_link_flags.

libstdc++-v3/
	* testsuite/29_atomics/atomic_float/compare_exchange_padding.cc:
	Use dg-require-libatomic-available.
---
 gcc/testsuite/lib/target-supports-dg.exp                 | 9 +++++++++
 gcc/testsuite/lib/target-supports.exp                    | 2 +-
 .../29_atomics/atomic_float/compare_exchange_padding.cc  | 1 +
 3 files changed, 11 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/gcc/testsuite/lib/target-supports-dg.exp b/gcc/testsuite/lib/target-supports-dg.exp
index 6dce9fdc1ce2..502e4e22b368 100644
--- a/gcc/testsuite/lib/target-supports-dg.exp
+++ b/gcc/testsuite/lib/target-supports-dg.exp
@@ -698,3 +698,12 @@  proc dg-require-prog-name-available { args } {
     }
 }
 
+# If the atomic library is supported on this target, skip this test.
+
+proc dg-require-libatomic-available { args } {
+    set libatomic_available [check_effective_target_libatomic_available]
+    if { $libatomic_available == 0 } {
+	upvar dg-do-what dg-do-what
+	set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
+    }
+}
diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp
index e307f4e69efb..de27297c1787 100644
--- a/gcc/testsuite/lib/target-supports.exp
+++ b/gcc/testsuite/lib/target-supports.exp
@@ -1662,7 +1662,7 @@  proc check_iconv_available { test_what } {
 proc check_effective_target_libatomic_available { } {
     return [check_no_compiler_messages libatomic_available executable {
 	int main (void) { return 0; }
-    } "-latomic"]
+    } "[atomic_link_flags [get_multilibs]] -latomic"]
 }
 
 # Return 1 if an ASCII locale is supported on this host, 0 otherwise.
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_float/compare_exchange_padding.cc b/libstdc++-v3/testsuite/29_atomics/atomic_float/compare_exchange_padding.cc
index 49626ac66511..351244b25279 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic_float/compare_exchange_padding.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_float/compare_exchange_padding.cc
@@ -1,4 +1,5 @@ 
 // { dg-do run { target c++20 } }
+// { dg-require-libatomic-available "" }
 // { dg-options "-O0" }
 // { dg-additional-options "[atomic_link_flags [get_multilibs]] -latomic" }