Skip to content

Commit 1813835

Browse files
committed
fix(bench): make the cmake arm actually compile, and stop handing bench a shim
**1. cmake + clang 建不了任何真实工程 —— 因为 `set()` 的顺序。** `CMAKE_CXX_EXTENSIONS OFF` 写在 `project()` **之后**。CMake 为 std 模块合成的 那个目标是在 `project()` 里的编译器探测阶段建出来的,它捕获的是**那一刻**的 `CMAKE_CXX_EXTENSIONS` —— 默认 ON。于是 std.pcm 按 `gnu++23` 编,而所有真实目标 按 `c++23` 编,clang 拒绝加载: error: GNU extensions was enabled in precompiled file 'std.pcm' but is currently disabled `import std;` 什么都没提供,构建在 19 处死于 `use of undeclared identifier 'std'` —— 报错指着 mcpp 的源码,既不提 std.pcm 也不提 extensions。**同一个文件里紧挨着 的注释已经为实验性 key 写下了「必须在 project() 之前」,方言设置漏了同一条规矩。** mcpp 与 xlings 两份描述都有,都已修。本地实测:改前 19 个错误 build 失败, 改后 `1 ok, 0 failed`,整棵 137 模块的树用 cmake+clang 编通。 **2. `$MCPP` 不是二进制,是 shim —— 上一次「按路径指定」的修复没有走出 shim。** `$MCPP` = `<xlings home>/subos/default/bin/mcpp`,是一个**指向 `xlings` 的符号 链接**,按 argv[0] 分发并**依据被调用时的工作目录**重新决定 exec 哪个 mcpp。而 bench 刻意让每个引擎在**被测树里**跑,那些树各自带 `.xlings.json`。于是: mcpp@2026.8.11.2 | [error] unknown command: build 上一版把裸 `mcpp` 换成 `$MCPP`,只是把解析提前了一步,**没有离开 shim** —— 症状从 `version not found` 变成 `unknown command`,缺陷没动。现在从 xlings 的 `data/runtimedir/mcpp-<ver>-<os>-<arch>/` 里解析出真正的 ELF,并且**断言它自己 报出的版本号等于 pin**(靠目录名叫这个版本是不够的)。解析不到就只跑单臂并 `::warning::`,不再拿一个会失败的引擎充数。 本地直接复现过:同一个目录下 shim 报 2026.8.11.2,解析出的二进制报 2026.8.11.3。 **3. xlings 的 lua_stdlib 生成器静默 return。** 包不在就跳过生成,构建随后死于 `missing mcpplibs.xpkg.lua_stdlib dependency`,指着消费者。与今天早些时候 mcpplibs.cmdline 那个是同一个形状,改成 raise。
1 parent bbd9c21 commit 1813835

4 files changed

Lines changed: 84 additions & 15 deletions

File tree

.github/workflows/bench.yml

Lines changed: 44 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,30 @@ jobs:
243243
xlings install "mcpp@$REFERENCE_MCPP" -y || echo "::warning::mcpp@$REFERENCE_MCPP unavailable; the reference column will be missing"
244244
echo "::endgroup::"
245245
246+
# Resolve the reference to a REAL BINARY, because the thing on PATH
247+
# (and $MCPP) is a shim that re-picks a version from the working
248+
# directory — see the engine-spec step for what that cost. xlings
249+
# unpacks each version to data/runtimedir/mcpp-<ver>-<os>-<arch>/mcpp;
250+
# $MCPP is <home>/subos/default/bin/mcpp, so the home is three levels up.
251+
ref=""
252+
xl_home="$(cd "$(dirname "$MCPP")/../../.." && pwd)"
253+
for c in "$xl_home"/data/runtimedir/mcpp-"$REFERENCE_MCPP"-*/mcpp \
254+
"$xl_home"/data/runtimedir/mcpp-"$REFERENCE_MCPP"-*/mcpp.exe; do
255+
[ -x "$c" ] || continue
256+
# Asserted, not assumed: a binary found by glob under a versioned
257+
# directory still has to SAY it is that version, or the reference
258+
# column silently compares against something else.
259+
got="$("$c" --version 2>/dev/null | grep -oE '[0-9]+(\.[0-9]+){2,3}' | head -1)"
260+
if [ "$got" = "$REFERENCE_MCPP" ]; then ref="$c"; break; fi
261+
echo "::warning::$c reports '$got', not '$REFERENCE_MCPP'; ignoring it"
262+
done
263+
if [ -n "$ref" ]; then
264+
echo "reference mcpp binary: $ref ($REFERENCE_MCPP)"
265+
else
266+
echo "::warning::no mcpp@$REFERENCE_MCPP binary under $xl_home/data/runtimedir; the reference column will be missing"
267+
fi
268+
echo "REFERENCE_BIN=$ref" >> "$GITHUB_ENV"
269+
246270
# Loud, because a version that quietly differs from the pin is the whole
247271
# class of bug this section exists to end.
248272
- name: Report the resolved tool versions
@@ -387,18 +411,28 @@ jobs:
387411
#
388412
# Putting it back is one line, and the §8 reproduction is the gate:
389413
# all six fixture scenarios green at --runs 2 before it returns.
390-
# BOTH ARMS BY PATH, never the bare `mcpp` shim. The measured
391-
# workloads carry their own `.xlings.json`, and the harness runs
392-
# every engine with its cwd inside the workload — so a bare `mcpp`
393-
# resolves against THAT workspace's pin and fails with
414+
# BOTH ARMS BY REAL BINARY — and $MCPP is NOT one.
415+
#
416+
# $MCPP is `<xlings home>/subos/default/bin/mcpp`, which is a
417+
# SYMLINK TO `xlings` that dispatches on argv[0] and re-resolves
418+
# which mcpp to exec from the workspace it is invoked in. bench
419+
# deliberately runs every engine with its cwd inside the measured
420+
# tree, and those trees carry their own `.xlings.json` — so the
421+
# shim executed a version nobody asked for and the cells failed as
394422
#
395-
# xlings: version '2026.8.11.2' not found for 'mcpp'
396-
# available: 2026.8.11.3
423+
# mcpp@2026.8.11.2 | [error] unknown command: build
397424
#
398-
# $MCPP is the binary the bootstrap installed, which IS
399-
# reference_mcpp (both come from .xlings.json — asserted by
400-
# tests/e2e/233_bench_matrix.sh).
401-
e="mcpp=$MCPP_UNDER_TEST,mcpp=$MCPP"
425+
# Passing $MCPP here was a fix for the PREVIOUS spelling of this
426+
# same bug (a bare `mcpp`, which failed as `version '2026.8.11.2'
427+
# not found`). It moved the resolution one step earlier without
428+
# leaving the shim, so the symptom changed and the defect did not.
429+
# $REFERENCE_BIN is resolved in the step above out of xlings'
430+
# runtimedir, i.e. an actual ELF.
431+
if [ -n "$REFERENCE_BIN" ]; then
432+
e="mcpp=$MCPP_UNDER_TEST,mcpp=$REFERENCE_BIN"
433+
else
434+
e="mcpp=$MCPP_UNDER_TEST"
435+
fi
402436
fi
403437
engines="${engines:+$engines,}$e"
404438
done

