Skip to content

Commit f51e6ab

Browse files
committed
feat(bench): xmake builds xlings; the binary still needs its deps static
**xmake 臂现在能编出二进制**(`build rc=0`,100%,产物存在),依赖链全部装上: cmdline / capi-lua / tinyhttps / xpkg / mbedtls / zstd / xz / lzo / lua / libarchive 都 `ok`。这是靠三处: * **mcpplibs-index 的三个修复**(#15 #16 #17,均已合入):cmdline 装测试、 libxpkg 的 tag 没有 `v` 前缀、以及 xpkg 的 lua_stdlib 生成时机 —— 生成必须 发生在**描述被读取之前**,`before_build` 比模块扫描还晚。 * **`libarchive-xlings` 覆盖包**,直接沿用 xlings 自己那份 (openxlings/xlings@bb27e43 的 `xmake/packages/libarchive.lua`)。xmake-repo 的 libarchive 在 payload 工具链下死在 `CMake Error at CMakeLists.txt:1349: libgcc not found.` —— 覆盖包里的 `-DENABLE_LibGCC=OFF` 正是这条。 * **工具链补齐 `as`/`ranlib`/`nm`/`objcopy`**:`-B<binutils>/bin` 只让 gcc 驱动 找得到汇编器,xrepo 建包时是 xmake 自己解析程序,否则停在 `cannot get program for as`。 **仍未完成的一步:二进制起不来。** error while loading shared libraries: libbz2.so.1.0 已经定位清楚,不是猜的:宿主**有** `/usr/lib/x86_64-linux-gnu/libbz2.so.1.0`, 链接期 ld 找得到;但产物的解释器是 payload 的**私有 loader** (`xim-x-glibc/2.44/lib64/ld-linux-x86-64.so.2`),它的默认搜索路径是载荷前缀而 **不是 `/usr/lib`**。根因再往上一层:bzip2/lz4/xz 没有真正被 xrepo 装上 (`.xmake/packages/b/` 是空的),libarchive 于是回落到宿主的动态库。 `add_requireconfs("**", {configs = {shared = false}})` 已加,但这次没生效 —— 包已按动态装好、configure 全命中缓存直接短路(日志只有 119 字节)。要让它生效 必须先清掉这些包重装。 **另外两条臂的过期说法已更正。** bench/README 里写着 cmake/xmake 臂 "stop at the link" 并记为已知缺口 —— 那不是缺口,是没做完的工作,而"缺口"这个 词让它躺了很久。现在写明 cmake/bazel 已能编出可运行二进制,且**表中数字是那 之前测的、尚未重测**,不要把"没有 cmake/xmake 列"读成对那些引擎的结论。
1 parent fa499b9 commit f51e6ab

4 files changed

Lines changed: 99 additions & 4 deletions

File tree

bench/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,16 @@ Four things this says, and the fixture can say none of them:
192192

193193
110 modules, 46k lines, different authors, never tuned for this. The two pins
194194
are the same project either side of one refactor. Ratios against the released
195-
mcpp, because the cmake and xmake arms stop at the link here (SPEC.md §2).
195+
mcpp.
196+
197+
> **These numbers predate the foreign arms working.** For a long time this said
198+
> the cmake and xmake arms "stop at the link", and that was recorded as a known
199+
> gap — it was not a gap, it was unfinished work, and calling it a gap let it
200+
> sit. The cmake and bazel arms now build both trees into a running binary
201+
> (`xlings --version` reports the tree's own version on each); xmake is in
202+
> progress. The table below is still mcpp-against-mcpp because it has not been
203+
> re-measured since. Until it is, do not read the absence of cmake and xmake
204+
> columns here as a statement about those engines.
196205
197206
| scenario | combined `2026.8.11.2` old → new | split `2026.8.13.1` old → new | what the split buys |
198207
|---|---|---|---|
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
-- libarchive-xlings — reused verbatim in shape from xlings' own
2+
-- `xmake/packages/libarchive.lua` (openxlings/xlings @ bb27e43), which is where
3+
-- xlings keeps it. Kept as a local package definition here for the same reason
4+
-- it is local there: it overrides a third-party package for this project's
5+
-- needs, so it does not belong in mcpplibs-index.
6+
--
7+
-- WHY THE OVERRIDE IS NEEDED AT ALL. xmake-repo's `libarchive` configures with
8+
-- libarchive's own defaults, and under the hermetic payload toolchain that
9+
-- stops the install dead:
10+
--
11+
-- CMake Error at CMakeLists.txt:1349 (MESSAGE):
12+
-- libgcc not found.
13+
--
14+
-- `-DENABLE_LibGCC=OFF` below is the line that fixes it. The rest of the OFFs
15+
-- are the tools and test suites xlings never links — the same class of problem
16+
-- the cmake arm hit from the other direction, where libarchive's test suite
17+
-- could not even configure.
18+
--
19+
-- UPSTREAM'S OWN NOTE, kept because it is not obvious: the dependency list uses
20+
-- `xz` rather than `lzma`, because libarchive probes via `find_package(LibLZMA)`
21+
-- and that resolves to xz-utils' liblzma, not the 7-Zip LZMA SDK. With the wrong
22+
-- one it silently falls back to fork-exec for `.tar.xz`, which is a correctness
23+
-- difference, not a packaging preference.
24+
package("libarchive-xlings")
25+
26+
set_base("libarchive")
27+
28+
add_versions("3.8.7", "4b787cca6697a95c7725e45293c973c208cbdc71ae2279f30ef09f52472b9166")
29+
add_versions("3.8.6", "213269b05aac957c98f6e944774bb438d0bd168a2ec60b9e4f8d92035925821c")
30+
31+
add_deps("cmake")
32+
add_deps("zlib", "bzip2", "lz4", "zstd", "xz")
33+
34+
if is_plat("windows") then
35+
add_syslinks("advapi32")
36+
end
37+
38+
on_install("windows", "linux", "macosx", function (package)
39+
local configs = {
40+
"-DENABLE_TEST=OFF",
41+
"-DENABLE_CAT=OFF",
42+
"-DENABLE_TAR=OFF",
43+
"-DENABLE_CPIO=OFF",
44+
"-DENABLE_OPENSSL=OFF",
45+
"-DENABLE_PCREPOSIX=OFF",
46+
"-DENABLE_LibGCC=OFF",
47+
"-DENABLE_CNG=OFF",
48+
"-DENABLE_ICONV=OFF",
49+
"-DENABLE_ACL=OFF",
50+
"-DENABLE_EXPAT=OFF",
51+
"-DENABLE_LIBXML2=OFF",
52+
"-DENABLE_LIBB2=OFF",
53+
"-DENABLE_ZLIB=ON",
54+
"-DENABLE_BZip2=ON",
55+
"-DENABLE_LZ4=ON",
56+
"-DENABLE_ZSTD=ON",
57+
"-DENABLE_LZMA=ON",
58+
}
59+
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
60+
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
61+
if not package:config("shared") then
62+
package:add("defines", "LIBARCHIVE_STATIC")
63+
end
64+
import("package.tools.cmake").install(package, configs)
65+
end)
66+
67+
on_test(function (package)
68+
assert(package:has_cfuncs("archive_version_number", {includes = "archive.h"}))
69+
end)
70+
71+
package_end()

bench/projects/xlings/xmake.lua

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,18 @@ bench_define_toolchains(XLINGS_MANIFEST)
7474
-- (mcpplibs/mcpplibs-index#14, merged.) MCPPLIBS_INDEX still overrides the URL,
7575
-- which is how the next version bump gets tested against a checkout before it
7676
-- is published.
77+
includes("packages/libarchive.lua")
78+
79+
-- EVERY dependency static, transitively. Without this the binary builds and
80+
-- then cannot start:
81+
-- error while loading shared libraries: libbz2.so.1.0: cannot open
82+
-- shared object file: No such file or directory
83+
-- bzip2 arrives through libarchive and xrepo built it shared, so the link
84+
-- succeeded against a .so that is not on any runtime path. It also matters for
85+
-- the comparison: mcpp produces a self-contained binary here (the arm passes
86+
-- `-static-libstdc++` below), so an arm that leaves its dependencies dynamic is
87+
-- not producing the same artifact.
88+
add_requireconfs("**", {configs = {shared = false}})
7789
add_repositories("mcpplibs-index " ..
7890
(os.getenv("MCPPLIBS_INDEX") or "https://github.com/mcpplibs/mcpplibs-index.git"))
7991

@@ -82,7 +94,10 @@ add_requires("mcpplibs-capi-lua 0.0.3")
8294
add_requires("mcpplibs-tinyhttps 0.2.9")
8395
add_requires("mcpplibs-xpkg 0.0.57")
8496
add_requires("ftxui 6.1.9")
85-
add_requires("libarchive 3.8.7")
97+
-- libarchive-xlings, not plain libarchive: xmake-repo's build stops at
98+
-- `CMake Error at CMakeLists.txt:1349 (MESSAGE): libgcc not found.` under the
99+
-- payload toolchain. The override is xlings' own (see packages/libarchive.lua).
100+
add_requires("libarchive-xlings 3.8.7")
86101

87102

88103
target("xlings")
@@ -112,7 +127,7 @@ target("xlings")
112127
-- (xrepo/packages/m/mcpplibs-xpkg/xmake.lua), which is where libxpkg keeps
113128
-- it too, instead of being re-implemented against the registry here.
114129
add_packages("cmdline", "mcpplibs-capi-lua", "mcpplibs-tinyhttps",
115-
"mcpplibs-xpkg", "ftxui", "libarchive")
130+
"mcpplibs-xpkg", "ftxui", "libarchive-xlings")
116131

117132
-- `[build] include_dirs = ["src/libs/json"]` — src/libs/json.cppm reaches
118133
-- for <json.hpp> from its global module fragment.

mcpp.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ default-profile = "release"
1717
include_dirs = ["src/libs/json"]
1818

1919
[toolchain]
20-
default = "gcc@16.1.0"
20+
default = "llvm@22.1.8"
2121
macos = "llvm@22.1.8"
2222
windows = "llvm@20.1.7"
2323

0 commit comments

Comments
 (0)