Skip to content

build: detect macOS architecture for CMake#414

Merged
qzhuyan merged 1 commit into
emqx:mainfrom
dmorn:fix/macos-cmake-arch-detection
May 7, 2026
Merged

build: detect macOS architecture for CMake#414
qzhuyan merged 1 commit into
emqx:mainfrom
dmorn:fix/macos-cmake-arch-detection

Conversation

@dmorn
Copy link
Copy Markdown
Contributor

@dmorn dmorn commented May 6, 2026

Fixes #413.
Related to #329 and #377.

What changed

build.sh now sets CMAKE_OSX_ARCHITECTURES on macOS when the caller has not already provided it.

The default is derived from the running Erlang VM via erlang:system_info(system_architecture), with a uname -m fallback. This keeps the NIF architecture aligned with the VM architecture and avoids Rosetta shell/host mismatches.

The existing SDKROOT setup now also preserves a caller-provided SDKROOT instead of unconditionally overwriting it.

Why

msquic's OpenSSL/QuicTLS Darwin configure path expects CMAKE_OSX_ARCHITECTURES to be arm64 or x86_64. If CMake leaves it empty, the build can fall through to the generic OpenSSL config path (ERRORWTF darwin in older msquic), causing architecture mismatch and/or bad -isysroot compiler flags.

Verified

On Apple Silicon/macOS:

bash -n build.sh
rm -rf c_build priv _build msquic && mkdir -p priv && ./build.sh v2.5.5
~/.mix/elixir/1-19-otp-28/rebar3 compile

Confirmed generated cache/configure output includes:

CMAKE_OSX_ARCHITECTURES:STRING=arm64
CMAKE_OSX_SYSROOT:PATH=/Applications/Xcode.app/.../MacOSX26.4.sdk
-- Configuring OpenSSL: ARCHFLAGS="-arch arm64";...;darwin64-arm64-cc ...

@dmorn
Copy link
Copy Markdown
Contributor Author

dmorn commented May 6, 2026

Kinda duplicate of #331

@qzhuyan qzhuyan merged commit 9074ee1 into emqx:main May 7, 2026
48 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

macOS build should set CMAKE_OSX_ARCHITECTURES explicitly

2 participants