Skip to content

Commit 270bd92

Browse files
committed
fix(bench): the same rewrite broke a third check — now there is a guard
`linux/clang/fixture` 84 ok / 6 failed: g++: error: unrecognized command-line option '--no-default-config' clang 格子里 xmake 用了 **g++**,而描述里写的是 clang 的 flags。成因和我上一个 提交修的 `payload_toolchain` **一模一样**:main.cpp 把 `--compiler payload:clang` 改写成绝对路径后,`job.compiler == "clang"` 在**恰恰需要它为真的那些格子里**永远 为假,于是 `--toolchain=llvm` 没传,xmake 回落到默认编译器。 **我上次只修了一处,没有回头查还有谁在比同一个字符串。** 这是同一个改写第三次 咬人,每次在 review 里都读着像对的 —— 因为被比较的正是用户敲进去的那个词。 所以补的不只是那一行,还有 e2e 233 §7:**禁止任何引擎适配器按字面量比较 `job.compiler`**(`engine.cppm` 的 `resolve_cxx` 除外 —— 它是入口归一化,在改写 之前运行)。判据剔除注释行,两个方向都验过:改回字面量比较会红,还原后绿。
1 parent 1f4552e commit 270bd92

2 files changed

Lines changed: 48 additions & 1 deletion

File tree

bench/src/engines/xmake.cppm

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,17 @@ public:
153153
return platform::run(argv, job.buildfile_dir, job.log_path, job.timeout_s);
154154
}
155155
}
156-
if (job.compiler == "clang") argv.push_back("--toolchain=llvm");
156+
// Decided from the RESOLVED DRIVER, not from the literal string "clang"
157+
// — main.cpp rewrites `--compiler payload:clang` into an absolute path
158+
// before any engine sees it, so `job.compiler == "clang"` is false in
159+
// exactly the cells that need this. xmake then fell back to g++ while
160+
// the description carried clang's flags:
161+
// g++: error: unrecognized command-line option '--no-default-config'
162+
// Six fixture cells in the linux/clang job. Same rewrite, same mistake
163+
// as `payload_toolchain` above — which I fixed without checking whether
164+
// anything else tested the same string.
165+
if (job.compiler.find("clang") != std::string::npos)
166+
argv.push_back("--toolchain=llvm");
157167
// The driver is pinned through CXX so every engine compiles with the
158168
// SAME binary; without it xmake resolves whatever `g++` means on this
159169
// host, and the comparison silently becomes compiler-vs-compiler.

tests/e2e/233_bench_matrix.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,4 +397,41 @@ if bad:
397397
print(f"no cell schedules bazel against a ruleless package ({len(m['cells'])} cells)")
398398
PY
399399

400+
# §7. No engine adapter may branch on the LITERAL compiler request.
401+
#
402+
# main.cpp resolves `--compiler payload:clang` into an absolute driver path
403+
# before any engine sees it, so `job.compiler == "clang"` is false in exactly
404+
# the cells that mean clang. That rewrite has now broken three separate checks:
405+
# * `payload_toolchain` — --toolchain=mcpp-* was never passed at all
406+
# * `--toolchain=llvm` — xmake fell back to g++ with clang's flags:
407+
# `g++: unrecognized command-line option
408+
# '--no-default-config'`, six fixture cells red
409+
# * (the same shape would hit any new one written the same way)
410+
#
411+
# Each time it looked correct in review, because the string being compared is
412+
# the string the user typed. Adapters must key off the RESOLVED PATH instead.
413+
python3 - "$ROOT" <<'PY' || exit 1
414+
import pathlib, re, sys
415+
root = pathlib.Path(sys.argv[1]) / "bench/src/engines"
416+
bad = []
417+
for f in root.glob("*.cppm"):
418+
# engine.cppm's resolve_cxx() is the NORMALISER — comparing there is how a
419+
# bare `gcc` becomes `g++`, and it runs before any rewrite. Everything else
420+
# sees the resolved path.
421+
if f.name == "engine.cppm":
422+
continue
423+
for n, line in enumerate(f.read_text().splitlines(), 1):
424+
code = line.split("//", 1)[0]
425+
if re.search(r'compiler\s*==\s*"(clang|gcc)"', code):
426+
bad.append(f"{f.name}:{n}: {line.strip()[:90]}")
427+
if bad:
428+
print("FAIL: an engine adapter compares job.compiler to a literal:")
429+
for b in bad:
430+
print(" " + b)
431+
print(" main.cpp rewrites payload:* into a path first, so that test never fires.")
432+
print(" Key off the resolved driver path (see payload_toolchain).")
433+
sys.exit(1)
434+
print("no engine adapter branches on the literal compiler request")
435+
PY
436+
400437
echo "bench matrix OK"

0 commit comments

Comments
 (0)