Linker issue on MIPS
On MIPS architecture, atomics operations have to be done with the help of libatomic. You'll find attached a patch that, in addition to atomic compilation check, test the linking of the same code. If it compiles but can't link, it append the -latomic
missing for a correct linking.
For the record, the problem occurs when linking kzonecheck
with libknotd.so
:
libtool: link: mipsel-unknown-linux-gnu-gcc -O2 -march=mips32r2 -mabi=32 -mplt -pipe -fstack-check -Wall -Werror=format-security -Werror=implicit -Wstrict-prototypes -Wl,-O1 -Wl,--as-needed -o .libs/kzonecheck utils/kzonecheck/kzonecheck-main.o utils/kzonecheck/kzonecheck-zone_check.o ./.libs/libknotd.a /var/tmp/portage/net-dns/knot-2.5.3/work/knot-2.5.3/src/.libs/libknot.so -llmdb /var/tmp/portage/net-dns/knot-2.5.3/work/knot-2.5.3/src/dnssec/.libs/libdnssec.so -lgnutls -lnettle /var/tmp/portage/net-dns/knot-2.5.3/work/knot-2.5.3/src/zscanner/.libs/libzscanner.so -lurcu ./.libs/libcontrib.a -lcap-ng -ldl -lpthread -lm -pthread
./.libs/libknotd.a(libknotd_la-query_module.o): In function `knotd_mod_stats_incr':
query_module.c:(.text+0xca0): undefined reference to `__atomic_fetch_add_8'
query_module.c:(.text+0xcb0): undefined reference to `__atomic_fetch_add_8'
query_module.c:(.text+0xcc4): undefined reference to `__atomic_fetch_add_8'
query_module.c:(.text+0xcd4): undefined reference to `__atomic_fetch_add_8'
./.libs/libknotd.a(libknotd_la-query_module.o): In function `knotd_mod_stats_decr':
query_module.c:(.text+0xd94): undefined reference to `__atomic_fetch_sub_8'
query_module.c:(.text+0xda4): undefined reference to `__atomic_fetch_sub_8'
query_module.c:(.text+0xdb8): undefined reference to `__atomic_fetch_sub_8'
query_module.c:(.text+0xdc8): undefined reference to `__atomic_fetch_sub_8'
./.libs/libknotd.a(libknotd_la-query_module.o): In function `knotd_mod_stats_store':
query_module.c:(.text+0xe88): undefined reference to `__atomic_store_8'
query_module.c:(.text+0xe98): undefined reference to `__atomic_store_8'
query_module.c:(.text+0xeac): undefined reference to `__atomic_store_8'
query_module.c:(.text+0xebc): undefined reference to `__atomic_store_8'
collect2: error: ld returned 1 exit status