bench/projects/mcpp/CMakeLists.txt

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,29 @@ cmake_minimum_required(VERSION 3.30)
2929
# compiler-support probe that reads it runs during project().
3030
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "a9e1cf81-9932-4810-974b-6eccaf14e457")
3131

32-
project(mcpp CXX)
33-
32+
# The DIALECT settings belong before project() for the same reason as the key
33+
# above, and getting that wrong is not a style question — it is why this arm
34+
# could not build at all.
35+
#
36+
# CMake synthesises its own target for the std module during the compiler probe
37+
# inside project(). That target captures whatever CMAKE_CXX_EXTENSIONS says AT
38+
# THAT MOMENT, and the default is ON. Set OFF afterwards, std.pcm is built as
39+
# `gnu++23` while every real target compiles as `c++23`, and clang refuses the
40+
# mismatch:
41+
#
42+
# error: GNU extensions was enabled in precompiled file 'std.pcm'
43+
# but is currently disabled
44+
# error: precompiled file 'std.pcm' cannot be loaded due to a configuration
45+
# mismatch with the current compilation
46+
#
47+
# `import std;` then supplies nothing and the build dies in 19 places with
48+
# `use of undeclared identifier 'std'` — an error that points at mcpp's sources
49+
# and names neither std.pcm nor extensions.
3450
set(CMAKE_CXX_STANDARD 23)
3551
set(CMAKE_CXX_STANDARD_REQUIRED ON)
3652
set(CMAKE_CXX_EXTENSIONS OFF)
53+
54+
project(mcpp CXX)
3755
# Every mcpp module says `import std;`. This asks CMake to build the standard
3856
# library module from the compiler's own libstdc++.modules.json, which the
3957
# hermetic gcc payload ships.

bench/projects/xlings/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,18 @@ cmake_minimum_required(VERSION 3.30)
4343
# CMake version — this is the CMake 4.0 key. Must be set BEFORE project().
4444
set(CMAKE_EXPERIMENTAL_CXX_IMPORT_STD "a9e1cf81-9932-4810-974b-6eccaf14e457")
4545

46-
project(xlings CXX)
47-
46+
# Before project() for the same reason as the key above: CMake builds the std
47+
# module through a target it synthesises during the compiler probe inside
48+
# project(), and that target captures CMAKE_CXX_EXTENSIONS as it stands right
49+
# then — default ON. Setting OFF afterwards yields a `gnu++23` std.pcm that no
50+
# `c++23` target can load, and the build fails with `use of undeclared
51+
# identifier 'std'` pointing at the project's own sources. See the identical
52+
# block in ../mcpp/CMakeLists.txt, where this was diagnosed.
4853
set(CMAKE_CXX_STANDARD 23)
4954
set(CMAKE_CXX_STANDARD_REQUIRED ON)
5055
set(CMAKE_CXX_EXTENSIONS OFF)
56+
57+
project(xlings CXX)
5158
set(CMAKE_CXX_MODULE_STD 1)
5259

5360
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)

bench/projects/xlings/xmake.lua

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,17 @@ target("xlings")
145145
-- LUA_STDLIB_DIR is an UPVALUE resolved at description scope: the
146146
-- helper that produces it is not reachable from inside this callback.
147147
local stdlib = LUA_STDLIB_DIR
148-
if not stdlib or not os.isdir(stdlib) then return end
148+
-- FATAL, not a silent return. Returning here skips emitting the module
149+
-- and the build dies far away with
150+
-- missing mcpplibs.xpkg.lua_stdlib dependency for module ...
151+
-- naming a consumer instead of the absent package — which is exactly
152+
-- how this failed on CI while passing on a box that had it unpacked.
153+
-- (Same defect, same day, as the mcpplibs.cmdline arm in ../mcpp/.)
154+
if not stdlib or not os.isdir(stdlib) then
155+
raise("bench: mcpplibs.xpkg's lua-stdlib is not unpacked (looked for "
156+
.. tostring(stdlib) .. ") — build the tree with mcpp once first, "
157+
.. "so this arm generates the same module mcpp does")
158+
end
149159

150160
local out = path.join(os.projectdir(), "build", "generated", "xpkg-lua-stdlib.cppm")
151161
local text = {

0 commit comments

Comments
 (0)