Skip to content

Commit 6c13349

Browse files
committed
ci(cross): scope the artefact search to the target tree; record B3
The cross-build itself succeeded on the first real Windows run — 'Finished release [optimized] in 119.09s', resolving through x86_64-linux-musl-g++.exe, which is B1's fix working. The job still failed, for two reasons worth separating: 1. target/ holds the host build from the previous step alongside the cross build, and both are named mcpp*. The search now starts at target/x86_64-linux-musl/ so it cannot pick up the wrong one. 2. The artefact is named mcpp.exe despite being an ELF. plan.cppm's target_output() spells the suffix from mcpp::platform::exe_suffix — a HOST constant — so this is the same host-decides-target confusion as B2, and it is symmetric: a Linux→Windows cross produces a PE with no .exe today. B3 is filed in the design doc (§6.5) rather than fixed here. Renaming build outputs is a behaviour change that reaches the mingw e2e, the release packaging paths and any user script, and neither direction is actually broken today — folding a regression-prone rename into this PR would defeat the layered-commit discipline the series was built around. The job matches both spellings so it is correct before and after that fix. Also prints the tree on failure, so the next person does not have to fetch the job log to find out what was actually produced.
1 parent 08f6638 commit 6c13349

2 files changed

Lines changed: 48 additions & 2 deletions

File tree

.agents/docs/2026-08-03-windows-host-linux-cross-design.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,36 @@ package = {
631631
632632
---
633633
634+
## 6.5 B3 —— 同一类问题的第三例(本期发现,**未修**,登记 follow-up)
635+
636+
CI 首次真正跑通交叉构建时暴露的:产物叫 `mcpp.exe`,而它是个 **ELF**
637+
638+
`plan.cppm:200-213` 的 `target_output()`:
639+
640+
```cpp
641+
return std::filesystem::path("bin") /
642+
std::format("{}{}", t.name, mcpp::platform::exe_suffix); // ← host 常量
643+
```
644+
645+
`exe_suffix` / `lib_prefix` / `static_lib_ext` / `shared_lib_ext` **四个都是 host 常量**
646+
(`platform/common.cppm:18-29`),却用来命名 **target** 产物。与 B2 完全同构,而且**对称地错**:
647+
648+
| 方向 | 现状 | 应当 |
649+
|---|---|---|
650+
| Windows → linux-musl | `mcpp.exe`(却是 ELF) | `mcpp` |
651+
| Linux → windows-gnu | `mcpp`(却是 PE) | `mcpp.exe` |
652+
653+
**为什么本期不修**:改产物命名是行为变更,会同时动到 `tests/e2e/102_mingw_cross_wine.sh`、
654+
release 打包路径和任何用户脚本;而两个方向的现状都**不致命**(扩展名在 Linux 上无意义,
655+
Windows 命令行也能跑无扩展名的 PE)。把一个有回归面的重命名塞进本 PR,违背了 §1.3 定下的
656+
「单 PR 但提交分层、失败可归因」的初衷。
657+
658+
**修的时候要一起改的四个常量**,并且要注意 `runtime_aliases_for_target()`(`plan.cppm:215`)
659+
依赖 `target_output()` 的结果去比对 soname —— 见 [[soname-alias-explicit-ninja-goals]],
660+
那条边曾经因为类似改动漏生成过。
661+
662+
---
663+
634664
## 7. 边界:本方案不做什么
635665
636666
- **不碰 clang cross 轴**。`cross-build-test.yml:38-40` 记着 "mcpp does not yet inject `-target <triple>` +

.github/workflows/cross-build-test.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,9 +340,25 @@ jobs:
340340
run: |
341341
export MCPP_VENDORED_XLINGS="$XLINGS_BIN"
342342
"$MCPP_SELF" build --target x86_64-linux-musl
343-
OUT=$(find target -name "mcpp" -type f -path "*/bin/*" -printf "%T@ %p\n" \
343+
# Scope the search to the TARGET's output tree — target/ also holds the
344+
# host build from the previous step, and both are named "mcpp*".
345+
#
346+
# The artefact carries a `.exe` suffix even though it is an ELF:
347+
# plan.cppm's target_output() spells the suffix from
348+
# mcpp::platform::exe_suffix, a HOST constant. That is the same
349+
# host-decides-target confusion as B2, and it is symmetric — a
350+
# Linux→Windows cross produces a PE with no `.exe` today. Renaming the
351+
# output is a behaviour change that would touch the mingw e2e and any
352+
# user script, so it is filed as follow-up rather than folded in here;
353+
# match both spellings so this job is correct either way.
354+
OUT=$(find target/x86_64-linux-musl -type f -path "*/bin/*" \
355+
\( -name "mcpp" -o -name "mcpp.exe" \) -printf "%T@ %p\n" \
344356
| sort -rn | head -1 | cut -d" " -f2-)
345-
test -n "$OUT" || { echo "FAIL: no cross artefact produced"; exit 1; }
357+
if [ -z "$OUT" ]; then
358+
echo "FAIL: no cross artefact produced; tree was:"
359+
find target/x86_64-linux-musl -type f -path "*/bin/*" | head -20
360+
exit 1
361+
fi
346362
cp "$OUT" mcpp-linux-musl
347363
ls -la mcpp-linux-musl
348364

0 commit comments

Comments
 (0)