From dfaff6d479e40b65649d2d8c7c2d130b9ba4afff Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Wed, 18 Nov 2026 06:49:34 +0900 Subject: [PATCH 1/7] 2026.11.18.1: a FreeBSD row is named as its system names it on every host; e2e 1116 runs wherever the LLVM payload is --- ...ninja-cascade-publish-supplement-design.md | 9 +++++++++ CHANGELOG.md | 19 +++++++++++++++++++ mcpp.toml | 2 +- modules/toolchain-model/src/triple.cppm | 7 ++++++- modules/versioning/src/version.cppm | 2 +- tests/e2e/targets/rows.cpp | 10 +++++++--- tests/unit/test_artifact_naming.cpp | 13 +++++++++++++ 7 files changed, 56 insertions(+), 6 deletions(-) diff --git a/.agents/docs/2026-11-17-ninja-cascade-publish-supplement-design.md b/.agents/docs/2026-11-17-ninja-cascade-publish-supplement-design.md index f60556309..c03f9229d 100644 --- a/.agents/docs/2026-11-17-ninja-cascade-publish-supplement-design.md +++ b/.agents/docs/2026-11-17-ninja-cascade-publish-supplement-design.md @@ -371,6 +371,15 @@ v4 把 macOS 的 FreeBSD 记为"读到 Apple SDK 的头文件"、把 Windows 的 Windows 上的 FreeBSD 行在以上两处修正之后停在第三处:FreeBSD 的 `crtend.o` 与 `libgcc.a` 带有 zlib 压缩的调试段,而 Windows 的 LLVM 包中的 lld 未带 zlib(`is compressed with ELFCOMPRESS_ZLIB, but lld is not built with zlib support`)。修正属于该 LLVM 包。e2e 1116 在 Windows 宿主上因 LLVM 能力不成立而跳过,所以 mcpp#949 的 CI 没有测到这一点;该两格不在 mcpp-platforms 的 Windows 构建矩阵中,文档按测得的结果陈述。 +随后的更正(2026-11-18): + +| 原因 | 记录 | 修正 | +|---|---|---| +| FreeBSD 基座的链接输入带 zlib 压缩的调试段 | Windows:`crtend.o`、`libgcc.a` 等 31 个文件,lld 报 `ELFCOMPRESS_ZLIB` | 基座包 14.5 修订 2(xim-pkgindex#1184):调试段解压,内容不变,`PROVENANCE.md` 陈述该改动 | +| `freebsd` 是三元组语言的词,却没有自己的产物命名,取了宿主的 | Windows:修订 2 之下构建完成,产物名为 `bin/hello.exe`,`bin/hello` 不存在 | mcpp 2026.11.18.1:`freebsd` 与 `linux` 同样命名;e2e 1116 改为在持有 LLVM 包的每种宿主上运行,并要求产物名与行一致 | + +Windows 的 LLVM 包中的 lld 仍不读取用户自己的对象中 zlib 压缩的段,这属于该 LLVM 包。 + ### 10.6 内容不变的重复运行仍在编译(2.4):命令行随根而变 真实工程(31 个成员的工作区)上以 ninja 的 explain 连续运行三遍,第三遍没有任何源文件变化,仍有 2779 条"command line diff --git a/CHANGELOG.md b/CHANGELOG.md index 6703fe53e..e6f4fc139 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,25 @@ > Each `## []` section is that release's notes. Entries are written in English > from 2026.9.28.3 on; earlier entries remain as written. +## [2026.11.18.1] - 2026-11-18 + +### Fixed + +- A FreeBSD row built on a Windows host named its program `.exe` and its archives + `.lib`: `freebsd` is a word of the triple language and had no naming of its own, so the + host's was taken. It is named as a Linux row is. Measured in mcpp-platforms' CI, where + the build finished and no `bin/hello` existed. +- e2e 1116 (a row of another ELF system on a host of any format) ran on Linux hosts only: + its capability, `llvm`, is a Linux one. It runs wherever the LLVM payload is, and holds + the program to the row's name. + +### Changed + +- The FreeBSD rows link on a Windows host with the FreeBSD sysroot packages' revision 2 + (xim-pkgindex): FreeBSD's crt objects and static archives hold zlib-compressed debug + sections, which the lld of the Windows LLVM payload, built without zlib, does not read; + revision 2 holds them decompressed. No change of mcpp. + ## [2026.11.17.2] - 2026-11-17 ### Added diff --git a/mcpp.toml b/mcpp.toml index 12ae9fe15..b280b4382 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -1,6 +1,6 @@ [package] name = "mcpp" -version = "2026.11.17.2" +version = "2026.11.18.1" description = "Modern C++ build & package management tool" license = "Apache-2.0" authors = ["mcpp-community"] diff --git a/modules/toolchain-model/src/triple.cppm b/modules/toolchain-model/src/triple.cppm index 0df62aa1c..43a98c037 100644 --- a/modules/toolchain-model/src/triple.cppm +++ b/modules/toolchain-model/src/triple.cppm @@ -892,7 +892,12 @@ inline ArtifactNaming artifact_naming(const Triple& t, const ArtifactNaming& hos .sharedNeedsImportLib = false, }; } - if (t.os == "linux") { + // `freebsd` is a word of the triple language as `linux` is, and names its + // artifacts the same way. Left to the host answer below, a FreeBSD row built + // on a Windows host was `bin/hello.exe` and its archives `.lib` (measured, + // mcpp-community/mcpp-platforms#4: the build finished and no `bin/hello` + // existed). + if (t.os == "linux" || t.os == "freebsd") { return ArtifactNaming{ .exeSuffix = "", .libPrefix = "lib", .staticLibExt = ".a", .sharedLibExt = ".so", diff --git a/modules/versioning/src/version.cppm b/modules/versioning/src/version.cppm index b1bfa9927..e2b8c9d39 100644 --- a/modules/versioning/src/version.cppm +++ b/modules/versioning/src/version.cppm @@ -31,6 +31,6 @@ import std; export namespace mcpp { -inline constexpr std::string_view MCPP_VERSION = "2026.11.17.2"; +inline constexpr std::string_view MCPP_VERSION = "2026.11.18.1"; } // namespace mcpp diff --git a/tests/e2e/targets/rows.cpp b/tests/e2e/targets/rows.cpp index 376cc524b..95ece43fc 100644 --- a/tests/e2e/targets/rows.cpp +++ b/tests/e2e/targets/rows.cpp @@ -379,7 +379,10 @@ int main() { expect(fatal(s::lacks(s::text(r), "[runner-not-enabled]"))) << "--no-runner was not believed: " << s::text(r); }; - "1116 a row of another ELF system builds on a host of any format"_test[s::llvm] = [] { + "1116 a row of another ELF system builds on a host of any format"_test[s::scan_deps] = [] { + // Run on every host that holds the LLVM payload (`scan-deps` is true of it on Linux, + // macOS and Windows; `llvm` is a Linux capability, and under it this case never ran + // on the two hosts it is about). // A target that parses is ELF unless it says otherwise. The format was asked of the // host for every system but `linux` and `none`, so `x86_64-freebsd` (the system's own // ABI, served by the platform the index lists for the row) linked as Mach-O on a macOS @@ -389,8 +392,9 @@ int main() { auto p = s::project::scaffold("bsd"); auto r = p.mcpp({"build", "--target", "x86_64-freebsd", "--verbose"}); expect(fatal(e2e::succeeded(r))) << "x86_64-freebsd did not build on this host: " << s::text(r); - const auto exe = program_under(p.at("target/x86_64-freebsd"), "bsd", true); - expect(fatal(exe.has_value())) << "no program: " << s::text(r); + // Named as the row names a program, with no suffix of the host (`bsd.exe` on Windows). + const auto exe = program_under(p.at("target/x86_64-freebsd"), "bsd"); + expect(fatal(exe.has_value())) << "no program named `bsd`: " << s::text(r); const auto bytes = s::read_file(*exe); expect(fatal(bytes.starts_with("\x7f" "ELF"))) << "the program is not an ELF"; const bool freebsd = (bytes.size() > 7 && bytes[7] == 9) || bytes.contains(std::string_view("FreeBSD\0", 8)); diff --git a/tests/unit/test_artifact_naming.cpp b/tests/unit/test_artifact_naming.cpp index dc4290799..b00027c2b 100644 --- a/tests/unit/test_artifact_naming.cpp +++ b/tests/unit/test_artifact_naming.cpp @@ -47,6 +47,19 @@ UTest linux_target_ignores_host_answer{"ArtifactNaming/LinuxTargetIgnoresHostAns expect(!n.sharedNeedsImportLib); }}; +// `freebsd` is a word of the triple language; it had no answer of its own and +// took the host's, so a FreeBSD row built on a Windows host was `hello.exe`. +UTest freebsd_target_ignores_host_answer{"ArtifactNaming/FreebsdTargetIgnoresHostAnswer", [] { + for (std::string_view triple : {"x86_64-freebsd", "aarch64-freebsd"}) { + auto n = tr::artifact_naming(T(triple), kBogusHost); + expect(eq(n.exeSuffix, "")); + expect(eq(n.libPrefix, "lib")); + expect(eq(n.staticLibExt, ".a")); + expect(eq(n.sharedLibExt, ".so")); + expect(!n.sharedNeedsImportLib); + } +}}; + UTest macos_target_ignores_host_answer{"ArtifactNaming/MacosTargetIgnoresHostAnswer", [] { auto n = tr::artifact_naming(T("aarch64-macos"), kBogusHost); expect(eq(n.exeSuffix, "")); From 7efca237663884a73f84379b7a5c7addcb0dba5d Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Wed, 18 Nov 2026 07:13:31 +0900 Subject: [PATCH 2/7] openkal-platform 0.29.2 is the default platform of the rows openkal serves --- CHANGELOG.md | 4 ++++ docs/50-machine-output.md | 2 +- docs/zh/50-machine-output.md | 2 +- modules/toolchain-model/data/builtin.toml | 6 +++--- tests/e2e/targets/rows.cpp | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6f4fc139..283af25fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,10 @@ ### Changed +- `mcpplibs.openkal-platform@0.29.2` is the default platform of the rows openkal serves + (0.29.1 in 2026.11.17.2). It states the hosts of each runner, so a row the machine starts + itself, `x86_64-windows-musl` on a Windows host, runs with no runner; a project no + longer states the release to get that. - The FreeBSD rows link on a Windows host with the FreeBSD sysroot packages' revision 2 (xim-pkgindex): FreeBSD's crt objects and static archives hold zlib-compressed debug sections, which the lld of the Windows LLVM payload, built without zlib, does not read; diff --git a/docs/50-machine-output.md b/docs/50-machine-output.md index aa12e3366..779820e34 100644 --- a/docs/50-machine-output.md +++ b/docs/50-machine-output.md @@ -553,7 +553,7 @@ installation, which is located on the machine rather than installed by mcpp. A target row is `{target, note, toolchain, pin, status, default}`, and `status` is one of `installed` / `available` / `via dependency graph` / `planned`. A target row also carries `platform` (2026.10.27.1+): the platform package the -target table selects for it (`mcpplibs.openkal-platform@0.29.1` from 2026.11.17.2, `@0.28.0` from 2026.11.15.1, `@0.27.1` from 2026.11.12.1, `@0.26.0` in 2026.11.10.2, `@0.25.0` in 2026.11.10.1, `@0.24.4` from 2026.11.8.1, `@0.24.3` in 2026.11.7.2; the series `^0.24` in 2026.11.7.1), or `null`. +target table selects for it (`mcpplibs.openkal-platform@0.29.2` from 2026.11.18.1, `@0.29.1` from 2026.11.17.2, `@0.28.0` from 2026.11.15.1, `@0.27.1` from 2026.11.12.1, `@0.26.0` in 2026.11.10.2, `@0.25.0` in 2026.11.10.1, `@0.24.4` from 2026.11.8.1, `@0.24.3` in 2026.11.7.2; the series `^0.24` in 2026.11.7.1), or `null`. **`toolchain` and `pin` are not the same field twice.** `toolchain` is what the row is associated with — the installed payload on an installed row, the diff --git a/docs/zh/50-machine-output.md b/docs/zh/50-machine-output.md index 855fd3c0d..9bfe64eeb 100644 --- a/docs/zh/50-machine-output.md +++ b/docs/zh/50-machine-output.md @@ -488,7 +488,7 @@ mcpp toolchain list --format json 的形状是 `{target, note, toolchain, pin, status, default}`,`status` 取 `installed` / `available` / `via dependency graph` / `planned` 之一。 目标行另有 `platform`(2026.10.27.1+):目标表为该目标选择的平台包 -(2026.11.17.2 起为 `mcpplibs.openkal-platform@0.29.1`,2026.11.15.1 起为 `@0.28.0`,2026.11.12.1 为 `@0.27.1`,2026.11.10.2 为 `@0.26.0`,2026.11.10.1 为 `@0.25.0`,2026.11.8.1 起为 `@0.24.4`,2026.11.7.2 为 `@0.24.3`;2026.11.7.1 为系列 `^0.24`),或 `null`。 +(2026.11.18.1 起为 `mcpplibs.openkal-platform@0.29.2`,2026.11.17.2 为 `@0.29.1`,2026.11.15.1 起为 `@0.28.0`,2026.11.12.1 为 `@0.27.1`,2026.11.10.2 为 `@0.26.0`,2026.11.10.1 为 `@0.25.0`,2026.11.8.1 起为 `@0.24.4`,2026.11.7.2 为 `@0.24.3`;2026.11.7.1 为系列 `^0.24`),或 `null`。 **`toolchain` 与 `pin` 不是把同一个字段写了两遍。** `toolchain` 表示这一行 关联到什么 —— 已装的行是装好的载荷,词表行是它自己的约定。`pin` 只承载目标 diff --git a/modules/toolchain-model/data/builtin.toml b/modules/toolchain-model/data/builtin.toml index 772471389..80548d0ae 100644 --- a/modules/toolchain-model/data/builtin.toml +++ b/modules/toolchain-model/data/builtin.toml @@ -664,7 +664,7 @@ hosts = ["*"] toolchain = "llvm@23.1.3" pairs = ["llvm"] linkage = "static" -platform = "mcpplibs.openkal-platform@0.29.1" +platform = "mcpplibs.openkal-platform@0.29.2" [[platform.provider]] name = "openkal" @@ -674,7 +674,7 @@ hosts = ["*"] toolchain = "llvm@23.1.3" pairs = ["llvm"] linkage = "static" -platform = "mcpplibs.openkal-platform@0.29.1" +platform = "mcpplibs.openkal-platform@0.29.2" # The same arrangement on Windows, whose own interfaces a resource script # compiles against: their headers are the MinGW-w64 base's, which states them @@ -687,7 +687,7 @@ hosts = ["*"] toolchain = "llvm@23.1.3" pairs = ["llvm"] linkage = "static" -platform = "mcpplibs.openkal-platform@0.29.1" +platform = "mcpplibs.openkal-platform@0.29.2" system-headers = "xim:mingw-w64-sysroot@20261104-2" # ── Systems ────────────────────────────────────────────────────────────────── diff --git a/tests/e2e/targets/rows.cpp b/tests/e2e/targets/rows.cpp index 95ece43fc..941972dfe 100644 --- a/tests/e2e/targets/rows.cpp +++ b/tests/e2e/targets/rows.cpp @@ -360,7 +360,7 @@ int main() { "1077 a program of another system is not started until its runner is enabled"_test[s::llvm] = [] { // `mcpp run` builds a FreeBSD program on this host and does not start it: the row's - // platform states a runner (openkal-platform 0.29.1: dirun), which no declaration has + // platform states a runner (openkal-platform 0.29: dirun), which no declaration has // enabled. The refusal names what the runner needs and the declaration that enables // it; --no-runner is believed. const std::string T = std::string(s::on_x86_64() ? "x86_64" : "aarch64") + "-freebsd-musl"; From fcfde860e590c3b9f3b0e84e4ede0a3b9b708117 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Wed, 18 Nov 2026 07:19:18 +0900 Subject: [PATCH 3/7] Every word of the triple language has its own artifact naming: none and ios beside freebsd; the rows snapshot --- CHANGELOG.md | 4 +- modules/toolchain-model/src/triple.cppm | 19 ++++---- tests/fixtures/target-rows.snapshot | 62 ++++++++++++------------- tests/unit/test_artifact_naming.cpp | 22 ++++++--- 4 files changed, 61 insertions(+), 46 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 283af25fd..2c296cac4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,9 @@ - A FreeBSD row built on a Windows host named its program `.exe` and its archives `.lib`: `freebsd` is a word of the triple language and had no naming of its own, so the host's was taken. It is named as a Linux row is. Measured in mcpp-platforms' CI, where - the build finished and no `bin/hello` existed. + the build finished and no `bin/hello` existed. The same held of `none` (the bare-metal + rows) and of `ios`; every word of the language now has its own naming, and the host's + is the answer for a word outside it only. - e2e 1116 (a row of another ELF system on a host of any format) ran on Linux hosts only: its capability, `llvm`, is a Linux one. It runs wherever the LLVM payload is, and holds the program to the row's name. diff --git a/modules/toolchain-model/src/triple.cppm b/modules/toolchain-model/src/triple.cppm index 43a98c037..b8fdc9334 100644 --- a/modules/toolchain-model/src/triple.cppm +++ b/modules/toolchain-model/src/triple.cppm @@ -885,19 +885,21 @@ inline ArtifactNaming artifact_naming(const Triple& t, const ArtifactNaming& hos .sharedNeedsImportLib = true, }; } - if (t.os == "macos") { + // iOS names what it builds as macOS does (a Mach-O row). + if (t.os == "macos" || t.os == "ios") { return ArtifactNaming{ .exeSuffix = "", .libPrefix = "lib", .staticLibExt = ".a", .sharedLibExt = ".dylib", .sharedNeedsImportLib = false, }; } - // `freebsd` is a word of the triple language as `linux` is, and names its - // artifacts the same way. Left to the host answer below, a FreeBSD row built - // on a Windows host was `bin/hello.exe` and its archives `.lib` (measured, + // The ELF words of the triple language name their artifacts one way: + // `linux`, `freebsd`, and `none` (a machine with no system). Left to the + // host answer below, a FreeBSD row built on a Windows host was + // `bin/hello.exe` and its archives `.lib` (measured, // mcpp-community/mcpp-platforms#4: the build finished and no `bin/hello` - // existed). - if (t.os == "linux" || t.os == "freebsd") { + // existed), and a `*-none-elf` row was named the same way there. + if (t.os == "linux" || t.os == "freebsd" || t.os == "none") { return ArtifactNaming{ .exeSuffix = "", .libPrefix = "lib", .staticLibExt = ".a", .sharedLibExt = ".so", @@ -941,8 +943,9 @@ inline ArtifactNaming artifact_naming(const Triple& t, const ArtifactNaming& hos .sharedNeedsImportLib = true, }; } - // Outside the triple language: fall back to the host answer rather than - // guessing. A wrong guess here silently misnames every artifact. + // Outside the triple language (every word of it is answered above): fall + // back to the host answer rather than guessing. A wrong guess here silently + // misnames every artifact. return hostNaming; } diff --git a/tests/fixtures/target-rows.snapshot b/tests/fixtures/target-rows.snapshot index 632e5fc0c..b7166edcd 100644 --- a/tests/fixtures/target-rows.snapshot +++ b/tests/fixtures/target-rows.snapshot @@ -113,7 +113,7 @@ row aarch64-windows-gnu descriptor-keys windows sysroot xim:mingw-w64-sysroot@20261104-2 row x86_64-windows-musl - table tier=preview note=PE pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.1 + table tier=preview note=PE pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.2 str x86_64-windows-musl llvm x86_64-w64-windows-gnu llvm@15.0 x86_64-w64-windows-gnu @@ -170,7 +170,7 @@ row aarch64-macos descriptor-keys macosx sysroot row aarch64-macos-musl - table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.1 + table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.2 str aarch64-macos-musl llvm arm64-apple-macos14.0 llvm@15.0 arm64-apple-macos15.0 @@ -208,7 +208,7 @@ row riscv64-linux-musl descriptor-keys linux sysroot row i686-linux-musl - table tier=planned note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.1 + table tier=planned note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.2 str i686-linux-musl llvm i686-unknown-linux-musl llvm@15.0 i686-unknown-linux-musl @@ -246,7 +246,7 @@ row i686-linux-gnu descriptor-keys linux sysroot row i686-openkal - table tier=planned note=ok pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.1 + table tier=planned note=ok pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.2 str i686-openkal llvm i686-unknown-none-elf llvm@15.0 i686-unknown-none-elf @@ -284,7 +284,7 @@ row x86_64-macos descriptor-keys macosx sysroot row x86_64-macos-musl - table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.1 + table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.2 str x86_64-macos-musl llvm x86_64-apple-macos14.0 llvm@15.0 x86_64-apple-macos15.0 @@ -315,7 +315,7 @@ row x86_64-freebsd musl/msvc/windows-gnu/x86_32 0000 msvc-arch x64 nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi x86_64 platform-name freebsd @@ -334,14 +334,14 @@ row aarch64-freebsd musl/msvc/windows-gnu/x86_32 0000 msvc-arch arm64 nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi arm64-v8a platform-name freebsd descriptor-keys freebsd sysroot row x86_64-freebsd-musl - table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.1 + table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.2 str x86_64-freebsd-musl llvm x86_64-unknown-freebsd14.0 llvm@15.0 x86_64-unknown-freebsd14.0 @@ -353,14 +353,14 @@ row x86_64-freebsd-musl musl/msvc/windows-gnu/x86_32 1000 msvc-arch x64 nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi x86_64 platform-name freebsd descriptor-keys freebsd sysroot row aarch64-freebsd-musl - table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.1 + table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.2 str aarch64-freebsd-musl llvm aarch64-unknown-freebsd14.0 llvm@15.0 aarch64-unknown-freebsd14.0 @@ -372,7 +372,7 @@ row aarch64-freebsd-musl musl/msvc/windows-gnu/x86_32 1000 msvc-arch arm64 nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi arm64-v8a platform-name freebsd @@ -391,7 +391,7 @@ row riscv64-none-elf musl/msvc/windows-gnu/x86_32 0000 msvc-arch nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi riscv64 platform-name none @@ -414,7 +414,7 @@ row riscv32-none-elf musl/msvc/windows-gnu/x86_32 0000 msvc-arch nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi riscv32 platform-name none @@ -437,7 +437,7 @@ row aarch64-none-elf musl/msvc/windows-gnu/x86_32 0000 msvc-arch arm64 nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi arm64-v8a platform-name none @@ -460,7 +460,7 @@ row x86_64-none-elf musl/msvc/windows-gnu/x86_32 0000 msvc-arch x64 nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi x86_64 platform-name none @@ -484,7 +484,7 @@ row thumbv6m-none-eabi musl/msvc/windows-gnu/x86_32 0000 msvc-arch nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi thumbv6m platform-name none @@ -507,7 +507,7 @@ row thumbv7m-none-eabi musl/msvc/windows-gnu/x86_32 0000 msvc-arch nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi thumbv7m platform-name none @@ -530,7 +530,7 @@ row thumbv7em-none-eabi musl/msvc/windows-gnu/x86_32 0000 msvc-arch nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi thumbv7em platform-name none @@ -553,7 +553,7 @@ row thumbv7em-none-eabihf musl/msvc/windows-gnu/x86_32 0000 msvc-arch nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi thumbv7em platform-name none @@ -576,7 +576,7 @@ row thumbv8m.base-none-eabi musl/msvc/windows-gnu/x86_32 0000 msvc-arch nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi thumbv8m.base platform-name none @@ -599,7 +599,7 @@ row thumbv8m.main-none-eabi musl/msvc/windows-gnu/x86_32 0000 msvc-arch nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi thumbv8m.main platform-name none @@ -622,7 +622,7 @@ row thumbv8m.main-none-eabihf musl/msvc/windows-gnu/x86_32 0000 msvc-arch nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi thumbv8m.main platform-name none @@ -645,7 +645,7 @@ row armv7a-none-eabi musl/msvc/windows-gnu/x86_32 0000 msvc-arch nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi armv7a platform-name none @@ -668,7 +668,7 @@ row armv7a-none-eabihf musl/msvc/windows-gnu/x86_32 0000 msvc-arch nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi armv7a platform-name none @@ -691,7 +691,7 @@ row i686-none-elf musl/msvc/windows-gnu/x86_32 0001 msvc-arch x86 nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.so import=0 sharedPrefix=- application exe android-abi i686 platform-name none @@ -753,7 +753,7 @@ row aarch64-ios musl/msvc/windows-gnu/x86_32 0000 msvc-arch arm64 nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.dylib import=0 sharedPrefix=- application exe android-abi arm64-v8a platform-name ios @@ -772,7 +772,7 @@ row aarch64-ios-sim musl/msvc/windows-gnu/x86_32 0000 msvc-arch arm64 nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.dylib import=0 sharedPrefix=- application exe android-abi arm64-v8a platform-name ios @@ -791,7 +791,7 @@ row x86_64-ios-sim musl/msvc/windows-gnu/x86_32 0000 msvc-arch x64 nasm - - naming exe=.host lib=hostlib static=.hosta shared=.hostso import=0 sharedPrefix=- + naming exe= lib=lib static=.a shared=.dylib import=0 sharedPrefix=- application exe android-abi x86_64 platform-name ios @@ -817,7 +817,7 @@ row wasm32-emscripten descriptor-keys emscripten linux sysroot row x86_64-openkal - table tier=verified note=ok pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.1 + table tier=verified note=ok pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.2 str x86_64-openkal llvm x86_64-unknown-none-elf llvm@15.0 x86_64-unknown-none-elf @@ -836,7 +836,7 @@ row x86_64-openkal descriptor-keys openkal linux sysroot row aarch64-openkal - table tier=verified note=ok pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.1 + table tier=verified note=ok pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.29.2 str aarch64-openkal llvm aarch64-unknown-none-elf llvm@15.0 aarch64-unknown-none-elf @@ -971,7 +971,7 @@ set linux-musl -> x86_64-linux-musl aarch64-linux-musl | set windows -> x86_64-windows-gnu aarch64-windows-gnu | set windows-msvc -> x86_64-windows-msvc | set macos -> aarch64-macos | -set openkal -> x86_64-openkal aarch64-openkal | mcpplibs.openkal-platform@0.29.1 +set openkal -> x86_64-openkal aarch64-openkal | mcpplibs.openkal-platform@0.29.2 set none-elf -> riscv64-none-elf riscv32-none-elf aarch64-none-elf x86_64-none-elf i686-none-elf | set none-eabihf -> thumbv7em-none-eabihf thumbv8m.main-none-eabihf armv7a-none-eabihf | set android -> aarch64-linux-android x86_64-linux-android | diff --git a/tests/unit/test_artifact_naming.cpp b/tests/unit/test_artifact_naming.cpp index b00027c2b..b1ae39857 100644 --- a/tests/unit/test_artifact_naming.cpp +++ b/tests/unit/test_artifact_naming.cpp @@ -120,14 +120,24 @@ UTest unknown_os_falls_back_to_host{"ArtifactNaming/UnknownOsFallsBackToHost", [ expect(eq(n.staticLibExt, ".HOST")); }}; -// A bare-metal `none` OS is not the emscripten row and must keep falling back -// to the host answer — the emscripten branch below must not widen the -// fallback it sits next to. -UTest none_os_falls_back_to_host{"ArtifactNaming/NoneOsFallsBackToHost", [] { +// A bare-metal `none` OS is an ELF word of the language: named as ELF from +// every host, and not as the emscripten row beside it (`.js`). It took the +// host's answer, so a `*-none-elf` program was `.exe` on a Windows host. +UTest none_os_is_named_as_elf{"ArtifactNaming/NoneOsIsNamedAsElfFromEveryHost", [] { tr::Triple none; none.arch = "aarch64"; none.os = "none"; auto n = tr::artifact_naming(none, kBogusHost); - expect(eq(n.exeSuffix, ".HOST")); - expect(eq(n.staticLibExt, ".HOST")); + expect(eq(n.exeSuffix, "")); + expect(eq(n.libPrefix, "lib")); + expect(eq(n.staticLibExt, ".a")); + expect(eq(n.sharedLibExt, ".so")); +}}; + +// iOS is a Mach-O row and names what it builds as macOS does. +UTest ios_is_named_as_macos{"ArtifactNaming/IosIsNamedAsMacos", [] { + auto n = tr::artifact_naming(T("aarch64-ios"), kBogusHost); + expect(eq(n.exeSuffix, "")); + expect(eq(n.staticLibExt, ".a")); + expect(eq(n.sharedLibExt, ".dylib")); }}; // ── wasm32-emscripten: the executable is the file a runner executes, and on From ed5c67902d957afa8c4232904ab25f551645ee78 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Wed, 18 Nov 2026 07:45:23 +0900 Subject: [PATCH 4/7] A row of the table is named by its object format: no system is named in the engine for it --- CHANGELOG.md | 10 +++---- modules/toolchain-model/src/triple.cppm | 40 +++++++++++++++++-------- tests/unit/test_artifact_naming.cpp | 31 +++++++++++-------- 3 files changed, 52 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c296cac4..f89bf9d95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,11 +9,11 @@ ### Fixed - A FreeBSD row built on a Windows host named its program `.exe` and its archives - `.lib`: `freebsd` is a word of the triple language and had no naming of its own, so the - host's was taken. It is named as a Linux row is. Measured in mcpp-platforms' CI, where - the build finished and no `bin/hello` existed. The same held of `none` (the bare-metal - rows) and of `ios`; every word of the language now has its own naming, and the host's - is the answer for a word outside it only. + `.lib`: the row had no naming of its own, so the host's was taken. A row of the table is + named by its object format, which is its data; the bare-metal rows and the iOS rows + answered with the host's naming too (21 rows of the snapshot). The host's naming is the + answer for a triple that is no row only. Measured in mcpp-platforms' CI, where the + build finished and no `bin/hello` existed. - e2e 1116 (a row of another ELF system on a host of any format) ran on Linux hosts only: its capability, `llvm`, is a Linux one. It runs wherever the LLVM payload is, and holds the program to the row's name. diff --git a/modules/toolchain-model/src/triple.cppm b/modules/toolchain-model/src/triple.cppm index b8fdc9334..5dc3c785b 100644 --- a/modules/toolchain-model/src/triple.cppm +++ b/modules/toolchain-model/src/triple.cppm @@ -885,21 +885,14 @@ inline ArtifactNaming artifact_naming(const Triple& t, const ArtifactNaming& hos .sharedNeedsImportLib = true, }; } - // iOS names what it builds as macOS does (a Mach-O row). - if (t.os == "macos" || t.os == "ios") { + if (t.os == "macos") { return ArtifactNaming{ .exeSuffix = "", .libPrefix = "lib", .staticLibExt = ".a", .sharedLibExt = ".dylib", .sharedNeedsImportLib = false, }; } - // The ELF words of the triple language name their artifacts one way: - // `linux`, `freebsd`, and `none` (a machine with no system). Left to the - // host answer below, a FreeBSD row built on a Windows host was - // `bin/hello.exe` and its archives `.lib` (measured, - // mcpp-community/mcpp-platforms#4: the build finished and no `bin/hello` - // existed), and a `*-none-elf` row was named the same way there. - if (t.os == "linux" || t.os == "freebsd" || t.os == "none") { + if (t.os == "linux") { return ArtifactNaming{ .exeSuffix = "", .libPrefix = "lib", .staticLibExt = ".a", .sharedLibExt = ".so", @@ -943,9 +936,32 @@ inline ArtifactNaming artifact_naming(const Triple& t, const ArtifactNaming& hos .sharedNeedsImportLib = true, }; } - // Outside the triple language (every word of it is answered above): fall - // back to the host answer rather than guessing. A wrong guess here silently - // misnames every artifact. + // A ROW OF THE TABLE WITH NO BRANCH ABOVE IS NAMED BY ITS OBJECT FORMAT, + // which is the row's data (`object_format()`), not by the host. Left to the + // host answer below, a FreeBSD row built on a Windows host was + // `bin/hello.exe` and its archives `.lib` (measured, + // mcpp-community/mcpp-platforms#4: the build finished and no `bin/hello` + // existed); the bare-metal rows and the iOS rows answered the same way, + // 21 rows of the snapshot in all. + if (mcpp::toolchain::target::find_row(t.str())) { + switch (t.object_format()) { + case ObjectFormat::Elf: + return ArtifactNaming{ + .exeSuffix = "", .libPrefix = "lib", + .staticLibExt = ".a", .sharedLibExt = ".so", + .sharedNeedsImportLib = false, + }; + case ObjectFormat::MachO: + return ArtifactNaming{ + .exeSuffix = "", .libPrefix = "lib", + .staticLibExt = ".a", .sharedLibExt = ".dylib", + .sharedNeedsImportLib = false, + }; + default: break; + } + } + // Not a row and outside the triple language: fall back to the host answer + // rather than guessing. A wrong guess here silently misnames every artifact. return hostNaming; } diff --git a/tests/unit/test_artifact_naming.cpp b/tests/unit/test_artifact_naming.cpp index b1ae39857..5c6b448a5 100644 --- a/tests/unit/test_artifact_naming.cpp +++ b/tests/unit/test_artifact_naming.cpp @@ -47,8 +47,8 @@ UTest linux_target_ignores_host_answer{"ArtifactNaming/LinuxTargetIgnoresHostAns expect(!n.sharedNeedsImportLib); }}; -// `freebsd` is a word of the triple language; it had no answer of its own and -// took the host's, so a FreeBSD row built on a Windows host was `hello.exe`. +// The FreeBSD rows had no answer of their own and took the host's, so one built +// on a Windows host was `hello.exe`. A row is named by its object format. UTest freebsd_target_ignores_host_answer{"ArtifactNaming/FreebsdTargetIgnoresHostAnswer", [] { for (std::string_view triple : {"x86_64-freebsd", "aarch64-freebsd"}) { auto n = tr::artifact_naming(T(triple), kBogusHost); @@ -120,20 +120,27 @@ UTest unknown_os_falls_back_to_host{"ArtifactNaming/UnknownOsFallsBackToHost", [ expect(eq(n.staticLibExt, ".HOST")); }}; -// A bare-metal `none` OS is an ELF word of the language: named as ELF from -// every host, and not as the emscripten row beside it (`.js`). It took the -// host's answer, so a `*-none-elf` program was `.exe` on a Windows host. -UTest none_os_is_named_as_elf{"ArtifactNaming/NoneOsIsNamedAsElfFromEveryHost", [] { +// A bare-metal `none` OS is not the emscripten row and must keep falling back +// to the host answer when it is no row of the table — the emscripten branch +// below must not widen the fallback it sits next to. +UTest none_os_falls_back_to_host{"ArtifactNaming/NoneOsFallsBackToHost", [] { tr::Triple none; none.arch = "aarch64"; none.os = "none"; auto n = tr::artifact_naming(none, kBogusHost); - expect(eq(n.exeSuffix, "")); - expect(eq(n.libPrefix, "lib")); - expect(eq(n.staticLibExt, ".a")); - expect(eq(n.sharedLibExt, ".so")); + expect(eq(n.exeSuffix, ".HOST")); + expect(eq(n.staticLibExt, ".HOST")); }}; -// iOS is a Mach-O row and names what it builds as macOS does. -UTest ios_is_named_as_macos{"ArtifactNaming/IosIsNamedAsMacos", [] { +// A ROW of the table is named by its object format from every host: the +// bare-metal rows as ELF, the iOS rows as Mach-O. They took the host's answer, +// so a `*-none-elf` program was `.exe` on a Windows host. +UTest a_row_is_named_by_its_object_format{"ArtifactNaming/ARowIsNamedByItsObjectFormat", [] { + for (std::string_view triple : {"aarch64-none-elf", "riscv64-none-elf", "thumbv7m-none-eabi"}) { + auto n = tr::artifact_naming(T(triple), kBogusHost); + expect(eq(n.exeSuffix, "")) << triple; + expect(eq(n.libPrefix, "lib")) << triple; + expect(eq(n.staticLibExt, ".a")) << triple; + expect(eq(n.sharedLibExt, ".so")) << triple; + } auto n = tr::artifact_naming(T("aarch64-ios"), kBogusHost); expect(eq(n.exeSuffix, "")); expect(eq(n.staticLibExt, ".a")); From fb1695af4e123ae8e565c1f543189d5dd73e5c6e Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Wed, 18 Nov 2026 08:54:01 +0900 Subject: [PATCH 5/7] A row's object format and artifact names are read from data: row, system, format The engine answered them by a branch per system, and a built-in row without a branch took the host's naming. One reading serves the built-in rows and a platform's: the row's statement, its system's ([[platform.system]] accepts object-format, exe-suffix and shared-suffix), then the convention of the object format. The built-in table states what the branches expressed; the rows snapshot is unchanged by the move and the system-name baseline falls. SPEC-016 v1.5, docs/35, design record section 12, e2e 1117. --- ...ninja-cascade-publish-supplement-design.md | 102 ++++++++++++ .github/tools/system-names.baseline | 10 +- CHANGELOG.md | 22 ++- docs/35-platforms.md | 19 +++ docs/specs/targets-and-providers.md | 29 +++- docs/zh/35-platforms.md | 14 ++ modules/manifest/src/platform.cppm | 8 +- modules/manifest/src/platform_toml.cppm | 17 +- modules/toolchain-model/build.mcpp | 15 +- modules/toolchain-model/data/builtin.toml | 26 ++- .../toolchain-model/src/target_schema.cppm | 13 +- modules/toolchain-model/src/triple.cppm | 150 ++++++------------ src/build/prepare/platform.cpp | 6 +- tests/e2e/targets/rows.cpp | 61 +++++++ tests/unit/test_artifact_naming.cpp | 82 +++++++++- tests/unit/test_platform.cpp | 15 +- 16 files changed, 452 insertions(+), 137 deletions(-) diff --git a/.agents/docs/2026-11-17-ninja-cascade-publish-supplement-design.md b/.agents/docs/2026-11-17-ninja-cascade-publish-supplement-design.md index c03f9229d..494b2b6f1 100644 --- a/.agents/docs/2026-11-17-ninja-cascade-publish-supplement-design.md +++ b/.agents/docs/2026-11-17-ninja-cascade-publish-supplement-design.md @@ -476,3 +476,105 @@ using 指令)按原样构建并给出所在行。其效果与手写的接口 ninja 是构建的后端,开发者不直接处理它:固定版本经 xlings 安装在已有版本旁边,升级后的首次运行说明所替换的版本;安装失败时沿用已有 版本,一天之后再试。升级测试据此改为:首次运行只允许这一项下载,第二次运行不允许任何下载。 + +## 12. 行的事实来自数据:对象格式与产物命名(2026-11-18) + +### 12.1 现状与缺陷 + +内置表(`modules/toolchain-model/data/builtin.toml`)与平台包使用同一 schema(`[[platform.define]]`、`[[platform.system]]`、 +`[[platform.provider]]`),但两者的读法不同: + +| | 平台包定义的行 | 内置行 | +|---|---|---| +| 对象格式 | 行的 `object-format` | `object_format()` 中按系统词的分支(`windows`、`macos`、`ios`),其余为 ELF | +| 产物命名 | 行的 `exe-suffix`、`shared-suffix` | `artifact_naming()` 中按系统词的五个分支(`windows`、`macos`、`linux`、`openkal`、`emscripten`),没有分支的行取**宿主**的命名 | + +后果在 10.5 的记录中测得:mcpp-platforms 定义的 NetBSD、OpenBSD 行在 Windows 宿主上一次构建通过;引擎自带的 FreeBSD 行产物名为 +`hello.exe`。行快照中取宿主命名的内置行共 21 行(FreeBSD 4 行、裸机 14 行、iOS 3 行),在 Linux 宿主上与正确答案相同,所以此前 +没有暴露。两套读法也意味着同一个事实有两个出处:新增一个系统时,平台包写数据,引擎却要加分支。 + +### 12.2 原则 + +SPEC-016 已规定:"系统的事实是数据:行的键、系统表的键或提供者的键",引擎源码中的系统名由 `check_system_names.py` 的基线持有, +只许减少。本节把对象格式与产物命名两项事实按这一规定落到数据上,使内置行与平台包的行经同一条路读取。 + +### 12.3 方案:三级读取 + +一行的三项事实 `object-format`、`exe-suffix`、`shared-suffix` 按以下次序读取,先陈述者生效: + +1. **行**(`[[platform.define]]`):该行自己的陈述。 +2. **系统**(`[[platform.system]]`,按行的 os 段):该系统各行共有的陈述。本节为系统表新增这三个键。 +3. **格式的约定**:引擎只认识对象格式这一封闭词汇的约定,不认识任何系统。 + +| 格式 | 程序 | 静态库 | 共享库 | 导入库 | +|---|---|---|---|---| +| `elf`(缺省) | 无后缀 | `lib*.a` | `.so` | 否 | +| `mach-o` | 无后缀 | `lib*.a` | `.dylib` | 否 | +| `pe` | `.exe` | `lib*.a`;`msvc` 环境为 `*.lib` | `.dll` | 是 | +| `coff` | 无后缀 | `lib*.a` | `.so` | 否 | +| `wasm` | 无后缀 | `lib*.a` | 不支持 | — | + +`msvc` 是三元组的环境段(一种 ABI),不是系统名,保留在引擎中。WebAssembly 的架构段(`wasm32`、`wasm64`)在行未陈述格式时 +决定格式,同样不是系统名。 + +宿主的命名只在两种情况下作答:空三元组(为本机构建),以及既不是表中的行、其 os 段也不是表中系统的三元组(引擎不认识,不猜)。 + +### 12.4 内置数据的陈述 + +此前由代码分支表达的内容改为数据,取值不变: + +| 位置 | 陈述 | 取代的分支 | +|---|---|---| +| 系统 `windows` | `object-format = "pe"` | `os == "windows"`(格式与命名) | +| 系统 `macos` | `object-format = "mach-o"` | `os == "macos"`(格式与命名) | +| 行 `aarch64-ios`、`aarch64-ios-sim`、`x86_64-ios-sim` | `object-format = "mach-o"` | `os == "ios"`(格式) | +| 行 `i686-openkal`、`x86_64-openkal`、`aarch64-openkal` | `exe-suffix = ".oke"`、`shared-suffix = ".okso"` | `os == "openkal"`(命名) | +| 行 `wasm32-emscripten` | `exe-suffix = ".js"` | `os == "emscripten"`(命名) | +| 系统 `linux`、`freebsd` | 不陈述(ELF 为缺省) | `os == "linux"`(命名) | + +iOS 与 ok 镜像的陈述落在行上而不新增系统条目:系统表同时是打包的词汇(`mcpp pack --systems all` 取表中全部系统;表中未陈述 +`uname` 的系统,其程序是多系统单文件开头的 PE),新增条目会改变这两处的行为,而那不是本节要改的。裸机行(`*-none-*`)没有 +系统,由格式的缺省作答(ELF)。 + +### 12.5 兼容性 + +- **内置行**:行快照(`tests/fixtures/target-rows.snapshot`)逐行记录每个内置行的格式与命名。实施前后只有 12.1 所述 21 行变化 + (由宿主的命名变为各自格式的命名),其余各行逐字相同。 +- **已发布的平台包**:逐一核对其 `[[platform.define]]`。PE 与 COFF 的行都陈述了 `exe-suffix`(`x86_64-uefi` 为 `.efi`, + `i586-dos-djgpp`、`i686-dos-musl` 为 `.exe`),ELF 的行未陈述(NetBSD、OpenBSD);三级读取对它们给出与此前相同的结果。 +- **读法变化的两处**:平台定义的 PE 行未陈述 `exe-suffix` 时,此前没有后缀,现为格式的约定 `.exe`;平台定义的行未陈述 + `object-format` 时,此前为 ELF,现先取其系统的(os 段为 `windows`、`macos` 的行因此得到 PE、Mach-O)。已发布的平台包中 + 没有落在这两处的行。 +- **平台包的 schema**:系统的三个键是可选的,行的 `object-format` 由必写变为可选。更早的 mcpp 对不认识的系统键给出警告并 + 忽略,平台包以 `[package] mcpp` 的下限陈述它需要的版本。 +- **宿主**:结果不再随宿主而变,这正是修正的内容;在 Linux 宿主上,21 行的取值与此前相同。 + +### 12.6 多角度的考量 + +| 角度 | 说明 | +|---|---| +| 规范 | 落实 SPEC-016 "系统的事实是数据";系统表新增的键写入 SPEC-016 §2.3 | +| 通用性 | 平台包可以为它定义的系统陈述一次格式与后缀,不必在每一行重复;新系统不需要引擎的分支 | +| 跨平台 | 命名与格式由目标的数据决定,同一目标在 Linux、macOS、Windows 宿主上得到同一组文件名 | +| 兼容性 | 见 12.5:内置行以快照为证,平台包逐一核对,新键可选 | +| 简洁 | `artifact_naming()` 与 `object_format()` 各自成为一次三级读取加一张格式表;五个系统词分支与三个格式分支删除,基线下降 | +| 复用 | 内置行与平台包的行经同一函数;`mcpp pack`、链接、运行各处读取的仍是同一个答案 | +| 测试 | 命名的单元测试以伪造的宿主命名为入参,从任一宿主验证;快照持有全部内置行;e2e 1116 在持有 LLVM 包的每种宿主上运行 | + +### 12.7 不在本次之内 + +引擎中其余按系统词的分支(编译器三元组的拼写、SDK 的定位、家族的约定等)仍由基线持有,各自在被改动时移入数据;本节只处理 +schema 已有键名的两项事实。 + +### 12.8 实施与验证 + +随 mcpp#951(2026.11.18.1)实施:系统表的三个键(生成器、schema、平台清单的解析与校验);内置数据的陈述; +`object_format()` 与 `artifact_naming()` 改为三级读取;SPEC-016 v1.5(§2.1、§2.3)与用户文档(docs/35)。 + +| 验证 | 结果 | +|---|---| +| 行快照(42 个内置行的格式与命名) | 由分支改为数据前后逐字相同 | +| 系统名基线 | `linux` 63→62,`macos` 51→49,`windows` 72→70,`emscripten` 18→17,`ios` 24→23 | +| 单元测试 | 行先于系统、系统先于格式的约定;表中系统的非行三元组不取宿主的命名;清单读取系统的三个键 | +| e2e 1117 | 平台包的系统陈述 `exe-suffix`,未陈述的行得到它,陈述了的行取自己的 | +| e2e 1116 | 在持有 LLVM 包的每种宿主上构建 `x86_64-freebsd` 并核对程序名 | diff --git a/.github/tools/system-names.baseline b/.github/tools/system-names.baseline index f0c0b064c..bf2ab5414 100644 --- a/.github/tools/system-names.baseline +++ b/.github/tools/system-names.baseline @@ -1,12 +1,12 @@ # One number per word: its occurrences in the engine's sources # (.github/tools/check_system_names.py). The numbers only fall. -linux 63 -macos 51 -windows 72 +linux 62 +macos 49 +windows 70 freebsd 1 android 19 -emscripten 18 -ios 24 +emscripten 17 +ios 23 darwin 10 netbsd 0 openbsd 0 diff --git a/CHANGELOG.md b/CHANGELOG.md index f89bf9d95..c0b60af03 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,15 +9,27 @@ ### Fixed - A FreeBSD row built on a Windows host named its program `.exe` and its archives - `.lib`: the row had no naming of its own, so the host's was taken. A row of the table is - named by its object format, which is its data; the bare-metal rows and the iOS rows - answered with the host's naming too (21 rows of the snapshot). The host's naming is the - answer for a triple that is no row only. Measured in mcpp-platforms' CI, where the - build finished and no `bin/hello` existed. + `.lib`: the engine named artifacts by a branch per system, and a built-in row without a + branch took the host's naming (21 rows of the snapshot: FreeBSD, bare metal, iOS). A + row's `object-format`, `exe-suffix` and `shared-suffix` are read from data in three + steps: the row, its system, the convention of the object format (SPEC-016 v1.5). The + built-in rows and a platform's rows share the reading, the engine names no system for + it, and the host's naming answers only for a triple that is neither a row nor of a + system the table states. Measured in mcpp-platforms' CI, where the build finished and + no `bin/hello` existed. The names of the other built-in rows are unchanged (the rows + snapshot). - e2e 1116 (a row of another ELF system on a host of any format) ran on Linux hosts only: its capability, `llvm`, is a Linux one. It runs wherever the LLVM payload is, and holds the program to the row's name. +### Added + +- `[[platform.system]]` accepts `object-format`, `exe-suffix` and `shared-suffix`: what + the system's rows share. A row's own statement precedes them. A `[[platform.define]]` + row may leave `object-format` unstated: it is then its system's, then ELF. The + built-in table states `pe` for Windows and `mach-o` for macOS this way, and the + suffixes of the ok images and of `wasm32-emscripten` on their rows. + ### Changed - `mcpplibs.openkal-platform@0.29.2` is the default platform of the rows openkal serves diff --git a/docs/35-platforms.md b/docs/35-platforms.md index d7eb4c613..3fec2671b 100644 --- a/docs/35-platforms.md +++ b/docs/35-platforms.md @@ -430,6 +430,25 @@ name = "haiku" uname = "Haiku" # what `uname -s` answers there ``` +**Object format and file names (2026.11.18.1+).** A row's `object-format`, +`exe-suffix` and `shared-suffix` are read in three steps, the first statement +taken: the row, the row's system (`[[platform.system]]` accepts the same three +keys for what its rows share), and the convention of the object format. The +same reading serves the built-in rows, whose statements are data of the +built-in table; the build machine's naming answers for no row, so a target has +one set of file names on every host. + +| Format | Program | Static library | Shared library | +|---|---|---|---| +| `elf` (when neither states one) | no suffix | `lib.a` | `.so` | +| `mach-o` | no suffix | `lib.a` | `.dylib` | +| `pe` | `.exe` | `lib.a`; `.lib` under the `msvc` env | `.dll` with an import library | +| `coff` | no suffix | `lib.a` | `.so` | +| `wasm` | no suffix | `lib.a` | not supported | + +A row whose program has another suffix states it (`exe-suffix = ".efi"`). A +row that states no `object-format` takes its system's, then ELF. + A provider's `runner` is the lowest tier of the runner statement: a build program's, this machine's `config.toml`, the project's `[target.] runner` and `MCPP_TARGET__RUNNER` each replace it. The platform's own diff --git a/docs/specs/targets-and-providers.md b/docs/specs/targets-and-providers.md index a3d863165..0e105a6c8 100644 --- a/docs/specs/targets-and-providers.md +++ b/docs/specs/targets-and-providers.md @@ -4,10 +4,10 @@ |---|---| | 规范编号 | SPEC-016 | | 标题 | 目标与提供者:行、提供者、选择、平台定义的行、报告与锁 | -| 状态 | 评审中 v1.3 | -| 版本 | 1.3 | -| 最后修改 | 2026-11-16 | -| 对应实现 | mcpp >= 2026.11.9.1;v1.1 条款 mcpp >= 2026.11.10.1;v1.2 条款 mcpp >= 2026.11.12.1;v1.3 条款 mcpp >= 2026.11.16.1 | +| 状态 | 评审中 v1.5 | +| 版本 | 1.5 | +| 最后修改 | 2026-11-18 | +| 对应实现 | mcpp >= 2026.11.9.1;v1.1 条款 mcpp >= 2026.11.10.1;v1.2 条款 mcpp >= 2026.11.12.1;v1.3 条款 mcpp >= 2026.11.16.1;v1.4 条款 mcpp >= 2026.11.17.1;v1.5 条款 mcpp >= 2026.11.18.1 | | 相关设计文档 | `.agents/docs/2026-11-15-ecosystem-gap-supplement-design.md`、`.agents/docs/2026-11-09-target-model-design.md`、`.agents/docs/2026-11-10-cross-platform-ecosystem-design.md`、`.agents/docs/2026-11-12-ecosystem-architecture-optimization-design.md` | | 相关 issue | mcpp#911、mcpp#913 | | 相关规范 | [SPEC-001](package-identity.md)(引用文法)、[SPEC-002](target-side.md)(层与能力)、[SPEC-013](platforms.md)(平台的语句)、[SPEC-014](packaging.md)(打包)、[SPEC-015](target-sets.md)(目标集合) | @@ -58,6 +58,19 @@ - `exe-suffix-fixed` 陈述行的可执行文件后缀是加载其程序的一部分(缺省为假)。为真时,名字模板(构建程序的 `artifact_name`、`link.exe`)只决定后缀之前的部分,后缀总在名字末尾出现一次:模板的结果已以该后缀结尾时不重复。 内置的 `wasm32-emscripten` 行为真(`.js` 使启动文件与模块成对)。引擎不按系统名判断(v1.4)。 +- `object-format`、`exe-suffix`、`shared-suffix` 按三级读取,先陈述者生效:行,行的系统(§2.3),对象格式的约定(v1.5)。 + 内置行与平台定义的行同一读法;引擎不按系统名判断,宿主的命名不为任何行作答。 + + | 格式 | 程序 | 静态库 | 共享库 | + |---|---|---|---| + | `elf`(行与系统都未陈述格式时) | 无后缀 | `lib.a` | `.so` | + | `mach-o` | 无后缀 | `lib.a` | `.dylib` | + | `pe` | `.exe` | `lib.a`;env 为 `msvc` 时 `.lib` | `.dll`,带导入库 | + | `coff` | 无后缀 | `lib.a` | `.so` | + | `wasm` | 无后缀 | `lib.a` | 不支持 | + + 行与系统都未陈述格式而 arch 段为 `wasm32`、`wasm64` 时,格式为 `wasm`。既不是表中的行、os 段也不是表中系统的三元组, + 其命名取宿主的;空请求(为本机构建)同样取宿主的。 ### 2.2 内置行 @@ -81,6 +94,9 @@ | `uname` | `uname -s` 在该系统上的回答;每个系统一个程序的单文件按它选择程序 | | `resources` | 该系统的加载器读取程序的资源节;工程的 `[resources]` 编入其行的程序,未写为 false(v1.3) | | `command-scripts` | 该系统经命令解释器启动的文件的后缀;在该系统上启动这类文件时,含解释器语法的参数被拒绝(SPEC-013 §10)(v1.3) | +| `object-format` | 该系统各行的对象格式(`elf`、`mach-o`、`pe`、`wasm`、`coff`);行自己的陈述在先(§2.1)(v1.5) | +| `exe-suffix` | 该系统的程序的后缀;行自己的陈述在先(v1.5) | +| `shared-suffix` | 该系统的共享库的后缀;行自己的陈述在先(v1.5) | - 陈述了 `uname` 的系统可以进入多系统单文件;表中未陈述 `uname` 的系统,其程序是文件开头的 PE;表中没有的系统被拒绝, 并指名 `[[platform.system]]`。 @@ -89,6 +105,10 @@ - 资源随行的 `execution` 所指系统而定,不随 PE 容器:UEFI 应用是固件加载的 PE,不编入资源。内置数据中 `windows` 陈述 `resources = true`(v1.3)。 - 内置数据中 `windows` 陈述 `command-scripts = [".bat", ".cmd"]`(v1.3)。 +- 内置数据中 `windows` 陈述 `object-format = "pe"`,`macos` 陈述 `object-format = "mach-o"`;iOS 的行各自陈述 + `mach-o`,ok 镜像的行陈述 `.oke` 与 `.okso`,`wasm32-emscripten` 陈述 `.js`(v1.5)。此前这些由引擎中按系统名的分支 + 表达,没有分支的内置行(FreeBSD、裸机、iOS)取宿主的命名。 +- 平台定义的行可以不陈述 `object-format`:未陈述时取其系统的,再取 ELF(v1.5)。 - 引擎源码中系统名的出现次数由检查持有(`.github/tools/check_system_names.py` 与其基线),只许减少。 ### 2.4 执行关系(v1.3) @@ -237,5 +257,6 @@ | 1.0 | 2026-11-09 | 初版:行、提供者、选择、平台定义的行、C 环境、执行、报告与锁 | | 1.1 | 2026-11-10 | `clang-triple`;内置行的系统词;FreeBSD 两种身份与 32 位 planned 行;提供者 sysroot 为基座陈述的最后一级;`mingw-llvm` 与 `aarch64-windows-gnu`;C 库由平台描述的行与内置行同一读法;打包读文件闭包;`link.flags` 的警告;构建程序的 `MCPP_KERNEL_ABI_INTERFACES` | | 1.2 | 2026-11-12 | 行的 `loader` 与 `execution` 为内置行所读;系统表(`uname`);提供者的 `tier`、`system-headers`、`runner`;一条条目一种安排;请求的回答是契约;`glibc-sysroot`;一个执行谓词,另一系统的程序不被启动;程序解释器与基座包的单一读法;运行器的占位、`requires` 与 `built-as` | +| 1.5 | 2026-11-18 | mcpp 2026.11.18.1(设计 2026-11-17 §12):`object-format`、`exe-suffix`、`shared-suffix` 的三级读取(行、系统、格式的约定);系统表的这三个键;内置行的命名不取宿主的 | | 1.4 | 2026-11-17 | mcpp 2026.11.17.1(设计 2026-11-16 N48):行的 `exe-suffix-fixed` | | 1.3 | 2026-11-16 | mcpp 2026.11.16.1(设计 2026-11-15 G7、N16、N23、N26、N33、R1、R2、X1):执行关系表(§2.4);系统表的 `resources` 与 `command-scripts`(§2.3);提供者运行器的 `host`、`enabled` 与 `exclusive`(§6);Android 行的运行器(G7);行的 `exceptions`(工程未陈述时的异常模型);行的 `companions`;平台以工具链列出的 planned 行可作载体的行 | diff --git a/docs/zh/35-platforms.md b/docs/zh/35-platforms.md index 145fcdfc9..40e5b9133 100644 --- a/docs/zh/35-platforms.md +++ b/docs/zh/35-platforms.md @@ -353,6 +353,20 @@ name = "haiku" uname = "Haiku" # `uname -s` 在该系统上的回答 ``` +**对象格式与文件名(2026.11.18.1+)。** 行的 `object-format`、`exe-suffix`、`shared-suffix` 按三级读取,先陈述者生效:行, +行的系统(`[[platform.system]]` 接受同样三个键,陈述其各行共有的值),对象格式的约定。内置行经同一读法,其陈述是内置表 +中的数据;构建机器的命名不为任何行作答,因此一个目标在每种宿主上是同一组文件名。 + +| 格式 | 程序 | 静态库 | 共享库 | +|---|---|---|---| +| `elf`(两者都未陈述格式时) | 无后缀 | `lib.a` | `.so` | +| `mach-o` | 无后缀 | `lib.a` | `.dylib` | +| `pe` | `.exe` | `lib.a`;env 为 `msvc` 时 `.lib` | `.dll`,带导入库 | +| `coff` | 无后缀 | `lib.a` | `.so` | +| `wasm` | 无后缀 | `lib.a` | 不支持 | + +程序取其他后缀的行陈述它(`exe-suffix = ".efi"`)。未陈述 `object-format` 的行取其系统的,再取 ELF。 + 提供者的 `runner` 是运行器陈述的最低一级:构建程序的、本机 `config.toml` 的、项目的 `[target.] runner` 与 `MCPP_TARGET__RUNNER` 依次替换它。平台自己的 `runner` 属于 `[platform] targets`, 不替换它(2026.11.13.1):提供者陈述它所服务的身份的运行器、链接(`link`)与基座(`sysroot`),`base = "platform"` 与 diff --git a/modules/manifest/src/platform.cppm b/modules/manifest/src/platform.cppm index 5acdda3e8..9f94eb4c3 100644 --- a/modules/manifest/src/platform.cppm +++ b/modules/manifest/src/platform.cppm @@ -262,7 +262,7 @@ struct Hosted { // engine's table does not have, with the facts a build of it needs. struct RowSpec { std::string triple; - std::string tier = "preview", note, clangTriple, gccTriple, objectFormat = "elf", family, dataModel, + std::string tier = "preview", note, clangTriple, gccTriple, objectFormat, family, dataModel, exeSuffix, sharedSuffix, loader, execution, exceptions; std::string march, mabi, codeModel, multilib, linkEmulation; std::vector flags, descriptorKeys, companions; @@ -301,6 +301,8 @@ struct SystemSpec { std::string name, uname; bool resources = false; std::vector commandScripts; + // What the system's rows share unless a row states its own. + std::string objectFormat, exeSuffix, sharedSuffix; Origin origin; }; @@ -401,7 +403,9 @@ inline constexpr std::string_view kProviderKeys[] = { "name", "serves", "priority", "hosts", "pairs", "toolchain", "sysroot", "linkage", "base", "hosted", "layers", "link", "execution", "tier", "system-headers", "runner", }; -inline constexpr std::string_view kSystemKeys[] = { "name", "uname", "resources", "command-scripts" }; +inline constexpr std::string_view kSystemKeys[] = { + "name", "uname", "resources", "command-scripts", "object-format", "exe-suffix", "shared-suffix", +}; inline constexpr std::string_view kBuildKeys[] = { "cflags", "cxxflags", "asmflags", "ldflags" }; inline constexpr std::string_view kLinkKeys[] = { "driver", "flags", "start", "script", "inputs", "exe", "shared", "seal", diff --git a/modules/manifest/src/platform_toml.cppm b/modules/manifest/src/platform_toml.cppm index 4d62c42ed..e5b92ba9b 100644 --- a/modules/manifest/src/platform_toml.cppm +++ b/modules/manifest/src/platform_toml.cppm @@ -100,6 +100,12 @@ std::string list_of(std::span keys) { return out; } +// The containers an object comes in (SPEC-016 §2): a row's and a system's +// `object-format`. +bool is_object_format(std::string_view f) { + return f == "elf" || f == "mach-o" || f == "pe" || f == "wasm" || f == "coff"; +} + bool contains(std::span keys, std::string_view k) { return std::ranges::find(keys, k) != keys.end(); } @@ -644,8 +650,8 @@ std::expected Reader::define(const toml::Table& t, std::st "\"x86_64-freebsd\"", where)); if (r.tier != "verified" && r.tier != "preview" && r.tier != "planned") return std::unexpected(std::format("{}.tier is verified, preview or planned", where)); - if (r.objectFormat != "elf" && r.objectFormat != "mach-o" && r.objectFormat != "pe" && r.objectFormat != "wasm" - && r.objectFormat != "coff") + // Unstated, the format is the row's system's, then ELF (SPEC-016 §2.3). + if (!r.objectFormat.empty() && !is_object_format(r.objectFormat)) return std::unexpected(std::format("{}.object-format is elf, mach-o, pe, wasm or coff", where)); return r; } @@ -843,8 +849,13 @@ std::expected Reader::statement(const toml::Table& t) co } if (!sv.is_string()) return std::unexpected(std::format("{}.{} must be a string", where, sk)); - (sk == "name" ? sys.name : sys.uname) = sv.as_string(); + (sk == "name" ? sys.name : sk == "uname" ? sys.uname + : sk == "object-format" ? sys.objectFormat + : sk == "exe-suffix" ? sys.exeSuffix : sys.sharedSuffix) = sv.as_string(); } + if (!sys.objectFormat.empty() && !is_object_format(sys.objectFormat)) + return std::unexpected( + std::format("{}.object-format is elf, mach-o, pe, wasm or coff", where)); if (sys.name.empty()) return std::unexpected(std::format("{} names no system: write name = \"\"", where)); s.systems.push_back(std::move(sys)); diff --git a/modules/toolchain-model/build.mcpp b/modules/toolchain-model/build.mcpp index 47fbc69cc..ce7069c1a 100644 --- a/modules/toolchain-model/build.mcpp +++ b/modules/toolchain-model/build.mcpp @@ -24,7 +24,10 @@ constexpr std::string_view kProviderKeys[] = { "platform", "tier", "system-headers", "runner", }; constexpr std::string_view kRunnerKeys[] = { "cmd", "host", "hosts", "requires", "enabled", "exclusive" }; -constexpr std::string_view kSystemKeys[] = { "name", "uname", "resources", "command-scripts" }; +constexpr std::string_view kSystemKeys[] = { + "name", "uname", "resources", "command-scripts", "object-format", "exe-suffix", "shared-suffix", +}; +constexpr std::string_view kObjectFormats[] = { "elf", "mach-o", "pe", "wasm", "coff" }; constexpr std::string_view kExecutesKeys[] = { "host", "arches" }; constexpr std::string_view kPayloadKeys[] = { "name", "aliases", "family", "serves", "hosts", "frontend-dir", "frontends", "builds-for", "glibc-fixup", "family-version", @@ -219,8 +222,14 @@ std::string system_entry(const toml::Table& t, Arrays& arrays, std::setsecond.is_bool()) throw Failure{std::format("{}: `resources` is not true or false", where)}; resources = it->second.as_bool(); } - return std::format(" {{ .name = {}, .uname = {}, .resources = {}, .commandScripts = {} }},\n", lit(name), - lit(text(t, "uname", where)), resources, arrays.add(words(t, "command-scripts", where))); + const auto format = text(t, "object-format", where); + if (!format.empty() && !std::ranges::contains(kObjectFormats, std::string_view(format))) + throw Failure{std::format("{}: `object-format` is elf, mach-o, pe, wasm or coff", where)}; + return std::format(" {{ .name = {}, .uname = {}, .resources = {}, .commandScripts = {}, .objectFormat = {}, " + ".exeSuffix = {}, .sharedSuffix = {} }},\n", + lit(name), lit(text(t, "uname", where)), resources, + arrays.add(words(t, "command-scripts", where)), lit(format), + lit(text(t, "exe-suffix", where)), lit(text(t, "shared-suffix", where))); } std::string executes_entry(const toml::Table& t, Arrays& arrays, std::set& seen) { diff --git a/modules/toolchain-model/data/builtin.toml b/modules/toolchain-model/data/builtin.toml index 80548d0ae..02c976428 100644 --- a/modules/toolchain-model/data/builtin.toml +++ b/modules/toolchain-model/data/builtin.toml @@ -100,6 +100,16 @@ # command-scripts the suffixes of the files the system starts through its # command interpreter; an argument holding the interpreter's # syntax (`%`, `^`, `&`, `|`, `<`, `>`, `"`) is refused +# object-format the container the objects of the system's rows come in +# (elf | mach-o | pe | wasm | coff); a row's own statement +# precedes it, and ELF is what neither states +# exe-suffix the suffix of the system's programs +# shared-suffix the suffix of its shared libraries +# +# A row's `object-format`, `exe-suffix` and `shared-suffix` are read row first, +# then system, then the convention of the object format (elf: none, `.so`; +# mach-o: none, `.dylib`; pe: `.exe`, `.dll`). No engine source names a system +# for them, and no host answers for a row. # ── Linux ──────────────────────────────────────────────────────────────────── @@ -205,6 +215,8 @@ standard = true [[platform.define]] triple = "i686-openkal" +exe-suffix = ".oke" +shared-suffix = ".okso" tier = "planned" note = "ok" standard = true @@ -439,16 +451,19 @@ exact = true [[platform.define]] triple = "aarch64-ios" +object-format = "mach-o" tier = "preview" standard = true [[platform.define]] triple = "aarch64-ios-sim" +object-format = "mach-o" tier = "verified" standard = true [[platform.define]] triple = "x86_64-ios-sim" +object-format = "mach-o" tier = "verified" standard = true @@ -471,18 +486,23 @@ exceptions = "wasm" companions = [".wasm"] # `.js` pairs the launcher with its module: a name template decides what # precedes it, and the name ends in `.js` (N48). +exe-suffix = ".js" exe-suffix-fixed = true # OK IMAGES (openkal SPEC clause 12): one artifact per architecture, run by # `okrun` on Linux, macOS and Windows of that architecture. [[platform.define]] triple = "x86_64-openkal" +exe-suffix = ".oke" +shared-suffix = ".okso" tier = "verified" note = "ok" standard = true [[platform.define]] triple = "aarch64-openkal" +exe-suffix = ".oke" +shared-suffix = ".okso" tier = "verified" note = "ok" standard = true @@ -697,8 +717,9 @@ name = "linux" uname = "Linux" [[platform.system]] -name = "macos" -uname = "Darwin" +name = "macos" +uname = "Darwin" +object-format = "mach-o" [[platform.system]] name = "freebsd" @@ -707,6 +728,7 @@ uname = "FreeBSD" # A Windows program is not selected by `uname`: it leads the file. [[platform.system]] name = "windows" +object-format = "pe" resources = true command-scripts = [".bat", ".cmd"] diff --git a/modules/toolchain-model/src/target_schema.cppm b/modules/toolchain-model/src/target_schema.cppm index 9bd5f7fed..c4fcf5220 100644 --- a/modules/toolchain-model/src/target_schema.cppm +++ b/modules/toolchain-model/src/target_schema.cppm @@ -30,8 +30,10 @@ struct Row { std::string_view multilib; // a C library's multilib directory std::span flags; // extra compile flags std::string_view linkEmulation; // `ld.lld -m`, when the driver reaches no lld - // The facts of a defined row (a platform's). Empty on a built-in row, - // whose system's conventions answer them. + // The facts a row states for itself. `objectFormat`, `exeSuffix` and + // `sharedSuffix` left empty are its system's (`System`), then the + // convention of the object format; the others, empty on a built-in row, + // are answered by the engine's conventions for the row's system. std::string_view clangTriple; // `{version}` / `{version:}` // The target a cross GCC payload is built for, in GNU's spelling // (`i586-pc-msdosdjgpp`): the payload is `-gcc` and its @@ -145,6 +147,13 @@ struct System { // as its own syntax, so an argument holding one is refused before the // start rather than passed to be rewritten or run as a command. std::span commandScripts; + // WHAT THE SYSTEM'S ROWS SHARE (design 2026-11-17 §12): the container its + // objects come in and the suffixes of its programs and shared libraries. + // A row's own statement precedes these; one neither states is the + // convention of the object format (`triple::artifact_naming`). + std::string_view objectFormat; // elf | mach-o | pe | wasm | coff; empty: unstated + std::string_view exeSuffix; + std::string_view sharedSuffix; }; // AN ARCHITECTURE A MACHINE EXECUTES BESIDES ITS OWN (design 2026-11-15 N23): diff --git a/modules/toolchain-model/src/triple.cppm b/modules/toolchain-model/src/triple.cppm index 5dc3c785b..a6175021d 100644 --- a/modules/toolchain-model/src/triple.cppm +++ b/modules/toolchain-model/src/triple.cppm @@ -275,8 +275,8 @@ struct Triple { // fallback would otherwise claim ELF for it -- the silent wrong answer this // whole axis exists to remove. ObjectFormat object_format() const { - // A row that states its format -- one a platform defines, or a built-in - // row whose data carries `object-format` -- is taken as written. + // READ FROM THE DATA (SPEC-016 §2.3): the row's own statement, then + // its system's. The engine names no system here. auto stated = [](std::string_view f) { if (f == "pe") return ObjectFormat::Pe; if (f == "mach-o") return ObjectFormat::MachO; @@ -284,11 +284,10 @@ struct Triple { if (f == "coff") return ObjectFormat::Coff; return ObjectFormat::Elf; }; - if (auto* d = defined()) return stated(d->objectFormat); if (auto const* r = mcpp::toolchain::target::find_row(str()); r && !r->objectFormat.empty()) return stated(r->objectFormat); - if (os == "windows") return ObjectFormat::Pe; - if (os == "macos" || os == "ios") return ObjectFormat::MachO; + if (auto const* s = mcpp::toolchain::target::find_system(os); s && !s->objectFormat.empty()) + return stated(s->objectFormat); if (arch.starts_with("wasm")) return ObjectFormat::Wasm; return ObjectFormat::Elf; } @@ -862,107 +861,48 @@ struct ArtifactNaming { // the decision testable from any host (and keeps this module dependency-free). inline ArtifactNaming artifact_naming(const Triple& t, const ArtifactNaming& hostNaming) { if (t.empty()) return hostNaming; - if (auto* d = t.defined()) { - const bool pe = t.is_pe(); - return ArtifactNaming{ - .exeSuffix = d->exeSuffix, .libPrefix = "lib", - .staticLibExt = ".a", - .sharedLibExt = !d->sharedSuffix.empty() ? d->sharedSuffix - : pe ? std::string_view(".dll") - : t.is_mach_o() ? std::string_view(".dylib") : std::string_view(".so"), - .sharedNeedsImportLib = pe, - }; - } - - if (t.os == "windows") { - // PE. The static-library convention splits on env, not on os. - const bool msvc = t.is_msvc_env(); - return ArtifactNaming{ - .exeSuffix = ".exe", - .libPrefix = msvc ? "" : "lib", - .staticLibExt = msvc ? ".lib" : ".a", - .sharedLibExt = ".dll", - .sharedNeedsImportLib = true, - }; - } - if (t.os == "macos") { - return ArtifactNaming{ - .exeSuffix = "", .libPrefix = "lib", - .staticLibExt = ".a", .sharedLibExt = ".dylib", - .sharedNeedsImportLib = false, - }; - } - if (t.os == "linux") { - return ArtifactNaming{ - .exeSuffix = "", .libPrefix = "lib", - .staticLibExt = ".a", .sharedLibExt = ".so", - .sharedNeedsImportLib = false, - }; - } - // SPEC 12: an executable image is `*.oke`, an image another loads `*.okso`. - if (t.os == "openkal") { - return ArtifactNaming{ - .exeSuffix = ".oke", .libPrefix = "lib", - .staticLibExt = ".a", .sharedLibExt = ".okso", - .sharedNeedsImportLib = false, - }; - } - if (t.os == "emscripten") { - // `artifact_naming`'s one sentence, unchanged: the executable is the - // file a runner executes, in the row's own convention. On this row - // that file is the JavaScript launcher — what the emsdk payload's - // `node` runs and what a browser loads — so the row's convention for - // "the executable" is `.js`, not the ELF/host-borrowed bare name this - // used to fall back to (a different file on Linux vs. Windows hosts). - // - // Read, not recalled: Emscripten's own CMake toolchain fixes - // `CMAKE_EXECUTABLE_SUFFIX ".js"` (`Platform/Emscripten.cmake`) and - // Rust's `wasm32-unknown-emscripten` target spec sets - // `exe_suffix: ".js"` — both because emcc's `-o` extension selects - // what it emits, and anything but `.js`/`.html`/`.wasm` falls back to - // the `.js` case. A future `wasm32-wasi` row would answer `.wasm` by - // the same sentence, the way Rust's other wasm targets do, because - // there the module IS the executable a runner executes. - // - // `sharedLibExt` is empty and `sharedNeedsImportLib` is set as the - // "shared libraries are not supported for this target" marker (see - // the field comment above): a wasm side module needs `-sSIDE_MODULE`, - // a link contract this engine does not render, so the fallback answer - // (a `.so`-shaped file that does not work as one) is refused instead - // of produced — see the plan-time refusal in prepare.cppm. - return ArtifactNaming{ - .exeSuffix = ".js", .libPrefix = "lib", - .staticLibExt = ".a", .sharedLibExt = "", - .sharedNeedsImportLib = true, - }; - } - // A ROW OF THE TABLE WITH NO BRANCH ABOVE IS NAMED BY ITS OBJECT FORMAT, - // which is the row's data (`object_format()`), not by the host. Left to the - // host answer below, a FreeBSD row built on a Windows host was - // `bin/hello.exe` and its archives `.lib` (measured, - // mcpp-community/mcpp-platforms#4: the build finished and no `bin/hello` - // existed); the bare-metal rows and the iOS rows answered the same way, - // 21 rows of the snapshot in all. - if (mcpp::toolchain::target::find_row(t.str())) { - switch (t.object_format()) { - case ObjectFormat::Elf: - return ArtifactNaming{ - .exeSuffix = "", .libPrefix = "lib", - .staticLibExt = ".a", .sharedLibExt = ".so", - .sharedNeedsImportLib = false, - }; - case ObjectFormat::MachO: - return ArtifactNaming{ - .exeSuffix = "", .libPrefix = "lib", - .staticLibExt = ".a", .sharedLibExt = ".dylib", - .sharedNeedsImportLib = false, - }; - default: break; - } + // ONE READING FOR EVERY ROW (SPEC-016 §2.3; design 2026-11-17 §12): the + // row's statement, then its system's, then the convention of the object + // format. The engine names no system here, and the host answers only for a + // triple that is neither a row nor of a system the table states -- left to + // the host, a FreeBSD row built on a Windows host was `bin/hello.exe` + // (measured, mcpp-community/mcpp-platforms#4), and 21 rows of the snapshot + // answered that way. + auto const* row = mcpp::toolchain::target::find_row(t.str()); + auto const* sys = mcpp::toolchain::target::find_system(t.os); + if (!row && !sys) return hostNaming; + + // THE CONVENTIONS OF THE FORMATS. A PE static library splits on the ABI + // (`msvc`), not on a system. A wasm row has no shared library: a side + // module needs `-sSIDE_MODULE`, a link contract this engine does not + // render, so the empty suffix with `sharedNeedsImportLib` is the "not + // supported" marker the plan refuses on (prepare.cppm). + ArtifactNaming n{ .exeSuffix = "", .libPrefix = "lib", .staticLibExt = ".a", .sharedLibExt = ".so", + .sharedNeedsImportLib = false }; + switch (t.object_format()) { + case ObjectFormat::Pe: + n.exeSuffix = ".exe"; + n.sharedLibExt = ".dll"; + n.sharedNeedsImportLib = true; + if (t.is_msvc_env()) { n.libPrefix = ""; n.staticLibExt = ".lib"; } + break; + case ObjectFormat::MachO: n.sharedLibExt = ".dylib"; break; + case ObjectFormat::Wasm: n.sharedLibExt = ""; n.sharedNeedsImportLib = true; break; + default: break; } - // Not a row and outside the triple language: fall back to the host answer - // rather than guessing. A wrong guess here silently misnames every artifact. - return hostNaming; + // What the data states over the convention. The executable is the file a + // runner executes: `.js` of wasm32-emscripten (the launcher `node` runs and + // a browser loads; Emscripten's CMake toolchain and Rust's target spec fix + // the same suffix), `.oke` of an ok image, `.efi` of a UEFI application. + auto first = [](std::string_view a, std::string_view b) { return !a.empty() ? a : b; }; + if (auto s = first(row ? row->exeSuffix : std::string_view{}, sys ? sys->exeSuffix : std::string_view{}); + !s.empty()) + n.exeSuffix = s; + if (auto s = first(row ? row->sharedSuffix : std::string_view{}, + sys ? sys->sharedSuffix : std::string_view{}); + !s.empty()) + n.sharedLibExt = s; + return n; } // ── The link form of `kind = "app"` ────────────────────────────────────────── diff --git a/src/build/prepare/platform.cpp b/src/build/prepare/platform.cpp index d154f5138..251e3dd5b 100644 --- a/src/build/prepare/platform.cpp +++ b/src/build/prepare/platform.cpp @@ -242,8 +242,10 @@ void define_platform(const mp::Statement& s, std::string_view shortName, std::st set.providers.push_back(p); }; for (auto const& sys : s.systems) - set.systems.push_back({ set.keep(sys.name), set.keep(sys.uname), sys.resources, - set.keep(sys.commandScripts) }); + set.systems.push_back({ .name = set.keep(sys.name), .uname = set.keep(sys.uname), + .resources = sys.resources, .commandScripts = set.keep(sys.commandScripts), + .objectFormat = set.keep(sys.objectFormat), .exeSuffix = set.keep(sys.exeSuffix), + .sharedSuffix = set.keep(sys.sharedSuffix) }); // A platform the engine's own providers name (openkal-platform) is served by // those; its shorthands are not registered twice. const bool builtin = std::ranges::any_of(mcpp::toolchain::builtin::kProviders, [&](auto const& b) { diff --git a/tests/e2e/targets/rows.cpp b/tests/e2e/targets/rows.cpp index 941972dfe..863333473 100644 --- a/tests/e2e/targets/rows.cpp +++ b/tests/e2e/targets/rows.cpp @@ -401,6 +401,67 @@ int main() { expect(freebsd) << "the ELF is not a FreeBSD program"; expect(s::lacks(s::text(r), "MacOSX") && s::lacks(s::text(r), "-isysroot")) << "the build names an SDK of the host: " << s::text(r); }; + + "1117 a platform's system states what its rows share"_test[s::llvm] = [] { + // SPEC-016 v1.5: `object-format`, `exe-suffix` and `shared-suffix` are read row + // first, then the row's system. The row here states none of them and its system + // states the program's suffix, so the plan names the program by it. The toy base + // holds no C library; the plan is what is read, and the link's outcome is not. + const auto t = s::case_dir(); + fs::create_directories(t / "toy-sysroot/usr/lib"); + s::project(t / "toy-sysroot", {{"mcpp.toml", "[package]\nname = \"toy-sysroot\"\nversion = \"1.0\"\nprovides = [\"mcpp:c-abi=toy-libc\", \"mcpp:c++-abi=libstdc++\", \"mcpp:compiler-runtime=libgcc\",\n \"hosted-standard-library\"]\n"}}); + s::project(t / "plat", {{"mcpp.toml", std::format(R"([package] +name = "toy-system-platform" +version = "0.1.0" + +[platform] +toolchain = "llvm@{}" + +[[platform.system]] +name = "toynet" +uname = "ToyNet" +exe-suffix = ".tny" +shared-suffix = ".tso" + +[[platform.define]] +triple = "x86_64-toynet" +clang-triple = "x86_64-unknown-netbsd10.2" +family = "unix" +execution = "toynet" +tier = "preview" + +[[platform.define]] +triple = "aarch64-toynet" +clang-triple = "aarch64-unknown-netbsd10.2" +exe-suffix = ".own" +family = "unix" +execution = "toynet" +tier = "preview" + +[[platform.provider]] +serves = ["*-toynet"] +sysroot = {{ path = "../toy-sysroot" }} +hosted = true + +[platform.link] +driver = "compiler" +)", s::llvm_version())}}); + s::project app(t / "app", {{"mcpp.toml", "[package]\nname = \"app\"\nversion = \"0.1.0\"\n\n[targets.app]\nkind = \"bin\"\nmain = \"src/main.cpp\"\n\n[target.'cfg(os = \"toynet\")']\nplatform = { path = \"../plat\" }\n"}, + {"src/main.cpp", "int main() { return 0; }\n"}}); + auto planned = [&](std::string_view triple) { + auto r = app.mcpp({"build", "--target", std::string(triple)}); + std::string plan; + std::error_code ec; + for (fs::recursive_directory_iterator it(app.at(std::format("target/{}", triple)), ec), end; !ec && it != end; it.increment(ec)) + if (it->path().filename() == "build.ninja") plan += s::read_file(it->path()); + return std::pair(plan, s::text(r)); + }; + auto [sys, out] = planned("x86_64-toynet"); + expect(fatal(e2e::contains(sys, "bin/app.tny"))) << "the program is not named by its system's suffix: " << out; + auto [own, out2] = planned("aarch64-toynet"); + expect(fatal(e2e::contains(own, "bin/app.own"))) << "the row's own suffix does not precede its system's: " << out2; + expect(fatal(!e2e::contains(own, "bin/app.tny"))) << "the system's suffix was taken over the row's"; + }; }}; } // namespace diff --git a/tests/unit/test_artifact_naming.cpp b/tests/unit/test_artifact_naming.cpp index 5c6b448a5..5cca73b5e 100644 --- a/tests/unit/test_artifact_naming.cpp +++ b/tests/unit/test_artifact_naming.cpp @@ -4,6 +4,8 @@ import mcpplibs.mtest; import mcpplibs.os.platform; import mcpp.toolchain.platform; import mcpp.toolchain.triple; +import mcpp.toolchain.target_schema; +import mcpp.toolchain.target_rows; using namespace mcpplibs::mtest; @@ -120,9 +122,8 @@ UTest unknown_os_falls_back_to_host{"ArtifactNaming/UnknownOsFallsBackToHost", [ expect(eq(n.staticLibExt, ".HOST")); }}; -// A bare-metal `none` OS is not the emscripten row and must keep falling back -// to the host answer when it is no row of the table — the emscripten branch -// below must not widen the fallback it sits next to. +// A bare-metal `none` OS that is no row of the table has neither a row nor a +// system to answer for it, and falls back to the host answer. UTest none_os_falls_back_to_host{"ArtifactNaming/NoneOsFallsBackToHost", [] { tr::Triple none; none.arch = "aarch64"; none.os = "none"; auto n = tr::artifact_naming(none, kBogusHost); @@ -147,6 +148,81 @@ UTest a_row_is_named_by_its_object_format{"ArtifactNaming/ARowIsNamedByItsObject expect(eq(n.sharedLibExt, ".dylib")); }}; +// A TRIPLE OF A SYSTEM THE TABLE STATES is named by that system's data when it +// is no row: the host answers only where the data knows neither the row nor +// the system. +UTest a_system_of_the_table_answers_for_a_triple_that_is_no_row{ + "ArtifactNaming/ASystemOfTheTableAnswersForATripleThatIsNoRow", [] { + tr::Triple elf; elf.arch = "sparc64"; elf.os = "freebsd"; + auto n = tr::artifact_naming(elf, kBogusHost); + expect(eq(n.exeSuffix, "")); + expect(eq(n.staticLibExt, ".a")); + expect(eq(n.sharedLibExt, ".so")); + tr::Triple pe; pe.arch = "sparc64"; pe.os = "windows"; pe.env = "gnu"; + expect(pe.object_format() == tr::ObjectFormat::Pe); + expect(eq(tr::artifact_naming(pe, kBogusHost).exeSuffix, ".exe")); + tr::Triple macho; macho.arch = "sparc64"; macho.os = "macos"; + expect(macho.object_format() == tr::ObjectFormat::MachO); + expect(eq(tr::artifact_naming(macho, kBogusHost).sharedLibExt, ".dylib")); +}}; + +// ROW, THEN SYSTEM, THEN THE FORMAT'S CONVENTION (SPEC-016 §2.3), for a +// platform's rows as for the table's: a system a platform states gives its +// rows their format and suffixes, a row's own statement precedes it, and what +// neither states is the convention of the format. +UTest a_row_is_read_before_its_system_and_the_format_last{ + "ArtifactNaming/ARowIsReadBeforeItsSystemAndTheFormatLast", [] { + namespace tg = mcpp::toolchain::target; + tg::DefinitionSet set; + set.source = "naming-test-platform"; + auto row = [&](std::string_view triple) -> tg::Row& { + auto& id = set.strings.emplace_back(triple); + const std::string_view v = id; + const auto dash = v.find('-'); + tg::Row r{}; + r.triple = v; + r.arch = v.substr(0, dash); + r.os = v.substr(dash + 1); + r.tier = "preview"; + r.defined = true; + return set.rows.emplace_back(r); + }; + row("x86_64-quux"); // states nothing + auto& own = row("aarch64-quux"); // states its own + own.objectFormat = "elf"; + own.exeSuffix = ".elf"; + own.sharedSuffix = ".so.1"; + row("x86_64-plainos"); // no system, nothing stated + auto& coff = row("i586-oldos"); + coff.objectFormat = "coff"; + set.systems.push_back({ .name = "quux", .objectFormat = "pe", .exeSuffix = ".app", .sharedSuffix = ".mod" }); + tg::define(std::move(set)); + + auto sys = T("x86_64-quux"); + expect(sys.object_format() == tr::ObjectFormat::Pe) << "the system's format"; + auto n = tr::artifact_naming(sys, kBogusHost); + expect(eq(n.exeSuffix, ".app")); + expect(eq(n.sharedLibExt, ".mod")); + expect(eq(n.staticLibExt, ".a")); + expect(n.sharedNeedsImportLib) << "the format's convention where the system states no key"; + + auto mine = T("aarch64-quux"); + expect(mine.object_format() == tr::ObjectFormat::Elf) << "the row's own format"; + n = tr::artifact_naming(mine, kBogusHost); + expect(eq(n.exeSuffix, ".elf")); + expect(eq(n.sharedLibExt, ".so.1")); + expect(!n.sharedNeedsImportLib); + + n = tr::artifact_naming(T("x86_64-plainos"), kBogusHost); + expect(eq(n.exeSuffix, "")) << "ELF where neither states a format"; + expect(eq(n.libPrefix, "lib")); + expect(eq(n.sharedLibExt, ".so")); + + n = tr::artifact_naming(T("i586-oldos"), kBogusHost); + expect(eq(n.exeSuffix, "")); + expect(eq(n.staticLibExt, ".a")); +}}; + // ── wasm32-emscripten: the executable is the file a runner executes, and on // this row that file is the JavaScript launcher, not a bare ELF-shaped name. // See .agents/docs/2026-09-12-622-a-ui-framework-on-android-ios-and-web.md §2.5. diff --git a/tests/unit/test_platform.cpp b/tests/unit/test_platform.cpp index 3b34a16a9..6b7067e75 100644 --- a/tests/unit/test_platform.cpp +++ b/tests/unit/test_platform.cpp @@ -130,6 +130,12 @@ version = "0.1.0" name = "netbsd" uname = "NetBSD" +[[platform.system]] +name = "quux" +object-format = "pe" +exe-suffix = ".app" +shared-suffix = ".mod" + [[platform.define]] triple = "x86_64-netbsd" clang-triple = "x86_64-unknown-netbsd10.2" @@ -139,9 +145,16 @@ execution = "netbsd" serves = ["x86_64-netbsd"] )"); expect(fatal(bool(m.platformDeclared))); - expect(fatal(eq(m.platform.systems.size(), 1u))); + expect(fatal(eq(m.platform.systems.size(), 2u))); expect(eq(m.platform.systems[0].name, "netbsd")); expect(eq(m.platform.systems[0].uname, "NetBSD")); + expect(eq(m.platform.systems[0].objectFormat, "")) << "unstated: the row's, then ELF"; + // What a system's rows share (2026.11.18.1): read before the format's convention. + expect(eq(m.platform.systems[1].objectFormat, "pe")); + expect(eq(m.platform.systems[1].exeSuffix, ".app")); + expect(eq(m.platform.systems[1].sharedSuffix, ".mod")); + expect(fatal(eq(m.platform.defines.size(), 1u))); + expect(eq(m.platform.defines[0].objectFormat, "")) << "a row that states no format is its system's"; }}; UTest refusals_name_the_key{"PlatformManifest/RefusalsNameTheKey", [] { From 954d30dd401a6467a307c8aba965bd62dc32cec7 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Wed, 18 Nov 2026 08:54:30 +0900 Subject: [PATCH 6/7] e2e: the platform-system case is 1118 (1117 is taken) --- .../docs/2026-11-17-ninja-cascade-publish-supplement-design.md | 2 +- tests/e2e/targets/rows.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.agents/docs/2026-11-17-ninja-cascade-publish-supplement-design.md b/.agents/docs/2026-11-17-ninja-cascade-publish-supplement-design.md index 494b2b6f1..e31f4696a 100644 --- a/.agents/docs/2026-11-17-ninja-cascade-publish-supplement-design.md +++ b/.agents/docs/2026-11-17-ninja-cascade-publish-supplement-design.md @@ -576,5 +576,5 @@ schema 已有键名的两项事实。 | 行快照(42 个内置行的格式与命名) | 由分支改为数据前后逐字相同 | | 系统名基线 | `linux` 63→62,`macos` 51→49,`windows` 72→70,`emscripten` 18→17,`ios` 24→23 | | 单元测试 | 行先于系统、系统先于格式的约定;表中系统的非行三元组不取宿主的命名;清单读取系统的三个键 | -| e2e 1117 | 平台包的系统陈述 `exe-suffix`,未陈述的行得到它,陈述了的行取自己的 | +| e2e 1118 | 平台包的系统陈述 `exe-suffix`,未陈述的行得到它,陈述了的行取自己的 | | e2e 1116 | 在持有 LLVM 包的每种宿主上构建 `x86_64-freebsd` 并核对程序名 | diff --git a/tests/e2e/targets/rows.cpp b/tests/e2e/targets/rows.cpp index 863333473..657cc8f45 100644 --- a/tests/e2e/targets/rows.cpp +++ b/tests/e2e/targets/rows.cpp @@ -402,7 +402,7 @@ int main() { expect(s::lacks(s::text(r), "MacOSX") && s::lacks(s::text(r), "-isysroot")) << "the build names an SDK of the host: " << s::text(r); }; - "1117 a platform's system states what its rows share"_test[s::llvm] = [] { + "1118 a platform's system states what its rows share"_test[s::llvm] = [] { // SPEC-016 v1.5: `object-format`, `exe-suffix` and `shared-suffix` are read row // first, then the row's system. The row here states none of them and its system // states the program's suffix, so the plan names the program by it. The toy base From 5a17553286560eeeeaefa0be880efd82a588eacf Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Wed, 18 Nov 2026 10:07:00 +0900 Subject: [PATCH 7/7] e2e 1116: the SDK check reads the build's commands, not the probe's description of the host --- tests/e2e/targets/rows.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/e2e/targets/rows.cpp b/tests/e2e/targets/rows.cpp index 657cc8f45..427d4d1b2 100644 --- a/tests/e2e/targets/rows.cpp +++ b/tests/e2e/targets/rows.cpp @@ -399,7 +399,16 @@ int main() { expect(fatal(bytes.starts_with("\x7f" "ELF"))) << "the program is not an ELF"; const bool freebsd = (bytes.size() > 7 && bytes[7] == 9) || bytes.contains(std::string_view("FreeBSD\0", 8)); expect(freebsd) << "the ELF is not a FreeBSD program"; - expect(s::lacks(s::text(r), "MacOSX") && s::lacks(s::text(r), "-isysroot")) << "the build names an SDK of the host: " << s::text(r); + // No command of the build names an SDK of the host. The probe of the toolchain's + // own compiler reports the host's SDK in the verbose log (`probe: sysroot`) before + // any command is written; that line is the host's description and reaches none. + const std::string log = s::text(r); + bool sdk = log.contains("-isysroot"); + for (auto line : std::views::split(log, '\n')) { + const std::string_view l(line.begin(), line.end()); + sdk = sdk || (l.contains("MacOSX") && !l.contains("probe: ")); + } + expect(!sdk) << "a command of the build names an SDK of the host: " << s::text(r); }; "1118 a platform's system states what its rows share"_test[s::llvm] = [] {