nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1From dfbbc505817bd0c3e01af5865196629c2a2a2b5e Mon Sep 17 00:00:00 2001
2From: Marie Ramlow <me@nycode.dev>
3Date: Wed, 10 Sep 2025 20:12:39 +0200
4Subject: [PATCH] Check if libatomic is needed
5
6---
7 c++/src/kj/CMakeLists.txt | 15 +++++++++++++++
8 1 file changed, 15 insertions(+)
9
10diff --git a/c++/src/kj/CMakeLists.txt b/c++/src/kj/CMakeLists.txt
11index 7114ddb80e..8ce355b8b0 100644
12--- a/c++/src/kj/CMakeLists.txt
13+++ b/c++/src/kj/CMakeLists.txt
14@@ -84,6 +84,21 @@ target_compile_features(kj PUBLIC cxx_std_20)
15 if(UNIX AND NOT ANDROID)
16 target_link_libraries(kj PUBLIC pthread)
17 endif()
18+
19+include(CheckCXXSourceCompiles)
20+check_cxx_source_compiles("#include <atomic>
21+int main() {
22+ std::atomic<uint8_t> w1;
23+ std::atomic<uint16_t> w2;
24+ std::atomic<uint32_t> w4;
25+ std::atomic<uint64_t> w8;
26+ return ++w1 + ++w2 + ++w4 + ++w8;
27+}" CAPNP_BUILDS_WITHOUT_LIBATOMIC)
28+
29+if(NOT CAPNP_BUILDS_WITHOUT_LIBATOMIC)
30+ target_link_libraries(kj PUBLIC atomic)
31+endif()
32+
33 #make sure the lite flag propagates to all users (internal + external) of this library
34 target_compile_definitions(kj PUBLIC ${CAPNP_LITE_FLAG})
35 #make sure external consumers don't need to manually set the include dirs