estraier / tkrzw

a set of implementations of DBM

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build fails on architectures where -latomic is needed

hosiet opened this issue · comments

Since libatomic is not automatically linked, tkrzw will fail to build on some architectures when this library is needed.

For example, in https://buildd.debian.org/status/fetch.php?pkg=tkrzw&arch=armel&ver=1.0.20%2Bdfsg1-1&stamp=1636210920&raw=0

g++ -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -std=c++17 -pthread -fPIC -fsigned-char -shared -Wl,-soname,libtkrzw.so.1 -o libtkrzw.so.1.63.0 tkrzw_lib_common.o tkrzw_str_util.o tkrzw_hash_util.o tkrzw_time_util.o tkrzw_compress.o tkrzw_file_util.o tkrzw_file_std.o tkrzw_file_mmap.o tkrzw_file_pos.o tkrzw_file_poly.o tkrzw_message_queue.o tkrzw_dbm.o tkrzw_dbm_ulog.o tkrzw_dbm_common_impl.o tkrzw_dbm_hash_impl.o tkrzw_dbm_hash.o tkrzw_dbm_tree_impl.o tkrzw_dbm_tree.o tkrzw_dbm_skip_impl.o tkrzw_dbm_skip.o tkrzw_dbm_tiny.o tkrzw_dbm_baby.o tkrzw_dbm_cache.o tkrzw_dbm_std.o tkrzw_dbm_poly.o tkrzw_dbm_shard.o tkrzw_dbm_async.o tkrzw_cmd_util.o tkrzw_langc.o -Wl,-z,relro -Wl,-z,now  -L. -L/usr/lib/arm-linux-gnueabi -Wl,-rpath-link,.:/usr/local/lib:.:/usr/local/lib: -Wl,--as-needed -llzma -llz4 -lzstd -lz -lstdc++ -lrt -lpthread -lm -lc 
ln -f -s libtkrzw.so.1.63.0 libtkrzw.so.1
ln -f -s libtkrzw.so.1.63.0 libtkrzw.so
g++ -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -std=c++17 -pthread -fPIC -fsigned-char -o tkrzw_build_util tkrzw_build_util.o -Wl,-z,relro -Wl,-z,now  -L. -L/usr/lib/arm-linux-gnueabi -Wl,-rpath-link,.:/usr/local/lib:.:/usr/local/lib: -Wl,--as-needed -L. -L/usr/lib/arm-linux-gnueabi -ltkrzw -llzma -llz4 -lzstd -lz -lstdc++ -lrt -lpthread -lm -lc 
/usr/bin/ld: ./libtkrzw.so: undefined reference to `__atomic_compare_exchange_8'
/usr/bin/ld: ./libtkrzw.so: undefined reference to `__atomic_fetch_sub_8'
/usr/bin/ld: ./libtkrzw.so: undefined reference to `__atomic_load_8'
/usr/bin/ld: ./libtkrzw.so: undefined reference to `__atomic_store_8'
/usr/bin/ld: ./libtkrzw.so: undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:974: tkrzw_build_util] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/<<PKGBUILDDIR>>'
dh_auto_build: error: make -j4 returned exit code 2

Currently Debian's workaround is to manually append -latomic to LDFLAGS on those architectures, see https://salsa.debian.org/debian/tkrzw/-/blob/c6c6fd2132ce0b98e60b88a63fedc143e319c2c5/debian/rules

ifneq (,$(filter $(DEB_HOST_ARCH), armel mips mipsel sparc powerpc powerpcspe sh4 m68k ))
  export DEB_LDFLAGS_MAINT_APPEND += -latomic
endif

While this works for now, I believe this should be fixed somewhere in upstream source code.

Thanks for the report and making the binary packages.
I added -latomic to library checks in configure. The next version won't cause the same error.

v1.0.12 was released. It fixes this issue.