sysroot/compile: add macOS arm64 cross-compilation support#4656
Open
mathetake wants to merge 7 commits into
Open
sysroot/compile: add macOS arm64 cross-compilation support#4656mathetake wants to merge 7 commits into
mathetake wants to merge 7 commits into
Conversation
✅ Deploy Preview for nifty-bassi-e26446 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Add repository rules and build scripts for cross-compiling to macOS arm64 from Linux x86_64: - sysroot.bzl: add `macos_sysroot` rule and `setup_macos_sysroot()` for macOS SDK sysroot (headers, frameworks, .tbd stubs) - libcxx_libs.bzl: add `libcxx_libs_darwin` rule and `setup_libcxx_libs_darwin()` for darwin libc++ (dylibs + __config_site) - versions.bzl: add placeholder hashes for macOS sysroot and darwin libcxx - build_macos_sysroot.sh: script to package macOS SDK from Xcode - build_libcxx_darwin.sh: script to build darwin libc++ from LLVM source The macOS SDK sysroot provides system headers and .tbd library stubs. The darwin libcxx provides libc++ dylibs and the __config_site header needed by the LLVM toolchain for cross-compilation. When hashes are empty (tarballs not yet built/uploaded), the rules generate fallback content: the sysroot creates an empty directory, and libcxx_libs generates __config_site from the Linux LLVM version. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Add a `build-macos-sysroot` job to the Bazel CI workflow that runs on `macos-14` and produces two artifacts: 1. `sysroot-macos-arm64.tar.xz` — macOS SDK sysroot extracted from the Xcode installation on the CI runner (headers, frameworks, .tbd stubs) 2. `libcxx-llvm18.1.8-darwin-aarch64.tar.xz` — libc++ built from LLVM source for darwin arm64 (dylibs + __config_site) These artifacts are needed for cross-compiling Envoy (and other C++ projects) from Linux x86_64 to macOS arm64. The Linux sysroots are built by debootstrap on Linux runners; the macOS sysroot requires a macOS runner with Xcode to extract Apple's SDK. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
- Fix shellcheck SC2295: quote expansions inside ${..} in sysroot scripts
- Fix shellcheck SC2034: remove unused ARCH variable in libcxx script
- Fix cmake error: add libunwind to LLVM_ENABLE_RUNTIMES and set
LIBCXXABI_USE_LLVM_UNWINDER=ON (required by libcxxabi)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
043c3fe to
fa34f54
Compare
Some frameworks (e.g., SystemConfiguration) have headers under Versions/A/Headers/ instead of just Headers/. Copy the full framework structure including versioned directories so clang can find all headers. Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com> Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
macOS `cp -a` requires the parent directory to exist. Create it with mkdir -p before copying Headers/Modules directories. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Ruby.framework contains self-referencing symlinks (ruby -> .) that cause infinite recursion during Bazel's glob expansion. Remove these circular symlinks before packaging. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
Selectively copying Headers/Modules/tbd from frameworks breaks clang's framework header lookup, which depends on symlinks like: Headers -> Versions/Current/Headers Versions/Current -> A SDK frameworks contain only headers, modules, and .tbd stubs (no large binaries), so copying the entire directory is safe and correct. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Takeshi Yoneda <tyoneda@netflix.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add repository rules and build scripts for cross-compiling to macOS arm64 from Linux x86_64:
macos_sysrootrule andsetup_macos_sysroot()for macOS SDK sysroot (headers, frameworks, .tbd stubs)libcxx_libs_darwinrule andsetup_libcxx_libs_darwin()for darwin libc++ (dylibs + __config_site)The macOS SDK sysroot provides system headers and .tbd library stubs. The darwin libcxx provides libc++ dylibs and the __config_site header needed by the LLVM toolchain for cross-compilation.
When hashes are empty (tarballs not yet built/uploaded), the rules generate fallback content: the sysroot creates an empty directory, and libcxx_libs generates __config_site from the Linux LLVM version.