Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 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
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 对齐)
Loading
Loading