Skip to content

cmake: accept versioned libatomic.so.1 in find_library - #176

Merged
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/libatomic-versioned-and-opensuse
Jun 16, 2026
Merged

cmake: accept versioned libatomic.so.1 in find_library#176
got3nks merged 1 commit into
amule-org:masterfrom
got3nks:fix/libatomic-versioned-and-opensuse

Conversation

@got3nks

@got3nks got3nks commented Jun 16, 2026

Copy link
Copy Markdown

Summary

Closes #171.

The 32-bit find_library (NAMES atomic) call only looks for the unversioned libatomic.so symlink, which on Debian / Fedora / Arch lives in the -dev / -devel package alongside the runtime library. openSUSE ships libatomic1 with only the versioned libatomic.so.1; there's no separate -devel package, so the symlink is absent and find_library hard-fails the configure even when the linker would happily resolve -latomic against the versioned library at link time.

@gcomes reported this on #171 (openSUSE Tumbleweed packman maintainer, i586 32-bit build); his workaround was to manually create the missing libatomic.so symlink. @mrjimenez confirmed the openSUSE package names with zypper search --provides 'libatomic.so' output.

Changes

Widen find_library NAMES to accept both forms:

-find_library (LIBATOMIC_LIBRARY NAMES atomic)
+find_library (LIBATOMIC_LIBRARY NAMES atomic libatomic.so.1)

Unversioned stays the preferred path; the versioned .so.1 is the fallback for distros that don't ship the symlink. The STATUS line also logs the resolved path so the build log captures which form matched.

Test plan

  • cmake configure clean on macOS arm64 (gate doesn't fire — 64-bit — but verifies the edits parse).
  • @gcomes — would you mind dropping the manual libatomic.so symlink, pulling this branch, and running cmake -B build on your openSUSE Tumbleweed i586 environment? The configure should now succeed without the symlink trick, and the STATUS line should print something like 32-bit target: linking libatomic for std::atomic<int64_t> (/usr/lib/libatomic.so.1). Please paste the configure output in code fences either way (success or failure).

Background

The binary's runtime libatomic dependency stays empty regardless — GNU ld's --as-needed default drops the DT_NEEDED entry when the compiler inlines the lock-free expansion (CMPXCHG8B on i586+). That's why @gcomes observed ldd showing no libatomic dependency in the linked binary. The -latomic flag is link-time scaffolding for cross-TU __atomic_*_8 references that the compiler can't inline, kept as a safety net per the rationale in CMakeLists.txt:282-292 (see also 22ba4f2 / closes #643).

openSUSE's `libatomic1` package ships only `libatomic.so.1` —
there's no separate -devel package, and therefore no unversioned
`libatomic.so` symlink, so the previous `find_library(NAMES atomic)`
failed even though the library was installed.

Accept `libatomic.so.1` as a fallback name. The canonical
unversioned name is kept first so distros that do ship the symlink
(Debian / Fedora / Arch) still resolve to it. Also tag the STATUS
line with the resolved path so the chosen variant is visible in the
configure summary.
@got3nks
got3nks force-pushed the fix/libatomic-versioned-and-opensuse branch from 750605f to b0323d2 Compare June 16, 2026 14:13
@got3nks got3nks changed the title cmake: accept versioned libatomic + openSUSE install hint cmake: accept versioned libatomic.so.1 in find_library Jun 16, 2026
@got3nks
got3nks merged commit cc9460c into amule-org:master Jun 16, 2026
9 checks passed
got3nks added a commit that referenced this pull request Jun 16, 2026
Post-3.0.0 master tip after #176 (libatomic find_library widened to
accept libatomic.so.1, fixing 32-bit configure on openSUSE-class
distros). #175 (Language picker bundled-catalog probe) is also
folded in via the prior merges leading up to this SHA.
@got3nks
got3nks deleted the fix/libatomic-versioned-and-opensuse branch June 17, 2026 13:58
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.

About libatomic requirement for 32-bit amule build 32-git archs may beed linking to libatomic: Undefined symbols: "___atomic_compare_exchange_8" etc.

1 participant