fix(cmake): detect libatomic with a link probe instead of find_library (#453)#454
Open
got3nks wants to merge 1 commit into
Open
fix(cmake): detect libatomic with a link probe instead of find_library (#453)#454got3nks wants to merge 1 commit into
got3nks wants to merge 1 commit into
Conversation
On 32-bit targets the throttler's std::atomic<int64_t> needs libatomic (the ops expand to __atomic_*_8 library calls). The availability check used find_library(atomic), which only searches standard filesystem paths. With GCC, libatomic ships inside the compiler's own runtime dir (e.g. .../lib/gcc14/), which isn't on that path, so find_library false-fails and configure aborts -- even though `-latomic` links fine because the GCC driver resolves its internal copy (reported on MacPorts, amule-project#453). Replace find_library with check_library_exists(atomic __atomic_load_8), which links a probe with `-latomic` through the compiler driver. It succeeds wherever the flag actually links -- GCC's internal libatomic or a system libatomic (Clang / distro packages, versioned or not) -- and only errors when the flag genuinely can't link. The 32-bit "require libatomic" decision and the FATAL_ERROR guidance are unchanged; only the availability probe changes. Closes amule-project#453.
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.
On 32-bit targets the download-bandwidth throttler holds its byte budget as
std::atomic<int64_t>, whose ops expand to__atomic_*_8library calls that live in libatomic. The availability check usedfind_library(atomic), which only searches standard filesystem paths. With GCC, libatomic ships inside the compiler's own runtime dir (e.g..../lib/gcc14/), which isn't on that path — sofind_libraryfalse-fails and configure aborts with the "libatomic was not found"FATAL_ERROR, even though-latomiclinks fine because the GCC driver resolves its internal copy. Reported on MacPorts in #453.This replaces
find_librarywithcheck_library_exists(atomic __atomic_load_8 "" HAVE_LIBATOMIC), which links a probe with-latomicthrough the compiler driver. It succeeds wherever the flag actually links — GCC's internal libatomic, or a system libatomic (Clang / distro-devpackages, versioned or not) — and only errors when the flag genuinely can't link. The 32-bit "require libatomic" decision and theFATAL_ERRORguidance are unchanged; only the availability probe changes.Test plan
check_library_existsprobe executes cleanly (verified standalone)CMAKE_SIZEOF_VOID_P EQUAL 4-gatedCloses #453.