Skip to content

Commit 76b7909

Browse files
committed
feat: LLVM as default toolchain on macOS + full xlings E2E CI
- 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
1 parent 7e7646d commit 76b7909

3 files changed

Lines changed: 287 additions & 117 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# macOS LLVM 默认工具链跨平台适配方案
2+
3+
Date: 2026-05-16
4+
5+
## 目标
6+
7+
mcpp 在 macOS 上默认使用 LLVM/Clang 作为工具链,支持 C++23 `import std`
8+
与 Linux 上的 GCC 默认体验对等。
9+
10+
## 设计
11+
12+
### 当前工具链解析优先级
13+
14+
```
15+
0. --target / --static CLI 覆盖 → [target.<triple>] 查找
16+
1. 项目 mcpp.toml [toolchain].<platform> 或 .default
17+
2. 全局 ~/.mcpp/config.toml [toolchain].default
18+
3. First-run auto-install(当前硬编码 gcc@15.1.0-musl)
19+
```
20+
21+
### 改动方案
22+
23+
**核心改动**:第 3 步的 first-run auto-install 改为平台感知:
24+
25+
```cpp
26+
#if defined(__APPLE__)
27+
std::string defaultSpec = "llvm@20.1.7";
28+
#else
29+
std::string defaultSpec = "gcc@15.1.0-musl";
30+
#endif
31+
```
32+
33+
**影响**
34+
- macOS 用户首次运行 `mcpp build` 时,自动安装 LLVM 20.1.7 而非 GCC
35+
- Linux 用户行为不变(仍然默认 GCC musl 静态链接)
36+
- 已配置 `[toolchain]` 或全局 default 的用户不受影响(优先级 1/2 覆盖)
37+
38+
### 其他适配点
39+
40+
1. **First-run UI 消息**:macOS 上显示 "installing llvm@20.1.7 as default" 而非 musl
41+
2. **`mcpp new` 模板**:可选在生成的 mcpp.toml 中加入 `[toolchain] macos = "llvm@20.1.7"`
42+
3. **错误消息**:MCPP_NO_AUTO_INSTALL 的提示信息也需平台感知
43+
44+
## CI 验证计划
45+
46+
在 macos-15 runner 上验证完整链路:
47+
1. xlings bootstrap ✅(已验证可用)
48+
2. xlings install llvm → 安装 LLVM 到 ~/.xlings
49+
3. 使用 LLVM clang++ 编译 `import std` 项目
50+
4. 验证 mcpp 的探测逻辑(target triple, sysroot, libc++ module 路径)

0 commit comments

Comments
 (0)