diff options
author | Christophe Lyon <christophe.lyon@linaro.org> | 2023-09-08 10:22:13 +0000 |
---|---|---|
committer | Christophe Lyon <christophe.lyon@linaro.org> | 2023-11-06 16:43:56 +0000 |
commit | 470b001c4a454a954d05740448e5d2a61a3679cd (patch) | |
tree | 79c583359804dfc32c3255cc1b6767efafbe7b8e /gcc | |
parent | e15dd9a04814af45a66ae4114aa16b1c11aae2ec (diff) | |
download | gcc-470b001c4a454a954d05740448e5d2a61a3679cd.zip gcc-470b001c4a454a954d05740448e5d2a61a3679cd.tar.gz gcc-470b001c4a454a954d05740448e5d2a61a3679cd.tar.bz2 |
testsuite: Add and use thread_fence effective-target
Some targets like arm-eabi with newlib and default settings rely on
__sync_synchronize() to ensure synchronization. Newlib does not
implement it by default, to make users aware they have to take special
care.
This makes a few tests fail to link.
This patch adds a new thread_fence effective target (similar to the
corresponding one in libstdc++ testsuite), and uses it in the tests
that need it, making them UNSUPPORTED instead of FAIL and UNRESOLVED.
2023-09-10 Christophe Lyon <christophe.lyon@linaro.org>
gcc/
* doc/sourcebuild.texi (Other attributes): Document thread_fence
effective-target.
gcc/testsuite/
* g++.dg/init/array54.C: Require thread_fence.
* gcc.dg/c2x-nullptr-1.c: Likewise.
* gcc.dg/pr103721-2.c: Likewise.
* lib/target-supports.exp (check_effective_target_thread_fence):
New.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/doc/sourcebuild.texi | 4 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/init/array54.C | 1 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/c2x-nullptr-1.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr103721-2.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/lib/target-supports.exp | 12 |
5 files changed, 19 insertions, 0 deletions
diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index c20af31..c8611a0 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2875,6 +2875,10 @@ Compiler has been configured to support link-time optimization (LTO). Compiler and linker support link-time optimization relocatable linking with @option{-r} and @option{-flto} options. +@item thread_fence +Target implements @code{__atomic_thread_fence} without relying on +non-implemented @code{__sync_synchronize()}. + @item naked_functions Target supports the @code{naked} function attribute. diff --git a/gcc/testsuite/g++.dg/init/array54.C b/gcc/testsuite/g++.dg/init/array54.C index f6be350..5241e45 100644 --- a/gcc/testsuite/g++.dg/init/array54.C +++ b/gcc/testsuite/g++.dg/init/array54.C @@ -1,5 +1,6 @@ // PR c++/90947 // { dg-do run { target c++11 } } +// { dg-require-effective-target thread_fence } #include <atomic> diff --git a/gcc/testsuite/gcc.dg/c2x-nullptr-1.c b/gcc/testsuite/gcc.dg/c2x-nullptr-1.c index 4e44023..97a31c2 100644 --- a/gcc/testsuite/gcc.dg/c2x-nullptr-1.c +++ b/gcc/testsuite/gcc.dg/c2x-nullptr-1.c @@ -1,5 +1,6 @@ /* Test valid usage of C23 nullptr. */ /* { dg-do run } */ +// { dg-require-effective-target thread_fence } /* { dg-options "-std=c2x -pedantic-errors -Wall -Wextra -Wno-unused-variable" } */ #include <stdarg.h> diff --git a/gcc/testsuite/gcc.dg/pr103721-2.c b/gcc/testsuite/gcc.dg/pr103721-2.c index aefa1f0..e059b1c 100644 --- a/gcc/testsuite/gcc.dg/pr103721-2.c +++ b/gcc/testsuite/gcc.dg/pr103721-2.c @@ -1,4 +1,5 @@ // { dg-do run } +// { dg-require-effective-target thread_fence } // { dg-options "-O2" } extern void abort (); diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index 024939e..17a87db 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -9514,6 +9514,18 @@ proc check_effective_target_sync_char_short { } { || [check_effective_target_mips_llsc] }}] } +# Return 1 if thread_fence does not rely on __sync_synchronize +# library function + +proc check_effective_target_thread_fence {} { + return [check_no_compiler_messages thread_fence executable { + int main () { + __atomic_thread_fence (__ATOMIC_SEQ_CST); + return 0; + } + } ""] +} + # Return 1 if the target uses a ColdFire FPU. proc check_effective_target_coldfire_fpu { } { |