public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Why doesn't gcc always emit sync builtins for MIPS?
@ 2021-02-03 21:28 Dani T
  0 siblings, 0 replies; only message in thread
From: Dani T @ 2021-02-03 21:28 UTC (permalink / raw)
  To: gcc

Using crosstool-ng, I built a GCC 10.2 cross toolchain for
mips-unknown-linux-uclibc. It works flawlessly for the legacy app I am
compiling. I recently tried to compile the same application for an embedded
device running an RTOS using a similar GCC cross toolchain built using
crosstool-ng. The main differences are that I configured it to use newlib
instead of uclibc and set it up for bare metal instead of linux. The
toolchain mostly works but I get the following errors when linking:

undefined reference to `__sync_val_compare_and_swap_4'
undefined reference to `__sync_add_and_fetch_4'

A quick look at libgcc.a shows that these symbols exist in the
mips-unknown-linux-uclibc toolchain

dani@ws:~/x-tools$ nm
mips-unknown-linux-uclibc/lib/gcc/mips-unknown-linux-uclibc/10.2.0/libgcc.a
| grep sync_add
sync_add_and_fetch_1.o:00000000 T __sync_add_and_fetch_1
sync_add_and_fetch_2.o:00000000 T __sync_add_and_fetch_2
sync_add_and_fetch_4.o:00000000 T __sync_add_and_fetch_4
sync_add_and_fetch_8.o:
sync_add_and_fetch_16.o:

And not in the mips-unknown-elf toolchain

dani@ws:~/x-tools$ nm
mips-unknown-elf/lib/gcc/mips-unknown-elf/10.2.0/libgcc.a | grep
sync_add
sync_add_and_fetch_1.o:
sync_add_and_fetch_2.o:
sync_add_and_fetch_4.o:
sync_add_and_fetch_8.o:
sync_add_and_fetch_16.o:
dani@ws:~/x-tools$

Why does the GCC compiler not emit the sync builtins when linux is not the
target? How do I configure it so that it does? My current hack is to create
my own assembly implementations that are identical to the ones that GCC
emits in the mips-unknown-linux-uclibc toolchain but would rather
understand why they are not emitted in the first place.


Thanks,


Dan

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-03 21:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-03 21:28 Why doesn't gcc always emit sync builtins for MIPS? Dani T

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).