Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
e1a2569
feat: Windows LLVM support — design doc + CI validation workflow
Sunrisepeak May 17, 2026
ae124da
fix: Windows CI xlings install path handling
Sunrisepeak May 17, 2026
2e0e8da
feat: Windows CI adds xmake bootstrap step (MSVC + C++23 modules)
Sunrisepeak May 17, 2026
002af19
fix: install xmake via xlings on Windows (psget.text unreliable)
Sunrisepeak May 17, 2026
9ea7787
feat: Windows portability — POSIX guards + Win32 API alternatives
Sunrisepeak May 17, 2026
16dd919
fix: add popen/_popen compat to remaining Windows-affected files
Sunrisepeak May 17, 2026
88c24e0
fix: WIFEXITED/WEXITSTATUS not available on Windows (use rc directly)
Sunrisepeak May 17, 2026
e904128
feat: Windows CI adds self-host build + packaging
Sunrisepeak May 18, 2026
a7bf8c9
fix: copy bootstrap mcpp.exe before cleaning build dir
Sunrisepeak May 18, 2026
b4c1339
fix: skip self-host on Windows (mcpp build system lacks MSVC support)
Sunrisepeak May 18, 2026
f0760e1
fix: use 7z instead of Compress-Archive to avoid backslash paths in zip
Sunrisepeak May 18, 2026
e2eea3d
feat: Windows self-host — POSIX compat fixes + LLVM toolchain config
Sunrisepeak May 18, 2026
2f88075
fix: Windows xlings command execution — use _putenv_s instead of cmd.…
Sunrisepeak May 18, 2026
70360ec
fix: Windows xlings — drop cmd.exe redirections + debug self-host
Sunrisepeak May 18, 2026
c30fa60
fix: Windows needs .exe suffix for xlings and ninja binary paths
Sunrisepeak May 18, 2026
818369a
fix: Windows cmd.exe quoting — use ^\" for inner double quotes
Sunrisepeak May 18, 2026
8df273b
fix: Windows shq — use bare \" without outer quotes
Sunrisepeak May 18, 2026
60ece4d
fix: LLVM frontend candidates need .exe suffix on Windows
Sunrisepeak May 18, 2026
13be30b
debug: list LLVM bin dir contents on self-host failure
Sunrisepeak May 18, 2026
40738ab
fix: pre-seed mcpp sandbox with global xlings LLVM via junction
Sunrisepeak May 18, 2026
cb2652a
fix: use cp -r instead of mklink /J for LLVM pre-seed (avoids permiss…
Sunrisepeak May 18, 2026
6e957b7
feat: self-host is best-effort on Windows, fall back to bootstrap binary
Sunrisepeak May 18, 2026
17b083e
fix: package step uses saved bootstrap copy at /tmp/mcpp-bootstrap/mc…
Sunrisepeak May 18, 2026
8ee2933
feat: Clang on Windows — find MSVC STL std.ixx for import std support
Sunrisepeak May 18, 2026
0b50602
fix: Windows std module build — restore shq outer quotes + absolute p…
Sunrisepeak May 18, 2026
8bb8167
fix: Clang needs -x c++-module for MSVC STL .ixx files + hard self-host
Sunrisepeak May 18, 2026
a3b53ff
fix: ninja invocation — use shq() instead of hardcoded single quotes
Sunrisepeak May 18, 2026
2f0774f
fix: Windows ninja rules — skip BMI restat (requires POSIX shell)
Sunrisepeak May 18, 2026
af1229c
debug: dump build.ninja on self-host failure
Sunrisepeak May 18, 2026
577bbcf
fix: Windows ninja rules — remove $toolenv prefix, fix cp_bmi
Sunrisepeak May 18, 2026
612a84c
fix: Windows linker flags — no -L/-rpath/-static (MSVC linker)
Sunrisepeak May 18, 2026
8d76b57
fix: Windows binary output needs .exe suffix + clean ldflags
Sunrisepeak May 18, 2026
6255c27
feat: Windows CI uses xlings to bootstrap mcpp (same as Linux/macOS)
Sunrisepeak May 18, 2026
f303655
feat: Windows CI adds unit tests, E2E suite, and self-host smoke
Sunrisepeak May 18, 2026
365f047
fix: pass MCPP_VENDORED_XLINGS to mcpp test step
Sunrisepeak May 18, 2026
3ef47e6
fix: set MCPP_HOME across all steps to share sandbox with LLVM toolchain
Sunrisepeak May 18, 2026
486b045
fix: restore xmake bootstrap + align CI triggers with Linux/macOS
Sunrisepeak May 18, 2026
b5fee8c
fix: skip mcpp test on Windows (needs clang-scan-deps not yet in xlin…
Sunrisepeak May 18, 2026
f954788
fix: expand WINDOWS_SKIP with tests that need Windows adaptation
Sunrisepeak May 18, 2026
4aca24a
fix: add 02_new_build_run and 16_test_failing to WINDOWS_SKIP
Sunrisepeak May 18, 2026
de6a8ce
fix: address code review feedback for Windows support
Sunrisepeak May 18, 2026
9723664
feat: Windows CI bootstraps via xlings (same as Linux/macOS)
Sunrisepeak May 18, 2026
b986882
fix: retry xlings install mcpp with explicit version on failure
Sunrisepeak May 18, 2026
e594bbb
debug: search for mcpp binary after xlings install
Sunrisepeak May 18, 2026
e1b1ef4
fix: suppress MSVC STL std.ixx warnings when compiled by Clang
Sunrisepeak May 18, 2026
334de05
docs: Windows platform maturity plan (P0-P5 optimization roadmap)
Sunrisepeak May 18, 2026
226a5ae
feat: add build-windows job to release workflow
Sunrisepeak May 18, 2026
c8f7086
fix: add Windows .exe compat to E2E tests 02, 35, 36; remove from WIN…
Sunrisepeak May 18, 2026
ecb186f
feat: P1 — add mcpp.platform module, centralize platform constants
Sunrisepeak May 18, 2026
1969d19
feat: P5 — replace E2E platform skip lists with capability-based tags
Sunrisepeak May 18, 2026
10bdc89
feat(P2): add toolchain ProviderCapabilities dispatch layer
Sunrisepeak May 18, 2026
a6190dc
feat(P3): add mcpp.process — platform-aware process runner module
Sunrisepeak May 18, 2026
4cc2f40
feat(P4): guard mcpp pack on Windows with clear error + add design doc
Sunrisepeak May 18, 2026
384e17b
fix: E2E capability detection — don't add gcc on Windows runners
Sunrisepeak May 18, 2026
71eb485
fix: E2E suite continue-on-error on Windows + better build error output
Sunrisepeak May 18, 2026
9cd7050
fix: macOS E2E — don't detect Apple Clang as gcc capability
Sunrisepeak May 18, 2026
15ebb4a
fix: Windows cmd.exe quoting and clang-scan-deps lookup in cli.cppm
Sunrisepeak May 18, 2026
efbd7d0
fix(e2e): Windows portability for tests 19, 24, 27, 32, 37-41
Sunrisepeak May 18, 2026
c4a9d51
docs: Windows E2E parity plan
Sunrisepeak May 18, 2026
23fa1db
fix: Windows E2E — PowerShell copy for cp_bmi, USERPROFILE fallback, …
Sunrisepeak May 18, 2026
b87176f
fix: tag tests needing fresh sandbox — Windows can't auto-install too…
Sunrisepeak May 18, 2026
29b8da6
docs(probe): note mcpp::process::run_capture for new process invocations
Sunrisepeak May 18, 2026
0b379b6
fix: Windows E2E — double-quote git paths, enable fresh-sandbox, unta…
Sunrisepeak May 18, 2026
e7a0db3
feat(flags): adopt mcpp.toolchain.provider in compute_flags()
Sunrisepeak May 18, 2026
14a8429
fix(e2e): remove stale symlink requirement from 10_env_command.sh
Sunrisepeak May 18, 2026
ebf115a
docs: update Windows maturity plan to reflect current infrastructure …
Sunrisepeak May 18, 2026
9fdfaba
docs: Windows maturity V2 plan
Sunrisepeak May 18, 2026
420051a
fix: re-tag 27_self_contained_home as unix-shell, revert fresh-sandbo…
Sunrisepeak May 19, 2026
0e79f3c
fix: restore elf tag on 27_self_contained_home (fails on macOS due to…
Sunrisepeak May 19, 2026
8a40d2a
fix: enable 3 more Windows E2E tests
Sunrisepeak May 19, 2026
1b1ca30
feat: enable mcpp test on Windows (clang-scan-deps now available)
Sunrisepeak May 19, 2026
c6d2b63
fix: mcpp test continue-on-error on Windows
Sunrisepeak May 19, 2026
577c008
fix: suppress xlings stderr (package index logs) on Windows with 2>nul
Sunrisepeak May 19, 2026
d51a973
debug: show build log on test 02 failure for Windows diagnosis
Sunrisepeak May 19, 2026
1289736
fix: resolve bar.pcm false positive + remove continue-on-error from m…
Sunrisepeak May 19, 2026
5173269
fix: convert ALL raw string literals with import to regular strings
Sunrisepeak May 19, 2026
d89931d
fix: guard POSIX headers and flock test in test_bmi_cache.cpp for Win…
Sunrisepeak May 19, 2026
6ace80f
fix: guard POSIX-only unit tests on Windows
Sunrisepeak May 19, 2026
e0aa359
fix: compare paths as path objects not strings (Windows backslash com…
Sunrisepeak May 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions .agents/docs/2026-05-17-windows-llvm-support-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Windows LLVM/Clang 支持设计方案

Date: 2026-05-17

## 目标

mcpp 在 Windows x86_64 上通过 xmake bootstrap 达到可用水平,产出 mcpp.exe 作为后续自举依赖。

## 平台特征

### Windows LLVM 包(xlings-res 20.1.7)

```
bin/clang.exe, clang++.exe, clang-cl.exe, lld-link.exe
bin/llvm-ar.exe, llvm-lib.exe, llvm-rc.exe
lib/clang/20/lib/windows/clang_rt.*.lib
没有 libc++(没有 include/c++/v1,没有 std.cppm)
没有 clang-scan-deps.exe
```

Windows LLVM 包不含 libc++。Windows 上 clang 搭配 MSVC STL。

### Bootstrap 策略

用 xmake + MSVC(和 xlings 自身做法一致):
- GitHub Actions windows-latest 预装 Visual Studio
- xmake 对 MSVC C++23 modules 支持成熟
- 不需要额外安装 LLVM(MSVC 即可)

## 代码适配清单

### 必须修改

| 文件 | 问题 | 方案 |
|------|------|------|
| ninja_backend.cppm | POSIX shell 命令 | #if _WIN32 cmd.exe 语法 |
| ninja_backend.cppm | mcpp_exe_path() 缺 Windows | GetModuleFileNameA() |
| config.cppm | MCPP_HOME 路径发现缺 Windows | 同上 |
| probe.cppm | command -v Unix only | where.exe |
| probe.cppm | LD_LIBRARY_PATH | Windows 用 PATH |
| flags.cppm | 链接 flags 缺 Windows 分支 | 无 sysroot/rpath |
| xlings.cppm | popen | _popen |

## 执行顺序

1. 创建 ci-windows.yml 用 xmake 构建,看编译错误
2. 根据 CI 错误逐步修代码
3. 产出 mcpp.exe bootstrap binary
4. 上传到 xlings-res
97 changes: 97 additions & 0 deletions .agents/docs/2026-05-19-pack-windows-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Windows Pack Design

**Date:** 2026-05-19
**Status:** Planned (stub guard in place, implementation not yet started)

## Current state

`mcpp pack` is fully functional on Linux and macOS. On Windows it exits early
with a clear error message directing users to the CI workflow:

```
error: `mcpp pack` is not yet supported on Windows.
Use the CI workflow (ci-windows.yml) to produce Windows zip packages.
Windows PE packaging (DLL collection + zip) is planned.
```

The guard lives at the top of `mcpp::pack::run()` in `src/pack/pack.cppm`.

## Why the current implementation cannot run on Windows

The POSIX implementation relies on three Linux/macOS-only mechanisms:

| Mechanism | POSIX usage | Windows equivalent |
|---|---|---|
| `LD_TRACE_LOADED_OBJECTS=1` | Tells the ELF dynamic linker to print deps without executing `main()` | No direct equivalent. Would need `dumpbin /dependents` (MSVC) or `ldd` emulation via `LoadLibraryEx` |
| `patchelf` | Rewrites `RUNPATH` / `PT_INTERP` ELF headers in-place | Not applicable to PE/COFF. DLL search order is controlled by the OS loader and manifest, not embedded paths |
| `tar -czf` | GNU tar — not universally present on Windows before Win11 22H2 | `Compress-Archive` (PowerShell), `7z`, or Win32 `CreateFile`/`MiniZip` |

## Planned Windows pack implementation

### Goal

Produce a self-contained `.zip` archive (not `.tar.gz`) that users can
extract and run with no additional setup:

```
<name>-<version>-x86_64-pc-windows-msvc.zip
└── <name>-<version>-x86_64-pc-windows-msvc/
├── <name>.exe
├── *.dll (bundled DLLs, if any)
└── README.md / LICENSE (if present)
```

### DLL discovery

Replace `ldd_parse()` with a Win32 equivalent:

1. **Primary: `dumpbin /dependents <binary>`** — available when MSVC tools are
on `PATH`. Produces a list of DLL names; resolve each against `PATH` /
`%SystemRoot%\System32` / side-by-side assemblies.

2. **Fallback: `PE header walk`** — open the PE file, walk the Import Directory,
extract DLL names. Can be implemented with `<windows.h>` + `ImageNtHeader`.

3. **Skip-list**: mirror the manylinux skip-list concept for Windows:
`kernel32.dll`, `user32.dll`, `ntdll.dll`, `vcruntime*.dll` (Redist),
`api-ms-win-*.dll` (API sets), `ucrtbase.dll`.

### Archive creation

Use `std::filesystem` to copy files into a staging directory, then produce
the zip with one of:

- **PowerShell** `Compress-Archive` — available on all modern Windows.
Invoke via `run_capture("powershell -Command \"Compress-Archive ..."`)`.
Slow for large trees; fine for typical release packages.
- **libzip / minizip** — statically linkable; avoid the PowerShell dependency.
Preferred long-term.

### Format

- Output file: `.zip` (not `.tar.gz`) on Windows.
- `pack::Format` enum needs a new `Zip` variant (or auto-select by platform).
- `make_plan()` should derive the output extension from the target platform.

### Entry point

No shell wrapper needed on Windows — users double-click `<name>.exe` or run
it from `cmd.exe` / PowerShell directly. If DLLs are bundled, they should be
placed in the **same directory** as the executable (the Win32 loader checks
`%EXE_DIR%` first, before `%PATH%`).

### Implementation checklist (for the future PR)

- [ ] Add `Format::Zip` (or `Format::ZipAuto`) to `pack::Format`
- [ ] Implement `dumpbin_parse()` (or PE header walk fallback) in `pack.cppm`
under `#if defined(_WIN32)`
- [ ] Implement `make_zip()` (PowerShell or libzip) in `pack.cppm`
- [ ] Remove the `#if defined(_WIN32)` early-return guard from `pack::run()`
once the above are ready
- [ ] Add a Windows-specific integration test to `ci-windows.yml`

### CI workflow (current workaround)

Until this is implemented, `ci-windows.yml` zips the raw build output with
PowerShell `Compress-Archive`. This is good enough for CI artifacts but does
not collect/bundle DLLs or apply the staging-directory layout.
43 changes: 43 additions & 0 deletions .agents/docs/2026-05-19-windows-e2e-parity-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Windows E2E 与 macOS 对齐方案

> 目标:Windows E2E 从 20/49 提升到 ~32/49,与 macOS 33/49 对齐。

## 根因分析

| 类别 | 测试数 | 问题 | 修复方式 |
|------|--------|------|----------|
| mcpp run/test 单引号 | 1 (02) | `cli.cppm` 用 POSIX 单引号执行 binary | `_WIN32` 改双引号 |
| clang-scan-deps 查找 | 1 (16) | `cli.cppm` 硬编码无 .exe | 调用已有 `find_scan_deps()` |
| symlink 依赖 | 4 (10,24,27,32) | `_inherit_toolchain.sh` 用 `ln -sf` | 加 `cp -r` fallback |
| bash-specific 语法 | 1 (19) | `compgen -G` 不在 Git Bash | 改用 `find` |
| unix-shell 误标 | 1 (38_mirror) | 实际只需 symlink fallback | 改标签 |
| import-std-libcxx 硬编码路径 | 4 (37,38,40,41) | 测试用 Linux 路径 | 加 Windows 路径 |

## 修复计划

### Fix 1: cli.cppm 单引号 → 双引号 (解锁 02)
- `src/cli.cppm:2611` — `mcpp run` 执行 binary 用 `'{}'` → Windows 改 `"{}"`
- `src/cli.cppm:2522` — fast-path ninja 同上
- `src/cli.cppm:3159` — test PATH prefix 是 POSIX 语法,Windows 跳过

### Fix 2: clang-scan-deps 查找 (解锁 16)
- `src/cli.cppm:2162-2167` — 直接查找 `clang-scan-deps`,不走 `find_scan_deps()`
- 改为调用 `mcpp::toolchain::clang::find_scan_deps(*tc)` 已正确处理 .exe

### Fix 3: _inherit_toolchain.sh cp fallback (解锁 10,24,27,32)
- 当 `ln -sf` 失败时用 `cp -r` 替代
- 自动检测 symlink 可用性

### Fix 4: 19_bmi_cache_reuse.sh bash 兼容 (解锁 19)
- `compgen -G` → `find ... | grep -q .`

### Fix 5: LLVM 测试 Windows 路径 (解锁 37,38,40,41)
- 参照 36_llvm_toolchain.sh 的模式加 Windows 路径和 .exe 处理

### Fix 6: 标签修正
- `38_self_config_mirror.sh` 改标签
- `run_all.sh` 移除已修复测试的标签限制

## 预期结果

修复后:**~32 passed, 0 failed, ~17 skipped** (与 macOS 33 passed 对齐)
40 changes: 40 additions & 0 deletions .agents/docs/2026-05-19-windows-maturity-v2-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Windows 成熟度提升 V2 方案

> 基于 GPT-5.5 评审反馈,将 Windows 从 22/48 提升到 30+/48。

## 任务清单

### T1: 修复 fresh-sandbox 能力 + git clone 单引号
**目标:解锁 02, 24, 27_self, 32(+4 tests)**

- `cli.cppm:1963-1970` — git clone 用 `'{}'` 单引号,Windows cmd.exe 不支持
- `run_all.sh` — Windows 添加 `fresh-sandbox` 能力
- `27_self_contained_home.sh` — 误标 `elf`,实际逻辑是 Windows 可移植的

### T2: process.cppm 实际接入
**目标:消除散落的 popen/system 拼接**

优先替换 5 个高风险 call site:
- `probe.cppm:90` — compiler probing
- `pm/publisher.cppm:211,239` — sha256sum, git archive
- `toolchain/stdmod.cppm:64` — std module compilation
- `build/ninja_backend.cppm:98` — ninja invocation

### T3: provider.cppm 接入 flags/ninja
**目标:消除散落的 is_clang/is_gcc/isMusl 检查**

- `flags.cppm` — 用 `capabilities_for(tc)` 决定 compile/link flags
- `ninja_backend.cppm:155` — scanner 策略用 provider
- `stdmod.cppm:102,122` — BMI 路径用 provider

### T4: 更新过时文档
**目标:文档与代码同步**

- 更新 `.agents/docs/2026-05-19-windows-platform-maturity-plan.md`
- 48 tests(非 49),P1/P2/P3/P5 已完成基础设施

### T5: E2E 标签修正
**目标:最大化 Windows 可运行测试**

- `27_self_contained_home.sh` — `elf` → 空(逻辑是 Windows 可移植的)
- `10_env_command.sh` — 验证是否仍需 symlink
165 changes: 165 additions & 0 deletions .agents/docs/2026-05-19-windows-platform-maturity-plan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
# Windows 平台成熟度提升方案

> 基于 PR #52 code review 反馈,针对 Windows 支持从"可自举"到"生产就绪"的优化路径。

## 当前状态

| 能力 | Linux | macOS | Windows | 差距 |
|------|-------|-------|---------|------|
| self-host | ✅ | ✅ | ✅ | — |
| `mcpp test` (unit) | ✅ | ✅ | ❌ | 缺 clang-scan-deps |
| E2E 覆盖 | 46/46 | 33/46 | 22/48 | 26 项 skip |
| `mcpp pack` | ✅ (musl static) | ✅ (手动) | ❌ (CI 手写 zip) | pack 不支持 PE |
| release workflow | ✅ | ✅ | ✅ | build-windows job 已加 |
| MSVC 工具链 | N/A | N/A | 模型预留 | detect 不支持 |
| 默认工具链回退 | gcc@15.1.0-musl | llvm@20.1.7 | llvm@20.1.7 | ✅ 已修 |

## 优化方案(按优先级)

### P0: 补齐 release workflow + 减少 E2E skip — DONE

**目标:** Windows 二进制进入正式 release 发布流程。

#### 1. release.yml 加 build-windows job — DONE

`release.yml` 中已有 `build-windows` job,产出 `mcpp-<version>-windows-x86_64.zip` + sha256,上传到 GitHub Release。

#### 2. 修复高价值 E2E skip 项

按投入产出排序:

| 测试 | 修复方式 | 工作量 |
|------|----------|--------|
| `02_new_build_run.sh` | 检查 `bin/hello` 或 `bin/hello.exe` | 小 |
| `16_test_failing.sh` | 调查 Windows 上 exit code 传递 | 小 |
| `35_workspace.sh` | 同上,binary 名加 `.exe` 检查 | 小 |
| `36_llvm_toolchain.sh` | 同上 | 小 |
| `19_bmi_cache_reuse.sh` | 修复 `cp_bmi` rule 的混合路径 | 中 |
| `24_git_dependency.sh` | CRLF + Windows 路径处理 | 中 |
| `38_self_config_mirror.sh` | xlings mirror cmd.exe 路径 | 中 |

**预计可把 E2E 从 22 passed 提升到 ~30 passed。**

### P1: PlatformTraits 抽象 — DONE (infrastructure)

**目标:** 减少散落的 `#if defined(_WIN32)` / `#if defined(__APPLE__)`。

`src/platform.cppm` 已创建,集中平台差异(exe_suffix、lib_prefix、null_redirect、shell_quote 等)。

**受益文件:** `plan.cppm`、`flags.cppm`、`ninja_backend.cppm`、`probe.cppm`、`clang.cppm`、`config.cppm`(待各文件迁移到 `mcpp::platform` 命名空间)

### P2: ToolchainProvider 重构 — TODO (src/provider.cppm 待创建)

**目标:** 把工具链行为从散落的 `if (isClang)` / `if (isGcc)` 收敛到 provider 接口。

当前工具链代码分散在:
- `gcc.cppm` — GCC 行为
- `clang.cppm` — Clang/libc++ 行为 + MSVC STL fallback
- `llvm.cppm` — xlings 包映射
- `detect.cppm` — 只处理 GCC/Clang
- `flags.cppm` — 编译/链接 flags 按平台分支
- `ninja_backend.cppm` — 构建规则按平台分支

建议拆成明确的 provider:

```
ToolchainProvider (interface)
├── GccProvider — GCC + glibc/musl
├── ClangLibcxxProvider — Clang + libc++ (Linux/macOS)
├── ClangMsvcProvider — Clang + MSVC STL (Windows)
└── MsvcProvider — cl.exe (未来)
```

每个 provider 声明:
- `frontend()` → 编译器路径
- `c_compiler()` → C 编译器
- `archive_tool()` → ar/llvm-ar/lib.exe
- `scanner()` → clang-scan-deps 路径
- `stdlib_id()` → libc++/libstdc++/msvc-stl
- `find_std_module()` → std.cppm/std.cc/std.ixx
- `compile_flags()` → 平台相关编译 flags
- `link_flags()` → 平台相关链接 flags
- `bmi_traits()` → .gcm/.pcm/.ifc

> **注:** `src/provider.cppm` 尚未创建;现有调用者(gcc.cppm、clang.cppm 等)待迁移。

### P3: 跨平台 Process Runner — DONE (infrastructure, callers pending)

**目标:** 消除 shell 字符串拼接,统一子进程执行。

`src/process.cppm` 已创建,提供 `ProcessOptions` / `ProcessResult` / `run()` 接口:
- POSIX: `fork/exec` + `pipe`
- Windows: `CreateProcessW` + `STARTUPINFOW`

> **注:** 现有调用点(`probe.cppm`、`xlings.cppm`、`stdmod.cppm`、`ninja_backend.cppm`、`config.cppm`)仍使用 `popen`,待逐步迁移到 `process::run()`。

### P4: `mcpp pack` Windows 支持

**目标:** `mcpp pack` 原生支持 Windows PE 打包。

当前 `pack.cppm` 依赖:
- `LD_TRACE_LOADED_OBJECTS` (Linux ELF)
- `patchelf` (RPATH 修改)
- `tar -czf` (打包格式)

Windows 需要:
- DLL 依赖收集(`dumpbin /dependents` 或 `llvm-objdump`)
- 无需 RPATH(DLL 在 exe 同目录自动找到)
- `.zip` 打包 + `.bat` wrapper

建议 pack 做成平台策略:

```
PackStrategy (interface)
├── LinuxElfPack — ldd + patchelf + tar.gz
├── MacosMachoPack — otool + install_name_tool + tar.gz
└── WindowsPePack — dumpbin + zip + .bat
```

### P5: E2E 能力标签化 — DONE (infrastructure)

**目标:** 从"平台 skip 列表"升级为"能力标签"。

能力标签体系已全面落地:
- 全部 48 个 E2E 脚本头部均已声明 `# requires:` 行
- `run_all.sh` 自动检测平台能力(elf、gcc、musl、pack、symlink、scan-deps、import-std-libcxx、unix-shell、fresh-sandbox)并动态 skip
- 不再维护平台 skip 列表

支持的标签:

```bash
# requires: elf — 需要 ELF 工具链
# requires: gcc — 需要 GCC
# requires: symlink — 需要 ln -sf(仅 Linux/macOS 或 Windows Developer Mode)
# requires: scan-deps — 需要 clang-scan-deps
# requires: import-std-libcxx — 需要 import std (std.cppm via libc++)
# requires: pack — 需要 mcpp pack
# requires: unix-shell — 需要 bash 风格 shell(非 cmd.exe)
# requires: fresh-sandbox — 需要隔离 MCPP_HOME
```

## 实施顺序

```
P0 release + E2E 修复 ✅ DONE(release.yml build-windows job 已加)
P1 PlatformTraits ✅ DONE(src/platform.cppm 已创建,待调用者迁移)
P2 ToolchainProvider ← src/provider.cppm 待创建 + 调用者迁移
P3 Process Runner ✅ DONE(src/process.cppm 已创建,待调用者迁移)
P4 mcpp pack Windows ← 产品化打包
P5 E2E 标签化 ✅ DONE(全部 48 个测试已标签化)
```

## 预期里程碑

| 阶段 | 目标 | Windows E2E 通过率 |
|------|------|-------------------|
| 当前 | self-host + 基础 E2E | 22/48 (46%) |
| P0 完成 | release + 高价值 E2E | ~30/48 (63%) |
| P1+P2 完成 | 平台抽象 + provider | ~35/48 (73%) |
| P3+P4 完成 | process runner + pack | ~40/48 (83%) |
| P5 完成 | 能力标签 | 动态评估 |
Loading
Loading