aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-16 09:15:40 +0000
committer_ov4 <ov4@ov4.org>2026-10-16 09:15:40 +0000
commitce584238e66a32f93c1af4d16bfe4a1928e25b88 (patch)
treea3b91ec06761d16a85ac45ca876f9610d597c867
parentb439592cf8113f34240095dcd6d8b6196c7d87c7 (diff)
fix(build): select the macOS SDK before compiler detection
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
-rw-r--r--.github/workflows/nightly-build.yml1
-rw-r--r--AGENTS/ARCH.md2
-rw-r--r--doc/build.md3
-rw-r--r--tools/build-static-lld.sh1
4 files changed, 7 insertions, 0 deletions
diff --git a/.github/workflows/nightly-build.yml b/.github/workflows/nightly-build.yml
index 048133d..773f8ca 100644
--- a/.github/workflows/nightly-build.yml
+++ b/.github/workflows/nightly-build.yml
@@ -139,6 +139,7 @@ jobs:
cmake -S . -B build \
-DCMAKE_BUILD_TYPE=Release -DCPSC_RUN_MODE=EMBEDDED \
-DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_DEPLOYMENT_TARGET=15.0 \
+ -DCMAKE_OSX_SYSROOT="$(xcrun --show-sdk-path)" \
-DCMAKE_C_COMPILER="$llvm_prefix/bin/clang" \
-DCMAKE_CXX_COMPILER="$llvm_prefix/bin/clang++" \
-DLLVM_DIR="$llvm_prefix/lib/cmake/llvm" \
diff --git a/AGENTS/ARCH.md b/AGENTS/ARCH.md
index e78d872..002d62e 100644
--- a/AGENTS/ARCH.md
+++ b/AGENTS/ARCH.md
@@ -150,6 +150,8 @@ prefix, and leaves LLVM itself installed. Source and build caches are versioned;
the resulting local `lib/cmake/lld` takes precedence over shared system packages.
The helper's build-time linker can use the installed LLVM dylib; cpsc still links
the LLD archives and static LLVM components.
+Both macOS configurations explicitly select the SDK with `CMAKE_OSX_SYSROOT`
+before compiler detection, so imported SDK include paths do not precede libc++.
Windows build instructions retain MSYS2 MINGW64. Its LLVM/Clang package names
and compiler executable names are unversioned; CMake still requires major 23.
diff --git a/doc/build.md b/doc/build.md
index 7f702d3..17f2741 100644
--- a/doc/build.md
+++ b/doc/build.md
@@ -161,6 +161,8 @@ sh tools/build-static-lld.sh "$(brew --prefix llvm@23)" "$PWD/build" 3
The helper downloads the matching official LLVM source release, extracts LLD, its common CMake utilities and libunwind's Mach-O headers, and builds LLD using the installed LLVM SDK. It installs static LLD libraries, headers, tools and CMake configuration into `build/`, where cpsc's local dependency lookup finds them before system packages. It does not rebuild LLVM or libunwind. Use the same build directory for the helper and cpsc. For an already-extracted LLVM bottle, pass its `build/deps/root/opt/llvm` prefix instead; the LLVM versions must match. The helper uses the host architecture and defaults to a macOS 15.0 deployment target; set `MACOSX_DEPLOYMENT_TARGET` to override that target for both builds.
+Both builds explicitly select the active SDK with `CMAKE_OSX_SYSROOT`. This lets CMake recognize SDK headers as implicit compiler includes, keeping C library headers behind libc++'s wrapper headers when imported libraries such as zlib expose the SDK include directory.
+
## Build
You must explicitly choose `-DCPSC_RUN_MODE=PATH`, `EMBEDDED`, or `NONE` on
@@ -200,6 +202,7 @@ macOS:
```bash
cmake -S . -B build -DCPSC_RUN_MODE=EMBEDDED -DCMAKE_BUILD_TYPE=Release \
+ -DCMAKE_OSX_SYSROOT="$(xcrun --show-sdk-path)" \
-DCMAKE_C_COMPILER="$PWD/build/deps/root/opt/llvm/bin/clang" \
-DCMAKE_CXX_COMPILER="$PWD/build/deps/root/opt/llvm/bin/clang++"
cmake --build build -j4
diff --git a/tools/build-static-lld.sh b/tools/build-static-lld.sh
index 407e814..2c2f77e 100644
--- a/tools/build-static-lld.sh
+++ b/tools/build-static-lld.sh
@@ -36,6 +36,7 @@ fi
set --
if [ "$(uname -s)" = Darwin ]; then
set -- "-DCMAKE_OSX_ARCHITECTURES=$(uname -m)" \
+ "-DCMAKE_OSX_SYSROOT=$(xcrun --show-sdk-path)" \
"-DCMAKE_OSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-15.0}"
fi
cmake -S "$work/src/lld" -B "$work/build" \