3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-25 01:50:33 +00:00
z3/cmake/check_link_atomic.cmake
Copilot 2081918cea
cmake: skip std::atomic link check for Emscripten and single-threaded builds (#9932)
The "Python bindings (Pyodide)" CI job fails at CMake configure time
because Emscripten's cross-compiler cannot pass the `std::atomic` link
tests in `check_link_atomic.cmake`, resulting in a fatal error even
though Pyodide builds are single-threaded and never need `libatomic`.

## Change

- **`cmake/check_link_atomic.cmake`**: guard the entire atomic check
behind `if (NOT (EMSCRIPTEN OR Z3_SINGLE_THREADED))`. Emscripten sets
`EMSCRIPTEN` automatically via `emcmake`; Pyodide builds also pass
`-DZ3_SINGLE_THREADED=TRUE`, so either condition is sufficient to bypass
the check safely.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
2026-06-23 14:05:02 -06:00

29 lines
871 B
CMake

if (EMSCRIPTEN OR Z3_SINGLE_THREADED)
# Emscripten (Pyodide/WASM) and single-threaded builds do not use
# libatomic; skip the check to avoid a spurious configure failure.
message(STATUS "Skipping std::atomic link check (EMSCRIPTEN or Z3_SINGLE_THREADED)")
else()
set(ATOMIC_TEST_SOURCE "
#include <atomic>
std::atomic<int> x;
std::atomic<short> y;
std::atomic<char> z;
std::atomic<long long> w;
int main() {
++z;
++y;
++w;
return ++x;
}")
CHECK_CXX_SOURCE_COMPILES("${ATOMIC_TEST_SOURCE}" BUILTIN_ATOMIC)
if (NOT BUILTIN_ATOMIC)
set(CMAKE_REQUIRED_LIBRARIES atomic)
CHECK_CXX_SOURCE_COMPILES("${ATOMIC_TEST_SOURCE}" ATOMICS_REQUIRE_LIBATOMIC)
unset(CMAKE_REQUIRED_LIBRARIES)
if (ATOMICS_REQUIRE_LIBATOMIC)
list(APPEND Z3_DEPENDENT_LIBS atomic)
else()
message(FATAL_ERROR "Host compiler must support std::atomic!")
endif()
endif()
endif()