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