ci: build libcapnp for the target arch on macOS

The macos-15 runner is arm64. Previously, cp38 was the first Python in
the cibuildwheel matrix, and because the cp38 macOS installer is
x86_64-only, cibuildwheel ran the build under \`arch -x86_64\`, which
also caused CMake to build libcapnp as x86_64. Subsequent Python
versions then reused that cached x86_64 libcapnp.

After dropping cp38, cp39 is built first and CMake auto-detects the
host arch (arm64), producing an arm64 libkj/libcapnp. The x86_64 wheel
then silently links via \`-undefined dynamic_lookup\` (the linker just
ignores arm64 archive members) and fails at dlopen time with
"symbol not found in flat namespace ... AsyncIoStream::getsockopt".

Set CMAKE_OSX_ARCHITECTURES to the matrix arch on macOS so libcapnp is
always built for the wheel's target architecture.
This commit is contained in:
Jacob Alexander
2026-05-30 11:42:28 -07:00
parent 9b65eded52
commit 6f70b8d737

View File

@@ -48,8 +48,10 @@ jobs:
CIBW_SKIP: "cp38-*"
CIBW_TEST_REQUIRES: pytest pytest-asyncio
CIBW_TEST_COMMAND: pytest {project}
# Only needed to make the macosx arm64 build work
CMAKE_OSX_ARCHITECTURES: "${{ matrix.arch == 'arm64' && 'arm64' || '' }}"
# Force libcapnp to build for the target arch on macOS (the runner
# is arm64, so without this an x86_64 wheel ends up linking against
# an arm64 libkj/libcapnp and failing to load at test time).
CMAKE_OSX_ARCHITECTURES: "${{ runner.os == 'macOS' && matrix.arch || '' }}"
- uses: actions/upload-artifact@v6
with: