Skip to content

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

Closed

Description

@aenawi

Ladybug version: lbug crate from main with engine v0.20.4 (LBUG_VERSION=0.20.4). I first hit it with the 0.19.1 crate and engine v0.20.0, and it has been the same on every release since.

OS: Ubuntu 24.04.5 LTS, x86_64. Also reproduces on aarch64.

What happened?

Setting LBUG_LINUX_VARIANT=perf makes the final link fail:

/usr/bin/ld: liblbug.a(buffer_manager.cpp.o): in function
  `lbug::storage::EvictionQueue::insert(unsigned int, unsigned int)':
  buffer_manager.cpp:(.text+0x66): undefined reference to `__atomic_compare_exchange'
  ... also in EvictionQueue::clear, EvictionQueue::tryClear,
      BufferManager::pin, BufferManager::evictPages
collect2: error: ld returned 1 exit status

The perf archive has an undefined reference to __atomic_compare_exchange, and the compat archive doesn't. Same on both architectures in v0.20.4:

nm -u liblbug.a | grep -c '__atomic_compare_exchange$'
  x86_64 compat: 0    x86_64 perf: 1
  aarch64 compat: 0   aarch64 perf: 1

It comes from the 16-byte atomics in the buffer manager's eviction queue, which GCC turns into libatomic calls. build.rs links stdc++, ssl and crypto but not atomic, so nothing provides the symbol. Compat is the default, which is probably why nobody has run into it.

I expected the perf variant to link the same way compat does.

Steps to reproduce

  1. On Linux, from a clean build directory, depend on lbug and build with the perf variant: LBUG_VERSION=0.20.4 LBUG_LINUX_VARIANT=perf cargo build --release.
  2. The link fails with the error above.

Fix

I've opened #39, which links libatomic next to libstdc++ on Linux static builds. Rust passes --as-needed to the linker, so compat binaries don't pick up a new runtime dependency; their NEEDED list is identical before and after. Happy to change it if you'd rather fix it on the engine side.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions