https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118977

            Bug ID: 118977
           Summary: m68k mcf5282 undefined symbol __atomic_test_and_set
                    from atomic_base.h
           Product: gcc
           Version: 14.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: joel at gcc dot gnu.org
  Target Milestone: ---

Target m68k-rtems but likely repeatable on m68k-elf

GCC version: 
m68k-rtems7-gcc (GCC) 14.2.0 20240801 (RTEMS 7, RSB
d5d9d1a4470134ea9292514c43d6a57402564578-modified, Newlib 1b3dcfd)

This is the error from compiling and linking an RTEMS C++ test that targets
"-mcpu=5282". Looking at a manual for that, it appears to be "ISA A" which
doesn't include a test and set instruction. :

/home/joel/rtems-work/tools/7/lib/gcc/m68k-rtems7/14.2.0/include/c++/bits/atomic_base.h:226:(.text.Init+0x19a):
undefined reference to `__atomic_test_and_set'
collect2: error: ld returned 1 exit status

Looking at the file ./libstdc++-v3/include/bits/atomic_base.h, I see a couple
of calls to that method. 

The test is located at
https://gitlab.rtems.org/rtems/rtos/rtems/-/blob/main/testsuites/sptests/spcxx01/init.cc?ref_type=heads.
 

We do have libatomic.a installed and a grep shows it has variants of
__atomic_test_and_set.

$ m68k-rtems7-nm -g
/home/joel/rtems-work/tools/7/lib/gcc/m68k-rtems7/14.2.0/m5208/libatomic.a |
grep atomic_test_and_
         U __atomic_test_and_set
00000000 T __atomic_test_and_set_1
00000000 T __atomic_test_and_set_2
00000000 T __atomic_test_and_set_4
00000000 T __atomic_test_and_set_8

This set of symbols matches what is in an arm-rtems version of the library. And
our test compiles and links fine on that.

Reply via email to