Skip to content

feat(toolchain): Linux→Windows MinGW cross toolchain (mingw-cross) — host≠target (0.0.92)#216

Merged
Sunrisepeak merged 1 commit into
mainfrom
feat/mingw-linux-cross-windows
Jul 14, 2026
Merged

feat(toolchain): Linux→Windows MinGW cross toolchain (mingw-cross) — host≠target (0.0.92)#216
Sunrisepeak merged 1 commit into
mainfrom
feat/mingw-linux-cross-windows

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

Linux → Windows MinGW-w64 交叉工具链(mingw-cross)

在 Linux 主机上交叉编译出 Windows x86_64 PE(含 import std)。补 0.0.89 msvc-mingw-design §4.4/§7 登记的延期项——工具链抽象的最后一维 host≠target

改动

  • registry: mingw-cross → xim mingw-cross-gcc(前端 x86_64-w64-mingw32-g++、triple 前缀 archiver、Linux 主机 index 可见)
  • lifecycle: 解除 MinGW 的 Windows-host 门(native mingw 仍 Windows-only);跳过 glibc/linux-headers(PE 自带 CRT)
  • prepare: --target x86_64-w64-mingw32 约定 → mingw-cross@16.1.0,默认 static
  • host≠target 修复(真实端到端验证暴露):
    • gcc.cppm: std 模块源探测补 <prefix>/<triple>/include/c++/ 子目录
    • gcc.cppm + flags.cppm: 自包含工具链(musl+mingw)跳过外部 -B(Linux as 编不了 MinGW 的 PE/SEH asm)
    • flags.cppm: MinGW PE link(-static/-lstdc++exp)由 is_windows host 门改为 is_mingw_target target 判定(此前 Linux 交叉永不进该分支)

工具链 + 生态(已发布)

  • 从源码建 GCC 16.1.0 mingw-w64 MSVCRT 交叉链(CRT 跟随 Rust Tier-1 x86_64-pc-windows-gnu)
  • 发布于 xlings-res/mingw-cross-gcc(GitHub+GitCode)+ xim-pkgindex(PR #389 已合)

验证(全链实测闭环)

mcpp toolchain install mingw-cross 16.1.0mcpp build --target x86_64-w64-mingw32crosswin.exe(PE32+,仅 KERNEL32+msvcrt)→ wine 跑 import std + 多模块。单测 33/33;e2e 102_mingw_cross_wine.sh 过;CI cross-build-testmingw-cross-wine job。

设计:.agents/docs/2026-07-15-mingw-linux-cross-windows-design.md(§11 实测结果 + 4 个 host≠target bug 复盘)。

…host≠target (0.0.92)

Cross-compile Windows x86_64 PE (incl. import std) from a Linux host — the
deferred host≠target axis registered in the 0.0.89 msvc-mingw design (§4.4/§7).

- registry: mingw-cross → xim mingw-cross-gcc (x86_64-w64-mingw32-g++ frontend,
  triple-prefixed archiver, Linux-host index visibility)
- lifecycle: lift the Windows-host gate for the cross package (native mingw stays
  Windows-only); skip glibc/linux-headers sysroot deps (PE own CRT)
- prepare: --target x86_64-w64-mingw32 convention → mingw-cross@16.1.0, static
- host≠target fixes surfaced by real end-to-end validation:
  * gcc.cppm: find std module source under <prefix>/<triple>/include/c++/
  * gcc.cppm + flags.cppm: self-contained toolchains (musl+mingw) skip external -B
    (Linux as can't assemble MinGW PE/SEH output)
  * flags.cppm: MinGW PE link (-static / -lstdc++exp) keyed on is_mingw_target
    (target) instead of is_windows (host) — was unreachable on a Linux cross
- toolchain: from-source GCC 16.1.0 mingw-w64 MSVCRT cross, published at
  xlings-res/mingw-cross-gcc + xim-pkgindex (import std verified under wine)
- tests: unit MapsMingwCrossSpecToCrossPackage; e2e 102_mingw_cross_wine.sh;
  run_all mingw-cross/wine caps; CI cross-build-test mingw-cross-wine job
- design: .agents/docs/2026-07-15-mingw-linux-cross-windows-design.md

Verified end-to-end via the published ecosystem: mcpp toolchain install
mingw-cross → mcpp build --target x86_64-w64-mingw32 → PE32+ (KERNEL32+msvcrt
only) → wine runs import std + multi-module.
@Sunrisepeak Sunrisepeak merged commit aad785b into main Jul 14, 2026
7 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.

2 participants