Commit 22ba4f2
cmake: drop atomic-probe heuristic, find libatomic directly on 32-bit
PR #648's cmake/atomic.cmake uses check_cxx_source_compiles to decide
whether linking libatomic is required for std::atomic<int64_t>. The
probe runs a tiny main() that stores / loads / fetch_adds /
compare_exchanges a std::atomic<int64_t>, then links it. On 32-bit
targets the compiler can inline the entire lock-free expansion of
those operations end-to-end -- no __atomic_*_8 library-call symbols
are emitted, the link succeeds, and the probe reports 'native 64-bit
atomics work, no -latomic needed'.
The real codebase's atomics live in CDownloadBandwidthThrottler
member functions called across translation-unit boundaries. GCC
can't inline those, emits __atomic_compare_exchange_8 /
__atomic_load_8 / __atomic_store_8 / __atomic_fetch_add_8 references,
and the link fails with the original Undefined Symbols errors the
probe was supposed to detect. Reported by @barracuda156 on PPC32
MacPorts -- amule_HAVE_NATIVE_ATOMIC64 = Success at configure, link
failure at build.
The probe heuristic is fundamentally fragile (any in-TU inlining
hides the library-call references) so drop it. 32-bit CPUs lack a
hardware 8-byte CAS -- the answer is always 'libatomic required'.
Just look up the library with find_library(NAMES atomic) and link
it; 64-bit targets stay a no-op.
Move the new logic to the top of the root CMakeLists.txt where the
include statement used to be. cmake/atomic.cmake is deleted. The
hard-fail message preserves the per-distro install hint the
previous FATAL_ERROR carried.
Closes #643 properly.1 parent 8ce30f9 commit 22ba4f2
3 files changed
Lines changed: 37 additions & 61 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | | - | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
249 | 281 | | |
250 | 282 | | |
251 | 283 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
655 | 655 | | |
656 | 656 | | |
657 | 657 | | |
658 | | - | |
659 | | - | |
660 | | - | |
661 | | - | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
662 | 662 | | |
663 | 663 | | |
664 | 664 | | |
| |||
0 commit comments