Repository navigation
Link libatomic when required for 64-bit atomics - #621
Merged
Merged
Conversation
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.
Some 32-bit toolchains emit runtime calls for the library's 64-bit atomic counters. Building a static archive succeeds, but applications linking it fail with unresolved symbols such as
__atomic_fetch_add_8.Probe a C++11 64-bit atomic fetch-add and load with an executable link. If the compiler cannot link it directly, retry with
libatomicand attach that dependency to the library. Fail configuration with an actionable message if neither works. Keep the check scoped so it also works with cross toolchains that normally use static-library compile probes.Carry the dependency through the exported static CMake target and
pkg-config --staticmetadata. Platforms whose toolchains already support the operations receive no extra library. Counter widths and runtime behavior are unchanged.Add a simple Linux 32-bit CI job and
make -f makefile.dev test_atomic_32. GCC's-m32 -march=i486forces the atomic runtime path; the check installs the library, then links and runs C++11 consumers using both CMake and pkg-config. The producer deliberately uses compile-only default probes to verify that atomic detection still checks the linker.Validation:
__atomic_fetch_add_8linker failure with GCC 12 targeting 32-bit i486.libatomic.git diff --checkpass.The historical 32-bit macOS toolchain from the report was not available locally; the check is based on compiler/linker capability rather than an OS or architecture list.
Closes #513.