Skip to content

feat: macOS ARM64 support — LLVM default toolchain + CI#45

Merged
Sunrisepeak merged 7 commits into
mainfrom
feat/macos-support
May 16, 2026
Merged

feat: macOS ARM64 support — LLVM default toolchain + CI#45
Sunrisepeak merged 7 commits into
mainfrom
feat/macos-support

Conversation

@Sunrisepeak
Copy link
Copy Markdown
Member

Summary

  • macOS ARM64 平台支持,LLVM/Clang 20.1.7 作为默认工具链
  • 支持 C++23 import stdimport std.compat、多模块项目
  • 通过 xlings LLVM 包实现自含工具链(仅依赖 macOS SDK)

Changes

核心适配

  • src/cli.cppm: macOS first-run 默认安装 llvm@20.1.7(Linux 不变,仍为 gcc@15.1.0-musl
  • src/toolchain/probe.cppm: 平台感知的运行时路径发现 + xcrun --show-sdk-path sysroot fallback
  • src/build/flags.cppm: macOS 跳过 -static(libSystem 必须动态链接)
  • src/config.cppm: macOS 跳过 patchelf 引导(Mach-O 不需要 ELF patching)
  • install.sh: 增加 darwin-arm64/darwin-x86_64 平台检测 + macOS sha256 兼容

CI

  • .github/workflows/ci-macos.yml: macOS ARM64 完整 E2E 验证
    • xlings bootstrap → LLVM 20.1.7 安装 → 非模块编译 → import stdimport std.compat → 多模块项目 → probe 逻辑验证

CI 验证结果

macos-15 (ARM64, macOS 15.7.4) 上全部通过:

  • ✅ xlings 0.4.30 正常运行
  • ✅ LLVM 20.1.7 安装成功(arm64-apple-darwin24.6.0
  • import std 编译+运行
  • import std.compat 编译+运行
  • ✅ 多模块项目编译+运行
  • ✅ sysroot/target-triple/libc++路径探测全部正确
  • ✅ install.sh 平台检测正确

Test plan

  • macOS CI 全部通过(自动)
  • Linux CI 不受影响(所有改动在 #if defined(__APPLE__) 保护下)
  • 未来:mcpp self-host on macOS(需要 mcpp 自身的 macOS 预编译包)

- probe.cppm: platform-aware runtime dir discovery (macOS paths + xcrun sysroot fallback)
- flags.cppm: skip -static on macOS (libSystem must be dynamic)
- config.cppm: skip patchelf bootstrap on macOS (Mach-O, not ELF)
- install.sh: add darwin-arm64/x86_64 platform detection + macOS sha256 compat
- ci-macos.yml: lightweight macOS ARM64 smoke test workflow
- Design doc: .agents/docs/2026-05-16-macos-support-design.md
xlings releases use "macosx-arm64" naming, not "macos-arm64" or "darwin-arm64".
macOS /tmp symlinks to /private/tmp which breaks find. Use explicit
mktemp -d and construct the expected directory name directly.
xlings macOS binary has dyld compatibility issues with GitHub runners.
Restructure CI to:
1. Use Homebrew LLVM to validate the compilation model (import std, modules)
2. Validate probe/sysroot behavior on macOS
3. Test install.sh platform detection
4. Separately check xlings binary compat (continue-on-error)
- cli.cppm: platform-aware first-run default (llvm@20.1.7 on macOS,
  gcc@15.1.0-musl on Linux)
- cli.cppm: platform-aware error messages for MCPP_NO_AUTO_INSTALL
- ci-macos.yml: full xlings → LLVM install → import std/std.compat/
  multi-module E2E validation on macos-15
The macOS CI is now stable and should gate all future changes.
@Sunrisepeak Sunrisepeak merged commit 27d0e97 into main May 16, 2026
2 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.

1 participant