2

使用 crosstool-ng,我为 mips-unknown-linux-uclibc 构建了一个 GCC 10.2 交叉工具链。它对我正在编译的遗留应用程序完美无缺。我最近尝试使用使用 crosstool-ng 构建的类似 GCC 交叉工具链为运行 RTOS 的嵌入式设备编译相同的应用程序。主要区别在于我将其配置为使用 newlib 而不是 uclibc 并将其设置为裸机而不是 linux。工具链大部分都有效,但链接时出现以下错误:

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

快速浏览一下 libgcc.a 会发现这些符号存在于 mips-unknown-linux-uclibc 工具链中

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:

而且不在 mips-unknown-elf 工具链中

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$

当 linux 不是目标时,为什么 GCC 编译器构建不发出同步内置命令?我该如何配置它才能做到这一点?我目前的技巧是创建我自己的程序集实现,这些实现与 GCC 在 mips-unknown-linux-uclibc 工具链中发出的那些实现相同,但宁愿理解为什么它们一开始就没有发出。

4

0 回答 0