cmake: accept versioned libatomic.so.1 in find_library - #176
Merged
got3nks merged 1 commit intoJun 16, 2026
Merged
Conversation
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
force-pushed
the
fix/libatomic-versioned-and-opensuse
branch
from
June 16, 2026 14:13
750605f to
b0323d2
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #171.
The 32-bit
find_library (NAMES atomic)call only looks for the unversionedlibatomic.sosymlink, which on Debian / Fedora / Arch lives in the-dev/-develpackage alongside the runtime library. openSUSE shipslibatomic1with only the versionedlibatomic.so.1; there's no separate-develpackage, so the symlink is absent andfind_libraryhard-fails the configure even when the linker would happily resolve-latomicagainst 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.sosymlink. @mrjimenez confirmed the openSUSE package names withzypper search --provides 'libatomic.so'output.Changes
Widen
find_libraryNAMES to accept both forms:Unversioned stays the preferred path; the versioned
.so.1is 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
libatomic.sosymlink, pulling this branch, and runningcmake -B buildon your openSUSE Tumbleweed i586 environment? The configure should now succeed without the symlink trick, and the STATUS line should print something like32-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-neededdefault drops theDT_NEEDEDentry when the compiler inlines the lock-free expansion (CMPXCHG8B on i586+). That's why @gcomes observedlddshowing no libatomic dependency in the linked binary. The-latomicflag is link-time scaffolding for cross-TU__atomic_*_8references that the compiler can't inline, kept as a safety net per the rationale in CMakeLists.txt:282-292 (see also 22ba4f2 / closes #643).