Skip to content

build: link libatomic on Linux static builds - #39

Merged
adsharma merged 1 commit into
LadybugDB:mainfrom
aenawi:link-libatomic-on-linux
Sep 19, 2026
Merged

adsharma merged 1 commit into
LadybugDB:mainfrom
aenawi:link-libatomic-on-linux

Conversation

@aenawi

@aenawi aenawi commented Sep 19, 2026

Copy link
Copy Markdown
Contributor

Fixes #38.

The perf prebuilt archive on Linux calls __atomic_compare_exchange for the 16-byte atomics in the buffer manager, and nothing on the link line provides it. So LBUG_LINUX_VARIANT=perf fails at the final link. This adds libatomic next to libstdc++ for Linux static builds.

Rust passes --as-needed to the linker, so if nothing calls into libatomic the binary doesn't end up depending on it. Compat builds come out exactly as before.

Tested with engine v0.20.4 on Ubuntu 24.04:

before after
aarch64, perf link fails builds; a 200k-row insert and count runs correctly
aarch64, compat builds, runs builds, runs; same NEEDED list as before
x86_64, perf (cross-linked) link fails links; libatomic.so.1 in NEEDED
x86_64, compat (cross-linked) links links; same NEEDED list as before

cargo test passes with both variants on aarch64. The perf link also works with gcc-14 as the linker. I couldn't run the x86_64 binaries on this machine, so on x86_64 that's link-only.

I went with linking it for every Linux static build rather than only for perf, since it costs nothing when unused and also covers anyone pointing LBUG_LIBRARY_DIR at a perf archive. Happy to narrow it to perf if you'd prefer.

The perf prebuilt archive references __atomic_compare_exchange from the
buffer manager's 16-byte atomics, and nothing on the link line provides
it, so LBUG_LINUX_VARIANT=perf fails to link. Link libatomic alongside
libstdc++; with --as-needed, compat builds are unchanged.
@adsharma
adsharma merged commit 3f60765 into LadybugDB:main Sep 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: the static perf variant fails to link on Linux (undefined __atomic_compare_exchange)

2 participants