Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing link to atomic on some architectures #371

Closed
legoktm opened this issue Jun 21, 2020 · 1 comment · Fixed by #372
Closed

Missing link to atomic on some architectures #371

legoktm opened this issue Jun 21, 2020 · 1 comment · Fixed by #372
Assignees

Comments

@legoktm
Copy link
Member

legoktm commented Jun 21, 2020

On Debian, builds for libkiwix are failing on armel, mipsel, and a few other architectures because of a missing link to atomic.

The error is something like:

/usr/bin/ld: src/25a6634@@kiwix@sha/server_request_context.cpp.o: in function `std::__atomic_base<unsigned long long>::fetch_add(unsigned long long, std::memory_order)':
/usr/include/c++/9/bits/atomic_base.h:541: undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status

Here are the full build logs: https://buildd.debian.org/status/package.php?p=libkiwix&suite=experimental

Searching around a bit, it seems we just need to add -latomic for those architectures. See e.g. how redis fixed this in redis/redis#6275 / redis/redis@f5d4853

For meson I think we can use https://mesonbuild.com/Reference-manual.html#build_machine-object to vary what we link against.

@legoktm legoktm self-assigned this Jun 21, 2020
@legoktm
Copy link
Member Author

legoktm commented Jun 21, 2020

The patch I have so far is:

From: Kunal Mehta <legoktm@debian.org>
Date: Sun, 21 Jun 2020 01:02:00 -0700
Subject: Pass -latomic for architectures that need it

---
 meson.build | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/meson.build b/meson.build
index 864b46a..e54a3a5 100644
--- a/meson.build
+++ b/meson.build
@@ -18,6 +18,11 @@ if 'java' in wrapper
   add_languages('java')
 endif
 
+# See https://github.com/kiwix/kiwix-lib/issues/371
+if target_machine.cpu() in ['arm', 'mips', 'm68k', 'ppc']
+  extra_libs += '-latomic'
+endif
+
 thread_dep = dependency('threads')
 libicu_dep = dependency('icu-i18n', static:static_deps)
 libzim_dep = dependency('libzim', version : '>=6.1.1', static:static_deps)

I'm just waiting to be able to log into Debian's porterboxes to test building on those architectures.

legoktm added a commit that referenced this issue Jun 29, 2020
Some architectures, specifically armel, mipsel, m68k & powerpc in
Debian, need to explicitly link to atomic.

Use meson to see if the target's CPU family is one of those, and if so,
pass -latomic to the linker.

Tested on armel and mipsel machines to verify passing -latomic works, and
on armhf and amd64 to ensure normal builds aren't broken.

Fixes #371.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants