[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1017345: mongo-c-driver: FTBFS on riscv64: needs to be linked with libatomic



Source: mongo-c-driver
Version: 1.22.1-1
Severity: important
Tags: ftbfs, patch
User: debian-riscv@lists.debian.org
Usertags: riscv64
X-Debbugs-Cc: debian-riscv@lists.debian.org

Dear maintainer,

mongo-c-driver fails to build on riscv64, due to te usage of bit atomics
which requires the link with libatomic on riscv64:

The full build log is available there:
https://buildd.debian.org/status/fetch.php?pkg=mongo-c-driver&arch=riscv64&ver=1.22.1-1%2Bb1&stamp=1659956521&raw=0

| cd /<<PKGBUILDDIR>>/obj-riscv64-linux-gnu/src/libbson && /usr/bin/cmake -E cmake_link_script CMakeFiles/bcon-col-view.dir/link.txt --verbose=1
| /usr/bin/cc -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -Wall -Wempty-body -Wformat -Wformat-nonliteral -Wformat-security -Winit-self -Wmissing-include-dirs -Wno-strict-aliasing -Wno-uninitialized -Wredundant-decls -Wshadow -Wswitch-default -Wswitch-enum -Wundef -Wuninitialized -Wexpansion-to-defined -pedantic -Wl,-z,relro -Wl,-z,now -lpthread -rdynamic "CMakeFiles/bcon-col-view.dir/examples/bcon-col-view.c.o" -o bcon-col-view  -Wl,-rpath,/<<PKGBUILDDIR>>/obj-riscv64-linux-gnu/src/libbson libbson-1.0.so.0.0.0 
| /usr/bin/ld: libbson-1.0.so.0.0.0: undefined reference to `__atomic_exchange_1'
| /usr/bin/ld: libbson-1.0.so.0.0.0: undefined reference to `__atomic_compare_exchange_1'
| collect2: error: ld returned 1 exit status
| make[3]: *** [src/libbson/CMakeFiles/bcon-col-view.dir/build.make:101: src/libbson/bcon-col-view] Error 1

It used to build successfully in the past as linking with -pthread
automatically links with libatomic, however the recent upload of glibc
2.34 made the -pthread flag not fully necessary anymore, and cmake
decided to stop using it. The workaround is to explicitly link with
libatomic like in the attached patch. Could you please include this
patch in the next upload?

Thanks
Aurelien
diff -Nru mongo-c-driver-1.22.1/debian/rules mongo-c-driver-1.22.1/debian/rules
--- mongo-c-driver-1.22.1/debian/rules	2022-08-02 19:03:22.000000000 +0000
+++ mongo-c-driver-1.22.1/debian/rules	2022-08-13 20:46:26.000000000 +0000
@@ -16,6 +16,10 @@
 #export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
 # package maintainers to append LDFLAGS
 export DEB_LDFLAGS_MAINT_APPEND := -lpthread
+# Link with libatomic on riscv64 to get access to the __atomic_*_1 functions
+ifeq ($(DEB_HOST_ARCH),riscv64)
+	export DEB_LDFLAGS_MAINT_APPEND += -Wl,--no-as-needed -latomic -Wl,--as-needed
+endif
 
 ifneq (,$(findstring nodoc,$(DEB_BUILD_OPTIONS)))
 	DOCS=OFF

Reply to: