libatomic is disabled on vxworks because it's part of libc, and not very granular there, so a separately-built libatomic often triggers link errors over duplicate definitions.
So, don't link with -latomic, but keep atomic tests enabled. Unfortunately, some fence and flag primitives that are declared as functions and then defined as macros are not defined as functions in libc, so the tests for non-macro calls fail. Expect those failures. Tested with gcc-14 targeting ppc-vx7r2 and ppc64-vx7r2. Also tested with trunk on ppc64le-linux-gnu, and with gcc-14 targeting powerpc-elf. Ok to install? for gcc/testsuite/ChangeLog * gcc.dg/atomic/stdatomic-fence-2.c: Xfail on vxworks. * gcc.dg/atomic/stdatomic-flag-2.c: Likewise. * lib/atomic-dg.exp (atomic_init): Don't add -latomic on vxworks. --- gcc/testsuite/gcc.dg/atomic/stdatomic-fence-2.c | 1 + gcc/testsuite/gcc.dg/atomic/stdatomic-flag-2.c | 1 + gcc/testsuite/lib/atomic-dg.exp | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/atomic/stdatomic-fence-2.c b/gcc/testsuite/gcc.dg/atomic/stdatomic-fence-2.c index 6916e89576c37..44d3c33dd50bc 100644 --- a/gcc/testsuite/gcc.dg/atomic/stdatomic-fence-2.c +++ b/gcc/testsuite/gcc.dg/atomic/stdatomic-fence-2.c @@ -1,6 +1,7 @@ /* Test atomic_*_fence routines for existence and execution with each valid memory model. Out-of-line function calls. */ /* { dg-do run } */ +/* { dg-do-if compile { target *-*-vxworks* } } */ /* { dg-options "-std=c11 -pedantic-errors" } */ #include <stdatomic.h> diff --git a/gcc/testsuite/gcc.dg/atomic/stdatomic-flag-2.c b/gcc/testsuite/gcc.dg/atomic/stdatomic-flag-2.c index e4e3a6ef33d79..b74a54e959183 100644 --- a/gcc/testsuite/gcc.dg/atomic/stdatomic-flag-2.c +++ b/gcc/testsuite/gcc.dg/atomic/stdatomic-flag-2.c @@ -2,6 +2,7 @@ function calls. */ /* The test needs a lockless atomic implementation. */ /* { dg-do run } */ +/* { dg-do-if compile { target *-*-vxworks* } } */ /* { dg-options "-std=c11 -pedantic-errors" } */ #include <stdatomic.h> diff --git a/gcc/testsuite/lib/atomic-dg.exp b/gcc/testsuite/lib/atomic-dg.exp index 83b225a4d3cc3..b47282c505875 100644 --- a/gcc/testsuite/lib/atomic-dg.exp +++ b/gcc/testsuite/lib/atomic-dg.exp @@ -71,7 +71,11 @@ proc atomic_init { args } { } } - append link_flags " -latomic " + if { [istarget *-*-vxworks*] } { + # vxworks provides libatomic as part of libc. + } else { + append link_flags " -latomic " + } if [info exists TEST_ALWAYS_FLAGS] { set atomic_saved_TEST_ALWAYS_FLAGS $TEST_ALWAYS_FLAGS -- Alexandre Oliva, happy hacker https://blog.lx.oliva.nom.br/ Free Software Activist FSFLA co-founder GNU Toolchain Engineer More tolerance and less prejudice are key for inclusion and diversity. Excluding neuro-others for not behaving ""normal"" is *not* inclusive!