From cdf43d3f5cd3d812b5cb44e691560fb9cf1adc7d Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 02:14:30 +0900 Subject: [PATCH 01/33] feat: the kernel headers are the kernel-abi layer's, platform keys hold on every row, a row states its interfaces, a generated unit names its origin - [target..layers] kernel-abi takes "xim:linux-headers@" or { path } on a system whose row states how its kernel headers are measured; the headers are decided once after the target side, measured by preprocessing, wired ahead of the base with -isystem, and reported (layers[].version). Without a statement the base's own headers answer, then the toolchain's declaration; the shared view is no longer read or written (mcpp#988). - The project's and the machine's [target.] layers, tools and link take effect on a row without a platform; carrier there is a warning. - System and target rows state interfaces; cfg(interface = ...) and layers[].interfaces read the provider's list, else the row's, else the system's (mcpp#1005). - mcpp::action::origin() and ide.generated[].origin; a generated unit that declares a module's primary name is its interface (mcpp#1004). --- ...face-and-derived-state-ecosystem-design.md | 634 ++++++++++++++++++ .agents/docs/README.md | 4 +- .github/tools/system-names.baseline | 2 +- CHANGELOG.md | 43 ++ docs/20-toolchains.md | 6 +- docs/22-target-side.md | 55 +- docs/30-build-mcpp.md | 27 + docs/35-platforms.md | 6 + docs/50-machine-output.md | 7 +- docs/91-toolchain-internals.md | 4 +- docs/specs/build-database.md | 16 +- docs/specs/manifest-semantics.md | 12 +- docs/specs/platforms.md | 17 +- docs/specs/target-side.md | 46 +- docs/specs/targets-and-providers.md | 22 +- docs/specs/toolchain-management.md | 9 +- docs/zh/20-toolchains.md | 5 +- docs/zh/22-target-side.md | 38 +- docs/zh/30-build-mcpp.md | 22 + docs/zh/35-platforms.md | 4 + docs/zh/50-machine-output.md | 6 +- docs/zh/91-toolchain-internals.md | 4 +- modules/buildmcpp/src/directives.cppm | 23 + modules/manifest/src/platform.cppm | 40 +- modules/manifest/src/platform_toml.cppm | 73 +- modules/manifest/src/targetside_model.cppm | 13 +- modules/manifest/src/types.cppm | 7 + modules/toolchain-model/build.mcpp | 70 +- modules/toolchain-model/data/builtin.toml | 76 ++- modules/toolchain-model/src/base.cppm | 96 ++- modules/toolchain-model/src/linkmodel.cppm | 32 +- modules/toolchain-model/src/target_rows.cppm | 2 + .../toolchain-model/src/target_schema.cppm | 37 + .../tests/test_kernel_headers.cpp | 114 ++++ src/build/build_database.cppm | 9 +- src/build/flags.cppm | 6 +- src/build/hostprogram.cppm | 9 + src/build/ninja_backend.cppm | 17 +- src/build/prepare/base.cpp | 256 ++++++- src/build/prepare/features.cpp | 11 +- src/build/prepare/graph_provisioning.cpp | 2 +- src/build/prepare/plan.cpp | 1 + src/build/prepare/platform.cpp | 121 +++- src/build/prepare/state.cppm | 7 + src/build/prepare/target_side.cpp | 35 +- src/doctor.cppm | 4 + src/fallback/sysroot_complete.cppm | 21 +- src/modgraph/graph.cppm | 3 + src/modgraph/scanner.cppm | 16 +- src/toolchain/base_probe.cppm | 3 +- src/toolchain/detect.cppm | 24 +- src/toolchain/probe.cppm | 24 +- tests/e2e/cdb/emit.cpp | 51 ++ tests/e2e/targets/kernel.cpp | 101 +++ tests/unit/test_build_directives.cpp | 27 + tests/unit/test_link_line_golden.cpp | 6 +- tests/unit/test_linkmodel.cpp | 50 +- 57 files changed, 2172 insertions(+), 204 deletions(-) create mode 100644 .agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md create mode 100644 modules/toolchain-model/tests/test_kernel_headers.cpp create mode 100644 tests/e2e/targets/kernel.cpp diff --git a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md new file mode 100644 index 000000000..3081010c7 --- /dev/null +++ b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md @@ -0,0 +1,634 @@ +--- +subject: design +status: active +--- + +# 生态级方案:内核接口的供给与能力,派生状态的核对,存储的引用 + +**日期:** 2026-11-22(v6 2026-11-23,实施中的测定与修订见 §10) · **版本:** v6 · **基线:** mcpp main `53b80e1e`(2026.11.22.1 之后) · **规范:** SPEC-002 §2.4、§2.5、§3.2、 +§3.3(目标侧)、SPEC-004 §2、§4.1(清单)、SPEC-006 §2.9、附录 A(工具链)、SPEC-013 §2、§6、§7.2、§8(平台)、 +SPEC-016 §2(目标行与系统行);xlings 的 xpkg-manifest-v1 §5.1、xpkg-resource-resolution、xlings-json;openkal 规范条款 6.1 + +**范围:** mcpp、xlings(含 Luban)、libxpkg、xim-pkgindex 与资源仓库、mcpp-index、openkal 家族、mcpp-language-server。 +每个仓库一个拉取请求(§6);实施计划与任务依赖见 §9。 + +## 0. 结论 + +**一条规则。** 派生的状态带有它所依据的事实;使用点核对该事实;不成立时重新生成或拒绝,不沉默地继续。存储的账目记录谁在 +引用。共享视图中的内核头文件、存储回收、体检的修复、宿主驱动的链接包,是同一条规则缺席的四处(§3.10)。 + +**内核接口头文件(mcpp、索引、openkal)。** + +1. Linux 的内核头文件是 `mcpp:kernel-abi=linux` 的一个预制供给者。陈述它用已有的键 + `[target..layers] kernel-abi`,不新增清单键、原因标记或接线机制。 +2. 平台键在没有平台的行上同样生效;此前本机与工程的这些键在这样的行上被接受而不起作用。 +3. 缺省依次取两条事实中第一个回答者:基座自带的头文件、工具链声明的版本。两者都不回答时拒绝。共享缺省视图的链接不是 + 事实;引擎数据中不放版本;引擎不向视图写入。 +4. 供给者以 `-isystem` 排在基座之前接线,实现与版本由预处理测量回答。陈述与缺省走同一个决定函数、同一条接线、同一次 + 测量;链接模型中按 C 库名与按文件存在与否的两处判断随之删除。 +5. 某一层能否以载荷陈述,由行的系统数据决定,而不是由引擎按层名决定。内核接口与 C 库同属一个 SDK 或基座的系统没有这份 + 数据,陈述被拒绝;`kernel-abi` 为 openkal 的各行由已有的规则一与规则二拒绝。引擎不为任何系统或实现写特例。 +6. 内核头文件是目标的数据,不是宿主架构的程序。载荷在一个资源中携带各架构的 `asm`,交叉构建与本机构建用同一份载荷、 + 同一条接线(§3.9)。已发布版本的新布局以 xpkg 的包装修订(`revision`)发布,不改写已发布的资源。 + +**存储与派生状态(xlings、Luban、索引)。** + +7. 存储回收的引用集合由四部分构成:工作区的登记、各视图的链接所指向的载荷、被引用载荷所声明依赖的闭包、其他程序登记的 + 根。mcpp 为构建所接线的每个载荷登记根;回收只有 xlings 的一个实现(§3.11)。 +8. 载荷目录的删除属于安装器,不委托给包的钩子;修复在动作之后重新检测,未消除即报告失败(§3.12)。 +9. 依据宿主事实生成的配置(宿主驱动的链接)记录该事实,在使用点与体检中核对,不同则重新配置(§3.13)。 + +**内核接口的能力(mcpp、openkal)。** + +10. 一行能做什么(文件、启动程序、终端)是 `kernel-abi` 供给者所提供的接口。openkal 的实现已经陈述它;系统行的数据为 + 传统的行陈述同一份事实,用同一套接口名。它经一个 `cfg` 谓词与机器可读的查询给出,工程不再按行手写(§3.17)。 + +**同一轮中并行的项。** + +11. 构建数据库为生成的源文件陈述其来源(mcpp#1004,§3.14)。 +12. 经 shell 运行一行命令在 libxpkg 中只有一个函数,输出以管道读取(libxpkg#52,§3.16);沙箱网络加入命名空间的参数 + 收敛为一个函数(§3.15)。 +13. 平台的版本组包含构建程序所用的插件;已登记而未被服务的行与缺少运行器的行各自以测量决定其层级(§3.18、§3.19)。 + +## 1. 问题与实测 + +需要的是三件事:对更新的内核接口编译(新的系统调用、ioctl 与常量);钉住所编译的头文件以便复现;同一清单在不同 home +中对同一份头文件编译。以下在 x86_64 Linux 上以 mcpp 2026.11.22.1 测得: + +| # | 写法或状态 | 结果 | +|---|---|---| +| 1 | `[target.x86_64-linux-gnu.layers] kernel-abi = "xim:linux-headers@6.18.64"` | 被接受而无效果,`--strict` 下同样无报告;`LINUX_VERSION_CODE` 仍为 330497(5.11.1) | +| 2 | `[target.x86_64-linux-gnu.xlings.workspace] "xim:linux-headers" = "6.18.64"` | 载荷被安装,没有单元读取它 | +| 3 | `sysroot = { path = "" }`,目录为 glibc 2.44.3 与 linux-headers 6.18.64 的链接树 | 生效(397888);代价是以手工组装的整个基座替换缺省基座,没有包身份 | +| 4 | `[toolchain] default = { …, companions = { linux-headers = … } }` | 拒绝,消息指向第 1 行的写法 | +| 5 | 共享缺省视图 `/registry/subos/default/usr/include/{linux,asm}` | 链接到 linux-headers 5.11.1;同一 home 的缺省工具链 gcc 16.2.0 声明的是 6.18.64,即它构建时所用的版本 | +| 6 | musl 工具链(musl-gcc 15.1.0、16.1.0)自带的头文件 | 4.19.88(267096),没有升级的途径 | +| 7 | compat.libarchive 的条件 `cfg(all(linux, c-abi = "musl"))` | 本为 openkal 的图去掉 uapi 相关的功能,同时也去掉了原生 musl 上的这些功能,尽管第 6 行的头文件存在 | + +**原因。** + +- 第 1 行:应用平台的步骤在"无平台"时直接返回,本机与工程的 `[target.]` 覆盖表只在读到平台包之后才合并;读取 + 这些字段的步骤(层与工具的补全、链接的驱动、输入、封装与脚本)以"平台生效"为前提。只经这些字段读取的键在没有平台的 + 行上因此一并被丢弃,而清单的解析已经接受了它们。 +- 第 5 行:视图由多个工具链共享,而它们声明的版本不同(gcc 16.2.0 为 6.18.64,捆绑的 LLVM 为 5.11.1),所以视图的链接至多 + 对其中一个成立。视图由包的安装步骤写入,引擎的补全只在链接缺席时再写入 `linux`、`asm`、`asm-generic` 三个目录(载荷共 + 有十四个);视图的内容因此取决于 home 的历史。捆绑 LLVM 的载荷优先路径已经按工具链 + 的声明读取内核头文件(SPEC-006 §2.9 的两条记录规则);gcc 的 sysroot 路径读取的却是视图。同一层有两种来源。 + +**根因。** Linux 行上 `kernel-abi` 的供给者既不是数据,也没有可用的显式覆盖。缓存键按头文件集合(`targetHeaderSet`) +区分,所以不会混用对象;但同一份清单在两个 home 中所编译的头文件可以不同。 + +## 2. 概念与取舍 + +### 2.1 内核头文件属于哪一层 + +SPEC-006 附录 A 写明,原生行上系统自身的接口由基座供给,属于 `kernel-abi`: + +- `*-linux-gnu` 的基座供给 `kernel-abi` 与 `c-abi`; +- macOS 的 SDK、Windows 的 SDK、MinGW-w64 与 FreeBSD 的基座同样如此。 + +Linux 是唯一把内核接口与 C 库分开发布的系统:内核头文件是一个独立的包,版本与 C 库无关。因此它是 `mcpp:kernel-abi=linux` +的一个预制供给者。目标侧今天已经把传统栈的 `kernel-abi` 命名为三元组的操作系统名(`linux`),本设计为它补上供给者与版本。 +在 openkal 的栈上,这一层是 openkal,Linux 头文件不在栈中(§3.7)。 + +### 2.2 不采用的方案 + +| 方案 | 不采用的原因 | +|---|---| +| 工程级的 `system-headers` 键 | 它是 `kernel-abi` 的第二种拼写,在五层闭集之外开出第六条通道。提供者条目的 `system-headers` 回答的是另一件事:`kernel-abi` 被 openkal 替代时,资源编译这个工具步骤仍要读系统自身的头文件。它不进入程序的单元,保持原样 | +| 归入 `sysroot` | `sysroot` 是供给 `c-abi` 的整个基座(SPEC-002 §3.1 的 c-abi 独占律)。为了换内核头文件而替换整个基座,粒度错误,也没有包身份 | +| mcpp-index 的包,经依赖边可见 | glibc 自身的头文件包含 ``,`std` 模块的预编译也读它们。头文件集合是配置作用域(C:全图一个值,只从根读取),依赖边是使用需求作用域(U),同一程序中的不同包会对不同的版本编译。载荷已经在 xim 上,再包一层是重复的数据 | +| 由 xlings 为每种组合组装视图 | 组合由引擎的接线完成即可(§3.5),不需要第二套物理组合;按组合命名的视图还会带来缓存键与清理的新问题 | +| 在 `companions` 中加入 `linux-headers` | `companions` 是编译器的工具,属于宿主轴;内核头文件是目标的输入,属于目标轴(SPEC-004 §4.1) | +| 引擎数据中放一个缺省版本 | 今天没有一行由它回答:gcc 与捆绑的 LLVM 都声明版本,musl 工具链与交叉基座自带头文件。它会使结果取决于 mcpp 的版本而不是工具链,并需要随发布维护。没有回答者时拒绝并指出陈述的写法,比沉默地选一个版本更准确 | +| 版本下限规则(不低于 C 库的声明) | 没有数据支撑:索引中的 glibc 包不声明 `linux-headers`,glibc 上游支持对较旧的内核头文件编译。不成立的组合由编译本身报告 | + +### 2.3 行业对照 + +| 生态 | 表达 | 归属 | +|---|---|---| +| Buildroot | `BR2_KERNEL_HEADERS_*`,版本不得高于目标上运行的内核 | 工具链与 sysroot 的独立组件 | +| crosstool-NG | `CT_LINUX_VERSION` | 同上 | +| Yocto | `linux-libc-headers`、`LINUXLIBCVERSION` | 同上 | +| Debian / Fedora | `linux-libc-dev` / `kernel-headers` | 系统中的独立包 | +| Zig | 每个架构内置一份;目标带操作系统版本区间(`x86_64-linux.4.19...6.6-gnu.2.38`) | 目标属性 | +| Apple / Windows / Android | SDK 版本;另有部署目标(`-mmacosx-version-min`、`_WIN32_WINNT`、API level) | SDK 与 C 库一体 | +| Rust | `linux-raw-sys`(rustix 使用) | 普通依赖;Rust 不读 C 头文件,绑定是生成的代码 | + +从中可以读出四点: + +1. 在 Linux 上,内核头文件是 sysroot 中独立版本化的组件,与 C 库分开选择。 +2. 其他系统的内核接口与 C 库同属一个 SDK,可以选的只有 SDK 版本。 +3. Rust 能把它作为普通依赖,是因为没有 C 头文件经它被包含;C 与 C++ 的情形与此不同。 +4. 业界分两个轴:编译时可见的接口(头文件或 SDK 的版本),与运行时的下限(部署目标)。Linux 工具链的惯例只陈述前者, + 运行时的下限由运行时的 `ENOSYS` 探测承担。本设计只陈述前者。 + +### 2.4 设计准则与本方案的对应 + +| 视角 | 准则 | 本方案中的体现 | +|---|---|---| +| 底层与架构 | 机制在引擎,事实在数据;一层一个供给者 | 测量方式、位宽、载荷布局与接口清单都在系统行的数据中;引擎不出现系统名、层名的分支 | +| 收敛 | 一个概念一种拼写,一个机制一处实现 | 不新增清单键与原因标记;一个决定函数;回收只有 xlings 的实现;shell 命令行只有一个函数 | +| 通用性 | 规则对每一行、每个包成立 | 平台键在每一行生效;宿主事实、引用根是 xlings 的通用机制,包只陈述事实 | +| 跨平台 | 做不到的行给出原因与补救 | 内核接口不可分离的系统拒绝并指向 `sysroot`;本机与交叉同一条路径;能力是行的数据 | +| 稳定性 | 结果是陈述的函数,不是历史的函数 | 不读共享视图;派生状态在使用点核对;修复以结果而不是动作为准 | +| 兼容性 | 已发布的键、资源与载荷不变 | 包装修订而不改写资源;旧布局的载荷保持可用;旧客户端忽略新字段;清单以 mcpp 的下限保护 | +| 用户体验 | 一行陈述;做得更少不沉默 | `kernel-abi = "xim:linux-headers@<版本>"`;报告写出实现、版本、来源;每个拒绝带补救 | +| 简洁 | 删除多于增加 | 删去两处特判、视图写入、版本下限规则、引擎数据中的缺省版本、索引中按宿主架构的重复资源 | + +## 3. 设计 + +### 3.1 陈述 + +```toml +[target.x86_64-linux-gnu.layers] +kernel-abi = "xim:linux-headers@6.18.64" +``` + +`layers.<层>` 的值有四种形式,前两种是本设计增加的: + +| 形式 | 含义 | 来源 | +|---|---|---| +| `"xim:<名>@<版本>"` | 生态的载荷;拼写与规则同 `companions`(带版本的包) | prebuilt | +| `{ path = "<目录>" }` | 一个头文件目录;版本由测量回答,架构由陈述者负责;拼写同 `sysroot = { path = … }` | prebuilt | +| 包引用 | 依赖图中供给该层的包,SPEC-013 §7.2 不变 | graph | +| `false` | 数据与平台不为该层加入供给者,SPEC-013 §7.2 不变 | — | + +- **哪一层接受预制形式由数据决定。** 行的系统数据为某层给出测量方式(§3.4)时,该层在这一行上接受载荷形式与目录形式; + 否则拒绝,并指出该行上陈述这一层的键(§3.6)。今天只有 Linux 的 `kernel-abi` 有这份数据,这与 SPEC-002 §3.3 把内核 + 头文件列为可叠加层一致。引擎不按层名或系统名分支。 +- **层次。** 依次为工程、本机(`config.toml`)、平台,按键替换(SPEC-004 §2、SPEC-013 §6);都不陈述时为 §3.3 的缺省。 +- **与依赖图的供给者。** 依赖图中已有包供给 `kernel-abi` 时(openkal 的实现),再陈述一个预制供给者违反规则一,被拒绝。 +- **平台陈述载荷时。** 与平台陈述 `sysroot` 相同,在第二遍准备中决定(SPEC-013 §8)。 +- **选择器的写法。** 选择器按三元组的成分书写(`cfg(env = "gnu")`);以层键选择 `layers` 自身是循环的,与 + `manifest/platform-selector` 警告的情形同理。 + +### 3.2 平台键在每一行生效 + +- "选定了平台包"与"这一行有平台字段"是两件事,今天由同一个标志表示。没有平台的行有一份空的平台陈述;本机与工程的 + `[target.]` 覆盖表以同一合并规则(SPEC-013 §6)并入其中,层与工具的补全(SPEC-013 §7.2、§7.3)照常执行。 +- 读取字段的步骤读字段本身;只有含义来自平台包的步骤(平台包的身份、版本组、平台程序)以"选定了平台包"为前提。 +- `carrier` 的含义由平台的映像定义(SPEC-013 §11)。在没有平台的行上写出时,以警告报告该键与原因,不使构建失败,因为一份 + 本机配置可以同时服务有平台与没有平台的行。其余的键在每一行生效。 + +### 3.3 缺省 + +缺省为基座而决定:基座是预制的 C 库,而它的头文件包含系统的接口头文件(glibc 包含 ``)。因此凡系统行带有 +`kernel-abi` 数据、且 C 库来自预制基座的行,都作这一决定并接线;依赖图中没有包供给 `kernel-abi` 时,它同时是该层的供给者。 +依赖图中的包在系统的 C 库之上供给 `kernel-abi`(`*-linux-gnu` 上的 openkal 实现)时,该层的身份是那个包,这些头文件只是 +基座的组成部分。C 库来自依赖图的行(openkal 承载的 `*-linux-musl`)不作这一决定。 + +没有陈述时,依次取第一个回答者: + +1. **基座自带。** 包括 `sysroot` 的任一陈述形式、工具链自带的 sysroot(MinGW-w64、musl 工具链的 `<三元组>/`、按路径指名的 + 编译器的厂商树)与宿主的 `/`,以测量确认(§3.4)。 +2. **工具链的声明。** 基座为共享缺省视图,或为不带内核头文件的载荷布局(`xim:glibc@…`)时,取工具链载荷所声明的 + `linux-headers` 版本,按 SPEC-006 §2.9 的两条记录规则读取。它是工具链自身的运行时构建时所用的版本,也是 `companions` + 与今天的载荷优先路径所用的同一个读取函数。载荷带有目标架构的 `asm` 时回答(§3.9);旧布局的载荷只带本机架构,只 + 回答目标架构与本机相同的构建。载荷可以位于只读的系统层(Luban 的 `/xlings`);读取函数按层查找,接线不写入任何层。 + +两者都不回答时,构建在编译前被拒绝,并指出陈述的写法(§3.6)。 + +共享缺省视图不作为第 1 条的回答者:它的链接是 home 的历史(§1 第 5 行)。引擎不再向视图写入内核头文件;视图中已有的链接 +由包的安装步骤所有,保持原样,被接线遮蔽(§3.5)。视图可以属于只读的系统层,引擎写入它本来就不成立。 + +**对缺省构建的影响。** 在 x86_64-linux-gnu 上: + +- 以 gcc 16.2.0 构建时,所编译的是它声明的 6.18.64,而不是视图碰巧链接的版本; +- 以捆绑的 LLVM 构建时不变(5.11.1,即其声明); +- musl 工具链、交叉基座与陈述的基座不变(第 1 条)。 + +### 3.4 测量 + +内核头文件与 C 库用同一个探针步骤(SPEC-002 §2.4、SPEC-006 §3.9.3):以最终的编译选项预处理探针单元,单元以 +`__has_include` 包含系统行所指名的头文件。系统行的数据如下: + +```toml +[[platform.system]] +name = "linux" +uname = "Linux" +kernel-abi = { header = "linux/version.h", + version = ["LINUX_VERSION_MAJOR", "LINUX_VERSION_PATCHLEVEL", "LINUX_VERSION_SUBLEVEL"], + packed = { macro = "LINUX_VERSION_CODE", bits = [16, 8, 8] } } +``` + +- **版本的读取。** `version` 的各个宏给出版本的各段;它们缺席时按 `packed` 的位宽解码,每段在其位宽的最大值处饱和。位宽 + 是数据,引擎只实现解码。实测:6.18.64 的 397888 与其三个宏一致;5.11.1 只定义 `LINUX_VERSION_CODE`(330497)。 +- **与陈述的比较。** 载荷形式所陈述的版本与测得的版本按测量的精度比较(饱和的一段不参与),不符时拒绝。 +- **实现名。** 实现名为系统名 `linux`,与目标侧今天给传统栈的名字相同;`cfg(kernel-abi = "linux")` 与 + `requires = ["mcpp:kernel-abi=linux"]` 的含义不变,报告与核对另得到版本。 +- **没有 `kernel-abi` 数据的系统行。** 这表示该系统的内核接口不是独立于其基座的包(§3.1、§3.6)。 + +### 3.5 接线 + +- **接线。** 供给者的头文件目录以 `-isystem` 加在基座自身的头文件目录之前,作用于每个单元与 `std` 模块的预编译;clang 与 + gcc 都在 sysroot 的系统目录之前搜索 `-isystem`,并且按文件继续向后搜索。这是链接模型已有的系统头文件目录列表,不是新的 + 通道。 +- **解析的结果。** 载荷的十四个目录(`linux`、`asm`、`asm-generic`、`drm`、`scsi`、`sound` 等)以及 glibc 自身对它们的包含都 + 解析到供给者。供给者没有的文件解析到基座:`scsi/sg.h` 由 glibc 发布,仍取自基座。同一个文件不会从两个版本中读取。 +- **版本之间被删除的文件。** 基座带有另一版本的内核头文件时,供给者中已不存在的文件仍可见。实测 5.11.1 的 833 个文件中 + 有 17 个不在 6.18.64 中(`linux/reiserfs_fs.h`、`linux/raw.h` 等已移除的接口)。这与在发行版上升级内核头文件包的结果不同, + 作为性质写入规范;缺省路径上基座是不含内核头文件的载荷布局或被遮蔽的视图,前者没有这一情形。 +- **与已有规则的关系。** 这是 SPEC-002 §2.5 中 `c++-abi` 替换的同一条规则:另一个供给者供给某层时,基座的该层让位;基座 + 不被写入,也不被重新组装。链接模型中"目标不是 musl"与"基座缺少 `linux/limits.h`"两处判断由 §3.3 的顺序取代。 +- **宿主图。** 构建程序所属的宿主图按其自身的行以同样的方式决定(SPEC-013 §4)。 + +### 3.6 拒绝 + +| 条件 | 原因标记 | 补救 | +|---|---|---| +| 行的系统数据不为该层给出测量方式,却写了载荷形式或目录形式(macOS、Windows、FreeBSD、`*-openkal` 上的 `kernel-abi`;任一行上的其他层) | `target-base` | 该行上陈述这一层的键:`sysroot`(`macosx@<版本>`、`msvc@<版本>`、基座包) | +| 载荷中没有目标架构的 `asm`(旧布局的载荷用于交叉构建,或目标架构未发布) | `target-base` | 带该架构的版本,或 `{ path = "<目标架构的头文件>" }` | +| 没有陈述,且 §3.3 没有回答者 | `target-base` | `layers.kernel-abi` 的写法,或带头文件的基座 | +| 测量与陈述不符(头文件缺席、版本不同) | `target-base` | 消息写出测得的实现与版本 | +| 载荷引用不带版本 | 清单错误 | 消息给出示例,与 `companions` 的消息相同 | +| 需要 `mcpp:kernel-abi=linux` 的包,处在 `kernel-abi` 为 openkal 的行上 | `layer-requirement`(已实现) | 原生的提供者(Linux 或 Windows 宿主上的 `musl-gcc`),或 openkal 的接口 | +| 在 openkal 的行上以 Linux 头文件替换 `kernel-abi` | 规则一的已有拒绝;`layer-requirement`,由 openkal-musl 已有的 `requires` 触发(§3.7) | 同上 | + +不新增原因标记。`target-base` 今天的含义是"目标的基座不能服务这次构建";内核头文件是基座旁的组成部分,docs/50 中它的说明 +扩充为包含前四种情形。 + +### 3.7 openkal + +- **层的身份。** openkal 承载的行上,`kernel-abi` 由依赖图中的实现包供给。再陈述一个预制供给者违反规则一;openkal-musl + 自身陈述 `requires = ["mcpp:kernel-abi=openkal"]`(已发布的事实,0.30.0 实测),替换该层违反规则二。两者都在编译前拒绝, + 不需要 openkal 家族的任何改动。 +- **与 openkal 能力模型的关系。** openkal 规范条款 6.1 规定接口的存在是链接期的事实,运行时才报告不支持被视为缺陷。 + Linux 的 uapi 不是 openkal 的接口;在这些行上提供它,会使"不存在"退回为运行时的 `ENOSYS`(openkal-musl 对没有对应 + 操作的系统调用号如此回答)。拒绝与该模型一致。 +- **不变的部分。** openkal 在 Windows 上的提供者条目中的 `system-headers` 不变(§2.2):它只由资源编译读取,不进入程序 + 的单元。 + +### 3.8 报告与缓存 + +- **报告。** 目标侧报告的 `kernel-abi` 行写出实现、测得的版本、供给者与来源,例如 + `linux 6.18.64 (xim:linux-headers@6.18.64, …)`。陈述的来源用已有的层次名;缺省的来源为基座或工具链的声明。SPEC-013 的 + `fields` 对每一行给出 `layers.kernel-abi`。 +- **缓存。** `targetHeaderSet` 按存储的相对路径记录头文件目录,供给者的身份因此进入缓存键。换版本会使全图重新编译,包括 + `std` 模块;同一组合在各工程之间经全局缓存共享。不需要迁移:每个版本的 mcpp 本来就使缓存键改变。 + +### 3.9 架构:一份载荷,各架构的 `asm` + +- **事实。** `make headers_install` 的产物在各架构之间只有 `asm/` 不同;其余十三个目录与架构无关。内核源码自身、Zig 的 + 内置头文件都按"公共部分加每架构一个目录"组织。今天的索引按宿主架构发布两个资源(x86_64、aarch64),各带宿主的 `asm`, + 这把目标的数据当作了宿主的程序,交叉构建因此没有载荷可用。 +- **布局。** 一个与架构无关的资源: + + ``` + include/ 与架构无关的目录;asm 由安装步骤链接到本机架构 + arch/<架构>/include/asm/ 每个已发布架构一份,<架构> 用 xpkg 的架构名(x86_64、aarch64、riscv64、loongarch64) + ``` + + `include/asm` 的链接使读取 `include/` 的已有消费者(共享视图、已发布的 mcpp)不变。 +- **在 xpkg 中的表达。** 版本条目写单一的 URL 与校验和,不带架构键,按 xpkg-manifest-v1 §5 对每个架构都适用;`archs` 列出 + 资源所带的架构。架构是 xpkg 资源解析的维度,用于随宿主不同的程序;与架构无关的数据不使用它。 +- **已发布的版本。** 6.18.64 的新布局以 `revision = 1` 与新的资源名发布(xpkg-manifest-v1 §5.1.1);`floor` 不提高, + 已安装的旧载荷保持可用(§5.1.2)。因此引擎不能假定布局,而是读取它:载荷带有 `arch/<目标架构>/include` 时把它排在 + `include` 之前,这一布局写在系统行的数据中;没有该目录时载荷只服务本机架构。本机与交叉走同一条路径,引擎不比较架构。 +- **不采用:`xlings install --host`。** `xlings download --host ` 已存在,把它扩展到安装需要存储路径带上架构,并 + 波及回收与体检;它解决的是"安装另一架构的程序",而这里要的是数据。 + +### 3.10 一条规则,四处缺席 + +| 位置 | 派生的状态 | 所依据的事实 | 失效的方式 | 处置 | +|---|---|---|---|---| +| 共享视图的 `usr/include/linux` | 安装时写入的链接 | 哪个包先安装 | 多个工具链声明不同版本,视图至多对一个成立 | mcpp 不读视图,由陈述或工具链的声明决定(§3.3) | +| 存储回收 | 版本库与工作区的登记 | 谁在引用载荷 | 登记不含视图的链接目标、依赖闭包与其他程序的引用 | §3.11 | +| 体检的修复 | "已移除""已修复"的报告 | 目录是否已清空 | 报告依据的是动作的发起而不是结果 | §3.12 | +| 宿主驱动的链接包 | 以安装时的驱动版本命名的链接 | 宿主当前加载的驱动 | 宿主升级后链接悬空,使用时无人核对 | §3.13 | + +xlings 的规则"派生的状态可以由任何流程重建"与"读不到不等于没有引用"已经陈述了这条规则的两半;本设计补上"使用点核对", +并把它写入 xlings 的规范。 + +### 3.11 存储的引用(xlings,openxlings/xlings#712) + +- **实测。** `self clean --dry-run` 的引用集合只取版本库与各 SubOS 工作区的 `active`、`installed`。它列出仍被 + `subos/default/usr/include/*` 链接的载荷;对 mcpp 的私有 home 试运行,列出 154 个包(约 16 GB),其中是各工程在用的 + 基座、库与平台包。mcpp 按存储路径接线,回收之后的下一次构建即失败。 +- **引用集合。** 以下四部分的并集,任何一部分读不到时拒绝(已有的二值规则): + 1. 工作区的登记(不变); + 2. 各视图中的链接所解析到的载荷; + 3. 上述载荷的安装记录所声明依赖的闭包(工具链声明的 `linux-headers`、`binutils`、`glibc`); + 4. 根:`/data/roots/<所有者>/` 下指向 `xpkgs/<存储名>/<版本>` 的链接,由其他程序登记。这是 Nix 的 gcroots 的 + 做法。 +- **根的形态。** 一个根是一个符号链接,名为 `<存储名>@<版本>`;它的修改时间是最后一次使用。悬空的根被忽略并清除。 + 登记与更新是创建或触碰一个链接,不需要锁,也不需要 xlings 的进程。 +- **mcpp 一侧。** mcpp 为每次构建所接线或读取的载荷登记根,并在使用时更新其时间;`mcpp cache gc` 按已有的未使用期限删除 + 过期的根,随后调用 xlings 的回收。回收只有一个实现,期限的策略属于所有者。 +- **已有的 home。** 升级前的 home 中没有根。mcpp 把 home 的格式向前移动时,为现存的每个载荷登记一个根,时间取当时; + 这一步执行一次,幂等,有记录。它与登记逻辑在同一个版本中发布。 +- **不采用。** home 声明所有者而 xlings 拒绝(mcpp 需要第二个回收的实现);把载荷登记进工作区(工作区的含义是 SubOS + 激活了什么);由 xlings 读取工程的锁(工程的位置不可枚举,格式属于 mcpp)。 +- **Luban。** 系统层(`/xlings`)的载荷由已有的归属判断保护;根与视图的链接按层读取,用户层的根可以引用系统层的载荷。 + +### 3.12 移除的归属与修复的核对(xlings,openxlings/xlings#711) + +- **实测。** 带有清扫痕迹而不在版本库中的载荷,`self doctor --fix` 报告已修复而磁盘不变:移除只运行包的钩子,钩子经 + 版本库回收目录,没有记录时什么也不做;随后的安装因目录非空而判定"已安装"。每次运行重复同样的循环并以 1 退出。 +- **规则。** 安装目录是安装器创建的,它的删除也属于安装器:钩子运行之后,安装器删除目录,再报告"已移除"。修复在每个 + 动作之后重新检测;发现仍在时报告失败与原因,不报告已修复。 +- **测试。** 已有的测试以登记过的包构造痕迹,覆盖不到这一形态;新增的用例构造未登记的载荷。 + +### 3.13 依据宿主事实的配置(xlings、libxpkg 与索引,openxlings/xlings#727) + +- **实测。** 宿主驱动的链接包以安装时的驱动版本命名链接并记录该版本;宿主驱动升级后链接悬空,包仍为"已安装",使用点 + 不核对,程序退回到另一个实现。 +- **陈述。** 包在包表中静态地陈述其配置所依据的宿主文件(该例为宿主当前加载的驱动的版本文件)。它是数据而不是钩子: + 包表静态可求值是 xpkg v1 的原则,核对不应运行包的代码。 +- **机制。** xlings 在配置时记录这些文件内容的摘要;在激活、进入 SubOS 与体检时比较;不同则重新运行配置,不能重新配置 + 时报告。比较不放在每一次经垫片的启动上。链接由配置步骤按当前事实以通配生成,不依赖文件名的列表。 +- **兼容。** 较旧的客户端忽略该字段,行为与今天相同。 +- **范围。** 同一族的各个包(宿主驱动的链接、其 WSL 与 Vulkan 的变体)用同一机制。 + +### 3.14 生成的源文件的来源(mcpp,mcpp-community/mcpp#1004) + +- **问题。** 规则把编写的源文件变换为被编译的单元时,构建数据库只把编写的文件列在该步骤的输入中;消费者无法区分"编辑 + 它即改变该单元的文件"与"步骤恰好读取的文件"。 +- **采纳。** `mcpp::action` 增加 `origin`(指名它的一个输入);构建数据库的生成条目增加 `origin`(S1 的增量字段)。 + 只有步骤陈述时才写出,引擎不从输入推断。来源文件同时被列为该集合的单元时,已有的重复提供者错误说明这一关系。 + 生成单元的角色在步骤陈述了它所提供的模块时由陈述给出。 +- **不采纳 `line-mapping`。** 生成文件中的 `#line` 指令本身是事实,由消费者读取;另作陈述会与文件不一致。 + +### 3.15 加入命名空间的参数(xlings,openxlings/xlings#732) + +修复已经合入:监督者为 root 时以命名空间所有者的身份启动网络辅助程序。同样的拼接写在会话与工作进程两处;它收敛为 +提供者中的一个函数,与已有的参数函数并列,并在以 root 运行的测试行中增加 `net=nat` 的用例。 + +### 3.16 经 shell 运行一行命令(libxpkg,openxlings/libxpkg#52) + +- **实测。** Windows 上 `os.iorun` 把重定向拼在命令行之后交给 `cmd /c`;命令行以引号开头且不止一对引号时,`cmd` 去掉 + 首尾两个引号,重定向落入引号之内,读回的输出为空。索引中有三个包各自绕过。 +- **根因有两层。** 一是 `cmd` 的去引号规则未被固定;二是输出的读取依赖对调用者的命令行做字符串拼接,调用者自带重定向时 + 同样出错。 +- **规则。** 经 shell 运行一行命令只有一个函数:Windows 上为 `cmd /d /s /c "<整行>"`(`/s` 使去引号规则确定),其他系统 + 为 `sh -c`。输出以管道读取,不拼接重定向。`os.exec`、`os.iorun` 与其余经 `std::system` 的各处都调用它。 +- **兼容。** 包中已有的绕过写法在修复之后仍然成立;它们在索引所支持的最低客户端包含该修复之前保留。 + +### 3.17 行的能力:`kernel-abi` 的接口(mcpp,mcpp-community/mcpp#1005 第 1 项) + +- **问题。** 一行能否启动程序、有没有文件与终端,今天只有运行才知道;工程因此在 CI 中按行手写清单,实现获得能力之后 + 清单即过时。 +- **已有的一半。** openkal 的实现包以 `[kernel-abi] provides-interfaces` 陈述它提供的接口;包以 `requires-interfaces` + 陈述所用的接口,缺少时以 `interface-not-provided` 拒绝;运行器已经把所提供的接口交给被运行的程序。openkal 规范 + 条款 6.1 规定接口的存在是构建期的事实。缺的是传统的行的陈述,以及让清单与工具读到它的出口。 +- **数据。** 系统行的 `kernel-abi` 数据(§3.4)增加该系统所提供的接口。接口名沿用已有的清单(`openkal.fs`、 + `openkal.process` 等):它是生态中对平台接口唯一有规范、有版本的命名,mcpp 把它当作不透明的名字。C 库限定了能力的 + 行(没有进程的行)由其系统行如实陈述。 +- **出口。** + 1. 谓词 `cfg(interface = "<接口名>")`,用于源文件、标志与测试的条件; + 2. 目标侧的报告与 SPEC-013 的 `fields` 对每一行给出 `layers.kernel-abi.interfaces`,测试程序经已有的环境变量读到同一 + 清单。 +- **限制。** 接口在目标侧决定之后才可知,它在依赖解析之后。以该谓词选择依赖、平台或 `layers` 是循环的;这样写时报告, + 与 `manifest/platform-selector` 的情形同理,不沉默地取假。 +- **效果。** 一个实现获得某个接口之后,各工程的测试不经修改即覆盖它;mcpp-index 中按实现名书写的条件可以按接口书写。 + +### 3.18 平台系列与构建程序的插件(openkal-platform,mcpp#1005 第 2 项) + +- **实测。** 平台的版本组(SPEC-013 §7.5)列出家族的十四个成员,不含构建程序所用的插件包;平台在自己的构建依赖中以 + 确切版本指名它。工程也指名该插件时,平台的修订发布即与工程的版本冲突。 +- **处置。** 版本组加入该插件包;SPEC-013 §15.1 已规定构建程序的版本条目。工程以兼容范围指名或不指名版本,由版本组 + 决定。这是平台包的数据,mcpp 不变;它是否对宿主图的请求成立,在实施时测定(§8)。 + +### 3.19 行与运行器(mcpp、索引、平台包,mcpp#1005 第 3、4 项) + +行的层级是测量的结果:CI 构建并运行为 `verified`,构建并链接为 `preview`,否则保持 `planned` 并写出测得的原因。 + +| 行 | 今天 | 需要的事实 | 归属 | +|---|---|---|---| +| `riscv64-linux-musl` | 已登记,有提供者条目 | 索引中的工具链载荷在两种宿主上可用;用户态模拟的运行器 | mcpp 数据、索引 | +| `i686-linux-gnu` | 已登记,索引中没有载荷 | 该架构的基座载荷与编译器运行时 | 索引、mcpp 数据 | +| `x86_64-macos` | 已登记,有提供者条目 | 在该架构的宿主上的 CI | mcpp 数据与 CI | +| `wasm32-wasi` | 没有行 | 行的定义、基座载荷、C 库的识别、运行器 | mcpp 数据、索引 | +| iOS 模拟器的两行 | `verified`,没有运行器 | 提供者条目的 `runner`;它启动设备并在构建树之外留下状态,按 SPEC-016 以 `enabled = false` 陈述,由工程开启 | mcpp 数据 | +| 固件之上的 openkal 行 | 没有行 | 平台包定义该行(`[[platform.define]]`) | openkal 家族 | + +每一行是数据与包,彼此独立,也不依赖本方案的其余部分;它们并行进行,随所在仓库的同一个拉取请求合入。 + +### 3.20 openkal 实现的缺口(openkal 家族,mcpp#1005 第 6 项) + +- 环境的条目上限(各实现中的固定常量):继承更大环境的进程丢失其余条目,这是沉默的截断;改为按需增长,或在超出时 + 报告。 +- 固件与 DOS 的实现中同步地启动程序:实现之后它们提供 `openkal.process`,§3.17 使各工程的测试随之覆盖。 +- **映像在 i686 上启动映像(mcpplibs/openkal-image#46)。** okrun 0.7.2 的 `linux-i686`(openkal-platform 0.31.2 的载体)上, + 一个 i386 映像以 `fork` 与 `execve` 启动另一个映像时,复制出的进程读出映像的头与 OPENKAL 注记、映射并释放文件、读取 + `/proc/self` 之后以 127 结束,不写任何消息;同一路径在 x86_64 上进入映像,i386 映像启动宿主程序也正常。两点都是缺陷: + - **结果。** 依条款 6.1,`openkal.process` 是该行陈述的接口,运行时不能以失败代替它; + - **沉默。** 复制出的进程在启动失败时没有写出原因,与 `kal_process_spawn` 拒绝时按原因返回(`kal_err_not_program` 等) + 不一致。 + + 修复按根因进行,在 i686 的宿主上复现,而不是只在 x86_64 上推断:找到复制出的进程中放弃启动的那一步(定位装载器、 + 解析映像名,或 32 位上的长度与缓冲),修复它;复制出的进程启动失败时,把原因写到标准错误,再以 127 结束,与宿主程序 + 启动失败的约定相同。`examples/starts` 加入 i686 的运行行,作为该行 `openkal.process` 的回归测试。修复随 openkal-image + 的补丁发布与平台版本组的修订进入本轮(K5)。 +- 它们随家族的一次发布与版本组的修订进入索引;mcpp 内置的缺省平台版本随之更新。 + +## 4. 跨平台 + +| 行 | `kernel-abi` 的供给者 | 写 `layers.kernel-abi` 的结果 | +|---|---|---| +| `*-linux-gnu`,本机 | 工具链的声明(共享视图)或陈述的基座 | 生效 | +| `*-linux-gnu`,交叉(如 `xim:aarch64-linux-gnu-sysroot`) | 基座 | 生效;载荷须带目标架构(§3.9) | +| 原生 `*-linux-musl`(`musl-gcc`) | 工具链自带(4.19.88) | 生效,接线相同 | +| openkal 承载的 `*-linux-musl`、`*-macos-musl`、`*-freebsd-musl` | openkal 的实现 | 拒绝(规则一、规则二);不接线 Linux 头文件 | +| `*-linux-gnu` 上带 openkal 实现的图 | openkal 的实现;Linux 头文件仍是基座的组成部分 | 拒绝(规则一);缺省照常接线 | +| `*-openkal` | 加载器(openkal) | 拒绝(系统数据不给出测量方式) | +| macOS、Windows(msvc 与 gnu)、FreeBSD | 与 C 库同属 SDK 或基座 | 拒绝,指向 `sysroot` | + +## 5. 兼容性 + +- **没有新的清单键。** `[target.] layers` 自 2026.10.27.1 起存在。 +- **行为变化**(写入 CHANGELOG): + 1. 平台键在没有平台的行上生效,此前被丢弃; + 2. 在共享视图上以 gcc 构建时,所编译的是工具链声明的内核头文件; + 3. compat.libarchive 在原生 musl 上恢复 Linux 相关的功能(索引侧)。 +- **较旧的 mcpp。** 读取带载荷形式的清单时,在没有平台的行上忽略该键(与此前相同);在有平台的行上,它把该值当作索引中 + 的包去解析而失败。使用载荷形式的清单因此应当以 `[package] mcpp = ">="` 写出 mcpp 的下限。 +- **索引。** `latest` 的移动只影响不带版本的新请求;已激活的版本保持,钉住版本的包(捆绑的 LLVM 钉 5.11.1)与 mcpp + 不变。已发布的资源与校验和不变;6.18.64 的旧载荷保持可用。 +- **较旧的 xlings 客户端。** 忽略包表中的宿主事实字段与 `revision` 之外的新内容;新布局的资源在它们上同样安装,因为 + `include/` 的形状不变。 +- **较旧的 home。** 没有根的 mcpp home 在升级时登记现存的载荷(§3.11);未升级的 mcpp 的 home 上,回收的行为与今天相同。 +- **构建数据库。** `origin` 是增量字段,符合 S1 的消费者忽略未知字段。 +- **谓词 `interface`。** 较旧的 mcpp 把它报告为未知的谓词;使用它的清单同样写出 mcpp 的下限。 + +## 6. 改动面 + +每个仓库一个拉取请求。 + +| 仓库 | 内容 | 条款 | +|---|---|---| +| libxpkg | shell 命令行的单一函数与管道读取;包表的宿主事实字段 | §3.16、§3.13 | +| xlings | 回收的引用集合与根;移除的归属与修复的核对;宿主事实的记录与比较;加入命名空间的参数;规范、文档、测试;libxpkg 的版本 | §3.11、§3.12、§3.13、§3.15 | +| xim-pkgindex 与资源仓库 | `linux-headers` 的新布局(6.18.64 `revision = 1`、7.3.5)与 `latest`;`gcc`、`binutils` 的 `latest`;宿主驱动链接包的陈述;§3.19 各行的载荷;xlings 与 mcpp 的版本 | §3.9、§3.13、§3.19 | +| openkal 家族 | 版本组加入插件包;实现的缺口;固件之上的行;一次家族发布 | §3.18、§3.19、§3.20 | +| mcpp | 见下 | §3.1 至 §3.8、§3.11、§3.14、§3.17、§3.19 | +| mcpp-index | compat.libarchive 的条件改为 `cfg(all(linux, kernel-abi = "openkal"))`;已发布的 mcpp 已把传统栈的 `kernel-abi` 命名为 `linux`,因此不依赖新的 mcpp | §1 第 7 行 | +| mcpp-language-server | S1 的 `origin` 字段文本 | §3.14 | + +**mcpp 的各项:** + +- `modules/manifest`:`layers.<层>` 的载荷形式与目录形式;谓词 `interface`; +- `modules/toolchain-model`:系统行的 `kernel-abi` 数据(测量、位宽、载荷布局、接口)、版本解码、`builtin.toml` 的各系统行、 + §3.19 的行与运行器、缺省平台的版本; +- `src/build/prepare/platform.cpp`:每一行都有平台陈述;"选定了平台包"与"有平台字段"分为两个事实,链接规划、标志与后端中 + 读取字段的各处改读字段本身; +- `src/build/prepare/base.cpp` 与探针:一个函数按 §3.1 的陈述与 §3.3 的顺序决定供给者,随后测量与 §3.6 的拒绝;载荷优先 + 路径与 sysroot 路径都调用它; +- 链接模型:每种模式都在基座之前接线,删除"目标不是 musl"与"基座缺少 `linux/limits.h`"两处判断; +- 基座补全:不再写入内核头文件。glibc 的补全按 SPEC-006 §2.2.1 对本生态所有的视图保留,它属于 `c-abi`; +- 目标侧模型:`kernel-abi` 带上版本、来源与接口,并写入报告与 `fields`; +- 存储:根的登记、home 格式的一步、`mcpp cache gc` 调用 xlings 的回收;捆绑的 xlings 版本; +- 构建程序的接口与构建数据库:`mcpp::action` 的 `origin`、生成条目的字段、角色与重复提供者的消息; +- 规范:SPEC-002、SPEC-004、SPEC-005、SPEC-006、SPEC-013、SPEC-016;用法:docs/04、docs/09、docs/20、docs/22、docs/50 的 + 中英文;CHANGELOG。 + +## 7. 验证 + +- **单元测试。** + - `modules/toolchain-model/tests`:版本解码(各段的宏优先;397888 解码为 6.18.64;一段在其位宽处饱和)、与陈述按精度 + 比较、系统行的解析、§3.3 的顺序(写成纯函数); + - `modules/manifest/tests`:值的四种形式与拒绝。 +- **e2e(一个脚本,`# requires: linux`):** + 1. x86_64-linux-gnu 上没有平台,陈述载荷形式:单元测得 397888,报告写出该行,`--strict` 下不再无声; + 2. 缺省:视图链接 5.11.1 时,以 gcc 16.2.0 构建测得 6.18.64,以捆绑的 LLVM 构建测得 5.11.1; + 3. 目录形式; + 4. aarch64-linux-gnu 上:新布局的载荷生效(以目标编译器测得版本,`` 给出该架构的调用号);旧布局的载荷 + `target-base`; + 5. 内核接口不可分离的行上的载荷形式,以及 Linux 行上 `layers.c-abi` 的载荷形式:`target-base`; + 6. 没有平台的行上,`[target..link] flags` 到达链接命令,`carrier` 给出警告; + 7. 基座带有另一版本时(宿主的 `/` 或带头文件的目录基座),陈述的版本被测得,`` 仍可包含; + 8. openkal 承载的 x86_64-linux-musl 上的载荷形式:规则一或 `layer-requirement`,以实测的先后为准。 +- **金丝雀。** 金丝雀矩阵的各行预期不变;任何一格不同即为失败。 +- **xlings。** 回收:视图链接的目标、依赖闭包与登记的根各一例不被列出,根目录读不到时拒绝;修复:未登记的清扫载荷一次 + 收敛;宿主事实:记录的值改变后在使用点重新配置;root 下的 `net=nat`。 +- **索引。** 新布局的资源在两个架构的宿主上安装,`include/asm` 指向本机架构;`latest` 移动之后索引的 CI 全部通过。 +- **生态。** 在全新的 home 中以 gcc、捆绑的 LLVM 与 musl 工具链各构建一次;mcpp 的私有 home 上回收的试运行不列出任何 + 在用的载荷;Luban 的系统层只读时构建不写入视图。 + +## 8. 实施时测定 + +1. 内核接口不可分离的行(§3.6 第一行)是否在获取 SDK 或工具链之前就被拒绝;第 5 个 e2e 用例取在本机上无需获取即可拒绝 + 的一行。 +2. 平台字段的每一个读取者(链接规划、标志、后端、执行、打包)逐一核对,列出在没有平台的行上改为生效的键;规范的表以 + 核对的结果为准。 +3. openkal 的行上陈述预制供给者时,规则一与规则二哪一个先报告;消息以先报告者为准写入规范。 +4. `*-linux-gnu` 上带 openkal 实现的图:基座的头文件决定与该层的身份分开之后,openkal 家族的测试是否不变。 +5. mcpp 今天以何种方式安装载荷而不进入工作区的登记;根的登记点取在读取函数(`companion_dir` 一类)还是安装点。 +6. 平台的版本组中的插件包条目是否约束宿主图中工程自身的请求(§3.18)。 +7. §3.19 的每一行:载荷是否存在、是否在 CI 的宿主上构建并运行;结果决定其层级。 + +## 9. 实施计划与任务依赖 + +### 9.1 任务 + +| 编号 | 仓库 | 任务 | 依赖 | 完成的判据 | +|---|---|---|---|---| +| L1 | libxpkg | shell 命令行的单一函数,管道读取 | — | 带引号且含空格的程序路径读回输出;三个系统的单元测试 | +| L2 | libxpkg | 包表的宿主事实字段 | — | 字段被解析并给出;缺席时与今天相同 | +| L3 | libxpkg | 发布 | L1、L2 | 版本进入 mcpp-index | +| X1 | xlings | 引用集合:视图链接、依赖闭包、根 | — | §7 的回收用例;根目录读不到时拒绝 | +| X2 | xlings | 安装器删除目录;修复后重新检测 | — | 未登记的清扫载荷一次收敛 | +| X3 | xlings | 宿主事实的记录、比较与重新配置 | L3 | 记录的值改变后在激活与体检时重新配置 | +| X4 | xlings | 加入命名空间的参数函数;root 下的 `net=nat` 用例 | — | 两处调用同一函数;用例在 root 的测试行通过 | +| X5 | xlings | 规范、文档、发布 | X1 至 X4 | 发布与 GitCode 的资源 | +| I1 | 资源仓库 | 新布局的构建脚本;6.18.64 修订与 7.3.5 的资源 | — | 两处发布,校验和记录 | +| I2 | xim-pkgindex | `linux-headers` 的条目、安装步骤的链接、`latest` | I1 | 两个架构的宿主上安装,`include/asm` 指向本机 | +| I3 | xim-pkgindex | `gcc`、`binutils` 的 `latest` | — | 索引的 CI 通过,含最低客户端 | +| I4 | xim-pkgindex | 宿主驱动链接包陈述其事实,按当前事实生成链接 | L2 | 旧客户端行为不变;新客户端在 X5 之后核对 | +| I5 | xim-pkgindex | §3.19 各行的载荷 | — | 每个载荷在其宿主上安装 | +| I6 | xim-pkgindex | xlings 的版本 | X5 | 索引指向新版本 | +| K1 | openkal-platform | 版本组加入插件包 | — | 工程不指名插件版本时构建通过 | +| K2 | openkal 各实现 | 环境的上限;固件与 DOS 的程序启动 | — | 各实现的 CTS | +| K3 | openkal-platform | 固件之上的行 | K2 | 该行构建并在模拟器中运行 | +| K5 | openkal-image | i686 上映像启动映像(openkal-image#46):复现、根因修复、失败时写出原因、i686 的 `examples/starts` | — | i686-openkal 上 `"%COMSPEC%" /c exit 3` 得 3 | +| K4 | openkal 家族 | 家族发布,进入 mcpp-index | K1 至 K3、K5 | 版本组的新版本可解析 | +| M1 | mcpp | 平台键在每一行生效 | — | §7 e2e 第 1、6 例 | +| M2 | mcpp | 系统行的数据、解码、接口 | — | 单元测试 | +| M3 | mcpp | `layers` 的两种形式、决定函数、测量、拒绝 | M1、M2 | §7 e2e 第 1 至 5、7、8 例 | +| M4 | mcpp | 接线,删除两处判断,停止写入视图 | M3 | 缺省构建在三种工具链上通过;金丝雀不变 | +| M5 | mcpp | 新布局的读取与交叉 | M4、I2 | §7 e2e 第 4 例 | +| M6 | mcpp | 谓词 `interface` 与查询 | M2 | 单元测试;报告与 `fields` 给出接口 | +| M7 | mcpp | 根的登记、home 格式的一步、`cache gc` | X5、I6 | 私有 home 上回收的试运行不列出在用的载荷 | +| M8 | mcpp | `origin`:构建程序的接口与构建数据库 | — | 单元测试与一个 e2e | +| M9 | mcpp | §3.19 的行与运行器 | I5、K4 | 每一行按测量得到其层级 | +| M10 | mcpp | 规范、文档、CHANGELOG、缺省平台的版本、发布 | M1 至 M9、K4 | 全部检查通过;发布与 GitCode 的资源 | +| S1 | mcpp-language-server | S1 的字段文本 | M8 | 文本与 mcpp 的输出一致 | +| D1 | mcpp-index | compat.libarchive 的条件 | — | 原生 musl 与 openkal 两种行的 CI | +| I7 | xim-pkgindex | mcpp 的版本 | M10 | 索引指向新版本 | +| E1 | 生态 | §7 的生态验证;各 issue 的评论与关闭 | I7 | 全新 home 上的各项验证通过 | + +### 9.2 依赖关系 + +```mermaid +graph LR + L1 --> L3 + L2 --> L3 + L3 --> X3 + L2 --> I4 + X1 --> X5 + X2 --> X5 + X3 --> X5 + X4 --> X5 + X5 --> I6 + I1 --> I2 + I6 --> M7 + I2 --> M5 + M1 --> M3 + M2 --> M3 + M2 --> M6 + M3 --> M4 + M4 --> M5 + K1 --> K4 + K2 --> K3 + K3 --> K4 + K5 --> K4 + I5 --> M9 + K4 --> M9 + M5 --> M10 + M6 --> M10 + M7 --> M10 + M8 --> M10 + M9 --> M10 + M8 --> S1 + M10 --> I7 + I7 --> E1 +``` + +### 9.3 顺序与并行 + +- **关键路径。** L1、L2 → L3 → X3 → X5 → I6 → M7 → M10 → I7 → E1。libxpkg 与 xlings 的发布决定 mcpp 的发布能否开始收尾。 +- **第一批,互不依赖。** L1、L2、X1、X2、X4、I1、I3、I5、K1、K2、K5、M1、M2、M8、D1。其中 mcpp 的 M1、M2、M3、M4、M6、M8 + 在本地完成,不等待任何发布。 +- **等待 CI 的时间。** 一个仓库的检查运行时,进行另一个仓库的任务;mcpp 的检查在较大的检查点推送,而不是每次提交。 +- **合入的顺序。** libxpkg;xlings 与 openkal 家族(互不依赖);xim-pkgindex 的 I2 至 I6;mcpp;xim-pkgindex 的 I7; + mcpp-index 的 D1 与 mcpp-language-server 的 S1 可以在各自就绪时合入。 +- **xim-pkgindex 的一个拉取请求。** I2 至 I6 在一个拉取请求中;I7 是 mcpp 发布之后的版本更新,按发布流程是另一次变更。 +- **§3.19 的行。** 测量未通过的行保持原层级并写出原因,不阻塞其余任务。 + +## 10. 实施中的测定与修订(v6) + +以下是实施中测得、并已据此修订实现的事实;前文条款按此理解。 + +1. **载荷布局(§3.9)。** "各架构之间只有 `asm/` 不同"被资源构建的检查推翻。6.18.64 上,除 `asm/` 外,`linux/a.out.h` + 只由 x86 安装,`linux/kvm_para.h` 在 riscv 上不安装。布局因此为:`include/` 只放各架构逐字节相同、且位于 `asm/` 之外的 + 文件;`arch/<架构>/include/` 放该架构的其余文件,`asm/` 整体属于它。构建脚本每次都比较,而不是假定。安装步骤把本机 + 架构的 `asm/` 与各架构独有的头文件链接进 `include/`。 +2. **已发布版本的修订(§3.9)。** 索引的保护规则要求更正的资源带 `<版本>-r<修订>` 的标签与资源名,并保持版本条目的形状。 + 因此 6.18.64 的修订 1 是资源 `6.18.64-r1`(`linux-headers-6.18.64-r1.tar.gz`),各宿主架构的条目指向同一个资源。7.3.5 + 是新版本,写单一的 URL。 +3. **接口的陈述位置(§3.17)。** `interfaces` 是系统行的键,与测量用的 `kernel-abi` 表分开:macOS、Windows、FreeBSD 陈述 + 接口,但不接受预制的 `kernel-abi`。iOS 与 Emscripten 不作为系统加入系统表,因为系统表决定 `mcpp pack --systems all` + 的范围与多系统单文件的选择。它们的行各自陈述 `interfaces`,先于系统读取,与 `object-format`、后缀"行先于系统"的 + 读法相同。接口清单是供给者的陈述,测试仍然是对它的验证(openkal-image#46 是一行声称 `openkal.process` 而实际失败的 + 反例)。 +4. **谓词已存在(§3.17)。** `cfg(interface = …)` 自 2026.11.13.1 起对依赖图的供给者成立。本轮补上的是系统与行的陈述, + 以及 `mcpp why toolchain` 的 `layers[].interfaces` 与 `layers[].version`;机器可读的查询在这里,而不在 SPEC-013 的 + `fields`(无平台的行上它为 `null`)。 +5. **目录形式(§3.1)。** `{ path }` 指向不带 `mcpp.toml` 的头文件目录时是预制形式;带清单时是依赖图中的包,与基座包的 + 规则相同。 +6. **缺省的回答者(§3.3)。** 基座是否自带由链接模型的模式判断(载荷布局即 `PayloadFirst`);共享视图是 SubOS 的根之下的 + 探测 sysroot,工具链自己载荷中的 sysroot(`musl-gcc` 的 `<三元组>/`)不是视图。工具链的回答只取其声明;编译器不在 + 存储中时取 home 中最新的版本,并在报告中写明。依赖图在预制的 glibc 之上供给 `kernel-abi` 时(`*-linux-gnu` 上的 openkal + 实现),头文件仍按基座的组成部分决定并接线,层的身份不变。 +7. **探针(§3.4)。** 探针单元按内容命名,写在临时目录中,不写入工程的 `target/`。 + diff --git a/.agents/docs/README.md b/.agents/docs/README.md index 09ed746d9..4f606d77b 100644 --- a/.agents/docs/README.md +++ b/.agents/docs/README.md @@ -18,7 +18,7 @@ superseded_by: 2026-09-07-....md # when status is superseded --- ``` -372 records. +373 records. ## By subject @@ -60,6 +60,7 @@ Records that declare one. Everything else is listed by date below. ### design +- [生态级方案:内核接口的供给与能力,派生状态的核对,存储的引用](2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md) — active - [程序起点模型:启动者、两层入口与 `main` 的三种陈述(mcpp#845、mcpp#981)](2026-11-20-program-start-model.md) — landed - [升级的连续性:打包修订不在使用路径上替换载荷、替换失败不拆掉可用状态、home 中的悬空记录自愈、真实的升级 lane](2026-10-17-upgrade-continuity-design.md) — active - [一处来源,一种含义:工作空间的传递语义、生成输出、模块角色与首次运行(#786、#785、#778、#790)](2026-10-10-one-source-one-meaning-design.md) — landed @@ -215,6 +216,7 @@ Records that declare one. Everything else is listed by date below. ### 2026-11 - [测试与 CI 一轮的收尾:平台列未命中的刷新条件(mcpp#996)、`i686-windows-msvc` 行、工作区索引与引号键的迁移、索引的全量验证](2026-11-22-test-round-wrap-up-plan.md) — active +- [生态级方案:内核接口的供给与能力,派生状态的核对,存储的引用](2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md) — active - [包的特性作为机器可读的回答:一个目录项,两种来源,三种状态(mcpp#992)](2026-11-21-package-features-query-design.md) — active - [离线、宿主输入与工具链的缺省:按内容取归档的来源、项目的取齐、宿主输入的声明、工具链的解析与锁、缺省版本的规则(mcpp#988、#989、#990)](2026-11-21-offline-host-inputs-and-toolchain-defaults-design.md) — active - [构建程序的输入由观测给出:编译读到的文件、三道闸门的同一份记录、头文件的用法提示、提示的统一机制、契约中名字的歧义(mcpp#991、#852)](2026-11-21-build-program-observed-inputs-design.md) — active diff --git a/.github/tools/system-names.baseline b/.github/tools/system-names.baseline index 304654dd6..8f9fc7436 100644 --- a/.github/tools/system-names.baseline +++ b/.github/tools/system-names.baseline @@ -1,6 +1,6 @@ # One number per word: its occurrences in the engine's sources # (.github/tools/check_system_names.py). The numbers only fall. -linux 62 +linux 58 macos 49 windows 70 freebsd 1 diff --git a/CHANGELOG.md b/CHANGELOG.md index ddf0e28a0..d0761bfef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,49 @@ > Each `## []` section is that release's notes. Entries are written in English > from 2026.9.28.3 on; earlier entries remain as written. +## [@RELEASE@] - @DATE@ + +### Added + +- On a Linux row, `[target..layers] kernel-abi` states the kernel headers: + `"xim:linux-headers@"` (an ecosystem payload, always with its version) or + `{ path = "" }` (a header directory without `mcpp.toml`). The statement holds with or + without a platform. Its directories reach every unit and the std module with `-isystem`, ahead + of the base. The headers in effect are measured by preprocessing ``, and the + report, `mcpp why toolchain` and `layers[].version` give the version. A stated version the + measurement contradicts is refused (`target-base`). So is a prebuilt form on any other layer, + on a row whose system publishes its kernel interface with its C library (macOS, Windows, + FreeBSD), and a second supplier on an openkal row. Which systems take the form, and how the + version is read, are the system row's data (`kernel-abi`), not the engine's (docs/22) + (mcpp#988). +- A system row and a target row state the interfaces of their kernel-abi layer (`interfaces`): + every openkal interface on Linux, macOS, FreeBSD and Windows, fewer on the iOS rows (no program + start) and on `wasm32-emscripten`. `cfg(interface = "...")` reads the provider's list, else the + row's, else the system's, so it holds on a row without openkal as well. The same list is in + `layers[].interfaces` and `MCPP_KERNEL_ABI_INTERFACES` (mcpp#1005). +- `mcpp::action::origin(path)` names the authored file a generated unit is a transformed copy + of, one of the action's inputs, on a `source` action. The build database gives it as + `ide.generated[].origin`. A generated unit that declares a module's primary name is a + `module-interface`. When the authored file is also among the sources, the duplicate-provider + error names the relation (S1 0.4.0, mcpp#1004). + +### Changed + +- Without a statement, the kernel headers are the base's own (a stated sysroot, a toolchain's own + sysroot such as `musl-gcc`'s, the host's root), else the version the toolchain's payload + declares. A build under gcc 16.2.0 now compiles against linux-headers 6.18.64, the version it + was built with, instead of the 5.11.1 the home's shared view linked to. The shared view is no + longer read for kernel headers, and mcpp no longer writes kernel headers into it; with neither + answer the build is refused before it compiles and names the statement to write. + +### Fixed + +- `layers`, `tools` and `link` in a `[target.]` table of the project or of + `config.toml` were accepted and had no effect on a row without a platform, with no report even + under `--strict`. They now complete the graph and reach the link on every row (docs/35); + `link.flags` that reaches no program says so, and `carrier`, a form of a platform's image, is a + warning there (`platform/carrier`). + ## [2026.11.22.1] - 2026-11-22 ### Added diff --git a/docs/20-toolchains.md b/docs/20-toolchains.md index d7b8a052f..1de39eb53 100644 --- a/docs/20-toolchains.md +++ b/docs/20-toolchains.md @@ -237,8 +237,10 @@ The build installs the package, says `Companion binutils 2.47 ()`, and passes its directory to the driver. A binutils older than the one the GCC payload declares is refused (`companion-too-old`): GCC chose its assembler features by that binutils when it was built. `companions` names binutils only; -the kernel headers follow the toolchain payload's declaration, since the -default base is the home's sysroot, which every project shares. +the kernel headers are the target's `kernel-abi` layer, stated with +`[target..layers] kernel-abi` ([22 — The Target +Side](22-target-side.md)); without a statement, over a base that carries none, +they follow the toolchain payload's declaration (mcpp @RELEASE@+). ## Switching the Default Toolchain diff --git a/docs/22-target-side.md b/docs/22-target-side.md index 0dafdab3b..ca9afb9eb 100644 --- a/docs/22-target-side.md +++ b/docs/22-target-side.md @@ -1207,9 +1207,11 @@ conditions and combinators. mcpp before 2026.11.10.2 reads only `linux`, `macos` `accelerator = "none"` is how a section says "this build named no backend" without enumerating the ones it is not. `interface` (mcpp 2026.11.13.1) is the kernel-abi layer's second answer: an interface its provider states in `[kernel-abi] - provides-interfaces`, compared by membership as `accelerator` is. A provider - that states no list provides every interface; a graph without the layer - provides none. A package selects its sources by what the implementation + provides-interfaces`, or, where the layer is the system itself, the system + row's `interfaces` (mcpp @RELEASE@), compared by membership as `accelerator` + is. A provider or a system that states no list provides every interface; a + graph without the layer provides none. On `aarch64-ios` the answer for + `openkal.process` is false: an application of iOS starts no program. A package selects its sources by what the implementation beneath it provides, and names no implementation: `[target.'cfg(not(interface = "openkal.fs"))'.build] sources = [...]`. Barewords `linux` / `macos` / `windows` / `unix` are sugar for the matching `os` / `family` test. A key @@ -1378,6 +1380,53 @@ this returns. To branch on the resolved layer, use a layer predicate: Side](22-target-side.md)). This paragraph said "which C library was resolved" until 2026.9.1.1, which was the wrong one of the two. +### `layers.kernel-abi` — the kernel headers (mcpp @RELEASE@+) + +Linux publishes its kernel headers apart from its C library, so on a Linux row +they are a prebuilt supplier of the `kernel-abi` layer and can be stated: + +```toml +[target.x86_64-linux-gnu.layers] +kernel-abi = "xim:linux-headers@6.18.64" # an ecosystem payload, always with its version +# kernel-abi = { path = "third_party/uapi" } # or a header directory (no mcpp.toml in it) +``` + +The statement is read from the project, then this machine's `config.toml`, then +the platform, key by key; it applies whether or not the row has a platform. With +no statement, and a C library from a prebuilt base, the build takes the first +of two answers: the base's own headers (a stated sysroot, a toolchain's own +sysroot such as `musl-gcc`'s, the host's root), then the version the +toolchain's payload declares (gcc 16.2.0 declares 6.18.64; the bundled LLVM +5.11.1). The home's shared view is not an answer: it is shared by toolchains +that declare different versions. With neither, the build is refused before it +compiles and names the statement to write. +`kernel-abi = false` states that the build has no such layer (a freestanding +arrangement): no headers are decided or measured. + +The headers in effect are measured, as the C library is: the compiler +preprocesses a unit that includes `` with the build's search +path, and the report shows the result: + +``` + Target x86_64-linux-gnu + kernel-abi linux 6.18.64 (xim:linux-headers@6.18.64, mcpp.toml:10, prebuilt) +``` + +A stated version that the measurement contradicts is refused. The directories +are given to every unit and to the std module with `-isystem`, ahead of the +base; a header the supplier lacks (``, which glibc ships) is still +the base's. A payload that carries each architecture's headers +(`arch//include`, linux-headers 6.18.64 revision 1 and 7.3.5) serves a +cross build too; one that carries its installing machine's only is refused for +another architecture, with the remedy. + +The forms are refused where they do not apply (`target-base`): on macOS, +Windows and FreeBSD the kernel interface is part of the base (`sysroot`), and no +other layer takes a prebuilt form. On an openkal row the layer is the openkal +implementation: a second supplier is refused by rule one. A manifest that uses +the forms states `[package] mcpp = ">=@RELEASE@"`; an older mcpp ignores the +key on a row without a platform. + ### `abi` — a switch the whole artefact shares (mcpp 2026.9.12.2+) ```toml diff --git a/docs/30-build-mcpp.md b/docs/30-build-mcpp.md index c8a60683c..889ac7e28 100644 --- a/docs/30-build-mcpp.md +++ b/docs/30-build-mcpp.md @@ -871,6 +871,33 @@ relative path among them is relative to `cwd`. A variable's value is part of the edge's command line, and changing it re-runs the action. An action that declares neither keeps the protocol 12 command line byte for byte. +#### The authored file of a generated unit: `.origin()` (@RELEASE@+) + +An action that writes a transformed copy of a file a person edits (a source +with its imports rewritten, a module unit with a prologue added) names that +file with `.origin(...)`. The file is one of the action's inputs, and the +action's role is `source`: + +```cpp +const std::string in = std::string(mcpp::manifest_dir()) + "/templates/core.cppm"; +a.role = mcpp::roles::source; +a.arg("rewrite").arg(in.c_str()).arg(out.c_str()) + .input(in.c_str()) + .origin(in.c_str()) + .output(out.c_str()) + .provides("app.core") + .submit(); +``` + +The build database states the relation as `ide.generated[].origin` +([50](50-machine-output.md)), so an editor shows the authored file as the +unit's source. The engine does not infer the relation from the inputs. An +`origin` that is not among the inputs, or one stated on an action of another +role, is refused when the build program runs. A unit that declares the primary +name of a module in `.provides(...)` is that module's interface unit. When the +authored file is also listed in `sources`, both provide the module, and the +error that refuses the second provider names this relation. + #### A dependency's program in an action: `${mcpp.artifact:}` (2026.9.27.1+) A dependency edge with `artifacts = [""]` builds that program for the diff --git a/docs/35-platforms.md b/docs/35-platforms.md index b86771db3..535837c18 100644 --- a/docs/35-platforms.md +++ b/docs/35-platforms.md @@ -109,6 +109,12 @@ a package of the graph already provides is left to that package and reported `graph`. The package of the C++ run-time also provides the compiler run-time, so `"c++-abi" = false` takes effect only with `compiler-runtime = false` beside it. +The tables apply on a row without a platform too (mcpp @RELEASE@): such a row +has an empty platform statement, and `layers`, `tools` and `link` written for +it complete the graph and reach the link as they would over a platform. Before, +they were accepted and had no effect. `carrier` is a form of a platform's image, +so on such a row it is reported as a warning (`platform/carrier`) and not used. + ## Selecting a platform, or none The first of these that answers selects the target's platform: diff --git a/docs/50-machine-output.md b/docs/50-machine-output.md index 14bd14fdb..69e50dc31 100644 --- a/docs/50-machine-output.md +++ b/docs/50-machine-output.md @@ -593,7 +593,7 @@ It resolves and reports; it does not build. `data` is: | `compiler` | `{family, version, driver, chosenBy}` — the driver that would run, and why | | `triple` | `{requested, toolchain, llvm}` | | `cLibrary` | `{mode, path, origin, suppliesTarget}` — `mode` is `sysroot` / `payload-first` / `none`; `origin` is `payload` / `subos` / `host` / `none` | -| `layers[]` | the five target-side layers: `{layer, interface, impl, origin, subset}` | +| `layers[]` | the five target-side layers: `{layer, interface, impl, origin, subset, version, interfaces}`; `version` is the kernel-abi layer's measured version where the system publishes its kernel headers as a package (empty otherwise), `interfaces` the layer's interfaces (`null`: unstated, every one) *(@RELEASE@+)* | **`compiler.chosenBy` answers "why this one".** `{origin, requiredBy, replaced}` — `origin` is the same phrase the build's status line uses @@ -657,7 +657,7 @@ a program classifying the outcome reads `reason`: | `payload-request` | a build program asked for a payload no manifest of this build declares `provision = "on-request"`, or asked again in three consecutive runs *(2026.10.1.3+)* | | `lto-export-discovery` | a PE shared library whose exports are discovered would be compiled by cl.exe into `/GL` objects, which hold no symbol table: `windows_auto_export = true` stated under `lto = true`, or `/GL` written into the flags of a package it links *(2026.10.5.2+)* | | `local-toolchain` | a toolchain named by path, or stated by a build program's toolchain phase, cannot be used: no driver, a contradicting family, a missing tool, or `spec` stated with a key only a toolchain named by path has *(2026.10.1.3+)* | -| `target-base` | the target base (`sysroot`) cannot serve this build: a spelling the row does not take, a path that does not exist, a directory that supplies no C library, a C library older than the compiler's runtime requires, a native base without its loader, or a second C library supplier in the graph *(2026.10.24.1+)* | +| `target-base` | the target base (`sysroot`) cannot serve this build: a spelling the row does not take, a path that does not exist, a directory that supplies no C library, a C library older than the compiler's runtime requires, a native base without its loader, or a second C library supplier in the graph *(2026.10.24.1+)*; the kernel headers: a prebuilt `layers` form on a row or layer that takes none, a payload without the target architecture's headers, no headers to answer the default, or a measurement that contradicts the statement *(@RELEASE@+)* | | `convention-unreplaced` | the convention was overridden and nothing replaced it | | `os-mismatch` | the requested and resolved triples name different systems | | `layer-requirement` | a package requires a layer the resolution did not give it | @@ -753,6 +753,9 @@ action, so such a file does not exist yet in the directory the document names. Each entry gives the path a `mcpp build` of the same selection writes (`build-path`) and the step that writes it, so that an editor can say "generated, build once" instead of reporting a missing header. +Since @RELEASE@ an entry of `kind` `source` also carries `origin` when its +action states one with `.origin(...)` ([30](30-build-mcpp.md)): the authored +file the generated unit is a transformed copy of (S1 0.4.0 section 7.2). `emit` plans every selected member on its own (#699 item 1): one member's planning failure does not cost its siblings'. Outside a project, or when diff --git a/docs/91-toolchain-internals.md b/docs/91-toolchain-internals.md index e89e9d50a..7b04ca09c 100644 --- a/docs/91-toolchain-internals.md +++ b/docs/91-toolchain-internals.md @@ -27,7 +27,7 @@ resolve toolchain payload ← project/default/install paths share one pip ▼ ensure_declared_runtime() ← exact glibc@version installed; the payload is never written ▼ -detect / probe ← triple, sysroot, payload paths (glibc, linux-headers) +detect / probe ← triple, sysroot, payload paths (glibc) ▼ ToolchainLinkModel (single resolver for the C-library axis) ├──► flags.cppm (main build compile/link flags) @@ -77,7 +77,7 @@ is resolved/auto-installed via the xlings backend into the sandbox |---|---| | `targetTriple` | ` -dumpmachine` | | `sysroot` | `-print-sysroot` (validated: must actually carry libc headers), with a remap fallback for xlings-built GCC whose baked build-time path doesn't exist locally | -| `payloadPaths` | the resolved runtime binding (§2.1) names the glibc payload exactly; linux-headers is still discovered as a sibling. No binding ⇒ no payload-first, by design | +| `payloadPaths` | the resolved runtime binding (§2.1) names the glibc payload exactly. No binding ⇒ no payload-first, by design. The kernel headers are decided after the target side (`base.kernel`, the kernel-abi layer) and wired ahead of the base in every mode | | runtime dirs | toolchain-private lib dirs for produced binaries' `-L`/`-rpath` | Note the probe deliberately does **not** mine the clang cfg for `--sysroot` diff --git a/docs/specs/build-database.md b/docs/specs/build-database.md index de6d8866c..6efd6feeb 100644 --- a/docs/specs/build-database.md +++ b/docs/specs/build-database.md @@ -4,10 +4,10 @@ |---|---| | 规范编号 | SPEC-005 | | 标题 | mcpp 输出的构建数据库:内容、取值规则与不写工程目录的保证 | -| 状态 | 评审中 v1.9 | -| 版本 | 1.9 | -| 最后修改 | 2026-10-21 | -| 对应实现 | mcpp >= 2026.9.15.1;v1.3 修改的 R2.5、R3.7、R3.8、R4.1、R5.2 为 mcpp >= 2026.9.26.2;v1.4 修改的 R2.5 为 mcpp >= 2026.9.27.1;v1.5 修改的 R3.7、R3.12、R5.1、R5.2 为 mcpp >= 2026.9.28.1;v1.6 修改的 R2.1、R3.3、R3.4、R3.5、R4.1、R5.2 为 mcpp >= 2026.9.29.5;v1.7 新增的 R3.8a 为 mcpp >= 2026.9.30.2;v1.8 新增的 R3.13 为 mcpp >= 2026.10.11.1;v1.9 明确的 R6.1a 为 mcpp >= 2026.10.21.1 | +| 状态 | 评审中 v1.10 | +| 版本 | 1.10 | +| 最后修改 | 2026-11-23 | +| 对应实现 | mcpp >= 2026.9.15.1;v1.3 修改的 R2.5、R3.7、R3.8、R4.1、R5.2 为 mcpp >= 2026.9.26.2;v1.4 修改的 R2.5 为 mcpp >= 2026.9.27.1;v1.5 修改的 R3.7、R3.12、R5.1、R5.2 为 mcpp >= 2026.9.28.1;v1.6 修改的 R2.1、R3.3、R3.4、R3.5、R4.1、R5.2 为 mcpp >= 2026.9.29.5;v1.7 新增的 R3.8a 为 mcpp >= 2026.9.30.2;v1.8 新增的 R3.13 为 mcpp >= 2026.10.11.1;v1.9 明确的 R6.1a 为 mcpp >= 2026.10.21.1;v1.10 的 R3.9、R3.12a 为 mcpp >= @RELEASE@ | | 相关设计文档 | `.agents/docs/2026-09-14-636-build-database-and-the-latest-xlings.md`
`.agents/docs/2026-09-26-compile-database-and-issue-699-design.md` | | 相关 issue | #636, #648, #655, #699, #702, #707, #732, #797 | | 依据的外部规范 | S1「C++ Build Database: IDE Profile」profile 0.3.0(§7.2 的 `generated`,Sunrisepeak/mcpp-language-server#28;此前为 0.2.0)与 S2 0.2.0 §3.4,取自 https://github.com/Sunrisepeak/lsp-mcpp-private 提交 `b82859d`(schema 自提交 `28ecd6e` 起未变);S2 0.3.0 §3.4 的部分回答(S2-3.4-12、S2-3.4-13,Sunrisepeak/mcpp-language-server#25);JSON Compilation Database | @@ -148,6 +148,7 @@ mcpp 输出的 S1 文档满足 S1 等级 2,不输出 `ide.options`。等级 3 | `module M:P;` | `module-partition-implementation` | | `module M;` | `module-implementation` | | `scan_overrides` 声明的单元;P1689 扫描中无法区分实现单元与导入者的单元 | `unknown` | + | 构建程序的 action 生成、并以 `provides` 声明模块主名(不含 `:`)的单元 | `module-interface`(只有接口单元提供主名;mcpp >= @RELEASE@) | **已实现** - **R3.9a** 没有被 `sources` glob 匹配的目标入口源文件(发现的测试、glob 之外的 @@ -182,6 +183,12 @@ mcpp 输出的 S1 文档满足 S1 等级 2,不输出 `ide.options`。等级 3 的文档,因为 JSON Compilation Database 的读者拒绝未知的键。命令不运行任何 action (R2.5);由消费方决定是否在其用户同意时运行 `generator`。**已实现** (mcpp >= 2026.9.28.1,mcpp#724) +- **R3.12a** `kind` 为 `source` 的一项另有 `origin`,当且仅当生成它的 action 以 `mcpp::action::origin` 陈述了它: + 该文件是其变换副本的那个编写的源文件(人为改变该单元而编辑的文件),是 action 的 `inputs` 之一。引擎**禁止**由 + `inputs` 推断它。`origin` 不在 `inputs` 中、或陈述在 `role` 不是 `source` 的 action 上时,构建程序的指令被拒绝。 + 同一模块由生成的单元与其 `origin` 一同提供时(工程把编写的文件也列在 `sources` 中),扫描器的重复提供者错误写明 + 二者的这一关系。不写 `line-mapping`:生成文件中的 `#line` 指令本身是事实,由消费方读取。S1 0.4.0 §7.2 的增量 + 字段。**已实现**(mcpp >= @RELEASE@,mcpp#1004) ### 3.6 构建程序 @@ -265,3 +272,4 @@ mcpp 输出的 S1 文档满足 S1 等级 2,不输出 `ide.options`。等级 3 | 1.7 | 2026-09-30 | 新增 R3.8a:同一配置中两个包提供同一个模块名时,两个单元都列出它,可能导入它的单元的 `arguments` 带有构建所用的绑定(#732)。 | | 1.8 | 2026-10-11 | 新增 R3.13:构建程序、构建程序实例的库与引擎接口以 `<包>:build`、`<包>:host`、`mcpp:core`、`mcpp:std:host` 集合描述,`ide.configuration` 为 `build-program`,只进入 S1 文档(#797)。 | | 1.9 | 2026-10-21 | R6.1a 明确合成 host 清单与锁文件不作为 watch 或 fingerprint 输入,保留可编辑依赖输入(#807)。 | +| 1.10 | 2026-11-23 | 新增 R3.12a:生成的单元以 action 陈述的 `origin` 指名其编写的源文件(S1 0.4.0);R3.9 以 `provides` 声明模块主名的生成单元为 `module-interface`(mcpp#1004)。 | diff --git a/docs/specs/manifest-semantics.md b/docs/specs/manifest-semantics.md index 5ee53a8ea..c16316f78 100644 --- a/docs/specs/manifest-semantics.md +++ b/docs/specs/manifest-semantics.md @@ -5,8 +5,8 @@ | **规范编号** | SPEC-004 | | **标题** | `mcpp.toml` 的平面划分、条件化形状、解析轴与命名规约 | | **状态** | **草案(Draft)** | -| **版本** | 1.28 | -| **最后修改** | 2026-11-21 | +| **版本** | 1.29 | +| **最后修改** | 2026-11-23 | | **最低实现版本** | 条件化形状:mcpp **2026.8.29.1**(`[target..build-dependencies]` 起齐备);目标轴:mcpp **2026.9.6.4** | | **作者/维护** | mcpp-community | | **相关设计文档** | `.agents/docs/2026-09-07-mcpp-toml-unified-semantics-design.md`
`.agents/docs/2026-06-04-manifest-schema-ownership.md`
`.agents/docs/2026-09-03-xlings-workspace-as-the-one-table.md`
`.agents/docs/2026-09-25-issue-690-workspace-build-inheritance-consistency.md`
`.agents/docs/2026-09-27-eight-reports-by-home-and-one-optimisation-plan.md`
`.agents/docs/2026-10-05-std-module-pair-msvc-lto-and-export-discovery-design.md`
`.agents/docs/2026-10-06-windows-x86-arch-vocabulary-and-rc-follow-ups-design.md`
`.agents/docs/2026-10-10-one-source-one-meaning-design.md`
`.agents/docs/2026-10-11-build-dependencies-one-pipeline-design.md`
`.agents/docs/2026-10-23-target-base-and-execution-host-design.md`
`.agents/docs/2026-10-26-control-contract-runtime-and-ide-ecosystem-design.md`(§24) | @@ -198,9 +198,14 @@ feature-deps feature-xlings ← 限定词是门 | `[target..xlings…]` | 目标 | **已实现**(2026.9.6.4) | | `[target.].sysroot` | 目标 | **已实现** | | `[target.].run_under` | 目标(执行宿主) | **已实现**(2026.10.24.1) | -| `[target.]` 的 `platform`、`layers`、`tools`、`link`、`carrier` | 目标 | **已实现**(2026.10.27.1,SPEC-013) | +| `[target.]` 的 `platform`、`layers`、`tools`、`link`、`carrier` | 目标 | **已实现**(2026.10.27.1,SPEC-013);没有平台的行上同样生效(@RELEASE@,SPEC-013 §6) | +| `[target..layers] kernel-abi` 的预制形式 `"<索引>:<名>@<版本>"`、`{ path = "<目录>" }` | 目标 | **已实现**(@RELEASE@,SPEC-002 §3.9) | | `[host] platform` | 宿主 | **已实现**(2026.10.27.1,SPEC-013 §4) | +`layers.<层>` 的值有四种形式:依赖图中的包(包引用)、`false`、生态载荷 `"<索引>:<名>@<版本>"` 与不带 `mcpp.toml` 的 +目录 `{ path = "<目录>" }`;后两种是预制供给者,拼写与 `companions` 的载荷、`sysroot = { path = … }` 相同,只在 +系统行为该层给出测量方式时被接受(SPEC-002 §3.9)。载荷引用**必须**带版本。 + 顶层平台键对象**不是**遗留拼法,它是宿主轴**正确**的写法:工具必须能在这台机器上 执行。`[target.].sysroot` 是目标轴 xpkg 引用的既有先例。 @@ -959,3 +964,4 @@ mcpp 2026.10.10.1,#785、#786;第 14 至 16 条与第 13 条的依赖位置为 m | 1.26 | 2026-11-21 | mcpp 2026.11.21.1(mcpp#990,设计 2026-11-21 离线与缺省 §3.2):§9 第 22 条 `[build] offline` 与第 23 条 `[xlings] archives`,两者按 §2 的四层取值,一次运行陈述为一个变量。 | | 1.27 | 2026-11-21 | mcpp 2026.11.21.1(mcpp#992):新增 §16,特性的 `description`、一个目录项与查询回答的三种状态。 | | 1.28 | 2026-11-22 | mcpp 2026.11.22.1(设计 2026-11-22 §6.2):§9 第 12 条,生效的 `[indices]` 中一个位置只有一个名字,两项指向同一位置时拒绝(`index-location-named-twice`)。 | +| 1.29 | 2026-11-23 | mcpp @RELEASE@(设计 2026-11-22 内核接口与派生状态 §3.1、§3.2):`layers.<层>` 的四种值,载荷与目录两种预制形式;平台键在没有平台的行上生效。 | diff --git a/docs/specs/platforms.md b/docs/specs/platforms.md index 152250c5d..bd6836055 100644 --- a/docs/specs/platforms.md +++ b/docs/specs/platforms.md @@ -4,10 +4,10 @@ |---|---| | 规范编号 | SPEC-013 | | 标题 | 平台:一类目标的可复用配置,其声明、选择、合并、对依赖图的补全、链接与封装、运行器与载体 | -| 状态 | 评审中 v1.16 | -| 版本 | 1.16 | -| 最后修改 | 2026-11-20 | -| 对应实现 | mcpp >= 2026.10.27.1;§10 的执行宿主与 §11 的载体架构 mcpp >= 2026.10.29.1;`runner.hosts`、载体列表、`descriptor_keys` 与 `universal` 的弃用 mcpp >= 2026.10.30.1;§7.5 版本组参与解析、§14 平台系列与 §15.1 系列的锁 mcpp >= 2026.11.7.1;§14 内置平台为确切版本与提示 mcpp >= 2026.11.7.2;v1.7 条款 mcpp >= 2026.11.10.1;v1.10 条款 mcpp >= 2026.11.16.1;v1.11 条款(§14 索引的平台列) mcpp >= 2026.11.17.1;v1.15 条款(§14 系列取本次构建可用的最新版本,§15.1 构建程序的版本条目) mcpp >= 2026.11.19.1;v1.16 条款(§14 平台列未命中的刷新条件) mcpp >= 2026.11.22.1;逐条标注 | +| 状态 | 评审中 v1.17 | +| 版本 | 1.17 | +| 最后修改 | 2026-11-23 | +| 对应实现 | mcpp >= 2026.10.27.1;§10 的执行宿主与 §11 的载体架构 mcpp >= 2026.10.29.1;`runner.hosts`、载体列表、`descriptor_keys` 与 `universal` 的弃用 mcpp >= 2026.10.30.1;§7.5 版本组参与解析、§14 平台系列与 §15.1 系列的锁 mcpp >= 2026.11.7.1;§14 内置平台为确切版本与提示 mcpp >= 2026.11.7.2;v1.7 条款 mcpp >= 2026.11.10.1;v1.10 条款 mcpp >= 2026.11.16.1;v1.11 条款(§14 索引的平台列) mcpp >= 2026.11.17.1;v1.15 条款(§14 系列取本次构建可用的最新版本,§15.1 构建程序的版本条目) mcpp >= 2026.11.19.1;v1.16 条款(§14 平台列未命中的刷新条件) mcpp >= 2026.11.22.1;v1.17 条款(§6 没有平台的行、§7.2 预制形式) mcpp >= @RELEASE@;逐条标注 | | 相关设计文档 | `.agents/docs/2026-11-16-ecosystem-gap-supplement-part2-design.md`、`.agents/docs/2026-11-15-ecosystem-gap-supplement-design.md`、`.agents/docs/2026-10-28-platforms-design.md`、`.agents/docs/2026-10-28-platforms-part2-packaging-and-distribution-design.md`、`.agents/docs/2026-10-29-openkal-run-test-pack-design.md` | | 相关 issue | mcpp#846、mcpp#847、mcpp#848 | | 相关规范 | [SPEC-002](target-side.md)(目标侧的层)、[SPEC-004](manifest-semantics.md)(条件化形状)、[SPEC-006](toolchain-management.md)(工具链选择)、[SPEC-007](build-plugins.md)(构建程序与协议)、[SPEC-011](concurrency.md)(原子发布)、[SPEC-014](packaging.md)(打包) | @@ -221,6 +221,11 @@ mcpp **必须**给出警告(`manifest/platform-selector`),并指出按三元组 | `runner`、`runners` 的每个名字 | `cmd`、`requires` 与 `enabled` 是一条陈述,随 `cmd` 一起替换,未写的 `enabled` 为真;`host`、`hosts`、`exclusive`、`longlived`、`built-as` 各自独立替换。只写 argv 的覆盖保留平台的 `host` 与 `exclusive`;覆盖层(本机配置、工程)不含 `cmd` 的表只改它写出的键(v1.10) | | 其余 | 按字段替换 | +**没有平台的行同样合并(v1.17,mcpp >= @RELEASE@)。** 未选平台包的行有一份空的平台陈述,`config.toml` 与工程的 +`[target.]` 按上表并入其中,§7.2、§7.3 的补全照常进行;读取字段的步骤(链接规划、标志、后端)读字段本身, +只有含义来自平台包的步骤(平台包的身份、版本组、平台插件)以选定了平台包为前提。此前这些键在没有平台的行上被接受而 +不起作用。`carrier` 是平台映像的形式(§11),在没有平台的行上以警告报告(`platform/carrier`)而不使构建失败。 + `MCPP_TARGET__RUNNER` 以空白分隔的 argv 替换 `runner.cmd`;值为 `none` 时清除运行器。**已实现** `MCPP_TARGET__RUNNER_ENABLED` 为 `true`(`1`)或 `false`(`0`)时设定缺省运行器的 `enabled`,位于全部层之上(v1.10)。 @@ -236,7 +241,8 @@ mcpp **必须**给出警告(`manifest/platform-selector`),并指出按三元组 第一轮遍历之后,对 `layers` 中的每一层: -1. 值为 `false`:平台不为该层提供包;报告为 `none`。 +1. 值为 `false`:平台不为该层提供包;报告为 `none`。值为预制形式(`"<索引>:<名>@<版本>"`,或不带 `mcpp.toml` 的 + `{ path }`)时不加入依赖图,由目标侧决定与接线(SPEC-002 §3.9;v1.17)。 2. 图中已有包以 `provides` 提供该层:平台让位;该包由平台加入时报告为 `platform`,否则为 `graph`。 判断读 `provides`,不比较包名。 3. 否则:该包作为根的依赖加入(来源 `the platform's `),一个包提供的多层只加入一次。 @@ -659,3 +665,4 @@ openkal-platform 的 `targets` 因此不含 WebAssembly。Web 经 `wasm32-emscri | 1.14 | 2026-11-19 | mcpp 2026.11.19.1(mcpp#967):§14 索引的平台列第 6 条,一行的未命中按依赖未命中的策略刷新索引并重新扫描,拒绝写出是否已刷新。 | | 1.15 | 2026-11-20 | mcpp 2026.11.19.1(mcpp#972,设计 2026-11-19 §21 A3、A5):§14 平台系列第 3 条,版本组不容许本次构建的请求时取范围内更早的版本并写出跳过的版本与请求,全部不可用时拒绝;§15.1 构建程序取得的另一版本为 `+b` 条目并写出 `programs`。 | | 1.16 | 2026-11-22 | mcpp 2026.11.22.1(mcpp#996):§14 索引的平台列第 6 条,没有平台也能构建的请求(段定义的自定义三元组、命名了工具链的 `planned` 行)的未命中不刷新索引;表中的 `platform = "none"` 结束平台列的查询。 | +| 1.17 | 2026-11-23 | mcpp @RELEASE@(设计 2026-11-22 §3.2):§6 没有平台的行有一份空的平台陈述,本机与工程的 `[target.]` 并入其中,`carrier` 在这样的行上为警告;§7.2 层的预制形式不加入依赖图(SPEC-002 §3.9)。 | diff --git a/docs/specs/target-side.md b/docs/specs/target-side.md index 7c0b3c36f..89043ff71 100644 --- a/docs/specs/target-side.md +++ b/docs/specs/target-side.md @@ -4,10 +4,10 @@ |---|---| | 规范编号 | SPEC-002 | | 标题 | 目标侧模型与能力声明(`mcpp:` 保留命名空间) | -| 状态 | 评审中 v1.11 | -| 最后修改 | 2026-11-20 | +| 状态 | 评审中 v1.12 | +| 最后修改 | 2026-11-23 | | 对应实现 | mcpp >= 2026.8.24.2;§2.2 的对象形式与 §7 mcpp >= 2026.10.26.1 | -| 相关设计文档 | `.agents/docs/2026-08-24-target-side-design.md`、`.agents/docs/2026-10-23-target-base-and-execution-host-design.md`、`.agents/docs/2026-10-26-control-contract-runtime-and-ide-ecosystem-design.md` §6 | +| 相关设计文档 | `.agents/docs/2026-08-24-target-side-design.md`、`.agents/docs/2026-10-23-target-base-and-execution-host-design.md`、`.agents/docs/2026-10-26-control-contract-runtime-and-ide-ecosystem-design.md` §6、`.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md` | | 使用文档 | [docs/22 - 目标侧](../zh/22-target-side.md) | 本规范定义一次构建的目标侧由哪些层构成、每一层可以由谁供给、 @@ -179,8 +179,8 @@ mcpp:<层名>[=<实现名>] 当前实现覆盖「两层均来自图」与「两层均来自载荷」。 「一层预制、一层来自图」的接线尚不完整。 -可叠加的层(内核头文件、第三方头文件与库)由引擎以 `-isystem` / `-L` 接线;本机的目标基座缺少 -内核头文件时,引擎**必须**补上生态的内核头文件,而**禁止**写入基座。 +可叠加的层(内核头文件、第三方头文件与库)由引擎以 `-isystem` / `-L` 接线,引擎**禁止**为此写入基座。 +内核头文件的决定与接线见 §3.9。 `c-abi` 层来自图时,链接的库搜索同样属于图:引擎**禁止**让驱动器从宿主推导库目录, 这样的链接上每一个 `-L` **必须**位于工具链存储、构建目录或图中某个包之内; @@ -232,6 +232,41 @@ hosted 与否是 C 环境的一个声明:提供 `hosted-standard-library` 的 sy 它需要的层。例:写在 C 库之上的 kernel-abi 实现(需要 `mcpp:c-abi`)与写在 kernel-abi 之上的 C 库(需要 `mcpp:kernel-abi`)不能同处一图;二者相互调用的递归在运行时才出现。 +### 3.9 内核头文件 已实现(mcpp >= @RELEASE@) + +系统行为 `kernel-abi` 给出测量方式(SPEC-016 §2.3)的系统,其内核头文件是与 C 库分开发布的包, +是 `mcpp:kernel-abi=<系统名>` 的预制供给者(当前为 `linux`)。 + +1. **陈述。** `[target.<选择器>.layers] kernel-abi` 接受两种预制形式:`"<索引>:<名>@<版本>"`(生态载荷, + **必须**带版本)与 `{ path = "<目录>" }`(不带 `mcpp.toml` 的头文件目录;带清单的目录是依赖图中的包)。 + 层次依次为工程、本机、平台,按键替换(SPEC-013 §6)。系统行不给出测量方式的行上,以及任一行的其他层上, + 预制形式**必须**被拒绝(`target-base`),消息指出陈述基座的键 `sysroot`。 +2. **缺省。** 没有陈述、且 C 库来自预制基座时,取第一个回答者:基座自带的头文件(陈述的基座、工具链自带的 + sysroot、宿主的根,以测量确认);工具链载荷所声明的版本(SPEC-006 §2.9 的两条记录;编译器不在存储中时取 + home 中最新的版本,报告写明)。生态的共享视图与载荷布局的 C 库不是回答者。都不回答时**必须**在编译前拒绝 + (`target-base`),并给出陈述的写法。依赖图供给 C 库时不作此决定。`kernel-abi = false` 陈述构建没有该层, + 不决定也不测量头文件。 +3. **测量。** 驱动以构建的头文件搜索路径预处理一个以 `__has_include` 包含系统行所指名头文件的单元。版本取各段的宏; + 缺席时按系统行的位宽解码打包的宏,达到位宽最大值的段为饱和,不参与比较。载荷形式陈述的版本与测得的版本按 + 此精度比较,不符**必须**拒绝(`target-base`)。 +4. **接线。** 决定的目录以 `-isystem` 加在基座的头文件目录之前,作用于每个单元与 std 模块,每种驱动与基座模式相同; + 供给者没有的文件取自基座,因此基座另带一版内核头文件时,供给者中已删除的文件仍可见。引擎**禁止**为此写入 + 基座或共享视图。 +5. **布局。** 载荷带系统行所指名的每架构目录(`arch/<架构>/include`)时,它先于公共目录被搜索;不带时载荷只服务 + 安装它的机器的架构,用于其他架构**必须**被拒绝(`target-base`)。 +6. **与依赖图。** 依赖图中的包供给 `kernel-abi` 时再陈述预制供给者,按规则一拒绝;依赖图供给 C 库时陈述被拒绝 + (`layer-requirement`)。 +7. **报告。** 目标侧报告与 `mcpp why toolchain` 的 `layers[]` 写出实现、测得的版本(`version`)、供给者与来源; + 头文件目录进入缓存键(`targetHeaderSet`)。 + +### 3.10 `kernel-abi` 的接口 已实现(mcpp >= @RELEASE@) + +`cfg(interface = "<接口名>")` 按成员关系回答 `kernel-abi` 层所提供的接口:依赖图供给该层时取其包的 +`[kernel-abi] provides-interfaces`,该层是系统自身时取系统行的 `interfaces`(SPEC-016 §2.3)。不陈述清单的包或 +系统提供每一个接口;没有该层的行不提供任何接口。同一清单写入 `mcpp why toolchain` 的 `layers[].interfaces` +与构建程序的 `MCPP_KERNEL_ABI_INTERFACES`。接口在目标侧决定之后才可知,以该谓词选择依赖时按 §2.2 的层谓词 +报告并忽略。 + ### 3.5 目标表的约定何时生效 已实现 目标行的 `pin` 命名的是**供给该目标 C 库的载荷**,不是偏好的编译器。 @@ -421,3 +456,4 @@ hosted 与否是 C 环境的一个声明:提供 `hosted-standard-library` 的 sy | v1.8 | 2026-11-12 | 随 mcpp 2026.11.12.1:§2.5 基座包只有一种读法(带清单即包根 sysroot,布局只对无清单的目录探测)。 | | v1.10 | 2026-11-19 | 随 mcpp 2026.11.19.1:§2.5 基座的 C++ 层与依赖图供给的层的隔离词在每个宿主上写出,与载荷旁有无驱动的配置文件无关;`-stdlib=` 取该层的库名(mcpp#965)。 | | v1.11 | 2026-11-20 | 随 mcpp 2026.11.19.1:§3.6 缺省以目标的解析判断,只被构建程序持有的包不为目标提供能力(设计 2026-11-19 §21 A1)。 | +| v1.12 | 2026-11-23 | 随 mcpp @RELEASE@(设计 2026-11-22):新增 §3.9 内核头文件(预制陈述、缺省的两个回答者、测量、接线、布局)与 §3.10 `kernel-abi` 的接口;§3.3 不再补上生态的内核头文件。 | diff --git a/docs/specs/targets-and-providers.md b/docs/specs/targets-and-providers.md index bc018e64d..5efd86650 100644 --- a/docs/specs/targets-and-providers.md +++ b/docs/specs/targets-and-providers.md @@ -4,11 +4,11 @@ |---|---| | 规范编号 | SPEC-016 | | 标题 | 目标与提供者:行、提供者、选择、平台定义的行、报告与锁 | -| 状态 | 评审中 v1.8 | -| 版本 | 1.8 | -| 最后修改 | 2026-11-22 | -| 对应实现 | 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;v1.7 条款 mcpp >= 2026.11.20.1;v1.8 条款 mcpp >= 2026.11.22.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` | +| 状态 | 评审中 v1.9 | +| 版本 | 1.9 | +| 最后修改 | 2026-11-23 | +| 对应实现 | 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;v1.7 条款 mcpp >= 2026.11.20.1;v1.8 条款 mcpp >= 2026.11.22.1;v1.9 条款 mcpp >= @RELEASE@ | +| 相关设计文档 | `.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`、`.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-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)(目标集合) | | 使用文档 | [21 —— 目标三元组](../zh/21-the-target-triple.md)、[35 —— 平台](../zh/35-platforms.md) | @@ -100,6 +100,8 @@ | `object-format` | 该系统各行的对象格式(`elf`、`mach-o`、`pe`、`wasm`、`coff`);行自己的陈述在先(§2.1)(v1.5) | | `exe-suffix` | 该系统的程序的后缀;行自己的陈述在先(v1.5) | | `shared-suffix` | 该系统的共享库的后缀;行自己的陈述在先(v1.5) | +| `kernel-abi` | 该系统的内核头文件是与 C 库分开发布的包:`header`(探针包含的头文件)、`version`(各段的宏)、`packed`(`{ macro, bits }`,打包的宏与各段的位宽)、`include` 与 `arch-include`(载荷的公共目录与每架构目录,`{arch}` 为目标架构)、`package`(工具链载荷所声明的生态包名);其各行接受预制的 `kernel-abi` 陈述(SPEC-002 §3.9)(v1.9) | +| `interfaces` | 该系统提供的接口,用 openkal 的接口名;`kernel-abi` 层是系统自身的行上为 `cfg(interface = …)` 的回答(SPEC-002 §3.10);未写为提供每一个接口(v1.9) | - 陈述了 `uname` 的系统可以进入多系统单文件;表中未陈述 `uname` 的系统,其程序是文件开头的 PE;表中没有的系统被拒绝, 并指名 `[[platform.system]]`。 @@ -112,6 +114,12 @@ `mach-o`,ok 镜像的行陈述 `.oke` 与 `.okso`,`wasm32-emscripten` 陈述 `.js`(v1.5)。此前这些由引擎中按系统名的分支 表达,没有分支的内置行(FreeBSD、裸机、iOS)取宿主的命名。 - 平台定义的行可以不陈述 `object-format`:未陈述时取其系统的,再取 ELF(v1.5)。 +- 内置数据中只有 `linux` 陈述 `kernel-abi`:版本取 `LINUX_VERSION_MAJOR`、`LINUX_VERSION_PATCHLEVEL`、`LINUX_VERSION_SUBLEVEL`, + 缺席时按 16、8、8 位解码 `LINUX_VERSION_CODE`;载荷布局为 `include` 与 `arch/{arch}/include`;包为 `linux-headers`。 + `macos`、`windows`、`freebsd` 的内核接口与其 C 库同属一个 SDK 或基座,不陈述 `kernel-abi`(v1.9)。 +- 内置数据中 `linux`、`macos`、`freebsd`、`windows` 陈述 openkal 规范所定义的全部接口;`ios` 不含 `openkal.process` 与 + `openkal.exec`(应用的沙箱不启动程序、不映射所写的代码);`emscripten` 陈述 `abort`、`stream`、`memory`、`env`、 + `time`、`random` 与 `fs`(v1.9)。 - 引擎源码中系统名的出现次数由检查持有(`.github/tools/check_system_names.py` 与其基线),只许减少。 ### 2.4 执行关系(v1.3) @@ -244,7 +252,8 @@ - 构建记录与 `plan` 事件的 `configuration.target` 为 `{request, identity, provider, priority, fallback}`;本机构建为 `null`。 - 构建程序读 `MCPP_TARGET_PROVIDER`(`mcpp::target_provider()`)。 - 声明 `requires = ["mcpp:kernel-abi=…"]` 的包,其构建程序读 `MCPP_KERNEL_ABI_INTERFACES`(`mcpp::kernel_abi_interfaces()`): - 所解析的 kernel-abi 提供者的 `provides-interfaces`,以 `;` 连接;总是设置,空为未知(v1.1)。 + 所解析的 kernel-abi 提供者的 `provides-interfaces`,该层是系统自身时为系统表的 `interfaces`,以 `;` 连接;总是设置, + 空为未知(v1.1;系统表 v1.9)。 - `mcpp.lock` 以 `[target.""] identity, provider` 记录每个请求得到的身份;`--locked` 下选择另一身份的构建被拒绝, 并写出锁中的与本次的身份。 @@ -270,3 +279,4 @@ | 1.6 | 2026-11-19 | mcpp 2026.11.19.1(mcpp#957):§6 执行可达性的谓词之前没有按系统的分支;Apple 的行由同一个谓词判定;系统名检查的词表含三元组的系统谓词 | | 1.7 | 2026-11-20 | mcpp 2026.11.20.1(mcpp#981):行的 `link-without-main`,没有程序起点的可执行映像的链接词;内置 `wasm32-emscripten` 行为 `--no-entry` | | 1.8 | 2026-11-22 | mcpp 2026.11.22.1(设计 2026-11-22 §4):`i686-windows-msvc` 为 preview 行;执行关系表中 `windows-x86_64` 执行 `i686`(§2.4)。 | +| 1.9 | 2026-11-23 | mcpp @RELEASE@(设计 2026-11-22 §3.4、§3.17):系统表的 `kernel-abi`(测量、载荷布局、包)与 `interfaces`;`MCPP_KERNEL_ABI_INTERFACES` 在系统供给该层时取系统表的 `interfaces` | diff --git a/docs/specs/toolchain-management.md b/docs/specs/toolchain-management.md index 20ac07a38..ca82e824a 100644 --- a/docs/specs/toolchain-management.md +++ b/docs/specs/toolchain-management.md @@ -4,8 +4,8 @@ |---|---| | 规范编号 | SPEC-006 | | 标题 | 工具链管理:身份、来源、选择与载荷契约 | -| 状态 | 草案 v0.13 | -| 最后修改 | 2026-11-22 | +| 状态 | 草案 v0.14 | +| 最后修改 | 2026-11-23 | | 对应实现 | 逐条标注;标为「已实现」的条款对应 mcpp >= 2026.9.24.1。标为「未实现」的条款计划与下一批 LLVM 工具链一同落地,届时按实测修订本规范 | | 相关设计文档 | `.agents/docs/2026-10-23-target-base-and-execution-host-design.md`、`.agents/docs/2026-09-24-toolchain-selection-and-payload-trust-design.md`、`.agents/docs/2026-09-24-685-687-msvc-stl-and-toolchain-payloads.md`、`.agents/docs/2026-09-28-ecosystem-design-and-optimisation-plan.md`、`.agents/docs/2026-10-02-pr-ci-acceleration-and-the-toolchain-specification-design.md`、`.agents/docs/2026-11-21-offline-host-inputs-and-toolchain-defaults-design.md` | | 相关 issue | mcpp#685、mcpp#687、mcpp#718、mcpp#755、mcpp#832、mcpp#988 | @@ -122,7 +122,9 @@ - 工程可以在工具链的陈述旁写明 binutils:`default = { package = "gcc@16.2.0", companions = { binutils = "xim:binutils@2.47" } }`, `[toolchain]` 的各平台键与 `[workspace.toolchain]` 同样可写。`companions` 只有 `binutils` 一项;只用于 GCC。 - 写明的 binutils 低于工具链载荷声明的版本时**必须**拒绝,原因标记 `companion-too-old`:GCC 在构建时按所用的 binutils 选定汇编器的能力。 -- 内核头文件不在工具链的陈述中覆盖:缺省的基础层是 home 中各工程共用的 sysroot,头文件的版本随工具链载荷的声明(其修订)改变。 +- 内核头文件不在工具链的陈述中覆盖,它们是目标的 `kernel-abi` 层(`[target..layers] kernel-abi`,SPEC-002 §3.9)。 + 基座不带内核头文件(共享视图、载荷布局的 glibc)时,缺省取工具链载荷声明的版本,读法同上;载荷没有声明时不取 store 中的 + 最新版本,而是拒绝并给出陈述的写法。引擎**禁止**向共享视图写入内核头文件(mcpp >= @RELEASE@)。 --- @@ -450,6 +452,7 @@ doctor 如实报告这一点。它同时报告 mcpp 的包 home 中指向不存 | v0.10 | 2026-10-23 | 随 mcpp 2026.10.24.1:§1 定义目标基座与执行宿主;新增 §3.9 目标基座(一次解析、四档写法与优先级、测量与声明、不写入、运行时语义)、§3.10 自备输入、§3.11 核心知识判据;§2.2.1 工具链阶段可陈述 `spec` 与 `sysroot`,`spec` 与路径专属键同时出现时拒绝;§3.1 补全读者名单;§3.3 增加主体 `sysroot` 与 `run_under`;§3.5 clang 行接受 `{ path }`;§4.3 要求被陈述的 gnu-sysroot 基座把 `--sysroot` 交给链接器;新增附录 A。 | | v0.11 | 2026-11-10 | 随 mcpp 2026.11.10.1:§3.9.2 引擎默认档为所选提供者的 `sysroot` 列,为包时按工程陈述的规则解析;附录 A 的 `*-windows-gnu` 接受基座包与 `{ path }`,新增 `*-freebsd` 行(基座包见 SPEC-002 §2.5)。 | | v0.13 | 2026-11-22 | 随 mcpp 2026.11.22.1:§2.9 配套载荷的声明依次取自载荷安装时的描述文件与索引的描述文件,取 store 持有的第一个。 | +| v0.14 | 2026-11-23 | 随 mcpp @RELEASE@(设计 2026-11-22 内核接口与派生状态 §3.3):§2.9 内核头文件是目标的 `kernel-abi` 层;基座不带时缺省取工具链载荷的声明,没有声明时拒绝;引擎不向共享视图写入内核头文件。 | | v0.9 | 2026-10-17 | 随 mcpp 2026.10.17.1:新增 §4.7,已安装的修订在构建中继续使用,`floor` 决定是否必须替换,`toolchain install` 取当前修订;§6.4 doctor 只读,报告构建实际使用的工具链与包 home 的一致性。 | --- diff --git a/docs/zh/20-toolchains.md b/docs/zh/20-toolchains.md index 61ed189bd..9b61fc358 100644 --- a/docs/zh/20-toolchains.md +++ b/docs/zh/20-toolchains.md @@ -191,8 +191,9 @@ default = { package = "gcc@16.2.0", companions = { binutils = "xim:binutils@2.47 ``` 构建安装该包,输出 `Companion binutils 2.47 ()`,并把它的目录交给编译器驱动。低于 GCC 载荷所声明版本的 binutils 被拒绝 -(`companion-too-old`):GCC 在构建时按所用的 binutils 选定汇编器的能力。`companions` 只有 binutils 一项;内核头文件随工具链载荷的声明, -因为缺省的基础层是 home 中各工程共用的 sysroot。 +(`companion-too-old`):GCC 在构建时按所用的 binutils 选定汇编器的能力。`companions` 只有 binutils 一项;内核头文件是目标的 `kernel-abi` 层,以 +`[target..layers] kernel-abi` 陈述([22 —— 目标侧](22-target-side.md));没有陈述、基座又不带内核头文件时, +它们随工具链载荷的声明(mcpp @RELEASE@+)。 ## 切换默认工具链 diff --git a/docs/zh/22-target-side.md b/docs/zh/22-target-side.md index 7779008b7..fc85fc66b 100644 --- a/docs/zh/22-target-side.md +++ b/docs/zh/22-target-side.md @@ -1012,9 +1012,10 @@ arch/env 条件与组合子用 `cfg(...)`。2026.11.10.2 之前的 mcpp 仅将 ` `[build] accel` 里的后端名)回答,因此它是对一个集合的成员判定; `accelerator = "none"` 是一种写法,用来说明「本次构建没有命名任何后端」, 而不必枚举它不是的那些后端。`interface`(mcpp 2026.11.13.1)是 kernel-abi 层的第二个回答: - 该层的提供者在 `[kernel-abi] provides-interfaces` 里陈述的接口,与 - `accelerator` 一样按成员判定。未陈述列表的提供者提供全部接口;没有该层的 - 图不提供任何接口。包据此按其下实现提供的接口选择源文件,而不命名任何实现: + 该层的提供者在 `[kernel-abi] provides-interfaces` 里陈述的接口,该层是系统自身时为 + 系统行的 `interfaces`(mcpp @RELEASE@),与 `accelerator` 一样按成员判定。未陈述列表的 + 提供者或系统提供全部接口;没有该层的图不提供任何接口。`aarch64-ios` 上 + `openkal.process` 的回答为假:iOS 的应用不启动程序。包据此按其下实现提供的接口选择源文件,而不命名任何实现: `[target.'cfg(not(interface = "openkal.fs"))'.build] sources = [...]`。裸词 `linux` / `macos` / `windows` / `unix` 是对应 `os` / `family` 判定的糖。集合之外的键会被报成一条 schema 警告, 且该段不生效——它过去静默地求值为假,而那与「这一段本就不该匹配」 @@ -1148,6 +1149,37 @@ Windows 行([21](21-the-target-triple.md))。索引中还有 `xim:aarch64-li (见 [22 —— 目标侧](22-target-side.md))。这一段在 2026.9.1.1 之前写的是 「解析到的是哪份 C 库」,那是两者里错的那一个。 +### `layers.kernel-abi` —— 内核头文件(mcpp @RELEASE@+) + +Linux 的内核头文件与 C 库分开发布,因此在 Linux 的行上它们是 `kernel-abi` 层的预制供给者,可以陈述: + +```toml +[target.x86_64-linux-gnu.layers] +kernel-abi = "xim:linux-headers@6.18.64" # 生态的载荷,总是带版本 +# kernel-abi = { path = "third_party/uapi" } # 或一个头文件目录(其中没有 mcpp.toml) +``` + +陈述依次取自工程、本机的 `config.toml`、平台,按键替换;不论该行有没有平台都生效。没有陈述、且 C 库来自预制基座时, +构建取两个回答中的第一个:基座自带的头文件(陈述的 sysroot、工具链自带的 sysroot,如 `musl-gcc` 的,宿主的根),然后是 +工具链载荷所声明的版本(gcc 16.2.0 声明 6.18.64,捆绑的 LLVM 声明 5.11.1)。home 的共享视图不是回答:声明不同版本的工具链 +共用它。两者都没有时,构建在编译前被拒绝,并给出要写的陈述。 +`kernel-abi = false` 陈述构建没有这一层(独立环境的安排):不决定、也不测量头文件。 + +所用的头文件被测量,与 C 库相同:编译器以构建的搜索路径预处理一个包含 `` 的单元,报告写出结果: + +``` + Target x86_64-linux-gnu + kernel-abi linux 6.18.64 (xim:linux-headers@6.18.64, mcpp.toml:10, prebuilt) +``` + +测量与陈述的版本不符时拒绝。这些目录以 `-isystem` 交给每个单元与 std 模块,排在基座之前;供给者没有的头文件 +(``,由 glibc 发布)仍取自基座。带有各架构头文件(`arch/<架构>/include`,linux-headers 6.18.64 修订 1 与 +7.3.5)的载荷也服务交叉构建;只带安装它的机器的架构的载荷,用于其他架构时被拒绝,并给出补救。 + +这两种形式在不适用处被拒绝(`target-base`):macOS、Windows 与 FreeBSD 的内核接口属于基座(`sysroot`),其他层也不接受 +预制形式。openkal 的行上该层是 openkal 的实现,第二个供给者按规则一被拒绝。使用这两种形式的清单写出 +`[package] mcpp = ">=@RELEASE@"`;较旧的 mcpp 在没有平台的行上忽略该键。 + ### `abi` —— 整个产物共享的开关(mcpp 2026.9.12.2+) ```toml diff --git a/docs/zh/30-build-mcpp.md b/docs/zh/30-build-mcpp.md index d2e443df8..5a439c4d5 100644 --- a/docs/zh/30-build-mcpp.md +++ b/docs/zh/30-build-mcpp.md @@ -727,6 +727,28 @@ a.env("GEN_MODE", "release") 命令行,值改变时该 action 重新运行。两者都未声明的 action,其命令行与 protocol 12 逐字节 相同。 +#### 生成单元的编写文件:`.origin()`(@RELEASE@+) + +写出某个人工编辑文件之变换副本的 action(改写了 import 的源文件、加了前置内容的模块单元),以 +`.origin(...)` 指名该文件。该文件是 action 的输入之一,action 的角色为 `source`: + +```cpp +const std::string in = std::string(mcpp::manifest_dir()) + "/templates/core.cppm"; +a.role = mcpp::roles::source; +a.arg("rewrite").arg(in.c_str()).arg(out.c_str()) + .input(in.c_str()) + .origin(in.c_str()) + .output(out.c_str()) + .provides("app.core") + .submit(); +``` + +构建数据库以 `ide.generated[].origin` 陈述这一关系([50](50-machine-output.md)),编辑器据此把 +编写的文件显示为该单元的源。引擎不由输入推断这一关系。不在输入中的 `origin`,或陈述在其他角色 +action 上的 `origin`,在构建程序运行时被拒绝。在 `.provides(...)` 中声明某模块主名的单元是该模块 +的接口单元。编写的文件同时列在 `sources` 中时,二者都提供该模块,拒绝第二个提供者的错误写明这一 +关系。 + #### action 中的依赖程序:`${mcpp.artifact:}`(2026.9.27.1+) 带 `artifacts = [""]` 的依赖边为消费方的目标构建该程序([05](05-dependencies.md))。 diff --git a/docs/zh/35-platforms.md b/docs/zh/35-platforms.md index cf7188311..c41e350dc 100644 --- a/docs/zh/35-platforms.md +++ b/docs/zh/35-platforms.md @@ -93,6 +93,10 @@ runner = ["my-okrun", "{}"] 同样的表也可以写在 `~/.mcpp/config.toml` 中,对一台机器生效。图中已有包提供的层交给该包,报告为 `graph`。 C++ 运行时的包同时提供编译器运行时,因此 `"c++-abi" = false` 只有与 `compiler-runtime = false` 同时写出才生效。 +这些表在没有平台的行上同样生效(mcpp @RELEASE@):这样的行有一份空的平台陈述,为它写的 `layers`、`tools` 与 `link` +像在平台之上一样补全依赖图、到达链接。此前它们被接受而不起作用。`carrier` 是平台映像的形式,在这样的行上以警告报告 +(`platform/carrier`)而不使用。 + ## 选择平台,或不用平台 第一个给出答案的来源决定目标的平台: diff --git a/docs/zh/50-machine-output.md b/docs/zh/50-machine-output.md index 3701d8db8..87d0c12f0 100644 --- a/docs/zh/50-machine-output.md +++ b/docs/zh/50-machine-output.md @@ -524,7 +524,7 @@ mcpp why toolchain [--target ] [--toolchain ] --format json | `compiler` | `{family, version, driver, chosenBy}` —— 真正会运行的驱动器,以及选中它的原因 | | `triple` | `{requested, toolchain, llvm}` | | `cLibrary` | `{mode, path, origin, suppliesTarget}` —— `mode` 取 `sysroot` / `payload-first` / `none`,`origin` 取 `payload` / `subos` / `host` / `none` | -| `layers[]` | 目标侧的五个层:`{layer, interface, impl, origin, subset}` | +| `layers[]` | 目标侧的五个层:`{layer, interface, impl, origin, subset, version, interfaces}`;`version` 为系统把内核头文件作为包发布时 kernel-abi 层测得的版本(其他情形为空),`interfaces` 为该层的接口(`null`:未陈述,即全部)*(@RELEASE@+)* | **`compiler.chosenBy` 回答「为什么是它」。** `{origin, requiredBy, replaced}` —— `origin` 与构建的状态行使用的是同一句话 @@ -583,7 +583,7 @@ replaced}` —— `origin` 与构建的状态行使用的是同一句话 | `payload-request` | 构建程序请求了本次构建中没有任何清单声明 `provision = "on-request"` 的载荷,或连续三次运行都在请求 *(2026.10.1.3+)* | | `lto-export-discovery` | 导出需要被发现的 PE 共享库会被 cl.exe 编译成没有符号表的 `/GL` 对象:在 `lto = true` 下陈述了 `windows_auto_export = true`,或在它所链接的包的 flag 中写了 `/GL` *(2026.10.5.2+)* | | `local-toolchain` | 由路径命名的工具链,或构建程序工具链阶段陈述的工具链无法使用:没有驱动、族与驱动矛盾、缺少某个工具,或 `spec` 与只属于路径工具链的键一同陈述 *(2026.10.1.3+)* | -| `target-base` | 目标基座(`sysroot`)无法服务本次构建:该行不接受的写法、不存在的路径、不供给 C 库的目录、低于编译器运行库要求的 C 库、缺少 loader 的本机基座,或依赖图中的第二个 C 库供给者 *(2026.10.24.1+)* | +| `target-base` | 目标基座(`sysroot`)无法服务本次构建:该行不接受的写法、不存在的路径、不供给 C 库的目录、低于编译器运行库要求的 C 库、缺少 loader 的本机基座,或依赖图中的第二个 C 库供给者 *(2026.10.24.1+)*;内核头文件:不接受预制形式的行或层上写了 `layers` 的预制形式、载荷不带目标架构的头文件、缺省没有回答者、测量与陈述不符 *(@RELEASE@+)* | | `convention-unreplaced` | 约定被推翻了,而没有任何东西接替它 | | `os-mismatch` | 请求的三元组与解析出的三元组命名不同的系统 | | `layer-requirement` | 某个包要求的层,解析结果没有提供 | @@ -672,6 +672,8 @@ mcpp emit build-database [--spec s1|compile-commands] --format json (S1 0.3.0 §7.2)。命令不运行任何 action,所以这样的文件在文档所指的目录中尚不存在。 每一项给出同一组选择下 `mcpp build` 写入的路径(`build-path`)以及写出它的步骤, 编辑器因此可以说明“这是生成的文件,构建一次即可”,而不是报告缺少头文件。 +自 @RELEASE@ 起,`kind` 为 `source` 的一项在其 action 以 `.origin(...)` 陈述时另有 +`origin`([30](30-build-mcpp.md)):生成的单元作为其变换副本的那个编写的文件(S1 0.4.0 §7.2)。 `emit` 独立规划每一个被选中的成员(#699 第 1 项):一个成员的规划失败不会 连累它的兄弟成员。不在项目中,或者被选中的成员全部规划失败时,信封省略 diff --git a/docs/zh/91-toolchain-internals.md b/docs/zh/91-toolchain-internals.md index 5caad9da1..e1bbba660 100644 --- a/docs/zh/91-toolchain-internals.md +++ b/docs/zh/91-toolchain-internals.md @@ -25,7 +25,7 @@ resolve toolchain payload ← project/default/install paths share one pip ▼ ensure_declared_runtime() ← exact glibc@version installed; the payload is never written ▼ -detect / probe ← triple, sysroot, payload paths (glibc, linux-headers) +detect / probe ← triple, sysroot, payload paths (glibc) ▼ ToolchainLinkModel (single resolver for the C-library axis) ├──► flags.cppm (main build compile/link flags) @@ -70,7 +70,7 @@ triple 解析器,加上封闭的已知目标词汇表;`compat.cppm` 是唯 |---|---| | `targetTriple` | ` -dumpmachine` | | `sysroot` | `-print-sysroot`(经校验:必须真的带有 libc 头文件),并为烙有构建期路径、在本机不存在的 xlings 构建版 GCC 提供 remap 回退 | -| `payloadPaths` | 由已解析的 runtime binding(§2.1)精确指名 glibc payload;linux-headers 仍作为同级 payload 被发现。没有 binding 就没有 payload-first,这是设计使然 | +| `payloadPaths` | 由已解析的 runtime binding(§2.1)精确指名 glibc payload。没有 binding 就没有 payload-first,这是设计使然。内核头文件在目标侧之后决定(`base.kernel`,即 kernel-abi 层),在每种模式下接在基座之前 | | runtime dirs | 工具链私有的 lib 目录,供产物的 `-L`/`-rpath` 使用 | 注意,probe 刻意**不再**从 clang cfg 中挖 `--sysroot`:cfg 是这套机制的输出, diff --git a/modules/buildmcpp/src/directives.cppm b/modules/buildmcpp/src/directives.cppm index 66bfb81c0..90bf1b2bf 100644 --- a/modules/buildmcpp/src/directives.cppm +++ b/modules/buildmcpp/src/directives.cppm @@ -1371,7 +1371,13 @@ std::optional decode_action(std::string_view payloa if (auto eq = e.find('='); eq == std::string::npos || eq == 0) return std::nullopt; a.cwd = j.value("cwd", std::string{}); + a.origin = j.value("origin", std::string{}); if (a.command.empty() || a.outputs.empty()) return std::nullopt; + // mcpp#1004: the origin is one of the inputs, of a source action. + if (!a.origin.empty() + && (a.role != mcpp::manifest::BuildAction::Role::Source + || std::ranges::find(a.inputs, a.origin) == a.inputs.end())) + return std::nullopt; // Prepare only: `output_dir` is the whole point of the role (R3.2, // R3.3) -- a `prepare` action with none declared would have a stamp // and nothing else, indistinguishable from a `check` that merely @@ -1663,6 +1669,23 @@ std::string action_error(const Directives& d) { "for the action's command; the name may not be empty.\n" " payload: {}", v, payload); } + if (auto it = j.find("origin"); it != j.end() && it->is_string()) { + const auto origin = it->get(); + const bool source = j.value("role", std::string("source")) == "source"; + bool input = false; + if (auto in = j.find("inputs"); in != j.end() && in->is_array()) + for (auto const& v : *in) input = input || (v.is_string() && v.get() == origin); + if (!source || !input) + return std::format( + "build.mcpp declared an action whose origin \"{}\" {}.\n" + " mcpp::action::origin(path) names the authored source a `source` " + "action's output is a\n" + " transformed copy of, and that file is one of the action's " + "inputs (`input(path)`).\n" + " payload: {}", origin, + source ? "is not one of its inputs" : "is stated on an action whose role is not source", + payload); + } } catch (...) {} // A malformed action is a hard error, never a skip: an action that // silently does not exist produces a build missing generated sources, diff --git a/modules/manifest/src/platform.cppm b/modules/manifest/src/platform.cppm index 174d02fe8..e775b1ae0 100644 --- a/modules/manifest/src/platform.cppm +++ b/modules/manifest/src/platform.cppm @@ -78,10 +78,15 @@ struct PackageRef { std::string program; // `layers. = false`: the platform provides no package for the layer. bool off = false; + // `layers. = "xim:@"`: an ecosystem payload, a + // prebuilt supplier of the layer and not a package of the graph (design + // 2026-11-22 §3.1); the reference as written, which `companions` spells + // the same way. + std::string payload; bool empty() const { return name.empty() && program.empty() && !off && spec.path.empty() - && spec.git.empty() && spec.version.empty(); + && spec.git.empty() && spec.version.empty() && payload.empty(); } }; @@ -265,8 +270,8 @@ struct RowSpec { 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, linkWithoutMain; - bool standard = true, exact = false, exeSuffixFixed = false; + std::vector flags, descriptorKeys, companions, linkWithoutMain, interfaces; + bool standard = true, exact = false, exeSuffixFixed = false, interfacesStated = false; Origin origin; }; @@ -303,6 +308,18 @@ struct SystemSpec { std::vector commandScripts; // What the system's rows share unless a row states its own. std::string objectFormat, exeSuffix, sharedSuffix; + // The kernel headers as a package of their own (SPEC-016 §2.3): how a + // probe measures them and a payload's layout; `header` empty: none. + struct KernelAbi { + std::string header; + std::vector version; + std::string packed; + std::vector bits; + std::string include, archInclude, package; + } kernelAbi; + // The interfaces the system provides (`cfg(interface = …)`). + std::vector interfaces; + bool interfacesStated = false; Origin origin; }; @@ -397,7 +414,7 @@ inline constexpr std::string_view kDefineKeys[] = { "triple", "tier", "note", "standard", "exact", "clang-triple", "gcc-triple", "object-format", "family", "data-model", "exe-suffix", "shared-suffix", "loader", "execution", "march", "mabi", "code-model", "multilib", "flags", "link-emulation", "descriptor-keys", "companions", "exceptions", - "exe-suffix-fixed", "link-without-main", + "exe-suffix-fixed", "link-without-main", "interfaces", }; inline constexpr std::string_view kProviderKeys[] = { "name", "serves", "priority", "hosts", "pairs", "toolchain", "sysroot", "linkage", "base", @@ -405,6 +422,10 @@ inline constexpr std::string_view kProviderKeys[] = { }; inline constexpr std::string_view kSystemKeys[] = { "name", "uname", "resources", "command-scripts", "object-format", "exe-suffix", "shared-suffix", + "kernel-abi", "interfaces", +}; +inline constexpr std::string_view kSystemKernelAbiKeys[] = { + "header", "version", "packed", "include", "arch-include", "package", }; inline constexpr std::string_view kBuildKeys[] = { "cflags", "cxxflags", "asmflags", "ldflags" }; inline constexpr std::string_view kLinkKeys[] = { @@ -458,6 +479,16 @@ inline std::expected parse_ref_text(std::string_view te return r; } const auto at = text.rfind('@'); + // AN ECOSYSTEM PAYLOAD (`xim:linux-headers@6.18.64`): named by its index + // and always with its version, the rule `companions` states. + if (const auto colon = text.find(':'); colon != std::string_view::npos && colon < at) { + if (colon == 0 || at == std::string_view::npos || at == colon + 1 || at + 1 == text.size()) + return std::unexpected(std::format( + "'{}' names a payload without its version; write \":@\", " + "for example \"xim:linux-headers@6.18.64\"", text)); + r.payload = std::string(text); + return r; + } if (at == std::string_view::npos || at == 0 || at + 1 == text.size()) return std::unexpected(std::format( "'{}' is not a package reference; write \"@\", for example " @@ -480,6 +511,7 @@ inline std::expected parse_ref_text(std::string_view te // `openkal-musl (path ../openkal-musl)`, `okrun (program)`. inline std::string display(const PackageRef& r) { if (r.off) return "false"; + if (!r.payload.empty()) return r.payload; if (!r.program.empty()) return std::format("{} (program)", r.program); std::string n = r.spec.shortName.empty() ? r.name : r.spec.shortName; if (!r.spec.path.empty()) diff --git a/modules/manifest/src/platform_toml.cppm b/modules/manifest/src/platform_toml.cppm index 1b4066ebd..d24a49b13 100644 --- a/modules/manifest/src/platform_toml.cppm +++ b/modules/manifest/src/platform_toml.cppm @@ -66,6 +66,10 @@ struct Reader { std::expected, std::string> carriers(const mcpp::libs::toml::Value& v, std::string_view where) const; + // A system's `kernel-abi` table: the measurement and the payload layout. + std::expected + system_kernel_abi(const mcpp::libs::toml::Value& v, std::string_view where) const; + // A list of `-` pairs (`runner.hosts`, `carrier.hosts`). std::expected, std::string> host_pairs(const mcpp::libs::toml::Value& v, std::string_view where) const; @@ -165,6 +169,12 @@ Reader::ref(const toml::Value& v, std::string_view where, bool allowOff, bool al if (v.is_string()) { auto parsed = parse_ref_text(v.as_string()); if (!parsed) return std::unexpected(std::format("{}: {}", where, parsed.error())); + // A payload supplies a layer; a platform, a tool or a carrier is a + // package of the graph. + if (!parsed->payload.empty() && !allowOff) + return std::unexpected(std::format( + "{}: '{}' is an ecosystem payload, which supplies a target-side layer; name a " + "package here (\"@\")", where, parsed->payload)); return std::move(*parsed); } if (!v.is_table()) @@ -524,6 +534,53 @@ Reader::tools(const toml::Value& v, std::string_view where, return {}; } +std::expected +Reader::system_kernel_abi(const toml::Value& v, std::string_view where) const { + if (!v.is_table()) return std::unexpected(std::format("{} must be a table", where)); + SystemSpec::KernelAbi k; + for (auto const& [kk, kv] : v.as_table()) { + const auto key = std::format("{}.{}", where, kk); + if (!contains(kSystemKernelAbiKeys, kk)) + return std::unexpected(std::format("{}: not a key of kernel-abi; the keys are {}", key, + list_of(kSystemKernelAbiKeys))); + if (kk == "version") { + auto w = strings(kv, key); + if (!w) return std::unexpected(w.error()); + k.version = std::move(*w); + } else if (kk == "packed") { + if (!kv.is_table()) return std::unexpected(std::format("{} must be {{ macro, bits }}", key)); + for (auto const& [pk, pv] : kv.as_table()) { + if (pk == "macro" && pv.is_string()) { k.packed = pv.as_string(); continue; } + if (pk == "bits" && pv.is_array()) { + for (auto const& b : pv.as_array()) { + if (!b.is_int() || b.as_int() <= 0 || b.as_int() > 32) + return std::unexpected(std::format("{}.bits holds widths from 1 to 32", key)); + k.bits.push_back(static_cast(b.as_int())); + } + continue; + } + return std::unexpected(std::format("{}: {{ macro = \"\", bits = [, ...] }}", key)); + } + if (k.packed.empty() || k.bits.empty()) + return std::unexpected(std::format("{}: `macro` and `bits` are stated together", key)); + } else { + if (!kv.is_string() || kv.as_string().empty()) + return std::unexpected(std::format("{} must be a non-empty string", key)); + (kk == "header" ? k.header : kk == "include" ? k.include + : kk == "package" ? k.package : k.archInclude) = kv.as_string(); + } + } + if (k.header.empty()) + return std::unexpected(std::format("{}: `header` names the header a probe includes", where)); + if (k.version.empty() && k.packed.empty()) + return std::unexpected(std::format("{}: `version` or `packed` says how the version is read", where)); + if (!k.version.empty() && !k.bits.empty() && k.version.size() != k.bits.size()) + return std::unexpected(std::format("{}: `version` and `packed.bits` name the same parts", where)); + if (!k.archInclude.empty() && k.archInclude.find("{arch}") == std::string::npos) + return std::unexpected(std::format("{}.arch-include names the architecture as {{arch}}", where)); + return k; +} + std::expected, std::string> Reader::host_pairs(const toml::Value& v, std::string_view where) const { auto w = strings(v, where); @@ -630,12 +687,13 @@ std::expected Reader::define(const toml::Table& t, std::st if (auto e = text(key, *to); !e) return std::unexpected(e.error()); for (auto [key, to] : std::initializer_list*>>{ {"flags", &r.flags}, {"descriptor-keys", &r.descriptorKeys}, {"companions", &r.companions}, - {"link-without-main", &r.linkWithoutMain}}) + {"link-without-main", &r.linkWithoutMain}, {"interfaces", &r.interfaces}}) if (auto it = t.find(key); it != t.end()) { auto w = strings(it->second, std::format("{}.{}", where, key)); if (!w) return std::unexpected(w.error()); *to = std::move(*w); } + r.interfacesStated = t.find("interfaces") != t.end(); for (auto [key, to] : std::initializer_list>{ {"standard", &r.standard}, {"exact", &r.exact}, {"exe-suffix-fixed", &r.exeSuffixFixed}}) if (auto it = t.find(key); it != t.end()) { @@ -848,6 +906,19 @@ std::expected Reader::statement(const toml::Table& t) co sys.resources = sv.as_bool(); continue; } + if (sk == "interfaces") { + auto w = strings(sv, std::format("{}.interfaces", where)); + if (!w) return std::unexpected(w.error()); + sys.interfaces = std::move(*w); + sys.interfacesStated = true; + continue; + } + if (sk == "kernel-abi") { + auto r = system_kernel_abi(sv, std::format("{}.kernel-abi", where)); + if (!r) return std::unexpected(r.error()); + sys.kernelAbi = std::move(*r); + continue; + } if (!sv.is_string()) return std::unexpected(std::format("{}.{} must be a string", where, sk)); (sk == "name" ? sys.name : sk == "uname" ? sys.uname diff --git a/modules/manifest/src/targetside_model.cppm b/modules/manifest/src/targetside_model.cppm index 21c2d2f32..eabd9646f 100644 --- a/modules/manifest/src/targetside_model.cppm +++ b/modules/manifest/src/targetside_model.cppm @@ -248,6 +248,13 @@ struct Layer { // The package was added to the graph by the target's platform (SPEC-013 // §4.3): still a graph package, reported as the platform's. bool byPlatform = false; + // The kernel-abi layer's measured version, where its headers are a + // package of the system's (design 2026-11-22 §3.4, §3.8): "6.18.64". + std::string version; + // The kernel-abi layer's interfaces (`cfg(interface = …)`, §3.17): its + // provider's statement, or the system's; unstated, every interface. + std::vector interfaces; + bool interfacesStated = false; bool absent() const { return origin == Origin::None; } bool prebuilt() const { return origin == Origin::Payload || origin == Origin::Xpkg; } @@ -1102,12 +1109,14 @@ inline std::string format_layers(const TargetSide& ts, bool verbose) { // rows read as a table rather than as a list of sentences. const std::string_view from = l.byPlatform ? std::string_view("platform") : origin_name(l.origin); + const auto shown = l.version.empty() ? l.interfaceName + : std::format("{} {}", l.interfaceName, l.version); if (l.impl.empty()) out += std::format("{}{:<17} {:<14} ({}{})\n", kIndent, label, - l.interfaceName, from, suffix); + shown, from, suffix); else out += std::format("{}{:<17} {:<14} ({}, {}{})\n", kIndent, label, - l.interfaceName, l.impl, from, suffix); + shown, l.impl, from, suffix); } return out; } diff --git a/modules/manifest/src/types.cppm b/modules/manifest/src/types.cppm index 92aa57a8b..3d8fdfcb1 100644 --- a/modules/manifest/src/types.cppm +++ b/modules/manifest/src/types.cppm @@ -119,6 +119,9 @@ struct Language { struct ScanOverride { std::vector provides; // module logical names the file exports std::vector imports; // module logical names the file imports + // An action's generated unit: the authored source it is a transformed + // copy of (mcpp#1004); empty otherwise. + std::string origin; }; struct Modules { @@ -836,6 +839,10 @@ struct BuildAction { // once `prepare_actions` has run; a relative spelling names a directory // of the declaring package (SPEC-007 R2.2). std::string cwd; + // The authored source the outputs are a transformed copy of (mcpp#1004), + // one of `inputs`; Source role only. Empty: unstated, and nothing is + // inferred from the inputs. + std::string origin; }; // `[resources]` — metadata and assets compiled INTO the produced artifact diff --git a/modules/toolchain-model/build.mcpp b/modules/toolchain-model/build.mcpp index a8f2b853e..2a31aa4b8 100644 --- a/modules/toolchain-model/build.mcpp +++ b/modules/toolchain-model/build.mcpp @@ -18,7 +18,7 @@ constexpr std::string_view kRowKeys[] = { "triple", "tier", "note", "standard", "exact", "march", "mabi", "code-model", "multilib", "flags", "link-emulation", "clang-triple", "gcc-triple", "family", "object-format", "data-model", "exe-suffix", "shared-suffix", "loader", "execution", "companions", "exceptions", "exe-suffix-fixed", - "link-without-main", + "link-without-main", "interfaces", }; constexpr std::string_view kProviderKeys[] = { "name", "serves", "priority", "hosts", "probe", "toolchain", "pairs", "sysroot", "linkage", @@ -27,7 +27,10 @@ constexpr std::string_view kProviderKeys[] = { constexpr std::string_view kRunnerKeys[] = { "cmd", "host", "hosts", "requires", "enabled", "exclusive" }; constexpr std::string_view kSystemKeys[] = { "name", "uname", "resources", "command-scripts", "object-format", "exe-suffix", "shared-suffix", + "kernel-abi", "interfaces", }; +constexpr std::string_view kKernelAbiKeys[] = { "header", "version", "packed", "include", "arch-include", "package" }; +constexpr std::string_view kPackedKeys[] = { "macro", "bits" }; constexpr std::string_view kObjectFormats[] = { "elf", "mach-o", "pe", "wasm", "coff" }; constexpr std::string_view kExecutesKeys[] = { "host", "arches" }; constexpr std::string_view kPayloadKeys[] = { @@ -89,6 +92,14 @@ struct Arrays { decls += "};\n"; return "d::" + name; } + std::string add_ints(const std::vector& v) { + if (v.empty()) return "{}"; + auto name = std::format("a{}", n++); + decls += std::format("inline constexpr int {}[] = {{", name); + for (std::size_t i = 0; i < v.size(); ++i) decls += std::format("{}{}", i ? ", " : "", v[i]); + decls += "};\n"; + return "d::" + name; + } }; std::string row_entry(const toml::Table& t, Arrays& arrays, std::set& seen) { @@ -136,7 +147,7 @@ std::string row_entry(const toml::Table& t, Arrays& arrays, std::set& rows) { @@ -216,6 +228,50 @@ std::string provider_entry(const toml::Table& t, Arrays& arrays, const std::set< runnerEnabled, runnerExclusive); } +// A system's `kernel-abi` table (design 2026-11-22 §3.4): how a probe measures +// the kernel headers in effect, and a payload's layout. The version is read +// from the parts' macros, else decoded from the packed macro by its widths. +std::string kernel_abi_entry(const toml::Table& sys, Arrays& arrays, std::string_view systemWhere) { + auto it = sys.find("kernel-abi"); + if (it == sys.end()) return "{}"; + const auto where = std::format("{}.kernel-abi", systemWhere); + if (!it->second.is_table()) throw Failure{std::format("{}: not a table", where)}; + auto const& t = it->second.as_table(); + known_keys(t, kKernelAbiKeys, where); + const auto header = text(t, "header", where); + if (header.empty()) throw Failure{std::format("{}: `header` names the header a probe includes", where)}; + const auto version = words(t, "version", where); + std::string packedMacro; + std::vector bits; + if (auto p = t.find("packed"); p != t.end()) { + const auto pwhere = std::format("{}.packed", where); + if (!p->second.is_table()) throw Failure{std::format("{}: not a table", pwhere)}; + known_keys(p->second.as_table(), kPackedKeys, pwhere); + packedMacro = text(p->second.as_table(), "macro", pwhere); + if (auto b = p->second.as_table().find("bits"); b != p->second.as_table().end()) { + if (!b->second.is_array()) throw Failure{std::format("{}: `bits` is not an array", pwhere)}; + for (auto const& v : b->second.as_array()) { + if (!v.is_int() || v.as_int() <= 0 || v.as_int() > 32) + throw Failure{std::format("{}: `bits` holds widths from 1 to 32", pwhere)}; + bits.push_back(static_cast(v.as_int())); + } + } + if (packedMacro.empty() || bits.empty()) + throw Failure{std::format("{}: `macro` and `bits` are stated together", pwhere)}; + } + if (version.empty() && packedMacro.empty()) + throw Failure{std::format("{}: `version` or `packed` says how the version is read", where)}; + if (!version.empty() && !bits.empty() && version.size() != bits.size()) + throw Failure{std::format("{}: `version` and `packed.bits` name the same parts", where)}; + const auto archInclude = text(t, "arch-include", where); + if (!archInclude.empty() && archInclude.find("{arch}") == std::string::npos) + throw Failure{std::format("{}: `arch-include` names the architecture as {{arch}}", where)}; + return std::format("{{ .header = {}, .version = {}, .packed = {}, .bits = {}, .include = {}, .archInclude = {}, " + ".package = {} }}", + lit(header), arrays.add(version), lit(packedMacro), arrays.add_ints(bits), + lit(text(t, "include", where)), lit(archInclude), lit(text(t, "package", where))); +} + std::string system_entry(const toml::Table& t, Arrays& arrays, std::set& seen) { known_keys(t, kSystemKeys, "[[platform.system]]"); const auto name = text(t, "name", "[[platform.system]]"); @@ -230,11 +286,15 @@ std::string system_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 65f9fc2d9..460ed9964 100644 --- a/modules/toolchain-model/data/builtin.toml +++ b/modules/toolchain-model/data/builtin.toml @@ -105,6 +105,28 @@ # 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 +# kernel-abi the system's kernel headers are a package apart from its C +# library: how a probe measures them and how a payload lays +# them out. Its rows accept a prebuilt `kernel-abi` statement +# (`[target..layers] kernel-abi`); a system without +# the table has its kernel interface in one SDK or base with +# its C library, and refuses one. +# header the header the probe includes +# version the macros of the version's parts, most significant first +# packed { macro, bits }: the packed version and its parts' widths, +# read when the macros above are absent; a part at its +# width's maximum is saturated and not compared +# include a payload's headers common to every architecture +# arch-include a payload's headers of one architecture, `{arch}` the +# target's, searched first; a payload without them serves +# its host's architecture only +# package the ecosystem package of the headers, which a toolchain's +# payload declares (the headers its runtime was built with) +# interfaces the interfaces the system provides, in openkal's names: the +# answer of `cfg(interface = "")` where the kernel-abi +# layer is the system itself; unstated, every interface. A row +# states its own where its C library or its system narrows +# them for it, read first # # 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`; @@ -464,12 +486,26 @@ triple = "aarch64-ios" object-format = "mach-o" tier = "preview" standard = true +# An application of iOS starts no program and maps no code it writes (the +# system's sandbox): the system's interfaces without openkal.process and +# openkal.exec. +interfaces = ["openkal.abort", "openkal.stream", "openkal.memory", "openkal.env", "openkal.time", + "openkal.random", "openkal.fs", "openkal.task", "openkal.terminal", "openkal.net", + "openkal.datagram", "openkal.space", "openkal.timeout", "openkal.map", "openkal.region", + "openkal.prof", "openkal.debug"] [[platform.define]] triple = "aarch64-ios-sim" object-format = "mach-o" tier = "verified" standard = true +# An application of iOS starts no program and maps no code it writes (the +# system's sandbox): the system's interfaces without openkal.process and +# openkal.exec. +interfaces = ["openkal.abort", "openkal.stream", "openkal.memory", "openkal.env", "openkal.time", + "openkal.random", "openkal.fs", "openkal.task", "openkal.terminal", "openkal.net", + "openkal.datagram", "openkal.space", "openkal.timeout", "openkal.map", "openkal.region", + "openkal.prof", "openkal.debug"] [[platform.define]] triple = "x86_64-ios-sim" @@ -480,6 +516,14 @@ standard = true # A new arch, a new os and a new object format; `em++` links `import std` with # the standard library surface the toolchain ships. One module plus its # JavaScript, no shared objects. +# An application of iOS starts no program and maps no code it writes (the +# system's sandbox): the system's interfaces without openkal.process and +# openkal.exec. +interfaces = ["openkal.abort", "openkal.stream", "openkal.memory", "openkal.env", "openkal.time", + "openkal.random", "openkal.fs", "openkal.task", "openkal.terminal", "openkal.net", + "openkal.datagram", "openkal.space", "openkal.timeout", "openkal.map", "openkal.region", + "openkal.prof", "openkal.debug"] + [[platform.define]] triple = "wasm32-emscripten" tier = "verified" @@ -505,6 +549,11 @@ 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. +# Emscripten's C library serves files from its own file systems and starts no +# program. +interfaces = ["openkal.abort", "openkal.stream", "openkal.memory", "openkal.env", "openkal.time", + "openkal.random", "openkal.fs"] + [[platform.define]] triple = "x86_64-openkal" exe-suffix = ".oke" @@ -731,17 +780,35 @@ system-headers = "xim:mingw-w64-sysroot@20261104-2" # ── Systems ────────────────────────────────────────────────────────────────── [[platform.system]] -name = "linux" -uname = "Linux" +name = "linux" +uname = "Linux" +interfaces = ["openkal.abort", "openkal.stream", "openkal.memory", "openkal.env", "openkal.time", + "openkal.random", "openkal.fs", "openkal.process", "openkal.task", "openkal.exec", + "openkal.terminal", "openkal.net", "openkal.datagram", "openkal.space", "openkal.timeout", + "openkal.map", "openkal.region", "openkal.prof", "openkal.debug"] +kernel-abi.header = "linux/version.h" +kernel-abi.version = ["LINUX_VERSION_MAJOR", "LINUX_VERSION_PATCHLEVEL", "LINUX_VERSION_SUBLEVEL"] +kernel-abi.packed = { macro = "LINUX_VERSION_CODE", bits = [16, 8, 8] } +kernel-abi.include = "include" +kernel-abi.arch-include = "arch/{arch}/include" +kernel-abi.package = "linux-headers" [[platform.system]] name = "macos" uname = "Darwin" object-format = "mach-o" +interfaces = ["openkal.abort", "openkal.stream", "openkal.memory", "openkal.env", "openkal.time", + "openkal.random", "openkal.fs", "openkal.process", "openkal.task", "openkal.exec", + "openkal.terminal", "openkal.net", "openkal.datagram", "openkal.space", "openkal.timeout", + "openkal.map", "openkal.region", "openkal.prof", "openkal.debug"] [[platform.system]] name = "freebsd" uname = "FreeBSD" +interfaces = ["openkal.abort", "openkal.stream", "openkal.memory", "openkal.env", "openkal.time", + "openkal.random", "openkal.fs", "openkal.process", "openkal.task", "openkal.exec", + "openkal.terminal", "openkal.net", "openkal.datagram", "openkal.space", "openkal.timeout", + "openkal.map", "openkal.region", "openkal.prof", "openkal.debug"] # A Windows program is not selected by `uname`: it leads the file. [[platform.system]] @@ -749,6 +816,11 @@ name = "windows" object-format = "pe" resources = true command-scripts = [".bat", ".cmd"] +interfaces = ["openkal.abort", "openkal.stream", "openkal.memory", "openkal.env", "openkal.time", + "openkal.random", "openkal.fs", "openkal.process", "openkal.task", "openkal.exec", + "openkal.terminal", "openkal.net", "openkal.datagram", "openkal.space", "openkal.timeout", + "openkal.map", "openkal.region", "openkal.prof", "openkal.debug"] + # ── Execution relations ────────────────────────────────────────────────────── # diff --git a/modules/toolchain-model/src/base.cppm b/modules/toolchain-model/src/base.cppm index 3d3334421..3cbc54745 100644 --- a/modules/toolchain-model/src/base.cppm +++ b/modules/toolchain-model/src/base.cppm @@ -339,6 +339,81 @@ inline std::map> parse_defines(std::string return m; } +// THE KERNEL HEADERS' VERSION (design 2026-11-22 §3.4), read from the defines +// a probe unit that includes the system's header printed. The parts' macros +// answer when every one is defined (Linux from 5.15: LINUX_VERSION_MAJOR, …); +// otherwise the packed macro is decoded by the widths the system states +// (LINUX_VERSION_CODE, 16.8.8 bits). A part at its width's maximum is +// saturated: the packing cannot say more (linux 4.19.256 packs as 4.19.255), +// so a comparison skips it. The widths are data; this decodes only. +struct KernelVersion { + std::vector parts; + std::vector saturated; // per part + std::string text() const { + std::string s; + for (std::size_t i = 0; i < parts.size(); ++i) s += std::format("{}{}", i ? "." : "", parts[i]); + return s; + } +}; + +inline std::optional decimal_value(std::string_view v) { + while (!v.empty() && (v.front() == '(' || v.front() == ' ')) v.remove_prefix(1); + while (!v.empty() && (v.back() == ')' || v.back() == ' ' || v.back() == 'U' || v.back() == 'L')) + v.remove_suffix(1); + if (v.empty()) return std::nullopt; + unsigned out = 0; + auto [p, ec] = std::from_chars(v.data(), v.data() + v.size(), out); + if (ec != std::errc{} || p != v.data() + v.size()) return std::nullopt; + return out; +} + +inline std::optional +kernel_version(const std::map>& defines, + std::span partMacros, std::string_view packedMacro, + std::span bits) { + KernelVersion kv; + for (auto name : partMacros) { + auto it = defines.find(name); + auto v = it == defines.end() ? std::nullopt : decimal_value(it->second); + if (!v) { kv.parts.clear(); break; } + kv.parts.push_back(*v); + } + if (!partMacros.empty() && kv.parts.size() == partMacros.size()) { + kv.saturated.assign(kv.parts.size(), false); + return kv; + } + kv.parts.clear(); + if (packedMacro.empty() || bits.empty()) return std::nullopt; + auto it = defines.find(packedMacro); + auto code = it == defines.end() ? std::nullopt : decimal_value(it->second); + if (!code) return std::nullopt; + int shift = 0; + for (auto b : bits) shift += b; + for (auto b : bits) { + shift -= b; + const unsigned max = b >= 32 ? 0xffffffffu : ((1u << b) - 1u); + const unsigned part = static_cast((static_cast(*code) >> shift) & max); + kv.parts.push_back(part); + kv.saturated.push_back(part == max); + } + return kv; +} + +// Whether a measured version is the stated one, to the measurement's +// precision: each part the measurement holds and did not saturate is equal. +inline bool kernel_version_matches(const KernelVersion& measured, std::string_view stated) { + std::size_t i = 0; + while (!stated.empty() && i < measured.parts.size()) { + const auto dot = stated.find('.'); + const auto part = decimal_value(stated.substr(0, dot)); + if (!part) return false; + if (!measured.saturated[i] && *part != measured.parts[i]) return false; + stated = dot == std::string_view::npos ? std::string_view{} : stated.substr(dot + 1); + ++i; + } + return i > 0; +} + // THE DEBIAN MULTIARCH TUPLE, from Debian's MultiarchTuples table. This is the // one piece of layout knowledge the engine carries (D10): it is specified, and // a gcc built without multiarch support cannot find `crt1.o` in a Debian or @@ -418,7 +493,21 @@ struct AppleSdk { struct PayloadPaths { std::filesystem::path glibcInclude; // glibc headers (features.h, bits/) std::filesystem::path glibcLib; // glibc runtime (libc.so, crt*.o, ld-linux) - std::filesystem::path linuxInclude; // linux kernel headers (linux/, asm/) +}; + +// THE KERNEL HEADERS OF A SYSTEM THAT PUBLISHES THEM APART FROM ITS C LIBRARY +// (design 2026-11-22 §3.3-§3.5; SPEC-002 §3.3): the prebuilt supplier of the +// kernel-abi layer on a Linux row, or the headers of the base when the base +// carries its own. Decided once, after the target side, by one function; +// `dirs` are wired with -isystem ahead of the base, so every unit, the std +// module and glibc's own includes read them. +struct KernelHeaders { + // Searched first to last ahead of the base; empty: the base's own. + std::vector dirs; + std::string version; // measured: "6.18.64" + std::string supplier; // "xim:linux-headers@6.18.64", "path ", "the base", … + std::string source; // the tier or the default that decided it + bool decided() const { return !version.empty(); } }; // THE ONE ANSWER. Every reader of "which sysroot" reads a field of this — the @@ -456,8 +545,9 @@ struct Resolution { // for a binding (which names `loader`) and for a static link. std::string interpreter; std::vector runtimeDirs; - // Kernel headers the base lacks, supplied by the engine (§2.4, additive). - std::vector addedIncludes; + // The kernel headers in effect, on a system that publishes them as a + // package (`KernelHeaders`). + KernelHeaders kernel; // Content identity: enters the runtime contract and so the fingerprint. // Empty for the ecosystem default, whose identity is the contract itself. std::string identity; diff --git a/modules/toolchain-model/src/linkmodel.cppm b/modules/toolchain-model/src/linkmodel.cppm index 2eaf166fd..1eec10934 100644 --- a/modules/toolchain-model/src/linkmodel.cppm +++ b/modules/toolchain-model/src/linkmodel.cppm @@ -82,8 +82,16 @@ struct ToolchainLinkModel { // LLVM 23.1.3 Part 3 §2.5). std::filesystem::path headerSysroot; - // Compile-side C library / kernel headers (payload dirs, or the - // linux-headers supplement for a sysroot that lacks them). + // THE KERNEL HEADERS (design 2026-11-22 §3.5): the kernel-abi layer's + // prebuilt supplier, or the toolchain's declaration over a base without + // its own. `-isystem` on every driver and in every mode, ahead of the + // base's directories: clang and gcc search `-isystem` before the + // sysroot's system directories and continue past it file by file, so a + // header the supplier lacks (``, glibc's) is the base's. No + // C++ header wraps these, so `-idirafter`'s reason below does not apply. + std::vector kernelIncludes; + + // Compile-side C library headers (payload dirs). std::vector systemIncludes; // DEBIAN MULTIARCH, FOR A DRIVER THAT DOES NOT KNOW IT (design 2026-10-23 @@ -116,6 +124,8 @@ struct ToolchainLinkModel { // Compile-side flags as argv tokens. Each entry is ONE argv word. std::vector compile_tokens(const PathEscape& esc) const { std::vector out; + for (auto& inc : kernelIncludes) + out.push_back("-isystem" + esc(inc)); // A managed libc supplies the complete system header surface. Keep // Clang's resource headers while refusing an ambient /usr/include // fallback, including when the driver cfg is explicitly bypassed. @@ -130,8 +140,8 @@ struct ToolchainLinkModel { // PayloadFirst headers: clang takes -isystem; GCC needs -idirafter so // libstdc++'s #include_next wrappers (which only search *after* the // current dir, and GCC's built-ins are last) can still reach libc. - // A Sysroot-mode supplement (kernel headers missing from the sysroot) - // is -isystem for both: the libc headers come from the sysroot there. + // In Sysroot mode these are -isystem for both: the libc headers come + // from the sysroot there. const char* incFlag = (mode == CLibMode::Sysroot || clangDriver) ? "-isystem" : "-idirafter"; for (auto& inc : systemIncludes) @@ -480,6 +490,10 @@ ClangDriverModel resolve_clang_driver(const Toolchain& tc) { ToolchainLinkModel resolve_link_model(const Toolchain& tc) { ToolchainLinkModel lm; + // The kernel headers ahead of the base: one wiring for every mode below, a + // toolchain's own sysroot included (a native musl toolchain's headers are + // replaced the same way), and nothing where none were decided. + lm.kernelIncludes = tc.base.kernel.dirs; lm.clangDriver = is_clang(tc); lm.clangWithCfg = resolve_clang_driver(tc).hasCfg; @@ -556,8 +570,6 @@ ToolchainLinkModel resolve_link_model(const Toolchain& tc) { lm.systemIncludes.push_back(pp.glibcInclude); if (!lm.clangDriver && !pp.glibcInclude.empty()) lm.headerSysroot = pp.glibcInclude.parent_path(); - if (!pp.linuxInclude.empty()) - lm.systemIncludes.push_back(pp.linuxInclude); // Resolved for both drivers now that both emit it. lm.loader = resolve_loader(pp.glibcLib, tc.targetTriple); }; @@ -592,7 +604,6 @@ ToolchainLinkModel resolve_link_model(const Toolchain& tc) { lm.multiarchLibDirs.push_back(root / "lib" / tc.base.multiarchTuple); } add_compiler_runtime_dir(); - for (auto const& inc : tc.base.addedIncludes) lm.systemIncludes.push_back(inc); return; } // Name the interpreter even here: see link_tokens. The payload is the @@ -620,13 +631,6 @@ ToolchainLinkModel resolve_link_model(const Toolchain& tc) { lm.libDirs.push_back(tc.base.payload->glibcLib); } add_compiler_runtime_dir(); - // Supplement kernel headers when the sysroot lacks them (glibc's - // local_lim.h needs ). Self-contained musl sysroots - // ship their own; a cross target must not see host-arch headers. - if (!is_musl_target(tc) && tc.base.payload - && !tc.base.payload->linuxInclude.empty() - && !std::filesystem::exists(root / "usr" / "include" / "linux" / "limits.h")) - lm.systemIncludes.push_back(tc.base.payload->linuxInclude); }; // A target that parses and is not Mach-O; a target that says nothing is the diff --git a/modules/toolchain-model/src/target_rows.cppm b/modules/toolchain-model/src/target_rows.cppm index 62699a902..e392145d7 100644 --- a/modules/toolchain-model/src/target_rows.cppm +++ b/modules/toolchain-model/src/target_rows.cppm @@ -25,6 +25,7 @@ struct DefinitionSet { bool provisional = false; std::deque strings; // stable addresses std::deque> lists; + std::deque> numbers; std::vector rows; std::vector providers; std::vector systems; @@ -35,6 +36,7 @@ struct DefinitionSet { for (auto const& s : v) out.push_back(keep(s)); return out; } + std::span keep(const std::vector& v) { return numbers.emplace_back(v); } }; // Registers a platform's definitions. A row the table or an earlier set already diff --git a/modules/toolchain-model/src/target_schema.cppm b/modules/toolchain-model/src/target_schema.cppm index 350d0502a..8ceaece3c 100644 --- a/modules/toolchain-model/src/target_schema.cppm +++ b/modules/toolchain-model/src/target_schema.cppm @@ -70,6 +70,12 @@ struct Row { // its module. A name template (`artifact_name("exe", "{name}")`) decides what // precedes it; the suffix ends the name, once. bool exeSuffixFixed = false; + // THE INTERFACES THE ROW PROVIDES where its kernel-abi layer is the system + // itself (design 2026-11-22 §3.17), when its C library or its system + // narrows them for this row (an iOS application starts no program). + // Read before the system's `interfaces`; unstated: the system's. + std::span interfaces; + bool interfacesStated = false; bool defined = false; // stated by a platform package }; @@ -175,6 +181,37 @@ struct System { std::string_view objectFormat; // elf | mach-o | pe | wasm | coff; empty: unstated std::string_view exeSuffix; std::string_view sharedSuffix; + // THE KERNEL INTERFACE AS A PACKAGE OF ITS OWN (design 2026-11-22 §3.4, + // §3.9). A system whose kernel headers are published apart from its C + // library (Linux) states how they are measured and laid out; a system + // whose kernel interface belongs to one SDK or base with its C library + // states nothing, and its rows accept no prebuilt `kernel-abi` statement. + struct KernelAbi { + // The header a probe unit includes (`__has_include`) to measure the + // headers in effect; empty: the system has no such package. + std::string_view header; + // The macros of the version's parts, most significant first; read + // when every one is defined. + std::span version; + // The macro of the packed version and its parts' widths in bits, + // most significant first: read when the macros above are absent. + std::string_view packed; + std::span bits; + // A payload's layout, relative to its root: the headers common to + // every architecture, and one architecture's (`{arch}` the target + // architecture), searched first when present. + std::string_view include; + std::string_view archInclude; + // The ecosystem package of the headers, which a toolchain's payload + // declares as the headers its own runtime was built against. + std::string_view package; + bool stated() const { return !header.empty(); } + } kernelAbi; + // THE INTERFACES THE SYSTEM PROVIDES (design 2026-11-22 §3.17): the + // answer of `cfg(interface = "")` on rows whose kernel-abi layer is + // the system itself, in openkal's vocabulary. Unstated: every interface. + std::span interfaces; + bool interfacesStated = false; }; // AN ARCHITECTURE A MACHINE EXECUTES BESIDES ITS OWN (design 2026-11-15 N23): diff --git a/modules/toolchain-model/tests/test_kernel_headers.cpp b/modules/toolchain-model/tests/test_kernel_headers.cpp new file mode 100644 index 000000000..00450991a --- /dev/null +++ b/modules/toolchain-model/tests/test_kernel_headers.cpp @@ -0,0 +1,114 @@ +import std; +import mcpplibs.mtest; +import mcpp.toolchain.base; +import mcpp.toolchain.target_rows; +import mcpp.toolchain.target_schema; + +using namespace mcpplibs::mtest; + +// THE KERNEL HEADERS' VERSION AND THE SYSTEM DATA THAT SAYS HOW TO READ IT +// (design 2026-11-22 §3.4). The decoding is the engine's; the macro names and +// the widths are the system row's, so these tests read them from the table. + +namespace { +namespace tb = mcpp::toolchain::base; + +std::map> defines(std::string_view text) { + return tb::parse_defines(text); +} + +const mcpp::toolchain::target::System& linux_system() { + auto const* s = mcpp::toolchain::target::find_system("linux"); + if (!s) throw std::runtime_error("no linux system row"); + return *s; +} + +std::optional read(std::string_view text) { + auto const& k = linux_system().kernelAbi; + return tb::kernel_version(defines(text), k.version, k.packed, k.bits); +} +} // namespace + +UTest the_linux_row_states_its_kernel_headers{"KernelHeaders/TheLinuxRowStatesItsKernelHeaders", [] { + auto const& k = linux_system().kernelAbi; + expect(k.stated()); + expect(eq(std::string(k.header), std::string("linux/version.h"))); + expect(eq(k.version.size(), std::size_t{3})); + expect(eq(k.bits.size(), std::size_t{3})); + expect(eq(std::string(k.package), std::string("linux-headers"))); + expect(std::string(k.archInclude).find("{arch}") != std::string::npos); +}}; + +UTest a_system_whose_kernel_is_its_base_states_none{"KernelHeaders/ASystemWhoseKernelIsItsBaseStatesNone", [] { + // macOS, Windows and FreeBSD publish the kernel interface with their C + // library: their rows accept no prebuilt kernel-abi statement. + for (auto os : { "macos", "windows", "freebsd" }) { + auto const* s = mcpp::toolchain::target::find_system(os); + expect(s != nullptr); + if (s) expect(!s->kernelAbi.stated()); + } +}}; + +UTest the_parts_macros_answer_first{"KernelHeaders/ThePartsMacrosAnswerFirst", [] { + // linux 6.18.64's , as `-E -dM` prints it. + auto v = read("#define LINUX_VERSION_CODE 397888\n#define LINUX_VERSION_MAJOR 6\n" + "#define LINUX_VERSION_PATCHLEVEL 18\n#define LINUX_VERSION_SUBLEVEL 64\n"); + expect(v.has_value()); + if (v) { + expect(eq(v->text(), std::string("6.18.64"))); + expect(!v->saturated[2]); + } +}}; + +UTest the_packed_macro_is_decoded_by_the_rows_widths{"KernelHeaders/ThePackedMacroIsDecodedByTheRowsWidths", [] { + // linux 5.11.1 defines LINUX_VERSION_CODE alone. + auto v = read("#define LINUX_VERSION_CODE 330497\n"); + expect(v.has_value()); + if (v) expect(eq(v->text(), std::string("5.11.1"))); + auto packed = read("#define LINUX_VERSION_CODE 397888\n"); + expect(packed.has_value()); + if (packed) expect(eq(packed->text(), std::string("6.18.64"))); +}}; + +UTest a_part_at_its_widths_maximum_is_saturated{"KernelHeaders/APartAtItsWidthsMaximumIsSaturated", [] { + // linux 4.19.256 packs its sublevel as 255: the packing says no more, and a + // comparison skips the part. + auto v = read("#define LINUX_VERSION_CODE 267263\n"); + expect(v.has_value()); + if (v) { + expect(eq(v->text(), std::string("4.19.255"))); + expect(v->saturated[2]); + expect(tb::kernel_version_matches(*v, "4.19.256")); + expect(!tb::kernel_version_matches(*v, "4.20.1")); + } +}}; + +UTest a_statement_is_compared_to_the_measurements_precision{"KernelHeaders/AStatementIsComparedToTheMeasurementsPrecision", [] { + auto v = read("#define LINUX_VERSION_CODE 397888\n"); + expect(v.has_value()); + if (!v) return; + expect(tb::kernel_version_matches(*v, "6.18.64")); + expect(!tb::kernel_version_matches(*v, "6.18.63")); + expect(!tb::kernel_version_matches(*v, "7.3.5")); + expect(!tb::kernel_version_matches(*v, "")); +}}; + +UTest no_header_no_version{"KernelHeaders/NoHeaderNoVersion", [] { + // The probe unit includes the header under __has_include: without it, + // nothing is defined and nothing is measured. + expect(!read("#define __linux__ 1\n").has_value()); +}}; + +UTest the_interfaces_are_the_systems_and_the_rows{"KernelHeaders/TheInterfacesAreTheSystemsAndTheRows", [] { + auto const& l = linux_system(); + expect(l.interfacesStated); + expect(std::ranges::find(l.interfaces, std::string_view("openkal.process")) != l.interfaces.end()); + // An iOS application starts no program: its rows narrow the system's list. + auto const* ios = mcpp::toolchain::target::find_row("aarch64-ios"); + expect(ios != nullptr); + if (ios) { + expect(ios->interfacesStated); + expect(std::ranges::find(ios->interfaces, std::string_view("openkal.process")) == ios->interfaces.end()); + expect(std::ranges::find(ios->interfaces, std::string_view("openkal.fs")) != ios->interfaces.end()); + } +}}; diff --git a/src/build/build_database.cppm b/src/build/build_database.cppm index fdde663a0..e7155e983 100644 --- a/src/build/build_database.cppm +++ b/src/build/build_database.cppm @@ -545,12 +545,17 @@ Rendered render(std::span members, const bool isUnit = std::ranges::any_of(set.units, [&](auto const& u) { return u.value("source", "") == path; }); - set.generated.push_back(nlohmann::json{ + nlohmann::json entry{ {"path", path}, {"build-path", build_path(p)}, {"kind", isUnit ? "source" : "header"}, {"generator", generator}, - }); + }; + // mcpp#1004: the authored source of a generated unit, + // as its action stated it; never inferred. + if (isUnit && !a.origin.empty()) + entry["origin"] = native_string(std::filesystem::path(a.origin).lexically_normal()); + set.generated.push_back(std::move(entry)); } } } diff --git a/src/build/flags.cppm b/src/build/flags.cppm index b3ea02afd..9df9f05be 100644 --- a/src/build/flags.cppm +++ b/src/build/flags.cppm @@ -2723,8 +2723,7 @@ CompileFlags compute_flags_impl(const BuildPlan& plan, bool packageLinkFlags) { // (mcpp#911 G4): the compiler driver then links, adding the start // files and libraries it knows for the target, where the row alone // would call ld.lld with its emulation. - const bool platformCompilerDriver = plan.platform.active - && plan.platform.fields.link.driver.set + const bool platformCompilerDriver = plan.platform.fields.link.driver.set && plan.platform.fields.link.driver.value == "compiler"; if (!spec->lldEmulation.empty() && !platformCompilerDriver) { f.ldDriver = in.lld; @@ -2790,7 +2789,8 @@ CompileFlags compute_flags_impl(const BuildPlan& plan, bool packageLinkFlags) { // freestanding block gives: the artifact has no loader path, no crt files // and no system library of the toolchain's, and what it holds is the // graph's, reached through the graph's own `-L`/`-l`. - if (auto const& p = plan.platform; p.active) { + { + auto const& p = plan.platform; // Each element one word, quoted for the shell and `$` doubled for // ninja, as every other word of a command is. auto words = [](const std::vector& v) { diff --git a/src/build/hostprogram.cppm b/src/build/hostprogram.cppm index cf91a209c..66858c41a 100644 --- a/src/build/hostprogram.cppm +++ b/src/build/hostprogram.cppm @@ -447,6 +447,12 @@ struct action { // inputs and outputs are unaffected: they keep naming files the way they // always have. action& cwd(const char* dir) { cwd_ = dir; return *this; } + // THE AUTHORED SOURCE THE OUTPUT IS A TRANSFORMED COPY OF (mcpp#1004): one + // of this action's inputs, the file a person edits to change the unit + // compiled from the output. Stated by the rule, which alone knows it; the + // build database names it (`ide.generated[].origin`) and a consumer reads + // the authored file as the unit's, not as a second provider of its module. + action& origin(const char* p) { origin_ = p; return *this; } void submit() const { std::printf("mcpp:action={\"id\":"); esc(id); std::printf(",\"role\":"); esc(role); @@ -469,6 +475,8 @@ struct action { // the bytes it did before protocol 13. if (env_.len) std::printf(",\"env\":[%s]", env_.c_str()); if (cwd_[0]) { std::printf(",\"cwd\":"); esc(cwd_); } + // Omitted unless stated, as `cwd` is. + if (origin_[0]) { std::printf(",\"origin\":"); esc(origin_); } // Set only when the process could not allocate memory for a list. // A declaration cut short would otherwise be INVALID rather than // obviously wrong -- the engine turns this marker into a diagnostic @@ -488,6 +496,7 @@ private: // `list`: it is one directory, never a JSON array. const char* outputDir_ = ""; const char* cwd_ = ""; + const char* origin_ = ""; mutable bool overflow_ = false; static void esc(const char* s) { json_detail::esc(s); } // One entry of a list field; a list the allocator refused marks the diff --git a/src/build/ninja_backend.cppm b/src/build/ninja_backend.cppm index 301904d40..771ac0a49 100644 --- a/src/build/ninja_backend.cppm +++ b/src/build/ninja_backend.cppm @@ -643,7 +643,7 @@ std::string pe_link_flag(const BuildPlan& plan, bool sep, // The platform links with `ld.lld` itself (`[platform.link] driver = "lld"`): // a flag is the linker's own spelling, not the driver's `-Wl,` form. bool links_with_lld(const BuildPlan& plan) { - return plan.platform.active && plan.platform.fields.link.driver.value == "lld"; + return plan.platform.fields.link.driver.value == "lld"; } std::string shared_soname_flag(const LinkUnit& lu, const BuildPlan& plan) { @@ -933,8 +933,7 @@ std::string action_phony_name(std::string_view pkg) { // same edge: the guard once took the seal edge for the link and refused every ok // image whose graph declares a `prepare` action. std::filesystem::path link_edge_output(const BuildPlan& plan, const LinkUnit& lu) { - if (!plan.platform.active || plan.platform.fields.link.seal.empty() - || lu.kind == LinkUnit::StaticLibrary) + if (plan.platform.fields.link.seal.empty() || lu.kind == LinkUnit::StaticLibrary) return lu.output; auto unsealed = std::filesystem::path("obj/platform") / lu.output.relative_path(); unsealed += ".unsealed"; @@ -1865,8 +1864,8 @@ std::string emit_ninja_string(const BuildPlan& plan, std::string* placements, // seal steps run on the linked file, written beneath `obj/platform/`, and // only a file every step accepted is published under the artifact's name. auto const& pf = plan.platform; - const bool platformLld = pf.active && pf.fields.link.driver.value == "lld"; - const bool platformSeal = pf.active && !pf.fields.link.seal.empty(); + const bool platformLld = pf.fields.link.driver.value == "lld"; + const bool platformSeal = !pf.fields.link.seal.empty(); // A program a platform names, as the platform resolved it, or its name for // PATH at build time. auto platform_program = [&](const std::string& name) { @@ -1874,7 +1873,7 @@ std::string emit_ninja_string(const BuildPlan& plan, std::string* placements, return it == pf.tools.end() ? name : it->second; }; std::vector platformInputs; - if (pf.active && !pf.fields.link.inputs.empty()) { + if (!pf.fields.link.inputs.empty()) { const auto tt = mcpp::toolchain::triple::parse(plan.toolchain.targetTriple); const bool clangDriver = plan.toolchain.compiler == mcpp::toolchain::CompilerId::Clang; append("rule platform_capture\n"); @@ -3797,7 +3796,7 @@ std::string emit_ninja_string(const BuildPlan& plan, std::string* placements, // this plan links; with seal steps, the artifact is written beneath // obj/ and published by its own edge (above). Not beside the name: // what bin/ holds is what was published, and an unsealed file is not. - const bool platformUnit = pf.active && lu.kind != LinkUnit::StaticLibrary; + const bool platformUnit = lu.kind != LinkUnit::StaticLibrary; if (platformUnit) for (auto const& in : platformInputs) add_in(in); const bool sealUnit = platformSeal && lu.kind != LinkUnit::StaticLibrary; @@ -5062,8 +5061,8 @@ std::expected NinjaBackend::build(const BuildPlan& plan // A platform that links with ld.lld itself and names its shared // artifacts is the exception (an ok image's `.okso`, placed by the loader // through DT_NEEDED or by `dlopen`): it has the rule. - const bool platformShared = plan.platform.active - && plan.platform.fields.link.driver.value == "lld" && plan.platform.fields.link.shared.set; + const bool platformShared = plan.platform.fields.link.driver.value == "lld" + && plan.platform.fields.link.shared.set; if (!flags.ldDriver.empty() && !platformShared) { for (auto const& lu : plan.linkUnits) { if (lu.kind != LinkUnit::SharedLibrary) continue; diff --git a/src/build/prepare/base.cpp b/src/build/prepare/base.cpp index 1ce36bc39..396def940 100644 --- a/src/build/prepare/base.cpp +++ b/src/build/prepare/base.cpp @@ -22,7 +22,12 @@ import mcpplibs.os.platform; import mcpp.toolchain.platform; import mcpp.run; import mcpp.provider; +import mcpp.provider.select; +import mcpp.targetside; +import mcpp.platform; import mcpp.runtime.binding; +import mcpp.toolchain.detect; +import mcpp.toolchain.linkmodel; import mcpp.toolchain.base; import mcpp.toolchain.base_probe; import mcpp.toolchain.triple; @@ -508,7 +513,6 @@ std::expected step2_resolve_base(PrepareState& state) { return std::unexpected(std::format("[target.{}].sysroot = \"{}\": {}", tt->str(), stmt->text, basePackage.error())); } - const auto ecosystemLinux = tc.base.payload ? tc.base.payload->linuxInclude : fs::path{}; const bool native = tt->os == "linux" && tt->arch == mcpp::toolchain::platform::host_arch && mcpplibs::os::is_linux; const bool staticLink = state.m->buildConfig.linkage == "static"; @@ -526,7 +530,7 @@ std::expected step2_resolve_base(PrepareState& state) { if (!*basePackage && tb::is_payload_layout(dir)) { // The ecosystem's own layout: a glibc package (`xim:glibc@2.39`). It // is linked as the default base is, from its own directories. - tc.base.payload = tb::payload_layout_paths(dir, ecosystemLinux); + tc.base.payload = tb::payload_layout_paths(dir); tc.base.root.clear(); auto v = driver_base(tc); v.push_back("-isystem" + tc.base.payload->glibcInclude.string()); @@ -574,11 +578,6 @@ std::expected step2_resolve_base(PrepareState& state) { !std.empty() && fs::exists(std, ec)) tc.base.loader = std; } - // Kernel headers are additive (§2.4): the engine supplies the - // ecosystem's for a native base that lacks them. - if (native && !ecosystemLinux.empty() - && !fs::exists(dir / "usr" / "include" / "linux" / "limits.h", ec)) - tc.base.addedIncludes.push_back(ecosystemLinux); } // THE LOADER AN ARTIFACT NAMES IS A PATH ON THE MACHINE THAT RUNS IT @@ -729,4 +728,247 @@ std::expected step2_resolve_run_under(PrepareState& state) { return {}; } +// ── The kernel headers (design 2026-11-22 §3.1-§3.6) ───────────────────────── +// +// ON A SYSTEM THAT PUBLISHES ITS KERNEL HEADERS APART FROM ITS C LIBRARY (the +// system row's `kernel-abi` data; Linux), the headers a build compiles against +// are decided here, once, after the target side: the statement +// (`[target..layers] kernel-abi`, a payload or a directory), else +// the first answerer of two -- the base's own headers, then the headers the +// toolchain's payload declares. The shared view of a home is not an answerer: +// its links are the home's history, and two toolchains of one home declare +// different versions. The decision is wired by the link model ahead of the +// base and measured by preprocessing, as the C library is (SPEC-006 §3.9.3). + +namespace { + +namespace mp = mcpp::manifest::platform; +namespace target = mcpp::toolchain::target; + +// A payload's header directories for one architecture: that architecture's +// first, when the payload carries it, then the common ones. A payload without +// per-architecture directories carries its host's (the layout published +// before), so it serves only a build for this machine's architecture. +std::vector payload_header_dirs(const fs::path& root, const target::System::KernelAbi& k, + std::string_view arch, std::string* why) { + std::error_code ec; + std::vector dirs; + const auto common = k.include.empty() ? root : root / std::string(k.include); + if (!k.archInclude.empty()) { + std::string rel(k.archInclude); + rel.replace(rel.find("{arch}"), 6, arch); + if (fs::is_directory(root / rel, ec)) dirs.push_back(root / rel); + else if (fs::is_directory(root / "arch", ec)) { + if (why) *why = std::format("it carries no headers of {} ({} is absent)", arch, (root / rel).string()); + return {}; + } + } + if (dirs.empty() && arch != mcpp::toolchain::platform::host_arch) { + if (why) *why = std::format("its layout carries the headers of {} only, the machine it was " + "installed on", mcpp::toolchain::platform::host_arch); + return {}; + } + dirs.push_back(common); + return dirs; +} + +// The headers in effect, measured: the driver preprocesses a unit that +// includes the system's header, with the base's search path as the build +// renders it and `dirs` ahead of it. nullopt: the header is not found there. +std::optional measure_kernel_headers(const PrepareState& state, + const mcpp::toolchain::Toolchain& tc, + const target::System::KernelAbi& k, + const std::vector& dirs) { + auto probeTc = tc; + probeTc.base.kernel = {}; + probeTc.base.kernel.dirs = dirs; + const mcpp::toolchain::PathEscape plain = [](const fs::path& p) { return p.string(); }; + auto v = driver_base(tc); + for (auto const& t : mcpp::toolchain::resolve_link_model(probeTc).compile_tokens(plain)) v.push_back(t); + // The unit is named by its content and kept in the temporary directory: + // it is the same for every build, and a probe writes nothing into a + // project's tree. + const auto text = std::format("#if __has_include(<{0}>)\n#include <{0}>\n#endif\n", k.header); + std::error_code ec; + const auto unit = fs::temp_directory_path(ec) + / std::format("mcpp-kernel-probe-{:016x}.c", std::hash{}(text)); + if (!fs::is_regular_file(unit, ec)) { + const auto partial = fs::path(unit).concat(std::format(".{:08x}", std::random_device{}())); + { std::ofstream os(partial); os << text; } + fs::rename(partial, unit, ec); + } + v.insert(v.end(), {"-E", "-dM", "-x", "c", unit.string()}); + auto r = mcpp::run::capture_stdout(v); + if (r.exit_code != 0) return std::nullopt; + return tb::kernel_version(tb::parse_defines(r.output), k.version, k.packed, k.bits); +} + +std::string layer_origin(const mp::LayerEntry& e) { return mcpp::platform::origin_text(e.origin); } + +} // namespace + +std::expected step9_kernel_headers(PrepareState& state) { + if (!state.tc || !state.targetSideResolved) return {}; + auto& tc = *state.tc; + tc.base.kernel = {}; + auto tt = mcpp::toolchain::triple::parse(tc.targetTriple); + if (!tt) return {}; + auto const& fields = state.platform.fields; + const auto* sys = target::find_system(tt->os); + const bool data = sys && sys->kernelAbi.stated(); + + // A PREBUILT FORM IS ACCEPTED WHERE THE SYSTEM SAYS HOW TO MEASURE IT + // (§3.1): the kernel-abi layer of such a system; no other layer, and no + // layer of a system whose kernel interface is one SDK or base with its C + // library. The engine asks the data, never a layer's or a system's name. + const mp::LayerEntry* stated = nullptr; + for (auto const& [layer, e] : fields.layers) { + if (!prebuilt_layer(e)) continue; + if (layer == "kernel-abi" && data) { stated = &e; continue; } + refusal::record(refusal::Code::TargetBase); + return std::unexpected(std::format( + "{}: [target..layers] {} = \"{}\" names a prebuilt supplier, and on {} {}.\n" + " What a prebuilt directory supplies there is stated with the base: " + "[target.{}] sysroot = \"@\" or {{ path = \"\" }}; a layer of the " + "graph is a package (\"@\").", + layer_origin(e), layer, mp::display(e.ref), tt->str(), + layer == "kernel-abi" + ? std::format("the kernel interface of {} is part of its base, not a package of its own", tt->os) + : std::format("only the kernel-abi layer of a system that publishes its kernel headers " + "apart from its C library takes one, not {}", layer), + tt->str())); + } + if (!data) return {}; + // `kernel-abi = false`: the statement says the build has no such layer (a + // freestanding arrangement), so there are no headers to decide or measure. + if (auto it = fields.layers.find("kernel-abi"); it != fields.layers.end() && it->second.ref.off) + return {}; + + auto& ts = state.resolvedTargetSide; + // ONE SUPPLIER PER LAYER (rule one): a package of the graph supplies the + // layer (an openkal implementation), so a prebuilt one is a second. + if (stated && ts.kernelAbi.fromGraph()) { + refusal::record(refusal::Code::ExclusiveCapability); + mcpp::targetside::Conflict c; + c.layer = mcpp::targetside::CapLayer::KernelAbi; + c.first = std::format("{} ({})", mp::display(stated->ref), layer_origin(*stated)); + c.firstVia = "stated as the layer"; + c.second = ts.kernelAbi.impl; + return std::unexpected(mcpp::targetside::format_conflict(c)); + } + // A C library of the graph is its own world: the base and its headers are + // not this build's (openkal over a C library it carries). A kernel + // interface of the graph over a prebuilt C library (an openkal + // implementation on `*-linux-gnu`) leaves the base's C library in place, + // and that library includes the kernel's headers: they are decided as the + // base's component, and the layer stays the package's. + const bool layerIsGraphs = ts.kernelAbi.fromGraph(); + if (!ts.cAbi.prebuilt()) { + if (!stated) return {}; + refusal::record(refusal::Code::LayerRequirement); + return std::unexpected(std::format( + "{}: layers.kernel-abi = \"{}\" states the kernel headers beneath a prebuilt C library, " + "and the C library of {} is the graph's ({}).\n" + " Its kernel interface is the one that package requires; remove the statement.", + layer_origin(*stated), mp::display(stated->ref), tt->str(), ts.cAbi.impl)); + } + + auto const& k = sys->kernelAbi; + tb::KernelHeaders kh; + std::optional measured; + if (stated) { + std::string why; + if (!stated->ref.payload.empty()) { + auto root = package_dir(state, stated->ref.payload, true); + if (!root) return std::unexpected(std::format("{}: layers.kernel-abi = \"{}\": {}", + layer_origin(*stated), stated->ref.payload, root.error())); + kh.dirs = payload_header_dirs(*root, k, tt->arch, &why); + kh.supplier = stated->ref.payload; + } else { + kh.dirs = {fs::path(stated->ref.spec.path)}; + kh.supplier = std::format("path {}", stated->ref.spec.path); + } + kh.source = layer_origin(*stated); + if (kh.dirs.empty()) { + refusal::record(refusal::Code::TargetBase); + return std::unexpected(std::format( + "{}: layers.kernel-abi = \"{}\" cannot serve {}: {}.\n" + " State a version published with the headers of {}, or the directory of " + "that architecture's headers: kernel-abi = {{ path = \"\" }}", + kh.source, kh.supplier, tt->str(), why, tt->arch)); + } + measured = measure_kernel_headers(state, tc, k, kh.dirs); + const auto at = stated->ref.payload.rfind('@'); + if (!measured || (at != std::string::npos + && !tb::kernel_version_matches(*measured, stated->ref.payload.substr(at + 1)))) { + refusal::record(refusal::Code::TargetBase); + return std::unexpected(std::format( + "{}: layers.kernel-abi = \"{}\": the headers measured there are {}.\n" + " The statement names what is compiled against, and the measurement must agree.", + kh.source, kh.supplier, + measured ? std::format("{} {}", tt->os, measured->text()) + : std::format("absent (no <{}>)", k.header))); + } + } else { + // 1. The base's own: a stated base, a toolchain's own sysroot, the + // host's root -- not the shared view, and not a payload layout, + // which carries the C library alone (the link model's PayloadFirst). + const bool payloadLayout = mcpp::toolchain::resolve_link_model(tc).mode + == mcpp::toolchain::CLibMode::PayloadFirst; + if (!mcpp::toolchain::base_is_ecosystem_view(tc) && !payloadLayout) { + measured = measure_kernel_headers(state, tc, k, {}); + if (measured) kh.supplier = tc.base.stated() ? "the base (sysroot)" : "the toolchain's sysroot"; + } + // 2. The toolchain's declaration: the headers its payload was built + // with, by the reading `companions` uses (SPEC-006 §2.9). A + // payload that declares none is not answered by whatever version + // the store happens to hold. A compiler outside any store declares + // nothing; the home's newest headers answer for it, and the report + // says so. + if (!measured && !k.package.empty()) { + const auto marker = (fs::path(std::string(k.include)) / std::string(k.header)).generic_string(); + std::optional root; + if (mcpp::provider::store_of(tc.binaryPath)) { + if (mcpp::provider::declared_dependency(tc.binaryPath, k.package)) { + root = mcpp::provider::beside(tc.binaryPath, k.package, marker); + kh.source = "the toolchain's declaration"; + } + } else { + root = mcpp::provider::in_home_store(k.package, marker); + kh.source = "the home's newest; the compiler is in no store"; + } + std::string why; + if (root) kh.dirs = payload_header_dirs(*root, k, tt->arch, &why); + if (!kh.dirs.empty()) { + measured = measure_kernel_headers(state, tc, k, kh.dirs); + kh.supplier = std::format("{}@{}", k.package, root->filename().string()); + } + } + if (!measured) { + refusal::record(refusal::Code::TargetBase); + return std::unexpected(std::format( + "{} has no kernel headers to compile against: the base carries none, and the toolchain " + "{} declares none that serve {}.\n" + " State them for the target:\n" + "\n" + " [target.{}.layers]\n" + " kernel-abi = \"xim:{}@\" # or {{ path = \"\" }}\n" + "\n" + " or name a base that carries them ([target.{}] sysroot).", + tt->str(), tc.label(), tt->arch, tt->str(), k.package.empty() ? "" : std::string(k.package), + tt->str())); + } + } + kh.version = measured->text(); + // A statement is a prebuilt supplier the build names; a default is the + // payload's, as the other layers the toolchain answers are. + if (!layerIsGraphs) { + ts.kernelAbi.version = kh.version; + if (stated) ts.kernelAbi.origin = mcpp::targetside::Origin::Xpkg; + ts.kernelAbi.impl = kh.source.empty() ? kh.supplier : std::format("{}, {}", kh.supplier, kh.source); + } + tc.base.kernel = std::move(kh); + return {}; +} + } // namespace mcpp::build diff --git a/src/build/prepare/features.cpp b/src/build/prepare/features.cpp index db0f538d4..0fd5b55ca 100644 --- a/src/build/prepare/features.cpp +++ b/src/build/prepare/features.cpp @@ -260,7 +260,16 @@ std::string kernel_abi_interfaces_for(const PrepareState& state, std::size_t i) } return joined; } - return {}; + // No package supplies the layer to the target: the system does, and its + // row states the interfaces (design 2026-11-22 §3.17). + auto const& l = state.resolvedTargetSide.kernelAbi; + if (!target || !state.targetSideResolved || l.fromGraph() || !l.interfacesStated) return {}; + std::string joined; + for (auto const& name : l.interfaces) { + if (!joined.empty()) joined += ';'; + joined += name; + } + return joined; } PackageInstances package_instances(const PrepareState& state) { diff --git a/src/build/prepare/graph_provisioning.cpp b/src/build/prepare/graph_provisioning.cpp index 4c15b954d..ebf09a100 100644 --- a/src/build/prepare/graph_provisioning.cpp +++ b/src/build/prepare/graph_provisioning.cpp @@ -141,7 +141,7 @@ step4b_define_provisioning_closures(PrepareState& state) { // file provides and imports, and reads nothing (D6). A unit // that declares no `provides` asserts nothing; the build's own // scan finds its imports, as it did with the empty placeholder. - mm.modules.declaredUnits[o] = mcpp::manifest::ScanOverride{a.provides, a.imports}; + mm.modules.declaredUnits[o] = mcpp::manifest::ScanOverride{a.provides, a.imports, a.origin}; // D26: a generated module interface must say which module it // is. Without `.provides()` nothing writes its BMI, and the // first importer fails far from the action. diff --git a/src/build/prepare/plan.cpp b/src/build/prepare/plan.cpp index 982b416a9..241f174da 100644 --- a/src/build/prepare/plan.cpp +++ b/src/build/prepare/plan.cpp @@ -1371,6 +1371,7 @@ static std::expected step13_build_graph_actions(PrepareState& // an environment-configured generator most often wants. for (auto& x : a.env) x = sub(x); if (!a.cwd.empty()) a.cwd = sub(a.cwd); + if (!a.origin.empty()) a.origin = sub(a.origin); // THE DEPENDENCY IS IMPLIED BY THE USE, so a member author // cannot forget it. Without this the edge is dirty only when a // link output changes, and a staged set that grew a dependency's diff --git a/src/build/prepare/platform.cpp b/src/build/prepare/platform.cpp index 6fee97a8d..91f8257e3 100644 --- a/src/build/prepare/platform.cpp +++ b/src/build/prepare/platform.cpp @@ -216,6 +216,8 @@ void define_platform(const mp::Statement& s, std::string_view shortName, std::st r.descriptorKeys = set.keep(d.descriptorKeys); r.companions = set.keep(d.companions); r.linkWithoutMain = set.keep(d.linkWithoutMain); + r.interfaces = set.keep(d.interfaces); + r.interfacesStated = d.interfacesStated; r.exceptions = set.keep(d.exceptions); r.exeSuffixFixed = d.exeSuffixFixed; r.execution = set.keep(d.execution.empty() ? seg[1] : d.execution); @@ -243,11 +245,20 @@ void define_platform(const mp::Statement& s, std::string_view shortName, std::st p.runnerExclusive = sp.runnerExclusive; set.providers.push_back(p); }; - for (auto const& sys : s.systems) + for (auto const& sys : s.systems) { + auto const& k = sys.kernelAbi; 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) }); + .sharedSuffix = set.keep(sys.sharedSuffix), + .kernelAbi = { .header = set.keep(k.header), .version = set.keep(k.version), + .packed = set.keep(k.packed), .bits = set.keep(k.bits), + .include = set.keep(k.include), + .archInclude = set.keep(k.archInclude), + .package = set.keep(k.package) }, + .interfaces = set.keep(sys.interfaces), + .interfacesStated = sys.interfacesStated }); + } // 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) { @@ -658,6 +669,30 @@ cfgpred::Ctx platform_cfg_context(const PrepareState& state) { return cfgpred::context_for(target_of(state).str(), state.platformPackageShortName); } +// THE TIERS ABOVE A PLATFORM (SPEC-013 §6): this machine's `[target.]` +// tables, then the project's, each matching one merged by key in specificity +// order. One merge for a platform's statement and for a row without one. +void merge_override_tables(const PrepareState& state, mp::Statement& into) { + const auto ctx = platform_cfg_context(state); + std::vector config; + if (auto cfg = state.get_cfg(false); cfg) config = (*cfg)->platformOverrides; + for (auto const* o : mcpp::platform::matching(config, matcher(ctx))) mcpp::platform::merge(into, o->fields); + auto project = project_tables(*state.m); + for (auto const* o : mcpp::platform::matching(project, matcher(ctx))) mcpp::platform::merge(into, o->fields); +} + +// A LAYER'S PREBUILT FORMS (design 2026-11-22 §3.1): an ecosystem payload +// (`xim:@`), or a directory that is no package (no mcpp.toml; +// a directory with one is a package of the graph, as a base package's is, +// SPEC-002 §2.5). Which layers accept them on a row is the system's data. +bool prebuilt_layer(const mp::LayerEntry& e) { + if (!e.ref.payload.empty()) return true; + if (e.ref.spec.path.empty()) return false; + std::error_code ec; + return !fs::is_regular_file(fs::path(e.ref.spec.path) / "mcpp.toml", ec); +} + + // A `planned` row the chosen platform was to serve (`state.plannedRow`), checked // against the platform's statement once it is read: served when a provider of the // statement lists the row with a toolchain; refused, naming the platform, when not. @@ -846,11 +881,22 @@ std::optional> take_platform_series_restart( std::expected step4b_apply_platform(PrepareState& state) { auto& P = state.platform; - if (P.selection.none) return false; const auto t = target_of(state); + // A ROW WITHOUT A PLATFORM HAS AN EMPTY STATEMENT, AND THE TIERS ABOVE IT + // OVERRIDE IT AS THEY OVERRIDE A PLATFORM'S (design 2026-11-22 §3.2). The + // keys of this machine's and the project's `[target.]` tables + // used to be merged only once a platform package was read, so on a row + // without one they were accepted and dropped; the layers and tools they + // name are completed below as a platform's are. Merged again each round: + // the merge replaces by key, and a round adds no table. + if (P.selection.none) { + P.fields = {}; + merge_override_tables(state, P.fields); + } + // ── The package, once: find it, read it, merge what overrides it ────── - if (!P.active) { + if (!P.selection.none && !P.active) { const mcpp::modgraph::PackageRoot* found = nullptr; const auto& ref = P.selection.ref; for (std::size_t i = 1; i < state.packages.size(); ++i) { @@ -924,14 +970,7 @@ std::expected step4b_apply_platform(PrepareState& state) { P.selection.hosted = *hosted; state.platformData = mcpp::platform::view_of(found->manifest.platform, t.str(), *hosted); P.fields = state.platformData; - const auto ctx = platform_cfg_context(state); - std::vector config; - if (auto cfg = state.get_cfg(false); cfg) config = (*cfg)->platformOverrides; - for (auto const* o : mcpp::platform::matching(config, matcher(ctx))) - mcpp::platform::merge(P.fields, o->fields); - auto project = project_tables(*state.m); - for (auto const* o : mcpp::platform::matching(project, matcher(ctx))) - mcpp::platform::merge(P.fields, o->fields); + merge_override_tables(state, P.fields); P.active = true; state.platformInjected.insert(P.package); // A base, or descriptor keys, the platform states, which this pass @@ -957,6 +996,12 @@ std::expected step4b_apply_platform(PrepareState& state) { P.layers[std::string(layer)] = { "none", e.origin.tier }; continue; } + // A prebuilt supplier is no package of the graph: the target side + // decides and wires it (`step9_kernel_headers`). + if (prebuilt_layer(e)) { + P.layers[std::string(layer)] = { mp::display(e.ref), e.origin.tier }; + continue; + } if (auto pv = provided.find(std::string(layer)); pv != provided.end()) { // Whose: the platform's when the provider is a package the // platform added, the graph's otherwise. @@ -1328,7 +1373,7 @@ std::expected step4b_check_platform_versions(PrepareState& st // a build programs' graph under a host platform linked its programs without // the C library and the C++ run-time, and `okld check` refused `free`.) void step4b_platform_member_edges(PrepareState& state) { - if (!state.platform.active || !state.workspacePlan() || state.platformLayerSpecs.empty()) return; + if (!state.workspacePlan() || state.platformLayerSpecs.empty()) return; // The packages of the plan by short name, so a member's edge to a layer // provider is a lookup. std::map, std::less<>> byName; @@ -1513,11 +1558,7 @@ mp::Statement platform_statement(const PrepareState& state, std::vector config; - if (auto cfg = state.get_cfg(false); cfg) config = (*cfg)->platformOverrides; - for (auto const* o : mcpp::platform::matching(config, matcher(cfgCtx))) mcpp::platform::merge(s, o->fields); - auto project = project_tables(*state.m); - for (auto const* o : mcpp::platform::matching(project, matcher(cfgCtx))) mcpp::platform::merge(s, o->fields); + merge_override_tables(state, s); if (P.active) keep_platform_naming(s, state.platformData, P.display(), conflicts); const auto envKey = target_env_name(t, "RUNNER"); if (auto e = mcpp::invocation::get(envKey); e && !e->empty()) { @@ -1559,7 +1600,6 @@ void step13_platform_statement(PrepareState& state) { // tables), as they stand when they are asked for: the std module is compiled // before the statement is final, and is a unit like any other. std::vector platform_unit_cxxflags(const PrepareState& state) { - if (!state.platform.active) return {}; return mcpp::platform::evaluate_flags(platform_statement(state), matcher(platform_cfg_context(state))).cxxflags; } @@ -1575,8 +1615,22 @@ std::expected step13_finish_platform(PrepareState& state, Bui return lu.kind != mcpp::build::LinkUnit::StaticLibrary; }); + // Who states the link: the platform, or on a row without one the tiers + // above it (design 2026-11-22 §3.2). The fields are read wherever they are + // stated; only the platform's identity needs a platform. + const std::string stater = P.active ? std::format("the platform {}", P.display()) + : std::string("this build"); + // `carrier` is a form of the platform's image (SPEC-013 §11): on a row + // without a platform it describes nothing, and a configuration that serves + // both kinds of row may state it, so it is said and not refused. + if (!P.active && !P.fields.carriers.empty()) + mcpp::diag::warning("platform/carrier", std::format( + "`carrier` ({}) is stated for {}, which uses no platform; a carrier is a form of a " + "platform's image, so this build has none and the key is not used", + mcpp::platform::origin_text(P.fields.carriers.front().origin), t.str())); + // ── The programs the link and the seal run (§4.4, §4.6) ─────────────── - if (P.active) { + { std::set needed; for (auto const& in : P.fields.link.inputs) if (!in.from.empty()) needed.insert(in.from.front()); @@ -1595,43 +1649,48 @@ std::expected step13_finish_platform(PrepareState& state, Bui refusal::record(refusal::Code::PlatformToolAbsent); auto it = P.fields.tools.find(name); const std::string from = it == P.fields.tools.end() - ? std::string("the platform names no package that builds it") + ? std::string("no package that builds it is named") : std::format("{} builds it ({})", mp::display(it->second.ref), mcpp::platform::origin_text(it->second.origin)); return std::unexpected(std::format( - "the platform {} links {} with `{}`, and it is neither built by the graph nor found " + "{} links {} with `{}`, and it is neither built by the graph nor found " "on this machine; {}.\n" " Name the package that builds it for this machine:\n" "\n" - " [target.'cfg(platform = \"{}\")'.tools]\n" + " [target.{}.tools]\n" " {} = \"@\" # or {{ path = \"\" }}, {{ program = \"\" }}", - P.display(), t.str(), name, from, mp::platform_name(state.platformPackageShortName), + stater, t.str(), name, from, + P.active ? std::format("'cfg(platform = \"{}\")'", + mp::platform_name(state.platformPackageShortName)) + : t.str(), name)); } } // A platform that links with ld.lld needs one beside the compiler; its // absence is said here, not as a link line that starts with a flag. - if (P.active && P.fields.link.driver.value == "lld" && linksSomething + if (P.fields.link.driver.value == "lld" && linksSomething && mcpp::freestanding::resolve_lld_any(state.tc->binaryPath).empty()) { refusal::record(refusal::Code::LldRequiredAbsent); return std::unexpected(std::format( - "the platform {} links {} with ld.lld itself ({}), and the toolchain has no ld.lld " + "{} links {} with ld.lld itself ({}), and the toolchain has no ld.lld " "beside {}.\n" " Use a toolchain whose payload carries it -- the platform's own is {} -- with " "`[target.] toolchain`, or remove the line that names this one.", - P.display(), t.str(), mcpp::platform::origin_text(P.fields.link.driver.origin), + stater, t.str(), mcpp::platform::origin_text(P.fields.link.driver.origin), state.tc->binaryPath.generic_string(), P.fields.toolchain.set ? P.fields.toolchain.value : std::string("an llvm toolchain"))); } // `link.flags` are words for ld.lld itself; a platform that links through // the compiler gives them to no program, and says so rather than dropping // them (`[platform.build] ldflags` reach the compiler's link). - if (P.active && P.fields.link.flags.set && P.fields.link.driver.value != "lld") + if (P.fields.link.flags.set && P.fields.link.driver.value != "lld") mcpp::diag::warning("build", std::format( - "the platform {} states `[platform.link] flags` ({}), and it links through the " + "{} states `{}` ({}), and it links through the " "compiler: those words are given to ld.lld only, so this link uses none of them.\n" - " Words for the compiler's link belong in `[platform.build] ldflags`.", - P.display(), mcpp::platform::origin_text(P.fields.link.flags.origin))); + " Words for the compiler's link belong in `{}`.", + stater, P.active ? "[platform.link] flags" : "[target..link] flags", + mcpp::platform::origin_text(P.fields.link.flags.origin), + P.active ? "[platform.build] ldflags" : "[target..build] ldflags")); // THE PLATFORM, REPORTED (SPEC-013 §9): which one and why, then what it // contributes beyond the layers the Target lines already showed. if (P.active) { diff --git a/src/build/prepare/state.cppm b/src/build/prepare/state.cppm index 49b08495f..b695ed662 100644 --- a/src/build/prepare/state.cppm +++ b/src/build/prepare/state.cppm @@ -1262,6 +1262,10 @@ base_statement(PrepareState& state, const mcpp::toolchain::triple::Triple& t); const std::string* base_statement_text(PrepareState& state, const mcpp::toolchain::triple::Triple& t); std::expected step2_resolve_base(PrepareState& state); +// The kernel headers a build compiles against, on a system that publishes them +// apart from its C library (design 2026-11-22 §3.3): decided after the target +// side, into `tc->base.kernel` and the kernel-abi layer's report. +std::expected step9_kernel_headers(PrepareState& state); // The directory a package statement names (`xim:@`): where its // payload stands, installed first when `install` and it does not stand. std::expected @@ -1471,6 +1475,9 @@ bool refused_without_platform(const PrepareState& state, std::string_view reques void step4b_seed_platform(PrepareState& state); std::expected step4b_apply_platform(PrepareState& state); +// Whether a layer entry names a prebuilt supplier (a payload, or a directory +// that is no package) rather than a package of the graph. +bool prebuilt_layer(const mcpp::manifest::platform::LayerEntry& e); // The capabilities packages require and nothing provides: each takes the // default its package states for the target (mcpp#911 G7). True when one was // added to the walk. diff --git a/src/build/prepare/target_side.cpp b/src/build/prepare/target_side.cpp index de69adf06..192159d02 100644 --- a/src/build/prepare/target_side.cpp +++ b/src/build/prepare/target_side.cpp @@ -736,6 +736,33 @@ static const mcpp::modgraph::PackageRoot* kernel_abi_provider(const PrepareState return nullptr; } +// THE KERNEL-ABI LAYER'S INTERFACES (design 2026-11-22 §3.17): its package's +// `[kernel-abi] provides-interfaces`, or, where the layer is the system itself, +// the system's statement (`[[platform.system]] interfaces`). One list answers +// `cfg(interface = …)`, the report and `mcpp why toolchain`. A package that +// states none, and a system that states none, provide every interface. +static void step9_kernel_abi_interfaces(PrepareState& state) { + auto& l = state.resolvedTargetSide.kernelAbi; + if (auto const* pkg = kernel_abi_provider(state)) { + l.interfaces = pkg->manifest.kernelAbiProvidesInterfaces; + l.interfacesStated = true; + return; + } + if (l.absent() || l.fromGraph() || !state.tc) return; + auto tt = mcpp::toolchain::triple::parse(state.tc->targetTriple); + if (!tt) return; + // The row's statement, then its system's. + if (auto const* row = mcpp::toolchain::target::find_row(tt->str()); row && row->interfacesStated) { + l.interfaces.assign(row->interfaces.begin(), row->interfaces.end()); + l.interfacesStated = true; + return; + } + auto const* sys = mcpp::toolchain::target::find_system(tt->os); + if (!sys || !sys->interfacesStated) return; + l.interfaces.assign(sys->interfaces.begin(), sys->interfaces.end()); + l.interfacesStated = true; +} + static std::expected step9_target_side_include_broadcast(PrepareState& state, TargetSideGather& gather) { namespace tsd = mcpp::targetside; @@ -1521,10 +1548,8 @@ static std::expected step9_layer_conditional_config(PrepareSt layerCtx.kernelAbi = state.resolvedTargetSide.kernelAbi.interfaceName; layerCtx.cAbi = state.resolvedTargetSide.cAbi.interfaceName; layerCtx.cxxAbi = state.resolvedTargetSide.cxx.interfaceName; - if (auto const* pkg = kernel_abi_provider(state)) { - layerCtx.interfaces = pkg->manifest.kernelAbiProvidesInterfaces; - layerCtx.interfacesStated = true; - } + layerCtx.interfaces = state.resolvedTargetSide.kernelAbi.interfaces; + layerCtx.interfacesStated = state.resolvedTargetSide.kernelAbi.interfacesStated; // A REQUIREMENT A LAYER DECIDES IS CHECKED NOW, WHEN THE LAYERS ARE // KNOWN. `[target.'cfg(all(windows, compiler = "llvm"))'] requires = // ["mcpp:compiler-runtime=compiler-rt"]` states what one compiler needs @@ -2117,6 +2142,8 @@ std::expected phase9_target_side(PrepareState& state) { if (!gather) return std::unexpected(gather.error()); if (auto r = step9_resolve_and_realise_cabi(state, *gather); !r) return std::unexpected(r.error()); + if (auto r = step9_kernel_headers(state); !r) return std::unexpected(r.error()); + step9_kernel_abi_interfaces(state); if (auto r = step9_target_side_include_broadcast(state, *gather); !r) return std::unexpected(r.error()); if (auto r = step9_kernel_abi_interfaces_and_requirements(state, *gather); !r) diff --git a/src/doctor.cppm b/src/doctor.cppm index c00d089d6..873867c40 100644 --- a/src/doctor.cppm +++ b/src/doctor.cppm @@ -1372,6 +1372,10 @@ export int why_toolchain_json(std::string_view target, std::string_view tcSpec) ? std::string("platform") : std::string(mcpp::targetside::origin_name(l.origin))}, {"subset", l.subset}, + // The kernel-abi layer's measured version and its interfaces + // (design 2026-11-22 §3.8, §3.17); added fields. + {"version", l.version}, + {"interfaces", l.interfacesStated ? nlohmann::json(l.interfaces) : nlohmann::json(nullptr)}, }; }; data["layers"] = nlohmann::json::array({ diff --git a/src/fallback/sysroot_complete.cppm b/src/fallback/sysroot_complete.cppm index fad98748d..6458ebe54 100644 --- a/src/fallback/sysroot_complete.cppm +++ b/src/fallback/sysroot_complete.cppm @@ -1,7 +1,7 @@ // mcpp.fallback.sysroot_complete — ensure sysroot has complete headers. // -// When GCC's probed sysroot exists but may be missing linux kernel -// headers or glibc headers, symlink them from the payload xpkgs. +// When GCC's probed sysroot exists but is missing the glibc headers, symlink +// them from the payload xpkgs. export module mcpp.fallback.sysroot_complete; @@ -12,7 +12,7 @@ export namespace mcpp::fallback { // Ensure sysroot directory has complete headers by symlinking from // payload xpkgs. Called when GCC's probed sysroot exists but may -// be missing linux kernel headers or glibc headers. +// be missing the glibc headers. void ensure_sysroot_complete(const std::filesystem::path& sysroot, const mcpp::toolchain::PayloadPaths& pp) { if (sysroot.empty()) return; @@ -22,17 +22,10 @@ void ensure_sysroot_complete(const std::filesystem::path& sysroot, std::error_code ec; - // Ensure linux kernel headers are present in sysroot. - // If missing, symlink from linux-headers payload. - if (!pp.linuxInclude.empty()) { - for (auto dir : {"linux", "asm", "asm-generic"}) { - auto target = sysrootInclude / dir; - auto source = pp.linuxInclude / dir; - if (!std::filesystem::exists(target, ec) && std::filesystem::exists(source, ec)) { - std::filesystem::create_directory_symlink(source, target, ec); - } - } - } + // The kernel headers are not written here: they are the kernel-abi + // layer's, decided per build and wired ahead of the base (design + // 2026-11-22 §3.3). A link written into a shared view is that view's + // history, and two toolchains that declare different versions share it. // Ensure glibc headers are present if sysroot is bare. if (!std::filesystem::exists(sysrootInclude / "features.h", ec)) { diff --git a/src/modgraph/graph.cppm b/src/modgraph/graph.cppm index 6496781de..9cd442b2f 100644 --- a/src/modgraph/graph.cppm +++ b/src/modgraph/graph.cppm @@ -53,6 +53,9 @@ struct SourceUnit { // reads this field). std::filesystem::path relPath; std::string packageName; + // An action's generated unit: the authored source it is a transformed + // copy of, as the action stated it (mcpp#1004); empty otherwise. + std::filesystem::path origin; std::vector localIncludeDirs; // #249: dirs emitted as -idirafter — searched after the toolchain's // system dirs, so a dep's source root can't shadow standard headers. diff --git a/src/modgraph/scanner.cppm b/src/modgraph/scanner.cppm index df9ddef17..e5566800f 100644 --- a/src/modgraph/scanner.cppm +++ b/src/modgraph/scanner.cppm @@ -1334,8 +1334,15 @@ void scan_one_into(ScanResult& result, // action unit that declares no module asserts nothing. u.scanOverridden = !declaredByAction || !ov->provides.empty(); // The override names modules; it does not carry the declaration. - u.declaration = declaredByAction && ov->provides.empty() - ? ModuleDeclaration::None : ModuleDeclaration::Unknown; + // An action that declares a module's primary name declares its + // interface: only `export module M;` provides `M`. A partition's + // name (`M:P`) is provided by an interface or an implementation + // partition alike, and stays unknown (mcpp#1004). + u.declaration = declaredByAction && ov->provides.empty() ? ModuleDeclaration::None + : declaredByAction && ov->provides.front().find(':') == std::string::npos + ? ModuleDeclaration::Interface + : ModuleDeclaration::Unknown; + if (declaredByAction && !ov->origin.empty()) u.origin = native_path_from_generic(ov->origin); // A declared unit still gets its role from the same classifier — // scan_overrides overrides what was SCANNED, not what the file is. u.kind = mcpp::classify(f, extTable); @@ -1505,6 +1512,11 @@ void resolve_graph(ScanResult& result) { same_file(first.path, second.path) ? "; one file is reached as two packages, and a package that " "both depend on would provide it once" + : (!first.origin.empty() && same_file(first.origin, second.path)) + || (!second.origin.empty() && same_file(second.origin, first.path)) + ? "; one is the generated copy of the other (its action's origin), so the " + "authored file is compiled through its copy and is listed as a source as " + "well: remove it from the package's sources" : "")}); }; std::set> withUnits; diff --git a/src/toolchain/base_probe.cppm b/src/toolchain/base_probe.cppm index e21ceb64a..0a27e8755 100644 --- a/src/toolchain/base_probe.cppm +++ b/src/toolchain/base_probe.cppm @@ -36,13 +36,12 @@ inline bool is_payload_layout(const fs::path& root) { || fs::exists(root / "lib64" / "libc.so", ec) || fs::exists(root / "lib" / "libc.so", ec); } -inline PayloadPaths payload_layout_paths(const fs::path& root, const fs::path& linuxInclude) { +inline PayloadPaths payload_layout_paths(const fs::path& root) { PayloadPaths pp; std::error_code ec; pp.glibcInclude = root / "include"; pp.glibcLib = fs::exists(root / "lib64" / "libc.so.6", ec) || fs::exists(root / "lib64" / "libc.so", ec) ? root / "lib64" : root / "lib"; - pp.linuxInclude = fs::exists(root / "include" / "linux" / "limits.h", ec) ? fs::path{} : linuxInclude; return pp; } diff --git a/src/toolchain/detect.cppm b/src/toolchain/detect.cppm index 3accb75f9..e1b0fe0e6 100644 --- a/src/toolchain/detect.cppm +++ b/src/toolchain/detect.cppm @@ -23,6 +23,12 @@ detect(const std::filesystem::path& explicit_compiler = {}, std::string_view runtimeBinding = {}, std::string_view runtimeContractHash = {}); +// THE ECOSYSTEM'S SHARED VIEW (SPEC-006 §2.2.1): the probed sysroot of a +// toolchain whose base nobody stated, living in the home of the payloads its +// glibc comes from. mcpp completes its glibc headers; its other contents are +// the home's history, which no build reads as a fact (design 2026-11-22 §3.3). +bool base_is_ecosystem_view(const Toolchain& tc); + // Compatibility helper for older call sites/tests: GCC std module lookup now // lives in the GCC provider. std::optional find_std_module_source( @@ -163,14 +169,20 @@ detect(const std::filesystem::path& explicit_compiler, // D10): its headers are completed on the command line instead. The view // is owned when it lives in the same home as the payloads it is completed // from. - if (tc.base.payload && !tc.base.root.empty()) { - auto store = mcpp::provider::store_of(tc.base.payload->glibcInclude); - if (store && mcpp::fallback::path_is_under( - tc.base.root, mcpp::provider::layout().home_of_store(*store))) - ensure_sysroot_complete(tc.base.root, *tc.base.payload); - } + if (base_is_ecosystem_view(tc)) + ensure_sysroot_complete(tc.base.root, *tc.base.payload); return tc; } +bool base_is_ecosystem_view(const Toolchain& tc) { + if (tc.base.stated() || !tc.base.payload || tc.base.root.empty()) return false; + // A view is one of the home's SubOS roots, the parent of the compiler's + // environment. A sysroot a managed toolchain carries in its own payload + // (a musl cross toolchain's `/`) lives in the same home and is + // that toolchain's tree, not a view. + auto env = mcpp::provider::environment_of(tc.binaryPath); + return env && mcpp::fallback::path_is_under(tc.base.root, env->parent_path()); +} + } // namespace mcpp::toolchain diff --git a/src/toolchain/probe.cppm b/src/toolchain/probe.cppm index 21ac57e3b..cea4af3d8 100644 --- a/src/toolchain/probe.cppm +++ b/src/toolchain/probe.cppm @@ -765,29 +765,7 @@ probe_payload_paths(const std::filesystem::path& compilerBin, pp.glibcInclude = glibcInclude; pp.glibcLib = glibcLib; - // Find linux kernel headers (optional — search across index prefixes, - // then the active home registry). Require the actual payload: a - // delegating index package (xim:linux-headers → scode:linux-headers) - // leaves a metadata-only husk under its own prefix, and the discovery - // must skip it instead of giving up (issue #120: glibc's local_lim.h - // needs , so a silent miss breaks every glibc build). - constexpr std::string_view kLinuxLimits = "include/linux/limits.h"; - auto linuxHeaders = - mcpp::provider::beside(compilerBin, "linux-headers", kLinuxLimits); - if (!linuxHeaders) - linuxHeaders = mcpp::provider::in_home_store("linux-headers", kLinuxLimits); - if (linuxHeaders) { - pp.linuxInclude = *linuxHeaders / "include"; - } else { - mcpp::log::verbose("probe", - "linux-headers payload not found under any index prefix — " - "glibc builds will fail at "); - } - - mcpp::log::verbose("probe", std::format( - "payload paths: glibcLib='{}' linuxInclude='{}'", - pp.glibcLib.string(), - pp.linuxInclude.empty() ? "(none)" : pp.linuxInclude.string())); + mcpp::log::verbose("probe", std::format("payload paths: glibcLib='{}'", pp.glibcLib.string())); return pp; } diff --git a/tests/e2e/cdb/emit.cpp b/tests/e2e/cdb/emit.cpp index 1ea42b6b1..fa8a5ae3f 100644 --- a/tests/e2e/cdb/emit.cpp +++ b/tests/e2e/cdb/emit.cpp @@ -418,6 +418,57 @@ int main() { expect(fatal(e2e::succeeded(r))) << "the compile database failed: " << r.err; expect(fatal(s::lacks(r.out, R"("generated")"))) << "C: compile_commands.json carries a generated field"; }; + "1152 a generated unit names the authored file it copies"_test[s::unix_shell][s::python3] = [] { + // mcpp#1004: A: the generated unit's entry gives `origin`, the authored file its action + // states, and the unit that declares the module's primary name is its interface; B: the + // authored file listed among the sources as well is refused, and the error names the + // relation. + const auto rule = R"(import std; +import mcpp; +int main() { + const std::string in = std::string(mcpp::manifest_dir()) + "/templates/core.cppm"; + const std::string out = std::string(mcpp::out_dir()) + "/core.cppm"; + mcpp::action a; + a.id = "copy:core"; + a.role = mcpp::roles::source; + a.arg("cp").arg(in.c_str()).arg(out.c_str()) + .input(in.c_str()) + .origin(in.c_str()) + .output(out.c_str()) + .provides("app.core") + .submit(); +} +)"; + const auto manifest = [](std::string_view sources) { + return std::format("[package]\nname = \"origin\"\nversion = \"0.1.0\"\n{}\n" + "[targets.origin]\nkind = \"bin\"\nmain = \"src/main.cpp\"\n", sources); + }; + s::project p({{"mcpp.toml", manifest("")}, + {"templates/core.cppm", "export module app.core;\nexport int answer() { return 42; }\n"}, + {"src/main.cpp", "import app.core;\nint main() { return answer() == 42 ? 0 : 1; }\n"}, + {"build.mcpp", rule}}); + auto r = p.mcpp({"emit", "build-database", "--format", "json"}, at_root); + expect(fatal(e2e::succeeded(r))) << "the plan failed: " << r.err; + const auto set = s::json(r.out)["data"]["database"]["sets"][0]; + nlohmann::json unit; + for (const auto& g : set["ide"].value("generated", nlohmann::json::array())) + if (g["kind"] == "source") unit = g; + expect(fatal(!unit.is_null())) << "A: no generated source entry: " << set.dump(); + expect(fatal(unit.contains("origin") && slash(unit["origin"].get()).ends_with("templates/core.cppm"))) + << "A: " << unit.dump(); + std::string role; + for (const auto& u : set["translation-units"]) + if (basename(u["source"]) == "core.cppm") role = u["ide"]["role"]; + expect(fatal(eq(role, std::string("module-interface")))) << "A: the generated unit's role"; + r = p.mcpp({"build"}); + expect(fatal(e2e::succeeded(r))) << "the build failed: " << s::text(r); + + p.write("mcpp.toml", manifest("\n[modules]\nsources = [\"src/**/*.cpp\", \"templates/*.cppm\"]\n")); + r = p.mcpp({"build"}); + expect(fatal(!e2e::succeeded(r))) << "B: the second provider was accepted"; + expect(fatal(e2e::contains(s::text(r), "generated copy of the other"))) << "B: " << s::text(r); + }; + "817 emit writes no xlings json under private work dir"_test[s::unix_shell][s::python3] = [] { // A project declaring [xlings] deps: emit leaves the project tree as it was, writes no // /.mcpp/.xlings.json, states no write-project effect, and writes the declaration diff --git a/tests/e2e/targets/kernel.cpp b/tests/e2e/targets/kernel.cpp new file mode 100644 index 000000000..857a801f6 --- /dev/null +++ b/tests/e2e/targets/kernel.cpp @@ -0,0 +1,101 @@ +// The kernel headers are the kernel-abi layer's (design 2026-11-22, kernel interface and derived +// state, §3.1-§3.6): a statement in a project's `[target..layers]` takes effect on a row +// without a platform, the headers in effect are measured and reported, a prebuilt form is refused +// where the row's system does not publish its kernel headers apart from its C library, and the +// platform keys of a row without a platform reach the build (§3.2). +import std; +import mcpplibs.mtest; +import mcpp.test.support; + +using namespace mcpplibs::mtest; +namespace s = mcpp::test::support; + +namespace { + +// A header directory standing in for a release of the kernel's UAPI headers: +// with the macros headers_install writes, and one header of its own that a program can include. +std::string version_h(int major, int patch, int sub, bool partsMacros) { + std::string h = std::format("#define LINUX_VERSION_CODE {}\n", (major << 16) + (patch << 8) + (sub > 255 ? 255 : sub)); + if (partsMacros) + h += std::format("#define LINUX_VERSION_MAJOR {}\n#define LINUX_VERSION_PATCHLEVEL {}\n" + "#define LINUX_VERSION_SUBLEVEL {}\n", major, patch, sub); + return h; +} + +const char* kProgram = + "#include \n" + "#include \n" + "#include \n" + "int main(void) { printf(\"code=%d probe=%d\\n\", LINUX_VERSION_CODE, MCPP_PROBE); return 0; }\n"; + +std::string manifest(std::string_view extra) { + return std::format("[package]\nname = \"kernel-probe\"\nversion = \"0.1.0\"\n\n" + "[targets.kernel-probe]\nkind = \"bin\"\nmain = \"src/main.c\"\n\n{}", extra); +} + +} // namespace + +E2E kernel{"kernel", s::home_fixture, [] { + "1147 a directory states the kernel headers on a row without a platform"_test[s::elf] = [] { + // The statement used to be accepted and dropped (the merge of the tiers waited for a + // platform package). It now supplies the layer: the program compiles against it, and the + // report gives the measured version. + s::project p({{"mcpp.toml", manifest( + "[target.'cfg(os = \"linux\")'.layers]\nkernel-abi = { path = \"uapi\" }\n")}, + {"src/main.c", kProgram}, + {"uapi/linux/version.h", version_h(6, 18, 64, true)}, + {"uapi/linux/mcpp_probe.h", "#define MCPP_PROBE 7\n"}}); + const auto out = s::text(p.mcpp({"run"})); + expect(fatal(s::has_line(out, R"(code=397888 probe=7)"))) << "the stated headers must be the ones compiled: " << out; + expect(fatal(s::has_line(out, R"(kernel-abi +linux 6\.18\.64 .*path .*uapi.*prebuilt)"))) + << "the report must give the measured version and the statement: " << out; + }; + + "1148 a packed version is decoded by the row's widths"_test[s::elf] = [] { + // linux 4.19.256 defines LINUX_VERSION_CODE alone, with its sublevel saturated at 255. + s::project p({{"mcpp.toml", manifest( + "[target.'cfg(os = \"linux\")'.layers]\nkernel-abi = { path = \"uapi\" }\n")}, + {"src/main.c", kProgram}, + {"uapi/linux/version.h", version_h(4, 19, 256, false)}, + {"uapi/linux/mcpp_probe.h", "#define MCPP_PROBE 1\n"}}); + const auto out = s::text(p.mcpp({"build"})); + expect(fatal(s::has_line(out, R"(kernel-abi +linux 4\.19\.255 )"))) << out; + }; + + "1149 a prebuilt form is refused where the system data takes none"_test[s::elf] = [] { + // Another layer of a Linux row takes no prebuilt form: the C library is stated with the base. + s::project p({{"mcpp.toml", manifest( + "[target.'cfg(os = \"linux\")'.layers]\nc-abi = \"xim:glibc@2.39\"\n")}, + {"src/main.c", "int main(void) { return 0; }\n"}}); + const auto r = p.mcpp({"build"}); + expect(fatal(!e2e::succeeded(r))); + const auto out = s::text(r); + expect(fatal(e2e::contains(out, "names a prebuilt supplier"))) << out; + expect(fatal(e2e::contains(out, "sysroot"))) << "the refusal must name the key that states a base: " << out; + // A payload without its version is a manifest error, with the example. + p.write("mcpp.toml", manifest("[target.'cfg(os = \"linux\")'.layers]\nkernel-abi = \"xim:linux-headers\"\n")); + const auto bare = s::text(p.mcpp({"build"})); + expect(fatal(e2e::contains(bare, "without its version"))) << bare; + }; + + "1150 the platform keys of a row without a platform reach the build"_test[s::elf] = [] { + // `link.flags` without ld.lld reaches no program, and the build says so; before, the key + // was dropped without a word. `carrier` describes a platform's image and is a warning. + s::project p({{"mcpp.toml", manifest( + "[target.'cfg(os = \"linux\")'.link]\nflags = [\"--mcpp-e2e-flag\"]\n\n" + "[target.'cfg(os = \"linux\")']\ncarrier = { package = \"none-such@1.0.0\", section = \"x\", main = \"src/main.c\" }\n")}, + {"src/main.c", "int main(void) { return 0; }\n"}}); + const auto out = s::text(p.mcpp({"build"})); + expect(fatal(e2e::contains(out, "states `[target..link] flags`"))) << out; + expect(fatal(e2e::contains(out, "`carrier`"))) << out; + }; + + "1151 the default kernel headers are measured and reported"_test[s::elf] = [] { + // Without a statement the headers are the base's own or the toolchain's declaration, never + // the shared view's links; either way the report names a measured version. + s::project p({{"mcpp.toml", manifest("")}, + {"src/main.c", "#include \nint main(void) { return LINUX_VERSION_CODE == 0; }\n"}}); + const auto out = s::text(p.mcpp({"build", "-v"})); + expect(fatal(s::has_line(out, R"(kernel-abi +linux [0-9]+\.[0-9]+\.[0-9]+ )"))) << out; + }; +}}; diff --git a/tests/unit/test_build_directives.cpp b/tests/unit/test_build_directives.cpp index 9ecd17205..718036de2 100644 --- a/tests/unit/test_build_directives.cpp +++ b/tests/unit/test_build_directives.cpp @@ -788,6 +788,33 @@ UTest decode_action_defaults_depfile_to_empty_when_absent{"BuildDirectives/Decod expect(eq(a->depfile, "")); }}; +// THE AUTHORED SOURCE OF A GENERATED UNIT (mcpp#1004): `origin` round-trips, +// is one of the inputs, and belongs to a `source` action; anything else is +// refused by name, never dropped. +UTest decode_action_round_trips_origin{"BuildDirectives/DecodeActionRoundTripsOrigin", [] { + auto d = parse( + "mcpp:action={\"id\":\"hcg\",\"role\":\"source\",\"description\":\"\",\"blocking\":false," + "\"origin\":\"/p/src/app.cppm\",\"inputs\":[\"/p/src/app.cppm\",\"/t/hcg\"]," + "\"outputs\":[\"out/hcg/app.cppm\"],\"command\":[\"/t/hcg\"],\"provides\":[\"app\"]," + "\"imports\":[],\"targets\":[]}\n"); + expect(fatal(eq(d.at(dirs::Slot::Actions).size(), 1u))); + auto a = dirs::decode_action(d.at(dirs::Slot::Actions).front()); + expect(fatal(a.has_value())); + expect(eq(a->origin, "/p/src/app.cppm")); + expect(eq(dirs::action_error(d), "")); +}}; + +UTest an_origin_outside_the_inputs_is_refused{"BuildDirectives/AnOriginOutsideTheInputsIsRefused", [] { + auto d = parse( + "mcpp:action={\"id\":\"hcg\",\"role\":\"source\",\"description\":\"\",\"blocking\":false," + "\"origin\":\"/p/src/other.cppm\",\"inputs\":[\"/p/src/app.cppm\"]," + "\"outputs\":[\"out/hcg/app.cppm\"],\"command\":[\"/t/hcg\"],\"provides\":[]," + "\"imports\":[],\"targets\":[]}\n"); + expect(fatal(eq(d.at(dirs::Slot::Actions).size(), 1u))); + expect(!dirs::decode_action(d.at(dirs::Slot::Actions).front()).has_value()); + expect(dirs::action_error(d).contains("is not one of its inputs")); +}}; + // The overflow marker. Until 2026.9.13.1 `mcpp::action` held its lists in // fixed arrays and set the marker when a declaration did not fit; the lists // now grow, and the marker means the build program could not allocate. The diff --git a/tests/unit/test_link_line_golden.cpp b/tests/unit/test_link_line_golden.cpp index ae116275b..f6f715a1f 100644 --- a/tests/unit/test_link_line_golden.cpp +++ b/tests/unit/test_link_line_golden.cpp @@ -106,7 +106,7 @@ UTest gcc_over_the_hosts_payload{"LinkLineGolden/GccOverTheHostsPayload", [] { t.dir("glibc/include"); t.dir("gcc/lib64"); auto plan = plan_for(tc::CompilerId::GCC, t.file("gcc/bin/g++"), "x86_64-linux-gnu"); - plan.toolchain.base.payload = tc::PayloadPaths{ t.root / "glibc/include", glibc, {} }; + plan.toolchain.base.payload = tc::PayloadPaths{ t.root / "glibc/include", glibc }; const auto f = compute_flags(plan); const Words want{ "-B/glibc/lib64", "-L/glibc/lib64", "-Wl,-rpath,/glibc/lib64", "-L/gcc/lib64", "-Wl,-rpath,/gcc/lib64", @@ -125,7 +125,7 @@ UTest clang_over_the_hosts_payload{"LinkLineGolden/ClangOverTheHostsPayload", [] t.file("llvm/bin/clang++.cfg"); t.dir("llvm/include/c++/v1"); auto plan = plan_for(tc::CompilerId::Clang, t.file("llvm/bin/clang++"), "x86_64-linux-gnu"); - plan.toolchain.base.payload = tc::PayloadPaths{ t.root / "glibc/include", glibc, {} }; + plan.toolchain.base.payload = tc::PayloadPaths{ t.root / "glibc/include", glibc }; const auto f = compute_flags(plan); const Words want{ "-B/glibc/lib64", "-L/glibc/lib64", "-Wl,-rpath,/glibc/lib64", "-Wl,--dynamic-linker=/glibc/lib64/ld-linux-x86-64.so.2" }; @@ -190,7 +190,7 @@ UTest the_graph_supplies_the_c_library{"LinkLineGolden/TheGraphSuppliesTheCLibra t.file("llvm/bin/clang++.cfg"); t.dir("llvm/include/c++/v1"); auto plan = plan_for(tc::CompilerId::Clang, t.file("llvm/bin/clang++"), "x86_64-linux-musl"); - plan.toolchain.base.payload = tc::PayloadPaths{ t.root / "glibc/include", glibc, {} }; + plan.toolchain.base.payload = tc::PayloadPaths{ t.root / "glibc/include", glibc }; plan.targetSide.kernelAbi = { ts::Origin::Graph, "openkal", "openkal-linux@0", false }; plan.targetSide.cAbi = { ts::Origin::Graph, "musl", "openkal-musl@0", false }; plan.targetSide.cxx = { ts::Origin::Graph, "libc++", "openkal-llvm-runtime@0", false }; diff --git a/tests/unit/test_linkmodel.cpp b/tests/unit/test_linkmodel.cpp index 3674de779..5201b4dc0 100644 --- a/tests/unit/test_linkmodel.cpp +++ b/tests/unit/test_linkmodel.cpp @@ -105,7 +105,6 @@ struct FakeClangWithPayload { t.base.payload = tc::PayloadPaths{ .glibcInclude = glibc / "include", .glibcLib = glibcLib, - .linuxInclude = {}, }; } }; @@ -153,7 +152,6 @@ UTest gcc_sysroot_wins_over_payload{"LinkModel/GccSysrootWinsOverPayload", [] { t.base.payload = tc::PayloadPaths{ .glibcInclude = dir.path / "glibc" / "include", .glibcLib = dir.path / "glibc" / "lib64", - .linuxInclude = dir.path / "linux" / "include", }; auto lm = tc::resolve_link_model(t); expect(eq(lm.mode, tc::CLibMode::Sysroot)); @@ -162,27 +160,42 @@ UTest gcc_sysroot_wins_over_payload{"LinkModel/GccSysrootWinsOverPayload", [] { // --sysroot already replaces the recorded sysroot. expect(eq(lm.compile_flags(ident).find("-isysroot"), std::string::npos)); expect(ne(lm.link_flags(ident).find("--sysroot="), std::string::npos)); - // Kernel headers exist in the sysroot → no supplement. + // No kernel headers decided: nothing ahead of the base. expect(lm.systemIncludes.empty()); + expect(lm.kernelIncludes.empty()); }}; -UTest gcc_sysroot_supplements_missing_kernel_headers{"LinkModel/GccSysrootSupplementsMissingKernelHeaders", [] { +// THE KERNEL HEADERS ARE ONE WIRING (design 2026-11-22 §3.5): the decided +// directories, `-isystem`, first, for gcc and clang and in every mode -- the +// sysroot of a view, a payload layout, a toolchain's own sysroot. The model +// asks no file of the base: the decision was made once, before it. +UTest kernel_headers_lead_every_mode{"LinkModel/KernelHeadersLeadEveryMode", [] { Tmp dir; - auto sysroot = dir.path / "sysroot"; - touch(sysroot / "usr" / "include" / "stdlib.h"); // no linux/limits.h - tc::Toolchain t; - t.compiler = tc::CompilerId::GCC; - t.targetTriple = "x86_64-linux-gnu"; - t.base.root = sysroot; - t.base.payload = tc::PayloadPaths{ - .glibcInclude = dir.path / "glibc" / "include", - .glibcLib = dir.path / "glibc" / "lib64", - .linuxInclude = dir.path / "linux" / "include", + const auto arch = dir.path / "lh" / "arch" / "aarch64" / "include"; + const auto common = dir.path / "lh" / "include"; + auto first_tokens = [&](tc::Toolchain t) { + t.base.kernel.dirs = {arch, common}; + t.base.kernel.version = "6.18.64"; + auto tokens = tc::resolve_link_model(t).compile_tokens(ident); + expect(fatal(tokens.size() >= 2u)); + expect(eq(tokens[0], "-isystem" + arch.string())); + expect(eq(tokens[1], "-isystem" + common.string())); }; - auto lm = tc::resolve_link_model(t); - expect(fatal(eq(lm.systemIncludes.size(), 1u))); - // Sysroot-mode supplement renders as -isystem even for GCC. - expect(ne(lm.compile_flags(ident).find("-isystem"), std::string::npos)); + tc::Toolchain sysrootGcc; + sysrootGcc.compiler = tc::CompilerId::GCC; + sysrootGcc.targetTriple = "x86_64-linux-gnu"; + sysrootGcc.base.root = dir.path / "sysroot"; + first_tokens(sysrootGcc); + tc::Toolchain payloadGcc; + payloadGcc.compiler = tc::CompilerId::GCC; + payloadGcc.targetTriple = "x86_64-linux-gnu"; + payloadGcc.base.payload = tc::PayloadPaths{ .glibcInclude = dir.path / "glibc" / "include", + .glibcLib = dir.path / "glibc" / "lib64" }; + first_tokens(payloadGcc); // -isystem, not the payload's -idirafter + tc::Toolchain ownMusl; + ownMusl.compiler = tc::CompilerId::GCC; + ownMusl.targetTriple = "x86_64-linux-musl"; + first_tokens(ownMusl); }}; UTest gcc_payload_emits_idirafter_and_its_own_addressing{"LinkModel/GccPayloadEmitsIdirafterAndItsOwnAddressing", [] { @@ -195,7 +208,6 @@ UTest gcc_payload_emits_idirafter_and_its_own_addressing{"LinkModel/GccPayloadEm t.base.payload = tc::PayloadPaths{ .glibcInclude = dir.path / "glibc" / "include", .glibcLib = glibcLib, - .linuxInclude = {}, }; auto lm = tc::resolve_link_model(t); expect(eq(lm.mode, tc::CLibMode::PayloadFirst)); From 54ae9ef829eaec9d9bb393c8d278ea8fc0b24e91 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 02:46:23 +0900 Subject: [PATCH 02/33] feat: riscv64-linux-musl is a preview row built by the musl cross payload and run under qemu-user; kernel-abi = false decides no headers The row's provider pins gcc@16.1.0 and states its runner (xim:qemu-user-riscv64@7.2.0, linux-x86_64). The snapshot records the new tier, the pin and the requests it answers; the linux-musl set now includes the row. A statement of kernel-abi = false, as a freestanding platform writes, decides and measures no kernel headers. --- CHANGELOG.md | 4 +++ README.md | 3 +- README.zh-CN.md | 3 +- docs/20-toolchains.md | 2 +- docs/21-the-target-triple.md | 4 +-- docs/specs/target-sets.md | 2 +- docs/zh/20-toolchains.md | 2 +- docs/zh/21-the-target-triple.md | 4 +-- modules/toolchain-model/data/builtin.toml | 16 +++++++---- tests/e2e/openkal/sets.cpp | 12 ++++---- tests/e2e/targets/rows.cpp | 34 +++++++++++++++++++++-- tests/fixtures/target-rows.snapshot | 10 +++---- tests/unit/test_target_set.cpp | 4 +-- 13 files changed, 71 insertions(+), 29 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d0761bfef..c90d21ca6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,10 @@ start) and on `wasm32-emscripten`. `cfg(interface = "...")` reads the provider's list, else the row's, else the system's, so it holds on a row without openkal as well. The same list is in `layers[].interfaces` and `MCPP_KERNEL_ABI_INTERFACES` (mcpp#1005). +- `riscv64-linux-musl` is a `preview` row: the musl cross payload `gcc@16.1.0` builds it on a + Linux x86_64 machine, and `mcpp run` starts its static programs under qemu-user + (`xim:qemu-user-riscv64@7.2.0`, installed on the first run). The `linux-musl` target set now + includes it (mcpp#1005). - `mcpp::action::origin(path)` names the authored file a generated unit is a transformed copy of, one of the action's inputs, on a `source` action. The build database gives it as `ide.generated[].origin`. A generated unit that declares a module's primary name is a diff --git a/README.md b/README.md index ab30c4288..5c6781fae 100644 --- a/README.md +++ b/README.md @@ -458,7 +458,8 @@ list` reports for this machine): | `aarch64-windows-gnu` | llvm 23 with `xim:mingw-w64-sysroot` (llvm-mingw's target side) — built on any host; the same base serves `x86_64-windows-gnu` where no gcc payload exists | preview | | `x86_64-freebsd` · `aarch64-freebsd` | the platform that serves them, over `xim:-freebsd-sysroot` ([22](docs/22-target-side.md)) | preview | | `x86_64-freebsd-musl` · `aarch64-freebsd-musl` | llvm 23 — a static FreeBSD program with a musl C library over openkal-freebsd, built on any host *(what `-freebsd` is with no platform chosen)* | preview | -| `riscv64-linux-musl` · `x86_64-macos` · `i686-linux-musl` · `i686-linux-gnu` · `i686-openkal` | — | planned | +| `riscv64-linux-musl` | gcc 16 musl cross from Linux x86_64; `mcpp run` starts it under qemu-user (`xim:qemu-user-riscv64`) | preview | +| `x86_64-macos` · `i686-linux-musl` · `i686-linux-gnu` · `i686-openkal` | — | planned | | `x86_64-openkal` · `aarch64-openkal` | llvm 23 — an ok image: one artifact per architecture, run by `okrun` on Linux, macOS and Windows; the C library and C++ run-time inside it are packages ([24](docs/24-openkal-cross.md)) | verified | | `wasm32-emscripten` | `emsdk@6.0.9` — Emscripten ships its own sysroot and its own libc++ module surface; `mcpp run` executes the module with the `node` the payload declares (`xim:node`), not one found on PATH | verified | | `x86_64-linux-android` | `android-ndk@30.0.16248370` — bionic from the NDK, one payload for both ABIs; ran on an API 24 x86_64 emulator image | verified | diff --git a/README.zh-CN.md b/README.zh-CN.md index bc95ca6d1..bdca8e79b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -407,7 +407,8 @@ mcpp 的身份模型有两条正交的轴:**工具链**是 `family@version`( | `aarch64-windows-gnu` | llvm 23 加 `xim:mingw-w64-sysroot`(llvm-mingw 的目标侧);任意宿主可构建;没有 gcc 载荷之处同一基座也服务 `x86_64-windows-gnu` | preview | | `x86_64-freebsd` · `aarch64-freebsd` | 服务它们的平台,基于 `xim:-freebsd-sysroot`([22](docs/zh/22-target-side.md)) | preview | | `x86_64-freebsd-musl` · `aarch64-freebsd-musl` | llvm 23;openkal-freebsd 之上带 musl C 库的静态 FreeBSD 程序,任意宿主可构建 *(未选平台时 `-freebsd` 即此身份)* | preview | -| `riscv64-linux-musl` · `x86_64-macos` · `i686-linux-musl` · `i686-linux-gnu` · `i686-openkal` | — | planned | +| `riscv64-linux-musl` | gcc 16 musl 交叉工具链,宿主为 Linux x86_64;`mcpp run` 经 qemu-user(`xim:qemu-user-riscv64`)启动 | preview | +| `x86_64-macos` · `i686-linux-musl` · `i686-linux-gnu` · `i686-openkal` | — | planned | | `x86_64-openkal` · `aarch64-openkal` | llvm 23;ok 映像:每种架构一个产物,由 `okrun` 在 Linux、macOS 与 Windows 上运行;映像内的 C 库与 C++ 运行时是包([24](docs/zh/24-openkal-cross.md)) | verified | | `wasm32-emscripten` | `emsdk@6.0.9`;Emscripten 自带 sysroot 与 libc++ 模块接口;`mcpp run` 使用 payload 声明的 `node`(`xim:node`)运行模块,不使用 PATH 上的 `node` | verified | | `x86_64-linux-android` | `android-ndk@30.0.16248370`;bionic 来自 NDK,一个 payload 服务两个 ABI;已在 API 24 的 x86_64 模拟器镜像上运行 | verified | diff --git a/docs/20-toolchains.md b/docs/20-toolchains.md index 1de39eb53..6c72a9dc2 100644 --- a/docs/20-toolchains.md +++ b/docs/20-toolchains.md @@ -346,7 +346,7 @@ Targets: * x86_64-linux-musl static gcc 16.1.0 installed x86_64-windows-gnu PE, static, cross gcc 16.1.0 installed aarch64-linux-musl static, cross gcc 16.1.0 available - riscv64-linux-musl static, cross — planned + riscv64-linux-musl static, cross gcc 16.1.0 available Available toolchains (run `mcpp toolchain install `): gcc 15.1.0 / 13.3.0 / 11.5.0 / 9.4.0 diff --git a/docs/21-the-target-triple.md b/docs/21-the-target-triple.md index 5383988c2..8c96c8de5 100644 --- a/docs/21-the-target-triple.md +++ b/docs/21-the-target-triple.md @@ -212,7 +212,7 @@ this mcpp builds. The environment is completed as above (`linux` is | Set | Members (2026.10.30.1, openkal-platform 0.18.0) | |---|---| | `openkal` | `x86_64-openkal`, `aarch64-openkal` | -| `linux-musl` | `x86_64-linux-musl`, `aarch64-linux-musl` | +| `linux-musl` | `x86_64-linux-musl`, `aarch64-linux-musl`, `riscv64-linux-musl` | | `linux` | `x86_64-linux-gnu`, `aarch64-linux-gnu` | Every member must select the same platform; a set whose members select @@ -545,7 +545,7 @@ provider's runner ([41](41-devices.md)). | `aarch64-linux-gnu` | preview | `llvm@23.1.3` | base package | payload | — | — | | `x86_64-linux-musl` | verified | `gcc@16.1.0` | payload | payload | — | payload | | `aarch64-linux-musl` | verified | `gcc@16.1.0` | payload | payload | — | — | -| `riscv64-linux-musl` | planned | — | planned | planned | planned | planned | +| `riscv64-linux-musl` | preview | `gcc@16.1.0` | payload | — | — | — | | `i686-linux-musl`, `i686-linux-gnu` | planned | — | planned | planned | planned | planned | | `x86_64-windows-gnu` | verified | `gcc@16.1.0` | payload | payload | base | payload | | `aarch64-windows-gnu` | preview | `llvm@23.1.3` | base | base | base | base | diff --git a/docs/specs/target-sets.md b/docs/specs/target-sets.md index 15c25a337..62d349bc3 100644 --- a/docs/specs/target-sets.md +++ b/docs/specs/target-sets.md @@ -52,7 +52,7 @@ | 写法 | 展开(mcpp 2026.10.30.1 的目标表与 openkal-platform 0.18.0) | |---|---| | `openkal` | `x86_64-openkal`、`aarch64-openkal` | -| `linux-musl` | `x86_64-linux-musl`、`aarch64-linux-musl`(`planned` 的行不在内) | +| `linux-musl` | `x86_64-linux-musl`、`aarch64-linux-musl`、`riscv64-linux-musl`(`planned` 的行不在内) | | `linux` | `x86_64-linux-gnu`、`aarch64-linux-gnu` | ### 1.4 一条命令的腿 diff --git a/docs/zh/20-toolchains.md b/docs/zh/20-toolchains.md index 9b61fc358..4297c22ad 100644 --- a/docs/zh/20-toolchains.md +++ b/docs/zh/20-toolchains.md @@ -293,7 +293,7 @@ Targets: * x86_64-linux-musl static gcc 16.1.0 installed x86_64-windows-gnu PE, static, cross gcc 16.1.0 installed aarch64-linux-musl static, cross gcc 16.1.0 available - riscv64-linux-musl static, cross — planned + riscv64-linux-musl static, cross gcc 16.1.0 available Available toolchains (run `mcpp toolchain install `): gcc 15.1.0 / 13.3.0 / 11.5.0 / 9.4.0 diff --git a/docs/zh/21-the-target-triple.md b/docs/zh/21-the-target-triple.md index ea9295b49..a3acccaa4 100644 --- a/docs/zh/21-the-target-triple.md +++ b/docs/zh/21-the-target-triple.md @@ -188,7 +188,7 @@ mcpp 构建的全部行。环境按上一节补全(`linux` 即 `linux-gnu`,` | 集合 | 成员(2026.10.30.1,openkal-platform 0.18.0) | |---|---| | `openkal` | `x86_64-openkal`、`aarch64-openkal` | -| `linux-musl` | `x86_64-linux-musl`、`aarch64-linux-musl` | +| `linux-musl` | `x86_64-linux-musl`、`aarch64-linux-musl`、`riscv64-linux-musl` | | `linux` | `x86_64-linux-gnu`、`aarch64-linux-gnu` | 全部成员必须选到同一个平台;成员选到不同平台时命令被拒绝,消息写出每个成员 @@ -495,7 +495,7 @@ docs/22。 | `aarch64-linux-gnu` | preview | `llvm@23.1.3` | 基座包 | 载荷 | — | — | | `x86_64-linux-musl` | verified | `gcc@16.1.0` | 载荷 | 载荷 | — | 载荷 | | `aarch64-linux-musl` | verified | `gcc@16.1.0` | 载荷 | 载荷 | — | — | -| `riscv64-linux-musl` | planned | — | planned | planned | planned | planned | +| `riscv64-linux-musl` | preview | `gcc@16.1.0` | payload | — | — | — | | `i686-linux-musl`、`i686-linux-gnu` | planned | — | planned | planned | planned | planned | | `x86_64-windows-gnu` | verified | `gcc@16.1.0` | 载荷 | 载荷 | 基座 | 载荷 | | `aarch64-windows-gnu` | preview | `llvm@23.1.3` | 基座 | 基座 | 基座 | 基座 | diff --git a/modules/toolchain-model/data/builtin.toml b/modules/toolchain-model/data/builtin.toml index 460ed9964..4767faac0 100644 --- a/modules/toolchain-model/data/builtin.toml +++ b/modules/toolchain-model/data/builtin.toml @@ -219,10 +219,12 @@ triple = "aarch64-macos-musl" tier = "preview" standard = false +# Served by the musl cross payload from x86_64 and run there under qemu-user +# (design 2026-11-22 §3.19): measured building, linking statically and running. [[platform.define]] triple = "riscv64-linux-musl" loader = "/lib/ld-musl-riscv64.so.1" -tier = "planned" +tier = "preview" standard = true # 32-BIT ROWS (E11): registered intent, refused until served. No payload of the @@ -622,11 +624,13 @@ toolchain = "gcc@16.1.0" linkage = "static" [[platform.provider]] -name = "musl-gcc" -serves = ["riscv64-linux-musl"] -priority = 100 -hosts = ["linux-{arch}", "linux-x86_64"] -linkage = "static" +name = "musl-gcc" +serves = ["riscv64-linux-musl"] +priority = 100 +hosts = ["linux-{arch}", "linux-x86_64"] +toolchain = "gcc@16.1.0" +linkage = "static" +runner = { cmd = ["qemu-riscv64-static", "{}"], hosts = ["linux-x86_64"], requires = ["xim:qemu-user-riscv64@7.2.0"] } # MinGW-w64: gcc, or clang with the payload as its sysroot (SPEC-016 §6). # On an x86_64 Linux machine a Windows program runs through Wine (design diff --git a/tests/e2e/openkal/sets.cpp b/tests/e2e/openkal/sets.cpp index 7fbf48a51..ab2aec83b 100644 --- a/tests/e2e/openkal/sets.cpp +++ b/tests/e2e/openkal/sets.cpp @@ -31,7 +31,9 @@ void needs_image_row() { // The system's word of a POSIX launcher (`case "$(uname -s)"`), or "". std::string posix_system() { return s::on_linux() ? "linux" : s::on_macos() ? "macos" : ""; } -std::uint32_t machine_of(std::string_view arch) { return arch == "x86_64" ? s::elf_machine::x86_64 : s::elf_machine::aarch64; } +std::uint32_t machine_of(std::string_view arch) { + return arch == "x86_64" ? s::elf_machine::x86_64 : arch == "riscv64" ? s::elf_machine::riscv : s::elf_machine::aarch64; +} // `env -i HOME="$HOME" PATH=/usr/bin:/bin `: the program with nothing installed. e2e::outcome run_bare(const fs::path& program, std::vector args) { @@ -297,7 +299,7 @@ E2E sets{"sets", s::home_fixture, timeout{std::chrono::minutes{45}}, [] { }; "984 a set of programs is a package per leg"_test[s::gcc][s::python3] = [] { - // `--target linux-musl`: A a package per leg named by its triple below the `-o` + // `--target linux-musl` (x86_64, aarch64, riscv64): A a package per leg named by its triple below the `-o` // directory, each holding the program of its architecture; B `-o` naming one file is // refused before a build; C the JSON envelope lists both packages and legs. if (!s::on_linux()) skip("the linux-musl rows are built on Linux"); @@ -307,7 +309,7 @@ E2E sets{"sets", s::home_fixture, timeout{std::chrono::minutes{45}}, [] { if (!e2e::succeeded(r) && s::has_line(s::text(r), "cannot be built on this host|install_packages failed|not found in the synced index")) skip("a linux-musl row cannot be built here"); expect(fatal(e2e::succeeded(r))) << "A: pack --target linux-musl: " << s::text(r); - for (std::string_view arch : {"x86_64", "aarch64"}) { + for (std::string_view arch : {"x86_64", "aarch64", "riscv64"}) { const auto f = app.at(std::format("out/per-0.1.0-{}-linux-musl-static.tar.gz", arch)); expect(fatal(fs::is_regular_file(f))) << "A: no " << f << ": " << s::text(r); std::string member; @@ -330,8 +332,8 @@ E2E sets{"sets", s::home_fixture, timeout{std::chrono::minutes{45}}, [] { const auto d = s::json(r.out)["data"]; auto legs = strings(d["legs"]); std::ranges::sort(legs); - expect(fatal(legs == std::vector{"aarch64-linux-musl", "x86_64-linux-musl"})) << "C: " << d["legs"].dump(); - expect(fatal(d["artifacts"].size() == 2u)) << "C: " << d["artifacts"].dump(); + expect(fatal(legs == std::vector{"aarch64-linux-musl", "riscv64-linux-musl", "x86_64-linux-musl"})) << "C: " << d["legs"].dump(); + expect(fatal(d["artifacts"].size() == 3u)) << "C: " << d["artifacts"].dump(); }; "985 a format list writes each container of one tree"_test[s::llvm][s::python3][s::unix_shell] = [] { diff --git a/tests/e2e/targets/rows.cpp b/tests/e2e/targets/rows.cpp index 652aa58f0..c40953d4f 100644 --- a/tests/e2e/targets/rows.cpp +++ b/tests/e2e/targets/rows.cpp @@ -1,8 +1,9 @@ // The rows a target names: the bare OS aliases of a conditional table, the vocabulary's refusals // and spellings, the sysroot override and the target queries a board package asks, the variable // that says a target was named, the cache slot of `run --target`, the optional env segment, the -// aarch64-linux-gnu cross served by a sysroot payload, and a program of another system that is -// built and not run (formerly tests/e2e/91, 103, 134, 267, 283, 284, 1076, 1077). +// aarch64-linux-gnu cross served by a sysroot payload, the riscv64-linux-musl cross run under +// qemu-user (1153), and a program of another system that is built and not run (formerly +// tests/e2e/91, 103, 134, 267, 283, 284, 1076, 1077). import std; import mcpplibs.mtest; import mcpp.test.support; @@ -358,6 +359,35 @@ int main() { expect(fatal(run.status == 44)) << "static: mcpp run exited " << run.status << ", the program returns 44: " << s::text(run); }; + "1153 a riscv64 linux musl program builds from the cross payload and runs under qemu-user"_test[s::elf][s::x86_64_host] = [] { + // riscv64-linux-musl is served by the musl cross payload the provider pins (design + // 2026-11-22 §3.19): a C program and an import-std program build static riscv64 ELFs + // without an interpreter, and `mcpp run` starts them through the provider's runner. + const std::string T = "riscv64-linux-musl"; + const auto tmp = s::case_dir(); + auto project = [&](std::string_view dir, std::string_view main, std::string_view source) { + return s::project(tmp / dir, {{"mcpp.toml", std::format("[package]\nname = \"rv\"\nversion = \"0.1.0\"\n\n[targets.rv]\nkind = \"bin\"\nmain = \"src/{}\"\n", main)}, + {std::format("src/{}", main), source}}); + }; + auto c = project("c", "main.c", "#include \nint main(void) { printf(\"rv-c\\n\"); return 42; }\n"); + auto stdp = project("std", "main.cpp", "import std;\nint main() { std::println(\"rv-std\"); return 44; }\n"); + auto check = [&](const s::project& p, std::string_view label, std::string_view word, int status) { + auto b = p.mcpp({"build", "--target", T}); + expect(fatal(e2e::succeeded(b))) << label << ": " << T << " did not build: " << s::text(b); + const auto exe = program_under(p.at("target/" + T), "rv"); + expect(fatal(exe.has_value())) << label << ": no program: " << s::text(b); + const auto h = s::read_header(*exe); + expect(fatal(h.kind == s::format::elf && h.machine == s::elf_machine::riscv)) << label << ": the artifact is not a riscv ELF (machine " << h.machine << ")"; + expect(fatal(!h.elf_interpreter)) << label << ": the static program names an interpreter: " << h.interpreter; + auto run = p.mcpp({"run", "--target", T}); + expect(fatal(run.status == status)) << label << ": mcpp run exited " << run.status << ", the program returns " << status << ": " << s::text(run); + expect(fatal(s::has_line(s::text(run), std::format("^{}$", word)))) << label << ": the program's output did not arrive: " << s::text(run); + expect(fatal(s::has_line(s::text(run), "Running .*qemu-riscv64"))) << label << ": the run did not go through the provider's runner: " << s::text(run); + }; + check(c, "c", "rv-c", 42); + check(stdp, "std", "rv-std", 44); + }; + "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: dirun), which no declaration has diff --git a/tests/fixtures/target-rows.snapshot b/tests/fixtures/target-rows.snapshot index 0c85f0378..2973bdf35 100644 --- a/tests/fixtures/target-rows.snapshot +++ b/tests/fixtures/target-rows.snapshot @@ -208,7 +208,7 @@ row aarch64-macos-musl descriptor-keys macosx sysroot row riscv64-linux-musl - table tier=planned note= pin= sysroot= static=1 platform= + table tier=preview note= pin=gcc@16.1.0 sysroot= static=1 platform= str riscv64-linux-musl llvm riscv64-unknown-linux-musl llvm@15.0 riscv64-unknown-linux-musl @@ -885,9 +885,9 @@ request aarch64-linux on windows-x86_64 -> aarch64-linux-musl openkal fallback=1 | aarch64-linux-gnu/glibc/100/x aarch64-linux-musl/musl-gcc/100/x aarch64-linux-musl/openkal/50 aarch64-linux-gnu/glibc-sysroot/40/x request riscv64-linux parsed riscv64-linux-gnu envExplicit=0 - on linux-x86_64 -> riscv64-linux-musl musl-gcc fallback=0 | riscv64-linux-musl/musl-gcc/100/x riscv64-linux-musl/openkal/50/x - on macos-aarch64 -> riscv64-linux-musl musl-gcc fallback=0 | riscv64-linux-musl/musl-gcc/100/x riscv64-linux-musl/openkal/50/x - on windows-x86_64 -> riscv64-linux-musl musl-gcc fallback=0 | riscv64-linux-musl/musl-gcc/100/x riscv64-linux-musl/openkal/50/x + on linux-x86_64 -> riscv64-linux-musl musl-gcc fallback=0 | riscv64-linux-musl/musl-gcc/100 riscv64-linux-musl/openkal/50 + on macos-aarch64 -> riscv64-linux-musl openkal fallback=1 | riscv64-linux-musl/musl-gcc/100/x riscv64-linux-musl/openkal/50 + on windows-x86_64 -> riscv64-linux-musl openkal fallback=1 | riscv64-linux-musl/musl-gcc/100/x riscv64-linux-musl/openkal/50 request x86_64-windows parsed x86_64-windows-gnu envExplicit=0 on linux-x86_64 -> x86_64-windows-musl openkal fallback=1 | x86_64-windows-msvc/msvc/100/x x86_64-windows-musl/openkal/50 x86_64-windows-gnu/mingw/10 x86_64-windows-gnu/mingw-llvm/5 @@ -986,7 +986,7 @@ did-you-mean aarch64-macso aarch64-macos did-you-mean riscv64-none-eld riscv64-none-elf did-you-mean thumbv7m-none - set linux -> x86_64-linux-gnu aarch64-linux-gnu | -set linux-musl -> x86_64-linux-musl aarch64-linux-musl | +set linux-musl -> x86_64-linux-musl aarch64-linux-musl riscv64-linux-musl | set windows -> x86_64-windows-gnu aarch64-windows-gnu | set windows-msvc -> x86_64-windows-msvc i686-windows-msvc | set macos -> aarch64-macos | diff --git a/tests/unit/test_target_set.cpp b/tests/unit/test_target_set.cpp index 34f6ef0d6..80b47cec3 100644 --- a/tests/unit/test_target_set.cpp +++ b/tests/unit/test_target_set.cpp @@ -61,8 +61,8 @@ UTest openkal_names_both_architectures{"TargetSet/OpenkalNamesBothArchitectures" UTest linux_musl_leaves_planned_rows_out{"TargetSet/LinuxMuslLeavesPlannedRowsOut", [] { auto e = ts::expand_set("linux-musl", column_platform); if (auto&& failed = expect(fatal(e.has_value())); !failed) failed << e.error(); - expect(eq(e->members, (std::vector{"x86_64-linux-musl", "aarch64-linux-musl"}))); - for (auto& m : e->members) expect(ne(m, "riscv64-linux-musl")); + expect(eq(e->members, (std::vector{"x86_64-linux-musl", "aarch64-linux-musl", "riscv64-linux-musl"}))); + for (auto& m : e->members) expect(ne(m, "i686-linux-musl")); }}; UTest linux_fills_gnu_and_leaves_android_out{"TargetSet/LinuxFillsGnuAndLeavesAndroidOut", [] { From 533fbe6e6daa054d5f0dc0965da30131b712401d Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 02:58:47 +0900 Subject: [PATCH 03/33] feat: the iOS simulator rows state simctl-run as their runner, enabled on request The apple provider's device row and simulator rows are two entries: the simulator rows carry runner { simctl-run, same-arch, xim:apple-simulator-tools@0.3.0, enabled = false }. ci-macos-ios asserts the refusal before consent and the run once enabled. --- .github/workflows/ci-macos-ios.yml | 28 +++++++++++++++++++++++ CHANGELOG.md | 5 ++++ docs/41-devices.md | 12 ++++++++++ docs/zh/41-devices.md | 9 ++++++++ modules/toolchain-model/data/builtin.toml | 16 ++++++++++++- 5 files changed, 69 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-macos-ios.yml b/.github/workflows/ci-macos-ios.yml index 7fe28452c..67fa609df 100644 --- a/.github/workflows/ci-macos-ios.yml +++ b/.github/workflows/ci-macos-ios.yml @@ -367,6 +367,34 @@ jobs: fi echo "ok: mcpp run --target aarch64-ios-sim printed 1-2-3 and exited 0" + # THE ROW'S OWN RUNNER (design 2026-11-22 §3.19): the same program with + # the project's runner and workspace removed. The provider states + # `simctl-run` with `enabled = false`, so the run is refused until it is + # enabled; enabled for one invocation, its `requires` are installed and + # the simulator runs the program. + - name: "aarch64-ios-sim: the provider's runner, refused until enabled, then runs" + run: | + set -uo pipefail + rm -rf /tmp/iosrow && cp -R /tmp/iostest /tmp/iosrow && rm -rf /tmp/iosrow/target + cd /tmp/iosrow + python3 - <<'PY' + import re + s = open("mcpp.toml").read() + s = re.sub(r'\[target\.aarch64-ios-sim\]\nrunner = \["simctl-run"\]\n', '', s) + s = re.sub(r'\[target\.aarch64-ios-sim\.xlings\.workspace\]\n"xim:apple-simulator-tools" = ""\n', '', s) + open("mcpp.toml", "w").write(s) + PY + if grep -q simctl-run mcpp.toml; then echo "FAIL: the fixture still states a runner"; exit 1; fi + out=$("$MCPP_FRESH" run --target aarch64-ios-sim 2>&1) && rc=0 || rc=$? + printf '%s\n' "$out" | tail -8 + [ "$rc" -eq 2 ] || { echo "FAIL: a run before consent exited $rc, not 2"; exit 1; } + grep -q 'runner-not-enabled' <<<"$out" || { echo "FAIL: the refusal carries no [runner-not-enabled]"; exit 1; } + out=$(MCPP_TARGET_AARCH64_IOS_SIM_RUNNER_ENABLED=true "$MCPP_FRESH" run --target aarch64-ios-sim 2>&1) && rc=0 || rc=$? + printf '%s\n' "$out" | tail -12 + [ "$rc" -eq 0 ] || { echo "FAIL: the enabled run exited $rc"; exit 1; } + grep -qx '1-2-3' <<<"$out" || { echo "FAIL: the program's output line '1-2-3' is absent"; exit 1; } + echo "ok: the row's runner is refused until enabled, and enabled it runs the program in the simulator" + # THE THIRD ROW, BUILT HERE AND RUN ELSEWHERE (design 2026-10-23 §2.6, # S15). A simulator runs the host's architecture and this runner is # Apple silicon, so this job proves the artefact and the SDK's slice; the diff --git a/CHANGELOG.md b/CHANGELOG.md index c90d21ca6..e69442b09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,11 @@ Linux x86_64 machine, and `mcpp run` starts its static programs under qemu-user (`xim:qemu-user-riscv64@7.2.0`, installed on the first run). The `linux-musl` target set now includes it (mcpp#1005). +- The iOS simulator rows (`aarch64-ios-sim`, `x86_64-ios-sim`) state their runner: `simctl-run` + (`xim:apple-simulator-tools@0.3.0`) chooses a device, boots it and returns the program's + status. It boots a simulator device, so it is enabled on request (`[target.aarch64-ios-sim] + runner = true`, or `MCPP_TARGET__RUNNER_ENABLED=true`); a project's own `runner` stands + over it as before. `aarch64-ios` has no runner (mcpp#1005). - `mcpp::action::origin(path)` names the authored file a generated unit is a transformed copy of, one of the action's inputs, on a `source` action. The build database gives it as `ide.generated[].origin`. A generated unit that declares a module's primary name is a diff --git a/docs/41-devices.md b/docs/41-devices.md index fe7299c5d..32bcaf749 100644 --- a/docs/41-devices.md +++ b/docs/41-devices.md @@ -166,6 +166,18 @@ runner: the emulator package serves no aarch64 machine. MCPP_TARGET_X86_64_LINUX_ANDROID_RUNNER_ENABLED=true mcpp run --target x86_64-linux-android ``` +**An iOS simulator program runs in the simulator (@RELEASE@+).** On a Mac, once +enabled, `aarch64-ios-sim` and `x86_64-ios-sim` run through `simctl-run` +(`xim:apple-simulator-tools`): it chooses an available device, boots it when +none is booted, spawns the program and returns its status. A simulator runs the +machine's architecture (`same-arch`). `aarch64-ios` has no runner: a program +runs on a device only signed by its developer. + +```toml +[target.aarch64-ios-sim] +runner = true +``` + ## The program a runner names (2026.11.16.1+) | | Rule | diff --git a/docs/zh/41-devices.md b/docs/zh/41-devices.md index aadda58b9..b31b8164c 100644 --- a/docs/zh/41-devices.md +++ b/docs/zh/41-devices.md @@ -131,6 +131,15 @@ runner 是什么(`cmd`、`requires`、`host`)由其数据陈述:提供者 MCPP_TARGET_X86_64_LINUX_ANDROID_RUNNER_ENABLED=true mcpp run --target x86_64-linux-android ``` +**iOS 模拟器的程序在模拟器中运行(@RELEASE@+)。** 在 Mac 上启用后,`aarch64-ios-sim` 与 `x86_64-ios-sim` 经 +`simctl-run`(`xim:apple-simulator-tools`)运行:它选择一个可用的设备,没有已启动的设备时启动它,在其中启动程序并返回其 +状态。模拟器运行本机的架构(`same-arch`)。`aarch64-ios` 没有 runner:程序只有经开发者签名才能在设备上运行。 + +```toml +[target.aarch64-ios-sim] +runner = true +``` + ## runner 所指名的程序(2026.11.16.1+) | | 规则 | diff --git a/modules/toolchain-model/data/builtin.toml b/modules/toolchain-model/data/builtin.toml index 4767faac0..27652ac2a 100644 --- a/modules/toolchain-model/data/builtin.toml +++ b/modules/toolchain-model/data/builtin.toml @@ -676,13 +676,27 @@ serves = ["aarch64-macos", "x86_64-macos"] priority = 100 hosts = ["macos-*"] +# A device row has no runner: an artifact runs on a device only signed by its +# developer. A simulator row runs through `simctl-run`, which chooses a device, +# boots it, spawns the program and returns its status (design 2026-11-22 +# §3.19). The simulator runs the machine's architecture (`same-arch`), and its +# first use boots a device whose state lives outside the build tree, so the +# runner is enabled on request. [[platform.provider]] name = "apple" -serves = ["aarch64-ios", "aarch64-ios-sim", "x86_64-ios-sim"] +serves = ["aarch64-ios"] priority = 100 hosts = ["macos-*"] toolchain = "llvm@23.1.3" +[[platform.provider]] +name = "apple" +serves = ["aarch64-ios-sim", "x86_64-ios-sim"] +priority = 100 +hosts = ["macos-*"] +toolchain = "llvm@23.1.3" +runner = { cmd = ["simctl-run", "{}"], host = "same-arch", hosts = ["macos-*"], requires = ["xim:apple-simulator-tools@0.3.0"], enabled = false } + # The C library of a bare-metal RISC-V row is the target's, like the compiler: # no bare-metal package has to name one. [[platform.provider]] From 1fb1c767f24ad6aec0fec4b3cce3465b749ea33c Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 03:28:10 +0900 Subject: [PATCH 04/33] feat: a build holds the store's payloads it uses as roots; mcpp cache gc collects the store A build registers a root (registry/data/roots/mcpp/@, xlings' store-roots specification) for each payload of the home store its graph names, by replacing the link so that its own time is the last use; a build that reuses its graph renews them from roots.list. mcpp toolchain install holds the toolchain it installs, and a home without roots has one made for every payload, once. mcpp cache gc releases the roots unused for --older-than and then asks the provider to collect the store; --dry-run removes nothing. The link's own time is read with mcpplibs.os 0.4.8. The kernel-headers refusal names its row as [target.]. --- CHANGELOG.md | 11 ++ docs/09-commands-by-scenario.md | 18 +++ docs/specs/README.md | 12 +- docs/specs/toolchain-management.md | 13 +- docs/zh/09-commands-by-scenario.md | 12 ++ mcpp.toml | 2 +- modules/invocation/mcpp.toml | 2 +- modules/manifest/mcpp.toml | 2 +- modules/toolchain-model/mcpp.toml | 2 +- src/bmi_cache/maintenance.cppm | 16 +- src/build/execute.cppm | 4 + src/build/ninja_backend.cppm | 4 + src/build/prepare/base.cpp | 2 +- src/cli.cppm | 4 +- src/cli/cmd_cache.cppm | 34 +++- src/config.cppm | 15 ++ src/provider/provider.cppm | 7 + src/provider/roots.cppm | 248 +++++++++++++++++++++++++++++ src/provider/xlings/provider.cppm | 5 + src/provider/xlings/xlings.cpp | 10 ++ src/provider/xlings/xlings.cppm | 4 + src/toolchain/lifecycle.cppm | 4 + tests/e2e/cache/entries.cpp | 39 ++++- 23 files changed, 447 insertions(+), 23 deletions(-) create mode 100644 src/provider/roots.cppm diff --git a/CHANGELOG.md b/CHANGELOG.md index e69442b09..e8ab5dc40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,8 +39,19 @@ `module-interface`. When the authored file is also among the sources, the duplicate-provider error names the relation (S1 0.4.0, mcpp#1004). +- A build holds each payload of mcpp's package store that its graph names as a root of the + store (`registry/data/roots/mcpp/@`, xlings' store-roots specification), + renewed by every build of that graph; `mcpp toolchain install` holds the toolchain it installs, + and a home from before has a root made for every payload it holds, once. `mcpp cache gc + --dry-run` says what would be collected and removes nothing. + ### Changed +- `mcpp cache gc` collects the package store after the cache: the provider removes the payloads + nothing references (`xlings self clean`), and with `--older-than` the roots no build used for + that long are released first. Before, payloads were never collected, and `xlings self clean` + in mcpp's registry listed the bases, libraries and platform packages projects use (154 payloads, + 16 GB, on one home) as unreferenced. - Without a statement, the kernel headers are the base's own (a stated sysroot, a toolchain's own sysroot such as `musl-gcc`'s, the host's root), else the version the toolchain's payload declares. A build under gcc 16.2.0 now compiles against linux-headers 6.18.64, the version it diff --git a/docs/09-commands-by-scenario.md b/docs/09-commands-by-scenario.md index aabb4e9ad..3a46ae8e3 100644 --- a/docs/09-commands-by-scenario.md +++ b/docs/09-commands-by-scenario.md @@ -111,6 +111,24 @@ warning states both (2026.11.8.1+). `mcpp cache prune` and `mcpp cache gc --older-than` collect `std` module entries by age as well; `gc --max-size` budgets packages and host tools, not `std` modules (2026.11.8.1+). +**The store's payloads (@RELEASE@+).** A build holds each payload of mcpp's +package store that its graph names -- the toolchain, its base and companions, +the packages and tools it wires -- as a **root**: a link +`registry/data/roots/mcpp/@` to the payload, renewed by +every build of that graph, so that its time is the payload's last use. `mcpp +toolchain install` holds the toolchain it installs. A home from before has a +root made for every payload it holds, once. After the cache, `mcpp cache gc` +asks the package provider to collect the store (`xlings self clean`): a payload +nothing references -- no environment, no link of one, no dependency of a kept +payload, no root -- is removed. With `--older-than`, the roots no build used +for that long are released first. `--dry-run` says what would be collected and +removes nothing. + +```bash +mcpp cache gc --older-than 60d --dry-run # what would go, cache and store +mcpp cache gc --older-than 60d +``` + ## The versions a package publishes `mcpp search` matches a substring and appends what each hit publishes, merged diff --git a/docs/specs/README.md b/docs/specs/README.md index ecf53a1cc..5d7235436 100644 --- a/docs/specs/README.md +++ b/docs/specs/README.md @@ -31,21 +31,21 @@ | 编号 | 标题 | 状态 | 最后修改 | 对应实现 | |---|---|---|---|---| | [SPEC-001](package-identity.md) | 包身份(`package.namespace` / `package.name`)、`[dependencies]` 选择器与匹配机制 | 评审中 v1.13 | 2026-11-21 | mcpp >= 0.0.106;§3.5 与 §10.4 mcpp >= 2026.11.19.1;§4.5、§3.5 的 `installed_manifest` 与 §10.4 第 7 条 mcpp >= 2026.11.21.1 | -| [SPEC-002](target-side.md) | 目标侧模型与能力声明(`mcpp:` 保留命名空间、五层、三条规则、目标侧执行、一个进程一套 C++ 运行时) | 评审中 v1.11 | 2026-11-20 | mcpp >= 2026.8.24.2;§2.4 与 §6 mcpp >= 2026.10.24.1;§2.2 的对象形式与 §7 mcpp >= 2026.10.26.1;§2.5 与 §3.8 mcpp >= 2026.11.10.1;§3.6 以目标的解析判断 mcpp >= 2026.11.19.1 | +| [SPEC-002](target-side.md) | 目标侧模型与能力声明(`mcpp:` 保留命名空间、五层、三条规则、目标侧执行、一个进程一套 C++ 运行时) | 评审中 v1.12 | 2026-11-23 | mcpp >= 2026.8.24.2;§2.4 与 §6 mcpp >= 2026.10.24.1;§2.2 的对象形式与 §7 mcpp >= 2026.10.26.1;§2.5 与 §3.8 mcpp >= 2026.11.10.1;§3.6 以目标的解析判断 mcpp >= 2026.11.19.1;§3.9 与 §3.10 mcpp >= @RELEASE@ | | [SPEC-003](exit-codes.md) | 退出码契约(分类、语义、稳定性承诺) | 评审中 v1.2 | 2026-10-26 | mcpp >= 2026.9.1.1;`5` 与信号 mcpp >= 2026.10.26.1 | -| [SPEC-004](manifest-semantics.md) | `mcpp.toml` 的平面划分、条件化形状、解析轴与命名规约 | 草案 v1.27 | 2026-11-21 | 条件化形状 mcpp >= 2026.8.29.1;目标轴 mcpp >= 2026.9.6.4;`linkage` 默认值 mcpp >= 2026.9.15.2;链接 flag 的词读法 mcpp >= 2026.9.26.2;条件化的 `dialect_cxxflags` 与 `-p` 的包身份 mcpp >= 2026.9.28.1;条件表按具体程度生效 mcpp >= 2026.9.28.2;平台前缀规约 mcpp >= 2026.10.5.1;根包的继承、根位置的 profile、链接 flag 的作用域、链接期优化与导出发现 mcpp >= 2026.10.5.2;架构段的 `x86` 即 `i686` mcpp >= 2026.10.5.3;前缀即语义与工作空间层 mcpp >= 2026.10.10.1;依赖的库与配置(§12) mcpp >= 2026.10.11.1;值的四档层次与 `run_under` mcpp >= 2026.10.24.1;§12 第 3 条一个程序一个版本 mcpp >= 2026.11.19.1;§9 第 21 至 23 条与 §16 mcpp >= 2026.11.21.1 | -| [SPEC-005](build-database.md) | 构建数据库:`mcpp emit build-database` 的内容、取值规则与不写工程目录的保证 | 评审中 v1.8 | 2026-10-11 | mcpp >= 2026.9.15.1;v1.3 条款 mcpp >= 2026.9.26.2;v1.4 条款 mcpp >= 2026.9.27.1;v1.5 条款 mcpp >= 2026.9.28.1;v1.6 条款 mcpp >= 2026.9.29.5;v1.7 条款 mcpp >= 2026.9.30.2;v1.8 条款 mcpp >= 2026.10.11.1 | -| [SPEC-006](toolchain-management.md) | 工具链管理:身份、来源、选择与载荷契约 | 草案 v0.11 | 2026-11-10 | 逐条标注;已实现条款 mcpp >= 2026.9.24.1;§3.7 mcpp >= 2026.9.28.1;§3.7.1 mcpp >= 2026.9.28.2;§2.2.1 与 §3.3 的非缺省来源 mcpp >= 2026.10.1.3;§3.8 mcpp >= 2026.10.8.1;§3.9 至 §3.11 mcpp >= 2026.10.24.1;v0.11 条款 mcpp >= 2026.11.10.1 | +| [SPEC-004](manifest-semantics.md) | `mcpp.toml` 的平面划分、条件化形状、解析轴与命名规约 | 草案 v1.29 | 2026-11-23 | 条件化形状 mcpp >= 2026.8.29.1;目标轴 mcpp >= 2026.9.6.4;`linkage` 默认值 mcpp >= 2026.9.15.2;链接 flag 的词读法 mcpp >= 2026.9.26.2;条件化的 `dialect_cxxflags` 与 `-p` 的包身份 mcpp >= 2026.9.28.1;条件表按具体程度生效 mcpp >= 2026.9.28.2;平台前缀规约 mcpp >= 2026.10.5.1;根包的继承、根位置的 profile、链接 flag 的作用域、链接期优化与导出发现 mcpp >= 2026.10.5.2;架构段的 `x86` 即 `i686` mcpp >= 2026.10.5.3;前缀即语义与工作空间层 mcpp >= 2026.10.10.1;依赖的库与配置(§12) mcpp >= 2026.10.11.1;值的四档层次与 `run_under` mcpp >= 2026.10.24.1;§12 第 3 条一个程序一个版本 mcpp >= 2026.11.19.1;§9 第 21 至 23 条与 §16 mcpp >= 2026.11.21.1;v1.29 条款 mcpp >= @RELEASE@ | +| [SPEC-005](build-database.md) | 构建数据库:`mcpp emit build-database` 的内容、取值规则与不写工程目录的保证 | 评审中 v1.10 | 2026-11-23 | mcpp >= 2026.9.15.1;v1.3 条款 mcpp >= 2026.9.26.2;v1.4 条款 mcpp >= 2026.9.27.1;v1.5 条款 mcpp >= 2026.9.28.1;v1.6 条款 mcpp >= 2026.9.29.5;v1.7 条款 mcpp >= 2026.9.30.2;v1.8 条款 mcpp >= 2026.10.11.1;v1.10 条款 mcpp >= @RELEASE@ | +| [SPEC-006](toolchain-management.md) | 工具链管理:身份、来源、选择与载荷契约 | 草案 v0.14 | 2026-11-23 | 逐条标注;已实现条款 mcpp >= 2026.9.24.1;§3.7 mcpp >= 2026.9.28.1;§3.7.1 mcpp >= 2026.9.28.2;§2.2.1 与 §3.3 的非缺省来源 mcpp >= 2026.10.1.3;§3.8 mcpp >= 2026.10.8.1;§3.9 至 §3.11 mcpp >= 2026.10.24.1;v0.11 条款 mcpp >= 2026.11.10.1;v0.14 条款 mcpp >= @RELEASE@ | | [SPEC-007](build-plugins.md) | 构建插件:配置、施工与校验的分工,运行时与规划期的义务 | 草案 v0.16 | 2026-11-21 | 逐条标注;mcpp >= 2026.9.26.2;v0.3 条款 mcpp >= 2026.9.27.1;v0.4 条款 mcpp >= 2026.9.28.1;v0.5 条款 mcpp >= 2026.9.28.2;v0.6(§9)mcpp >= 2026.9.28.3;R3.9、R3.10 mcpp >= 2026.10.10.1;§10 mcpp >= 2026.10.11.1;§3.1 协议 18 mcpp >= 2026.11.5.1;协议 19 mcpp >= 2026.11.16.1;协议 20、R10.7 mcpp >= 2026.11.19.1;协议 21、R10.8–R10.10 mcpp >= 2026.11.21.1 | | [SPEC-008](library-interface.md) | 库的接口:公开模块、发布闭包与两种形态的一致 | 草案 v0.2 | 2026-10-11 | 第一阶段(只警告)mcpp >= 2026.9.28.3;v0.2 mcpp >= 2026.10.11.1 | | [SPEC-009](toolchain-maintenance.md) | 工具链的支持与维护:版本线、默认值、来源、移动与退役 | 草案 v0.7 | 2026-11-21 | 逐条标注;本版只有规范,多数条款未实现;§6.4 mcpp >= 2026.10.8.1 | | [SPEC-010](home-initialization.md) | home 选择、单跳入口、初始化、网络边界、单次运行的 `--home` 与来自目录的 home | 草案 v0.3 | 2026-11-21 | mcpp >= 2026.10.19.1;网络能力逐条标注;§6 mcpp >= 2026.10.26.1、xlings >= 2026.10.26.1 | | [SPEC-011](concurrency.md) | 并发运行:三段、构建目录锁、原子发布、`mcpp.lock` 的乐观写入、取消;编译执行器的恢复、发布、记录与文本 | 评审中 v1.2 | 2026-11-19 | mcpp >= 2026.10.26.1;§5.1 mcpp >= 2026.11.7.1;§5.1 第 6 条的不可观察单元与第 8 至 12 条 mcpp >= 2026.11.19.1 | | [SPEC-012](human-output.md) | 面向人的输出:两条流、两种介质、行的种类、颜色、程序的文本 | 评审中 v1.1 | 2026-11-19 | mcpp >= 2026.10.26.1;§5 mcpp >= 2026.11.19.1 | -| [SPEC-013](platforms.md) | 平台:`[platform]` 的七组键、版本组与 `hosted`,三种写法与层次,目标图与宿主图的选择,`cfg(platform)`,依赖图的补全,链接、命名与封装,运行器与载体,平台阶段与协议 17 | 评审中 v1.15 | 2026-11-20 | mcpp >= 2026.10.27.1;§10 的执行宿主与 §11 的载体架构 mcpp >= 2026.10.29.1;§7.5 版本组参与解析与 §14 平台系列 mcpp >= 2026.11.7.1;§14 内置平台为确切版本 mcpp >= 2026.11.7.2;v1.7 条款 mcpp >= 2026.11.10.1;§14 索引的平台列 mcpp >= 2026.11.17.1;§14 系列取可用的最新版本与 §15.1 的 `+b` 条目 mcpp >= 2026.11.19.1 | +| [SPEC-013](platforms.md) | 平台:`[platform]` 的七组键、版本组与 `hosted`,三种写法与层次,目标图与宿主图的选择,`cfg(platform)`,依赖图的补全,链接、命名与封装,运行器与载体,平台阶段与协议 17 | 评审中 v1.17 | 2026-11-23 | mcpp >= 2026.10.27.1;§10 的执行宿主与 §11 的载体架构 mcpp >= 2026.10.29.1;§7.5 版本组参与解析与 §14 平台系列 mcpp >= 2026.11.7.1;§14 内置平台为确切版本 mcpp >= 2026.11.7.2;v1.7 条款 mcpp >= 2026.11.10.1;§14 索引的平台列 mcpp >= 2026.11.17.1;§14 系列取可用的最新版本与 §15.1 的 `+b` 条目 mcpp >= 2026.11.19.1;v1.17 条款 mcpp >= @RELEASE@ | | [SPEC-014](packaging.md) | 打包与分发:链接、闭包、容器三个维度与构建腿,腿的合并,暂存树与 `mcpp-package.json`,平台的树、运行覆盖、单文件、polyglot、容器列表、签名、压缩、合并与分发描述 | 评审中 v2.2 | 2026-11-10 | mcpp >= 2026.10.31.1;逐条标注;v2.2 条款 mcpp >= 2026.11.10.1 | | [SPEC-015](target-sets.md) | 目标集合与腿:集合的写法与展开,命令对多条腿的语义,串行规划与一起构建,测试归档,机器输出 | 评审中 v1.0 | 2026-10-30 | mcpp >= 2026.10.30.1 | -| [SPEC-016](targets-and-providers.md) | 目标与提供者:行、提供者、选择规则、平台定义的行、C 环境与执行、报告、机器输出与锁 | 评审中 v1.1 | 2026-11-10 | mcpp >= 2026.11.9.1;v1.1 条款 mcpp >= 2026.11.10.1 | +| [SPEC-016](targets-and-providers.md) | 目标与提供者:行、提供者、选择规则、平台定义的行、C 环境与执行、报告、机器输出与锁 | 评审中 v1.9 | 2026-11-23 | mcpp >= 2026.11.9.1;v1.1 条款 mcpp >= 2026.11.10.1;v1.9 条款 mcpp >= @RELEASE@ | | [SPEC-017](test.md) | mcpp 测试规范:测试程序、测试协议、记录、存储、启动描述与框架声明;基础能力 B1–B6 与可选能力 O1–O12 | 评审中 v2.6 | 2026-11-21 | mcpp >= 2026.11.8.1;逐条标注;B5、B6 的新键、O3 的运行器一侧、O8 mcpp >= 2026.11.10.1;O9 mtest >= 0.6.0;O10 mcpp >= 2026.11.13.1;O11、O12 与 P5.6 mcpp >= 2026.11.21.1 | | [SPEC-018](module-rebuilds.md) | 模块的重编译:按 BMI 内容截断,GCC 的时间戳与行映射,`bmi_cutoff`,构建目录的记录 | 评审中 v1.0 | 2026-11-17 | mcpp >= 2026.11.17.2 | | [SPEC-019](build-optimizations.md) | 构建优化:登记表、级别、接缝、总开关,私有模块片段作为独立单元,构建后的建议 | 评审中 v1.0 | 2026-11-17 | mcpp >= 2026.11.17.2 | diff --git a/docs/specs/toolchain-management.md b/docs/specs/toolchain-management.md index ca82e824a..9b28c503a 100644 --- a/docs/specs/toolchain-management.md +++ b/docs/specs/toolchain-management.md @@ -126,6 +126,17 @@ 基座不带内核头文件(共享视图、载荷布局的 glibc)时,缺省取工具链载荷声明的版本,读法同上;载荷没有声明时不取 store 中的 最新版本,而是拒绝并给出陈述的写法。引擎**禁止**向共享视图写入内核头文件(mcpp >= @RELEASE@)。 +### 2.10 存储的根 已实现(@RELEASE@ 起) + +- 构建**必须**为其图所指名的、mcpp 包存储中的每个载荷登记一个根:提供者为 mcpp 给出的根目录中一个指向该载荷的链接,名为 + `<存储名>@<版本>`(xlings 的存储根规范)。根以临时名创建后改名覆盖,因此每次使用都更新链接自身的时间;复用其图的构建按图旁 + `roots.list` 的记录同样更新。`mcpp toolchain install` 为它安装的工具链登记根。 +- 没有根目录的 home 在第一次装载配置时为存储中的每个载荷登记一次根,时间取当时;根目录整体发布,因此这一步只执行一次且幂等。 + 借用的 registry 由其所有者登记。 +- `mcpp cache gc` 在缓存之后调用提供者的回收(`xlings self clean`);给出 `--older-than` 时先移除在该期限内没有使用过的根, + 期限按链接自身的时间判断。回收只有提供者的一个实现。根无法创建时以 `degraded`(`store/roots`)报告一次,构建继续。 + `--dry-run` 只列出会回收的条目与根。 + --- ## 3. 来源与选择 @@ -452,7 +463,7 @@ doctor 如实报告这一点。它同时报告 mcpp 的包 home 中指向不存 | v0.10 | 2026-10-23 | 随 mcpp 2026.10.24.1:§1 定义目标基座与执行宿主;新增 §3.9 目标基座(一次解析、四档写法与优先级、测量与声明、不写入、运行时语义)、§3.10 自备输入、§3.11 核心知识判据;§2.2.1 工具链阶段可陈述 `spec` 与 `sysroot`,`spec` 与路径专属键同时出现时拒绝;§3.1 补全读者名单;§3.3 增加主体 `sysroot` 与 `run_under`;§3.5 clang 行接受 `{ path }`;§4.3 要求被陈述的 gnu-sysroot 基座把 `--sysroot` 交给链接器;新增附录 A。 | | v0.11 | 2026-11-10 | 随 mcpp 2026.11.10.1:§3.9.2 引擎默认档为所选提供者的 `sysroot` 列,为包时按工程陈述的规则解析;附录 A 的 `*-windows-gnu` 接受基座包与 `{ path }`,新增 `*-freebsd` 行(基座包见 SPEC-002 §2.5)。 | | v0.13 | 2026-11-22 | 随 mcpp 2026.11.22.1:§2.9 配套载荷的声明依次取自载荷安装时的描述文件与索引的描述文件,取 store 持有的第一个。 | -| v0.14 | 2026-11-23 | 随 mcpp @RELEASE@(设计 2026-11-22 内核接口与派生状态 §3.3):§2.9 内核头文件是目标的 `kernel-abi` 层;基座不带时缺省取工具链载荷的声明,没有声明时拒绝;引擎不向共享视图写入内核头文件。 | +| v0.14 | 2026-11-23 | 随 mcpp @RELEASE@(设计 2026-11-22 内核接口与派生状态 §3.3、§3.11):§2.9 内核头文件是目标的 `kernel-abi` 层;基座不带时缺省取工具链载荷的声明,没有声明时拒绝;引擎不向共享视图写入内核头文件。新增 §2.10 存储的根。 | | v0.9 | 2026-10-17 | 随 mcpp 2026.10.17.1:新增 §4.7,已安装的修订在构建中继续使用,`floor` 决定是否必须替换,`toolchain install` 取当前修订;§6.4 doctor 只读,报告构建实际使用的工具链与包 home 的一致性。 | --- diff --git a/docs/zh/09-commands-by-scenario.md b/docs/zh/09-commands-by-scenario.md index a4092b517..d4dda371a 100644 --- a/docs/zh/09-commands-by-scenario.md +++ b/docs/zh/09-commands-by-scenario.md @@ -90,6 +90,18 @@ host 工具条目。一份 `std` BMI 被机器上每个工程共享,实现以" 与 `mcpp cache gc --older-than` 也按年龄收集 `std` 模块条目;`gc --max-size` 只对包与宿主工具做 预算(2026.11.8.1+)。 +**存储中的载荷(@RELEASE@+)。** 构建把其图所指名的 mcpp 包存储中的每个载荷(工具链、其基座与伴随包、它接线的包与工具) +作为一个**根**持有:一个指向该载荷的链接 `registry/data/roots/mcpp/<存储名>@<版本>`,该图的每次构建都更新它,因此它的 +时间就是该载荷的最后使用时间。`mcpp toolchain install` 持有它安装的工具链。此前的 home 为它所持有的每个载荷建立一次根。 +`mcpp cache gc` 在缓存之后请包提供者回收存储(`xlings self clean`):没有任何引用的载荷(没有环境、没有环境中的链接、不是 +被保留载荷的依赖、没有根)被删除。给出 `--older-than` 时,先释放在这段时间内没有构建使用过的根。`--dry-run` 只说明会回收 +什么,不删除任何东西。 + +```bash +mcpp cache gc --older-than 60d --dry-run # 会回收什么:缓存与存储 +mcpp cache gc --older-than 60d +``` + ## 一个包已发布的版本 `mcpp search` 按子串匹配,并在每个命中行后附上该包发布的版本 —— 跨描述符 diff --git a/mcpp.toml b/mcpp.toml index 2c6531802..578766525 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -125,7 +125,7 @@ mcpplibs.mwrap.xz = "5.8.3.1" # The operating system is mcpplibs.os's (design 2026-10-26 §25): mcpp keeps no # layer of its own. -mcpplibs.os = "0.4.7" +mcpplibs.os = "0.4.8" # `modules/` holds what gets linked into this binary; `src/` is what has not # been separated yet, and shrinking it is the direction. Each entry is an diff --git a/modules/invocation/mcpp.toml b/modules/invocation/mcpp.toml index cf26a37c3..554f2763e 100644 --- a/modules/invocation/mcpp.toml +++ b/modules/invocation/mcpp.toml @@ -13,4 +13,4 @@ description = "The environment of one invocation of mcpp: statements over the st license = "Apache-2.0" [dependencies] -mcpplibs.os = "0.4.7" +mcpplibs.os = "0.4.8" diff --git a/modules/manifest/mcpp.toml b/modules/manifest/mcpp.toml index 4d3a947ad..61a32f44b 100644 --- a/modules/manifest/mcpp.toml +++ b/modules/manifest/mcpp.toml @@ -25,7 +25,7 @@ mcpp.surface = { path = "../surface" } mcpp.toolchain-model = { path = "../toolchain-model" } mcpp.versioning = { path = "../versioning" } -mcpplibs.os = "0.4.7" +mcpplibs.os = "0.4.8" # Subsystem-level tests. They see only this package, which is what lets them # state its contract in isolation; the root `tests/unit/` states the facts two diff --git a/modules/toolchain-model/mcpp.toml b/modules/toolchain-model/mcpp.toml index c322fc519..eca5cda83 100644 --- a/modules/toolchain-model/mcpp.toml +++ b/modules/toolchain-model/mcpp.toml @@ -23,7 +23,7 @@ license = "Apache-2.0" mcpp.invocation = { path = "../invocation" } mcpp.versioning = { path = "../versioning" } -mcpplibs.os = "0.4.7" +mcpplibs.os = "0.4.8" # Subsystem-level tests. They see only this package, which is what lets them # state its contract in isolation; the root `tests/unit/` states the facts two diff --git a/src/bmi_cache/maintenance.cppm b/src/bmi_cache/maintenance.cppm index 4ecca044a..50150104e 100644 --- a/src/bmi_cache/maintenance.cppm +++ b/src/bmi_cache/maintenance.cppm @@ -449,6 +449,9 @@ std::uintmax_t remove_entry(const Entry& e) { } // namespace +// How long ago `stampSeconds` was, as the commands here word it ("3d ago"). +export std::string age_text(std::int64_t stampSeconds) { return format_age(stampSeconds); } + // `mcpp cache dir` — where IS the cache? Before this, `cache *`, `doctor` and // `clean --bmi-cache` each resolved the root themselves while config.cppm's // reset path used GlobalConfig::bmiCacheDir, and the copies could disagree. @@ -655,7 +658,7 @@ void reclaim_runner_cache() { // `mcpp cache gc [--max-size N] [--older-than N]` — real LRU, driven by // entry.json's `accessed` stamp. -export int cache_gc(const std::string& maxSizeArg, const std::string& olderThanArg) { +export int cache_gc(const std::string& maxSizeArg, const std::string& olderThanArg, bool dryRun = false) { if (maxSizeArg.empty() && olderThanArg.empty()) { mcpp::ui::error("`mcpp cache gc` requires --max-size {MiB,GiB} " "and/or --older-than {s,m,h,d}"); @@ -706,11 +709,11 @@ export int cache_gc(const std::string& maxSizeArg, const std::string& olderThanA && (now - e.accessed) > *olderThan; bool overBudget = maxSize && live > *maxSize && e.kind != "std"; if (!tooOld && !overBudget) continue; - remove_entry(e); + if (!dryRun) remove_entry(e); ++removed; freed += e.size; if (e.kind != "std") live -= e.size; - mcpp::ui::status("Collected", + mcpp::ui::status(dryRun ? "Would collect" : "Collected", std::format("{} ({}, last used {})", e.label, human_bytes(e.size), format_age(e.accessed))); } @@ -719,9 +722,10 @@ export int cache_gc(const std::string& maxSizeArg, const std::string& olderThanA // because std entries are deliberately out of scope here. Reporting it as // the cache size would read as "the cache is now empty" while tens of MB of // std BMIs sit right next to it. - std::println("Collected {} entries, freed {} (package and tool entries now {})", - removed, human_bytes(freed), human_bytes(live)); - reclaim_runner_cache(); + std::println("{} {} entries, {} {} (package and tool entries {} {})", + dryRun ? "Would collect" : "Collected", removed, dryRun ? "would free" : "freed", + human_bytes(freed), dryRun ? "would be" : "now", human_bytes(live)); + if (!dryRun) reclaim_runner_cache(); if (maxSize && live > *maxSize) { // Say it rather than silently under-delivering: a size target that // cannot be met without evicting std BMIs is a real outcome, and a diff --git a/src/build/execute.cppm b/src/build/execute.cppm index 403b3a7cc..b89f60f3a 100644 --- a/src/build/execute.cppm +++ b/src/build/execute.cppm @@ -57,6 +57,7 @@ import mcpp.toolchain.stdmod; import mcpp.version; // MCPP_VERSION — the engine a build record names import mcpp.provider; import mcpp.provider.select; +import mcpp.provider.roots; import mcpp.runtime.binding; import mcpp.log; import mcpplibs.os.platform; @@ -2589,6 +2590,9 @@ std::optional run_ninja_fast(const std::string& ninjaProgram, const std::string& runtimeEnvKey, const std::string& runtimeEnvValue, std::chrono::milliseconds* elapsedOut = nullptr) { + // A build that reuses its graph renews the roots the graph's plan + // recorded: their time is the payloads' last use (design 2026-11-22 §3.11). + mcpp::provider::roots::hold(outputDir); // Read as it runs, into this directory's report, unless nothing is to be // shown (build progress design 2026-09-29, §6.1). const bool reporting = !mcpp::ui::is_quiet(); diff --git a/src/build/ninja_backend.cppm b/src/build/ninja_backend.cppm index 771ac0a49..265dd7346 100644 --- a/src/build/ninja_backend.cppm +++ b/src/build/ninja_backend.cppm @@ -46,6 +46,7 @@ import mcpp.toolchain.fingerprint; // hash_string: a platform seal's digest import mcpp.toolchain.msvc_coroutines; import mcpp.provider; import mcpp.provider.select; +import mcpp.provider.roots; import mcpp.buildopt.keep; import mcpp.buildopt.advice; import mcpp.modgraph.graph; @@ -5019,6 +5020,9 @@ std::expected NinjaBackend::build(const BuildPlan& plan if (existed && !tec && std::filesystem::last_write_time(ninja_path, tec) == before && !tec) std::filesystem::last_write_time(ninja_path, std::filesystem::file_time_type::clock::now(), tec); } + // The payloads this graph names are held as the store's roots, so that the + // provider's collection keeps them (design 2026-11-22 §3.11). + if (!opts.dryRun) mcpp::provider::roots::hold(plan.outputDir, manifest); stage("write-ninja"); // compile_commands.json — via the dedicated module. diff --git a/src/build/prepare/base.cpp b/src/build/prepare/base.cpp index 396def940..eae802bbb 100644 --- a/src/build/prepare/base.cpp +++ b/src/build/prepare/base.cpp @@ -947,7 +947,7 @@ std::expected step9_kernel_headers(PrepareState& state) { if (!measured) { refusal::record(refusal::Code::TargetBase); return std::unexpected(std::format( - "{} has no kernel headers to compile against: the base carries none, and the toolchain " + "[target.{}] has no kernel headers to compile against: the base carries none, and the toolchain " "{} declares none that serve {}.\n" " State them for the target:\n" "\n" diff --git a/src/cli.cppm b/src/cli.cppm index f04ac812b..9a4cba48d 100644 --- a/src/cli.cppm +++ b/src/cli.cppm @@ -1329,7 +1329,9 @@ int run(int argc, char** argv) { .option(cl::Option("max-size").takes_value().value_name("N{MiB|GiB}") .help("Keep the package cache under this size (e.g. 5GiB)")) .option(cl::Option("older-than").takes_value().value_name("N{s|m|h|d}") - .help("Also drop entries unused for longer than this")) + .help("Also drop entries, and the store's roots, unused for longer than this")) + .option(cl::Option("dry-run") + .help("Say what would be collected, and remove nothing")) .action(cmd_cache_gc)) .subcommand(cl::App("clean") .description("Drop cache entries (default: package entries only)") diff --git a/src/cli/cmd_cache.cppm b/src/cli/cmd_cache.cppm index 89f661505..ac60235cf 100644 --- a/src/cli/cmd_cache.cppm +++ b/src/cli/cmd_cache.cppm @@ -7,6 +7,8 @@ import std; import mcpplibs.mwrap.libc; import mcpplibs.cmdline; import mcpp.bmi_cache.maintenance; +import mcpp.config; +import mcpp.provider.roots; import mcpp.ui; import mcpp.wire; import nlohmann.json; @@ -53,10 +55,36 @@ export int cmd_cache_prune(const mcpplibs::cmdline::ParsedArgs& parsed) { return mcpp::bmi_cache::cache_prune(parsed.option_or_empty("older-than").value()); } +// THE CACHE, THEN THE STORE (design 2026-11-22 §3.11). The store's payloads +// are collected by the provider, whose one implementation keeps what anything +// references; mcpp's part is its roots: with `--older-than`, the roots of +// payloads no build used for that long are removed first. export int cmd_cache_gc(const mcpplibs::cmdline::ParsedArgs& parsed) { - return mcpp::bmi_cache::cache_gc( - parsed.option_or_empty("max-size").value(), - parsed.option_or_empty("older-than").value()); + const bool dryRun = parsed.is_flag_set("dry-run"); + const auto olderThan = parsed.option_or_empty("older-than").value(); + if (int rc = mcpp::bmi_cache::cache_gc(parsed.option_or_empty("max-size").value(), olderThan, dryRun); rc != 0) + return rc; + if (!olderThan.empty()) { + const auto secs = mcpp::bmi_cache::parse_duration(olderThan).value_or(0); + for (const auto& r : mcpp::provider::roots::expire(secs, dryRun)) + mcpp::ui::status(dryRun ? "Would release" : "Released", + std::format("the store's root {} (last used {})", r.name, + mcpp::bmi_cache::age_text(r.lastUse))); + } + // Read only: a home whose provider was never set up has no store to + // collect, and collecting is no reason to set one up. + auto cfg = mcpp::config::load_or_init(/*quiet=*/true, {}, {}, mcpp::config::Initialization::ReadOnly); + if (!cfg) { + mcpp::ui::error(cfg.error().message); + return 1; + } + // A home's roots before its first collection: without them, the provider + // would remove every payload a build of this home uses. + if (!mcpp::provider::roots::seed()) { + mcpp::ui::error("the store is not collected: its roots could not be registered (see the warning above)"); + return 1; + } + return mcpp::config::collect_store(*cfg, dryRun); } export int cmd_cache_clean(const mcpplibs::cmdline::ParsedArgs& parsed) { diff --git a/src/config.cppm b/src/config.cppm index fe3b85309..331a7739b 100644 --- a/src/config.cppm +++ b/src/config.cppm @@ -27,6 +27,7 @@ import nlohmann.json; import mcpp.pm.index_spec; import mcpp.provider; import mcpp.provider.select; +import mcpp.provider.roots; import mcpplibs.os.platform; import mcpplibs.os.windows; import mcpplibs.os.env; @@ -443,6 +444,10 @@ std::expected load_or_init( // Pretty-print resolved config for `mcpp env` command. void print_env(const GlobalConfig& cfg); +// The provider's collection of the registry's store (`mcpp cache gc`): what +// nothing references is removed, or with `dryRun` listed. Its exit status. +int collect_store(const GlobalConfig& cfg, bool dryRun); + // `[xlings.overrides]` of a parsed config.toml, keyed by package identity // (`:`, the namespace defaulted to `xim`): where a declared xlings // payload comes from on this machine (mcpp#755). A pure function of the @@ -1344,6 +1349,10 @@ std::expected load_or_init( if (!r.dir.empty()) owned.push_back({ r.name, r.url, {}, {}, {}, r.dir, r.store }); if (!cfg.registryBorrowed) mcpp::provider::open(make_xlings_env(cfg))->own_indices(owned); } + // A home from before the store's roots: one root for each payload it holds, + // before its first collection (design 2026-11-22 §3.11). A borrowed + // registry is its owner's to seed. + if (!cfg.registryBorrowed) (void)mcpp::provider::roots::seed(); // The upstreams are the registry's too: a borrowing home's `[xlings] // upstream` would replace its owner's. @@ -1447,6 +1456,12 @@ std::expected load_or_init( return cfg; } +int collect_store(const GlobalConfig& cfg, bool dryRun) { + auto provider = mcpp::provider::open(make_xlings_env(cfg)); + if (!provider->initialized()) return 0; // no store yet: nothing to collect + return provider->collect_store(dryRun); +} + void print_env(const GlobalConfig& cfg) { const auto home = mcpp::home::selection(); std::println("MCPP_HOME = {}", mcpp::home::spelling(home.original)); diff --git a/src/provider/provider.cppm b/src/provider/provider.cppm index d9047ec99..09c370b84 100644 --- a/src/provider/provider.cppm +++ b/src/provider/provider.cppm @@ -331,6 +331,9 @@ public: virtual std::filesystem::path store_of_home(const std::filesystem::path& home) const = 0; // The home a store belongs to. virtual std::filesystem::path home_of_store(const std::filesystem::path& store) const = 0; + // The directory in which `owner` keeps its roots of `store`: the links that + // state which payloads it uses, which the provider's collection keeps. + virtual std::filesystem::path roots_of(const std::filesystem::path& store, std::string_view owner) const = 0; // Whether `dir` is a home's default runtime environment. virtual bool is_default_environment(std::string_view dir) const = 0; // Whether `dir` is a store (a payload's path is /...). @@ -473,6 +476,10 @@ public: // the packages resolving with its snapshots. The provider's exit status. virtual int download_to(std::span refs, const std::filesystem::path& dir) const = 0; virtual int install_from(const std::filesystem::path& dir, std::span refs) const = 0; + // The provider's collection of its store: every payload nothing references + // -- its environments, their links, the dependency closure, the owners' + // roots -- is removed, or with `dryRun` listed. The provider's exit status. + virtual int collect_store(bool dryRun) const = 0; // A bundle's snapshot of index `name` made this home's index: placed where // the home has none, or holds a snapshot or an artifact's tree; a git // work tree or any other directory is the home's own and is kept. diff --git a/src/provider/roots.cppm b/src/provider/roots.cppm new file mode 100644 index 000000000..d91432f53 --- /dev/null +++ b/src/provider/roots.cppm @@ -0,0 +1,248 @@ +// mcpp.provider.roots — the payloads mcpp holds in its home's store, as roots +// (xlings' store-roots specification; design 2026-11-22 §3.11). +// +// mcpp wires store paths into its builds, and the provider's collection +// deletes a payload nothing references. A root is the reference mcpp states: +// a link `/@` to the payload, in the directory the +// provider gives mcpp. A build registers a root for each payload of the store +// its graph names, by replacing the link, so that the link's own time is the +// payload's last use; `mcpp cache gc --older-than` removes the roots unused for +// longer, and the provider's collection does the rest. The collection has one +// implementation, the provider's; when a root goes is mcpp's. + +export module mcpp.provider.roots; + +import std; +import mcpp.provider; +import mcpp.provider.select; +import mcpp.diag; +import mcpplibs.os.fs; + +export namespace mcpp::provider::roots { + +// The owner name mcpp's roots are kept under. +inline constexpr std::string_view kOwner = "mcpp"; + +// The home store's payloads that `text` names (a build graph's text, its +// escapes undone), each once, as `/`. +std::vector named_in(std::string_view text); + +// Hold the payloads of the build in `outputDir`: with `graphText`, the ones +// it names, recorded in `roots.list` beside it; without, the ones the record +// names (a build that reuses its graph). Each root is registered or renewed. +// A root that cannot be made is reported once (`store/roots`): the build goes +// on, and the provider's collection may delete what it uses. +void hold(const std::filesystem::path& outputDir, std::optional graphText = {}); + +// Register or renew a root for each `/`, or for each +// payload directory of the home store. +void use(const std::vector& payloads); +void use_dirs(const std::vector& payloadDirs); + +// THE HOME'S FORMAT STEP: a home that has no roots yet gets one for every +// payload its store holds, dated now, before its first collection. Once per +// home, and idempotent: the roots directory is published whole. Whether the +// home has its roots directory afterwards (a store that does not exist needs +// none, and answers true). +bool seed(); + +struct Root { + std::string name; // `@` + std::int64_t lastUse = 0; // seconds since the epoch; 0: unknown +}; + +// The roots last used more than `olderThan` seconds ago, removed unless +// `dryRun`. +std::vector expire(std::int64_t olderThan, bool dryRun); + +} // namespace mcpp::provider::roots + +namespace mcpp::provider::roots { + +namespace fs = std::filesystem; + +namespace { + +std::optional store() { + auto s = mcpp::provider::home_store(); + if (!s || s->empty()) return std::nullopt; + return s; +} + +fs::path directory(const fs::path& store) { return mcpp::provider::layout().roots_of(store, kOwner); } + +// A store name and a version are one path component each, of these bytes. +bool component_char(char c) { + return std::isalnum(static_cast(c)) || c == '.' || c == '-' || c == '_' || c == '+' + || c == '@'; +} + +std::string unescape_ninja(std::string_view text) { + std::string out; + out.reserve(text.size()); + for (std::size_t i = 0; i < text.size(); ++i) { + if (text[i] == '$' && i + 1 < text.size() + && (text[i + 1] == ':' || text[i + 1] == ' ' || text[i + 1] == '$')) { + out.push_back(text[++i]); + continue; + } + out.push_back(text[i]); + } + return out; +} + +// `/` at `at`, or empty. +std::string payload_at(std::string_view text, std::size_t at) { + std::string parts[2]; + for (auto& part : parts) { + while (at < text.size() && component_char(text[at])) part.push_back(text[at++]); + if (part.empty() || part == "." || part == "..") return {}; + if (&part == &parts[0] && (at >= text.size() || (text[at] != '/' && text[at] != '\\'))) return {}; + ++at; + } + return parts[0] + "/" + parts[1]; +} + +void report_once(std::string_view why) { + static std::once_flag once; + std::call_once(once, [&] { + mcpp::diag::degraded("store/roots", std::format("the store's roots of this build were not registered: {}", why), + "the provider's collection (`mcpp cache gc`) may remove a payload this build uses; " + "the next build installs it again"); + }); +} + +std::int64_t seconds_of(std::uint64_t ns) { return static_cast(ns / 1'000'000'000ull); } + +} // namespace + +std::vector named_in(std::string_view text) { + std::vector out; + const auto s = store(); + if (!s) return out; + const auto plain = unescape_ninja(text); + std::set seen; + for (const auto& prefix : {s->generic_string() + "/", s->string() + std::string(1, fs::path::preferred_separator)}) { + for (auto at = plain.find(prefix); at != std::string::npos; at = plain.find(prefix, at + prefix.size())) { + auto p = payload_at(plain, at + prefix.size()); + if (!p.empty() && seen.insert(p).second) out.push_back(std::move(p)); + } + } + return out; +} + +void use(const std::vector& payloads) { + const auto s = store(); + if (!s || payloads.empty()) return; + const auto dir = directory(*s); + std::error_code ec; + fs::create_directories(dir, ec); + for (const auto& p : payloads) { + const auto slash = p.find('/'); + if (slash == std::string::npos || !fs::is_directory(*s / p, ec)) continue; + const auto name = p.substr(0, slash) + "@" + p.substr(slash + 1); + // Relative to the owner's directory, as the specification recommends: + // it survives a move of the home. Made under a temporary name and + // renamed over the root, so that the root is never absent and its own + // time is now. + const auto target = s->lexically_relative(dir) / p.substr(0, slash) / p.substr(slash + 1); + const auto staged = dir / std::format(".{}.{:08x}", name, std::random_device{}()); + if (auto made = mcpplibs::os::fs::create_link(target, staged, true); !made) { + report_once(made.error().message()); + return; + } + if (auto moved = mcpplibs::os::fs::rename(staged, dir / name, true); !moved) { + fs::remove(staged, ec); + report_once(moved.error().message()); + return; + } + } +} + +void use_dirs(const std::vector& payloadDirs) { + const auto s = store(); + if (!s) return; + std::vector payloads; + for (const auto& d : payloadDirs) { + const auto rel = d.lexically_normal().lexically_relative(s->lexically_normal()); + if (std::distance(rel.begin(), rel.end()) != 2 || rel.begin()->string() == "..") continue; + payloads.push_back(rel.begin()->string() + "/" + std::next(rel.begin())->string()); + } + use(payloads); +} + +void hold(const fs::path& outputDir, std::optional graphText) { + const auto list = outputDir / "roots.list"; + std::vector payloads; + if (graphText) { + payloads = named_in(*graphText); + std::string text; + for (const auto& p : payloads) text += p + "\n"; + std::error_code ec; + fs::create_directories(outputDir, ec); + std::ofstream(list, std::ios::binary | std::ios::trunc) << text; + } else { + std::ifstream in(list, std::ios::binary); + for (std::string line; std::getline(in, line);) + if (!line.empty()) payloads.push_back(line); + } + use(payloads); +} + +bool seed() { + const auto s = store(); + if (!s) return true; + const auto dir = directory(*s); + std::error_code ec; + if (fs::exists(dir, ec) || !fs::is_directory(*s, ec)) return true; + // Published whole: the payloads' roots in a directory of this process's + // own, renamed to the owner's directory. Another process that seeds at the + // same time loses the rename and removes its copy; either copy is complete. + const auto staged = dir.parent_path() / std::format(".{}.seeding.{:08x}", kOwner, std::random_device{}()); + fs::create_directories(staged, ec); + if (ec) { report_once(ec.message()); return false; } + for (const auto& e : mcpp::provider::layout().entries(*s)) { + const auto rel = e.dir.lexically_relative(*s); + if (rel.empty() || rel.begin() == rel.end() || std::distance(rel.begin(), rel.end()) != 2) continue; + const auto storeName = rel.begin()->string(), version = std::next(rel.begin())->string(); + const auto target = s->lexically_relative(dir) / storeName / version; + if (auto made = mcpplibs::os::fs::create_link(target, staged / (storeName + "@" + version), true); !made) { + fs::remove_all(staged, ec); + report_once(made.error().message()); + return false; + } + } + if (!mcpplibs::os::fs::rename(staged, dir, false)) fs::remove_all(staged, ec); + return fs::is_directory(dir, ec); +} + +std::vector expire(std::int64_t olderThan, bool dryRun) { + std::vector out; + const auto s = store(); + if (!s) return out; + const auto dir = directory(*s); + const auto now = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()).count(); + std::error_code ec; + for (auto it = fs::directory_iterator(dir, ec); !ec && it != fs::directory_iterator{}; it.increment(ec)) { + const auto name = it->path().filename().string(); + // A root is a link (a junction on a Windows volume without symbolic + // links); a file or a directory here is not one. + if (name.starts_with(".") || !mcpplibs::os::fs::read_link(it->path())) continue; + // The link's own time, not its payload's: the time mcpp last used it. + const auto st = mcpplibs::os::fs::stamp_of(it->path(), false); + if (!st) continue; + const auto last = seconds_of(st->modified_ns); + if (now - last <= olderThan) continue; + if (!dryRun) { + std::error_code rec; + fs::remove(it->path(), rec); + if (rec) continue; + } + out.push_back({name, last}); + } + std::ranges::sort(out, {}, &Root::name); + return out; +} + +} // namespace mcpp::provider::roots diff --git a/src/provider/xlings/provider.cppm b/src/provider/xlings/provider.cppm index d0618ce7f..01152b9f6 100644 --- a/src/provider/xlings/provider.cppm +++ b/src/provider/xlings/provider.cppm @@ -57,6 +57,10 @@ public: std::filesystem::path home_of_store(const std::filesystem::path& store) const override { return store.parent_path().parent_path(); } + // xlings' store-roots specification: `/data/roots//`. + std::filesystem::path roots_of(const std::filesystem::path& store, std::string_view owner) const override { + return store.parent_path() / "roots" / std::string(owner); + } // A home's environment as a payload's build bakes it into its compiler: `subos/default`, or // `subos/current`, the link a home keeps to its active environment (gcc 16.2.0 revision 1 // was built in `/w/xh/subos/current`). Either names the building home's, not this one's. @@ -317,6 +321,7 @@ public: int install_from(const std::filesystem::path& dir, std::span refs) const override { return xlings::install_from(env_, dir, refs); } + int collect_store(bool dryRun) const override { return xlings::collect_store(env_, dryRun); } std::string adopt_index_snapshot(std::string_view name, const std::filesystem::path& snapshot) const override { return xlings::adopt_index_snapshot(env_, name, snapshot); } diff --git a/src/provider/xlings/xlings.cpp b/src/provider/xlings/xlings.cpp index 643162138..022335d68 100644 --- a/src/provider/xlings/xlings.cpp +++ b/src/provider/xlings/xlings.cpp @@ -1806,6 +1806,16 @@ int install_from(const Env& env, const std::filesystem::path& dir, std::span turn; + if (!dryRun) hold_state_turn(turn, env, "collecting the store"); + std::vector args{"self", "clean"}; + if (dryRun) args.push_back("--dry-run"); + return run_shown(invocation(env, std::move(args))); +} + std::string adopt_index_snapshot(const Env& env, std::string_view name, const std::filesystem::path& snapshot) { namespace fs = std::filesystem; fs::path dir; diff --git a/src/provider/xlings/xlings.cppm b/src/provider/xlings/xlings.cppm index 5c9c3c788..f4830f574 100644 --- a/src/provider/xlings/xlings.cppm +++ b/src/provider/xlings/xlings.cppm @@ -626,6 +626,10 @@ int install_direct(const Env& env, std::string_view target, bool quiet = false); // ` (xlings 2026.11.21.1), their lines shown as install_direct's. int download_to(const Env& env, std::span refs, const std::filesystem::path& dir); int install_from(const Env& env, const std::filesystem::path& dir, std::span refs); +// `xlings self clean [--dry-run]` in the home: the store's collection, which +// keeps what the home's environments, their dependency closure and the owners' +// roots reference (xlings' store-roots specification). +int collect_store(const Env& env, bool dryRun); std::string adopt_index_snapshot(const Env& env, std::string_view name, const std::filesystem::path& snapshot); // The marker of an index tree a bundle placed, which a later bundle may // replace. A refresh replaces it as it replaces any copy: an index mcpp owns diff --git a/src/toolchain/lifecycle.cppm b/src/toolchain/lifecycle.cppm index d545b1f06..1e7698f51 100644 --- a/src/toolchain/lifecycle.cppm +++ b/src/toolchain/lifecycle.cppm @@ -5,6 +5,7 @@ export module mcpp.toolchain.lifecycle; import std; +import mcpp.provider.roots; import mcpp.config; import mcpp.fetcher; import mcpp.fetcher.progress; @@ -1196,6 +1197,9 @@ export int toolchain_install(const mcpp::config::GlobalConfig& cfg, } } // a binding that cannot be resolved degrades, as on the build path + // Held from its install, before a build names it: the store's + // collection keeps what a root names (design 2026-11-22 §3.11). + mcpp::provider::roots::use_dirs({payload->root}); mcpp::ui::status("Installed", std::format("{} → {}", pkg.display_spec(), bin.string())); if (cfg.defaultToolchain.empty()) { diff --git a/tests/e2e/cache/entries.cpp b/tests/e2e/cache/entries.cpp index b169ebb35..b5830c8ba 100644 --- a/tests/e2e/cache/entries.cpp +++ b/tests/e2e/cache/entries.cpp @@ -1,6 +1,7 @@ // The global build cache: an entry shared across projects and keyed by what it was compiled // against, the cache modes and the maintenance commands, an entry's layout, a hit's std BMI, and -// the age of a std module (formerly tests/e2e/172, 174, 184, 212, 959, 1029). +// the age of a std module, and the store's roots a build holds (formerly tests/e2e/172, 174, 184, +// 212, 959, 1029; 1154). import std; import mcpplibs.mtest; import mcpp.test.support; @@ -489,4 +490,40 @@ E2E entries{"entries", s::home_fixture, [] { expect(fatal(e2e::succeeded(r))) << s::text(r); expect(fatal(fs::exists(std_dir / "old"))) << "a size budget evicted a std module\n" << s::text(r); }; + + "1154 a build holds its payloads as the store's roots"_test[s::unix_shell][s::fresh_sandbox] = [] { + // Design 2026-11-22 §3.11: A a build records the store's payloads its graph names + // (`roots.list`) and holds each as a root, a link to the payload; B the store's collection + // does not list them; C a root no build used for the period is released first, and a dry + // run removes nothing. + const s::options home{.where = s::home::inherited}; + const auto mcpp_home = s::case_home(s::home::inherited); + s::project p({{"mcpp.toml", "[package]\nname = \"held\"\nversion = \"0.1.0\"\n"}, + {"src/main.cpp", "import std;\nint main() { std::println(\"held\"); }\n"}}); + auto r = p.mcpp({"build"}, home); + expect(fatal(e2e::succeeded(r))) << s::text(r); + const auto lists = s::find_files(p.at("target"), R"(roots\.list)"); + expect(fatal(lists.size() == 1u)) << "A: no roots.list beside the graph"; + const auto roots = mcpp_home / "registry/data/roots/mcpp"; + std::vector held; + std::istringstream lines(s::read_file(lists.front())); + for (std::string line; std::getline(lines, line);) if (!line.empty()) held.push_back(line); + expect(fatal(std::ranges::any_of(held, [](const std::string& h) { return h.starts_with("xim-x-gcc/") || h.starts_with("xim-x-llvm/"); }))) + << "A: the toolchain's payload is not among the held: " << s::read_file(lists.front()); + for (const auto& h : held) { + const auto name = h.substr(0, h.find('/')) + "@" + h.substr(h.find('/') + 1); + expect(fatal(fs::is_symlink(roots / name) && fs::is_directory(roots / name))) << "A: no root " << name << " that reaches its payload"; + } + r = p.mcpp({"cache", "gc", "--older-than", "3650d", "--dry-run"}, home); + expect(fatal(e2e::succeeded(r))) << "B: " << s::text(r); + for (const auto& h : held) + expect(fatal(s::lacks(s::text(r), "would remove xpkgs/" + h + " "))) << "B: the collection lists a held payload " << h << "\n" << s::text(r); + const auto first = held.front(); + const auto aged = roots / (first.substr(0, first.find('/')) + "@" + first.substr(first.find('/') + 1)); + expect(fatal(e2e::succeeded(e2e::run({.argv = {"touch", "-h", "-t", "200001010000", aged.string()}})))) << "C: the root could not be aged"; + r = p.mcpp({"cache", "gc", "--older-than", "30d", "--dry-run"}, home); + expect(fatal(e2e::succeeded(r))) << "C: " << s::text(r); + expect(fatal(e2e::contains(s::text(r), "Would release the store's root " + aged.filename().string()))) << "C: " << s::text(r); + expect(fatal(fs::is_symlink(aged))) << "C: a dry run released the root"; + }; }}; From 10ceab416d96a1dcf201ad779f7ab71fc4f95716 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 03:40:58 +0900 Subject: [PATCH 05/33] feat: emit build-database states S1 0.4.0, which defines ide.generated[].origin --- ...-interface-and-derived-state-ecosystem-design.md | 13 +++++++++++++ CHANGELOG.md | 3 ++- docs/50-machine-output.md | 2 +- docs/specs/build-database.md | 8 ++++---- docs/zh/50-machine-output.md | 2 +- src/build/build_database.cppm | 2 +- tests/e2e/cdb/emit.cpp | 4 ++-- 7 files changed, 24 insertions(+), 10 deletions(-) diff --git a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md index 3081010c7..f3880213f 100644 --- a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md +++ b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md @@ -632,3 +632,16 @@ graph LR 实现),头文件仍按基座的组成部分决定并接线,层的身份不变。 7. **探针(§3.4)。** 探针单元按内容命名,写在临时目录中,不写入工程的 `target/`。 +8. **插件与版本组(§3.18,K1)。** 测定的前提不再成立:工程以 `[build-dependencies.mcpp] plugins = "0.26.0"` 构建 + `x86_64-openkal`(openkal-platform 0.31.2 的构建程序钉 0.26.1)时,两个版本各属一个构建程序的解析,锁中为 + `mcpp.plugins` 0.26.0 与 `mcpp.plugins+b<摘要>` 0.26.1(`programs = ["build:mcpplibs.openkal-platform@0.31.2"]`, + SPEC-013 §15.1,mcpp 2026.11.19.1 起)。平台的修订发布与工程指名的插件版本互不约束;把插件加入版本组反而会约束工程 + 自己的请求(版本组参与解析,§7.5)。K1 因此不改动 openkal-platform,K4 不依赖它。 +9. **索引中的行(§3.19)。** `riscv64-linux-musl`:x86_64 上的 musl 交叉载荷构建、静态链接,并在 qemu-user 下运行;该载荷的 + sysroot 不带内核头文件(`aarch64-linux-musl-gcc` 带 4.19.88),由其描述文件声明 `linux-headers` 6.18.64,修订 1 带 + riscv64 的头文件。行升为 `preview`,运行器为 `xim:qemu-user-riscv64`。`i686-linux-gnu` 与 `wasm32-wasi` 在索引中没有 + 基座载荷与编译器运行时,保持 `planned` 与未登记。iOS 模拟器的两行以 `simctl-run` 为运行器,`enabled = false`。 + `x86_64-macos` 在 Apple silicon 的运行器上经 Rosetta 测定(探针工作流),其层级按测定结果确定。 +10. **存储的根(§3.11,M7)。** 根的最后使用时间是链接自身的时间;读取它需要不跟随链接的状态查询,由 mcpplibs.os 0.4.8 的 + `fs::stamp_of(node, false)` 给出。根的登记点是构建图写出之处(图文本中指名的存储路径)与复用图的构建(图旁的 + `roots.list`),以及 `mcpp toolchain install`;`mcpp cache gc` 在回收之前先为没有根的 home 登记根,登记失败时不回收。 diff --git a/CHANGELOG.md b/CHANGELOG.md index e8ab5dc40..a32b341d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,7 +37,8 @@ of, one of the action's inputs, on a `source` action. The build database gives it as `ide.generated[].origin`. A generated unit that declares a module's primary name is a `module-interface`. When the authored file is also among the sources, the duplicate-provider - error names the relation (S1 0.4.0, mcpp#1004). + error names the relation (mcpp#1004). `emit build-database` states S1 profile 0.4.0, the version + that defines the field (Sunrisepeak/mcpp-language-server#98). - A build holds each payload of mcpp's package store that its graph names as a root of the store (`registry/data/roots/mcpp/@`, xlings' store-roots specification), diff --git a/docs/50-machine-output.md b/docs/50-machine-output.md index 69e50dc31..db402b817 100644 --- a/docs/50-machine-output.md +++ b/docs/50-machine-output.md @@ -737,7 +737,7 @@ writes nothing into the project. `data` is: | field | | |---|---| -| `spec` | `{"name": "s1", "version": "0.3.0"}` (0.2.0 before 2026.9.28.1), or `{"name": "compile-commands"}` with `--spec compile-commands` | +| `spec` | `{"name": "s1", "version": "0.4.0"}` (0.3.0 before @RELEASE@, 0.2.0 before 2026.9.28.1), or `{"name": "compile-commands"}` with `--spec compile-commands` | | `database` | the document of that specification: an S1 build database, or the entries `mcpp build --configure-only` writes to `compile_commands.json` | | `watch` | the inputs whose change can change the document: paths and glob patterns relative to the workspace root, or absolute paths | | `inputs-fingerprint` | `fnv1a:<16 hex digits>`, a digest of those inputs, the mcpp version and the selectors | diff --git a/docs/specs/build-database.md b/docs/specs/build-database.md index 6efd6feeb..7813f7474 100644 --- a/docs/specs/build-database.md +++ b/docs/specs/build-database.md @@ -7,10 +7,10 @@ | 状态 | 评审中 v1.10 | | 版本 | 1.10 | | 最后修改 | 2026-11-23 | -| 对应实现 | mcpp >= 2026.9.15.1;v1.3 修改的 R2.5、R3.7、R3.8、R4.1、R5.2 为 mcpp >= 2026.9.26.2;v1.4 修改的 R2.5 为 mcpp >= 2026.9.27.1;v1.5 修改的 R3.7、R3.12、R5.1、R5.2 为 mcpp >= 2026.9.28.1;v1.6 修改的 R2.1、R3.3、R3.4、R3.5、R4.1、R5.2 为 mcpp >= 2026.9.29.5;v1.7 新增的 R3.8a 为 mcpp >= 2026.9.30.2;v1.8 新增的 R3.13 为 mcpp >= 2026.10.11.1;v1.9 明确的 R6.1a 为 mcpp >= 2026.10.21.1;v1.10 的 R3.9、R3.12a 为 mcpp >= @RELEASE@ | +| 对应实现 | mcpp >= 2026.9.15.1;v1.3 修改的 R2.5、R3.7、R3.8、R4.1、R5.2 为 mcpp >= 2026.9.26.2;v1.4 修改的 R2.5 为 mcpp >= 2026.9.27.1;v1.5 修改的 R3.7、R3.12、R5.1、R5.2 为 mcpp >= 2026.9.28.1;v1.6 修改的 R2.1、R3.3、R3.4、R3.5、R4.1、R5.2 为 mcpp >= 2026.9.29.5;v1.7 新增的 R3.8a 为 mcpp >= 2026.9.30.2;v1.8 新增的 R3.13 为 mcpp >= 2026.10.11.1;v1.9 明确的 R6.1a 为 mcpp >= 2026.10.21.1;v1.10 的 R3.9、R3.12a 与 R5.1 的 S1 0.4.0 为 mcpp >= @RELEASE@ | | 相关设计文档 | `.agents/docs/2026-09-14-636-build-database-and-the-latest-xlings.md`
`.agents/docs/2026-09-26-compile-database-and-issue-699-design.md` | | 相关 issue | #636, #648, #655, #699, #702, #707, #732, #797 | -| 依据的外部规范 | S1「C++ Build Database: IDE Profile」profile 0.3.0(§7.2 的 `generated`,Sunrisepeak/mcpp-language-server#28;此前为 0.2.0)与 S2 0.2.0 §3.4,取自 https://github.com/Sunrisepeak/lsp-mcpp-private 提交 `b82859d`(schema 自提交 `28ecd6e` 起未变);S2 0.3.0 §3.4 的部分回答(S2-3.4-12、S2-3.4-13,Sunrisepeak/mcpp-language-server#25);JSON Compilation Database | +| 依据的外部规范 | S1「C++ Build Database: IDE Profile」profile 0.4.0(§7.2 的 `origin`,Sunrisepeak/mcpp-language-server#98;0.3.0 的 §7.2 `generated`,Sunrisepeak/mcpp-language-server#28;此前为 0.2.0)与 S2 0.2.0 §3.4,取自 https://github.com/Sunrisepeak/lsp-mcpp-private 提交 `b82859d`(schema 自提交 `28ecd6e` 起未变);S2 0.3.0 §3.4 的部分回答(S2-3.4-12、S2-3.4-13,Sunrisepeak/mcpp-language-server#25);JSON Compilation Database | ## 0. 适用范围 @@ -214,7 +214,7 @@ mcpp 输出的 S1 文档满足 S1 等级 2,不输出 `ide.options`。等级 3 ## 5. 信封 - **R5.1** `kind` 为 `mcpp.build-database`,`kindVersion` 为 1。`data` 含 `spec` - (`{"name": "s1", "version": "0.3.0"}` 或 `{"name": "compile-commands"}`)、 + (`{"name": "s1", "version": "0.4.0"}`,@RELEASE@ 之前为 0.3.0;或 `{"name": "compile-commands"}`)、 `database`、`watch` 与 `inputs-fingerprint`。**已实现** - **R5.2** 一个成员规划失败只影响它自己,不影响其余成员的集合(#699 第 1 项)。命令 按配置规划被选中的成员;一个配置的规划失败时,该配置的成员逐个规划,因此失败仍归于 @@ -272,4 +272,4 @@ mcpp 输出的 S1 文档满足 S1 等级 2,不输出 `ide.options`。等级 3 | 1.7 | 2026-09-30 | 新增 R3.8a:同一配置中两个包提供同一个模块名时,两个单元都列出它,可能导入它的单元的 `arguments` 带有构建所用的绑定(#732)。 | | 1.8 | 2026-10-11 | 新增 R3.13:构建程序、构建程序实例的库与引擎接口以 `<包>:build`、`<包>:host`、`mcpp:core`、`mcpp:std:host` 集合描述,`ide.configuration` 为 `build-program`,只进入 S1 文档(#797)。 | | 1.9 | 2026-10-21 | R6.1a 明确合成 host 清单与锁文件不作为 watch 或 fingerprint 输入,保留可编辑依赖输入(#807)。 | -| 1.10 | 2026-11-23 | 新增 R3.12a:生成的单元以 action 陈述的 `origin` 指名其编写的源文件(S1 0.4.0);R3.9 以 `provides` 声明模块主名的生成单元为 `module-interface`(mcpp#1004)。 | +| 1.10 | 2026-11-23 | 新增 R3.12a:生成的单元以 action 陈述的 `origin` 指名其编写的源文件(S1 0.4.0);R3.9 以 `provides` 声明模块主名的生成单元为 `module-interface`(mcpp#1004)。R5.1:S1 版本为 0.4.0(Sunrisepeak/mcpp-language-server#98)。 | diff --git a/docs/zh/50-machine-output.md b/docs/zh/50-machine-output.md index 87d0c12f0..91e2b7e0b 100644 --- a/docs/zh/50-machine-output.md +++ b/docs/zh/50-machine-output.md @@ -659,7 +659,7 @@ mcpp emit build-database [--spec s1|compile-commands] --format json | 字段 | | |---|---| -| `spec` | `{"name": "s1", "version": "0.3.0"}`(2026.9.28.1 之前为 0.2.0);使用 `--spec compile-commands` 时为 `{"name": "compile-commands"}` | +| `spec` | `{"name": "s1", "version": "0.4.0"}`(@RELEASE@ 之前为 0.3.0,2026.9.28.1 之前为 0.2.0);使用 `--spec compile-commands` 时为 `{"name": "compile-commands"}` | | `database` | 该规范对应的文档:一份 S1 构建数据库,或者 `mcpp build --configure-only` 写入 `compile_commands.json` 的那些条目 | | `watch` | 一旦发生变化就可能改变这份文档的输入:相对工作区根目录的路径与 glob,或绝对路径 | | `inputs-fingerprint` | `fnv1a:<16 位十六进制>`,对上述输入、mcpp 版本与选择器求出的摘要 | diff --git a/src/build/build_database.cppm b/src/build/build_database.cppm index e7155e983..37fa4d243 100644 --- a/src/build/build_database.cppm +++ b/src/build/build_database.cppm @@ -41,7 +41,7 @@ import mcpp.toolchain.stdmod; export namespace mcpp::build::database { // 0.3.0: a set carries `generated` (S1 section 7.2, mcpp#724). -inline constexpr std::string_view kProfileVersion = "0.3.0"; +inline constexpr std::string_view kProfileVersion = "0.4.0"; inline constexpr std::string_view kStdSetName = "mcpp:std"; // One planned member of the document. diff --git a/tests/e2e/cdb/emit.cpp b/tests/e2e/cdb/emit.cpp index fa8a5ae3f..433a6cc5e 100644 --- a/tests/e2e/cdb/emit.cpp +++ b/tests/e2e/cdb/emit.cpp @@ -76,8 +76,8 @@ E2E emit{"emit", s::home_fixture, [] { const auto effects = e["effects"].get>(); expect(fatal(std::ranges::find(effects, "write-project") == effects.end() && std::ranges::find(effects, "read-project") != effects.end())) << "A: effects " << e["effects"].dump(); const auto& d = e["data"]; - expect(fatal(d["spec"] == nlohmann::json{{"name", "s1"}, {"version", "0.3.0"}})) << "A: spec " << d["spec"].dump(); - expect(fatal(d["database"]["ide"]["profile-version"] == "0.3.0")) << "A: profile-version"; + expect(fatal(d["spec"] == nlohmann::json{{"name", "s1"}, {"version", "0.4.0"}})) << "A: spec " << d["spec"].dump(); + expect(fatal(d["database"]["ide"]["profile-version"] == "0.4.0")) << "A: profile-version"; expect(fatal(d["inputs-fingerprint"].get().starts_with("fnv1a:"))) << "A: fingerprint " << d["inputs-fingerprint"].dump(); const auto proto = s::json(hello.mcpp({"--protocol-version"}).out); expect(fatal(proto["kinds"]["mcpp.build-database"] == 1)) << "A: the protocol document"; From 739f28c82edc1f27d51922c19f062bc519062192 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 04:59:24 +0900 Subject: [PATCH 06/33] fix: a platform-defined row takes its provider's linkage, a path platform's provider is selected, every web program packs its module, $ORIGIN is the directory a library was opened in, and a macOS link names its target (mcpp#1007) - One function gives a row's view under its provider (view_of), for the built-in table, a non-default provider and a row a platform package defines; the latter's `linkage = "static"` now reaches the build, and the default pack mode packs a static program of a format without a dynamic linker (DJGPP) with no closure. - `path:`, the reference text a path platform's provider names its package by, parses; the selection no longer leaves that provider out. - `--all-programs` on wasm32-emscripten stages each program's module. - The ELF closure model expands `$ORIGIN` at the directory the loader opened a library in, not at the target of the link it was reached through (compat.curand under LLVM). - On a macOS host the link names the target whenever the compile does (x86_64-macos on Apple silicon); the row stays planned, its C++ link lacking an x86_64 libc++. - e2e 103 and 300 take i686 as the planned example now that riscv64-linux-musl is preview; new e2e 1155 and 1156, unit tests for both parsers and the closure. --- ...face-and-derived-state-ecosystem-design.md | 38 +++++++++- .github/workflows/ci-macos-ios.yml | 20 +++++ CHANGELOG.md | 18 +++++ docs/10-pack-and-release.md | 7 ++ docs/zh/10-pack-and-release.md | 4 + modules/manifest/src/platform.cppm | 10 +++ modules/toolchain-model/src/triple.cppm | 13 +++- src/build/flags.cppm | 12 +-- src/build/prepare/toolchain.cpp | 17 ++--- src/pack/pack.cppm | 39 +++++++--- src/pack/pipeline.cppm | 1 + src/runtime/elf.cppm | 31 +++++--- ...gistered_family_is_not_reported_unknown.sh | 46 +++++++----- tests/e2e/pack/modes.cpp | 73 ++++++++++++++++++- tests/e2e/targets/requests.cpp | 19 +++-- tests/e2e/targets/rows.cpp | 4 +- tests/e2e/web/emscripten.cpp | 15 +++- tests/unit/test_elf_runtime.cpp | 31 ++++++++ tests/unit/test_platform.cpp | 6 ++ 19 files changed, 337 insertions(+), 67 deletions(-) diff --git a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md index f3880213f..7e498ec99 100644 --- a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md +++ b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md @@ -422,6 +422,27 @@ xlings 的规则"派生的状态可以由任何流程重建"与"读不到不等 的补丁发布与平台版本组的修订进入本轮(K5)。 - 它们随家族的一次发布与版本组的修订进入索引;mcpp 内置的缺省平台版本随之更新。 +### 3.21 平台定义的行的打包(mcpp,mcpp#1007) + +按目标逐个打包一个有两个程序目标的 C 工程(`--all-programs`)时,两处结果与工程的陈述不符。两处都在 mcpp 内,归入本轮; +工程自身的发布做法(DJGPP 行改用 `--mode static`、WebAssembly 改用 `--pkg-format web`)是绕行,不是修复的对象。 + +- **平台包陈述的链接方式没有到达构建。** djgpp-platform 的提供者陈述 `linkage = "static"`,缺省(vendored)模式仍按动态 + 程序求其运行时闭包,而 go32 程序既不是 ELF、PE 也不是 Mach-O,于是被拒绝。根因有两层,都是基础设施: + - 行的缺省链接方式只从内置表的行视图(`TargetInfo`)读取;平台包定义的行不在内置表中,选中的提供者的事实被跳过。 + 行在其提供者之下的视图由一个函数给出(`view_of(row, provider)`),内置表、非缺省的提供者与平台包定义的行都经它 + 得到同一组字段,三处不再各自拼装。 + - 路径形式的平台包,其提供者以 `path:` 指名所属的包(SPEC-013 的引用字符串形式),而引用文本的解析不认识这一形式, + 把它读作缺少版本的载荷;选择按所选平台过滤提供者时,路径平台的提供者因此全部落选,它陈述的每个键都不生效。解析补上 + 该形式,与规范所列的字符串形式一致。 + - 链接方式为静态、且文件格式不是三种可询问装载器的格式之一时,程序没有运行时闭包,打包不再询问装载器;链接方式不是 + 静态时,同一文件仍被拒绝并写出格式,因为闭包无从得知("做得更少不沉默")。 +- **Web 行只为一个程序带上模块。** 启动脚本的伴随文件(`.wasm` 等,按文件名主干的家族)只为与包同名的程序收集; + `--all-programs` 的其余程序只带启动脚本。伴随文件改为对打包的每个程序收集。`cmd.exe` 中的 `.exe` 不是原因。 + +回归由两个 e2e 覆盖:路径平台的静态提供者下,两个原始映像格式的程序都被打包,去掉 `linkage` 后被拒绝并写出格式; +Web 行上两个程序各带其模块。 + ## 4. 跨平台 | 行 | `kernel-abi` 的供给者 | 写 `layers.kernel-abi` 的结果 | @@ -551,7 +572,8 @@ xlings 的规则"派生的状态可以由任何流程重建"与"读不到不等 | M7 | mcpp | 根的登记、home 格式的一步、`cache gc` | X5、I6 | 私有 home 上回收的试运行不列出在用的载荷 | | M8 | mcpp | `origin`:构建程序的接口与构建数据库 | — | 单元测试与一个 e2e | | M9 | mcpp | §3.19 的行与运行器 | I5、K4 | 每一行按测量得到其层级 | -| M10 | mcpp | 规范、文档、CHANGELOG、缺省平台的版本、发布 | M1 至 M9、K4 | 全部检查通过;发布与 GitCode 的资源 | +| M10 | mcpp | 规范、文档、CHANGELOG、缺省平台的版本、发布 | M1 至 M9、M11、K4 | 全部检查通过;发布与 GitCode 的资源 | +| M11 | mcpp | §3.21:行视图的单一函数、`path:` 引用的解析、无闭包的静态程序、每个程序的伴随文件 | — | §3.21 的两个 e2e | | S1 | mcpp-language-server | S1 的字段文本 | M8 | 文本与 mcpp 的输出一致 | | D1 | mcpp-index | compat.libarchive 的条件 | — | 原生 musl 与 openkal 两种行的 CI | | I7 | xim-pkgindex | mcpp 的版本 | M10 | 索引指向新版本 | @@ -589,6 +611,7 @@ graph LR M7 --> M10 M8 --> M10 M9 --> M10 + M11 --> M10 M8 --> S1 M10 --> I7 I7 --> E1 @@ -641,7 +664,18 @@ graph LR sysroot 不带内核头文件(`aarch64-linux-musl-gcc` 带 4.19.88),由其描述文件声明 `linux-headers` 6.18.64,修订 1 带 riscv64 的头文件。行升为 `preview`,运行器为 `xim:qemu-user-riscv64`。`i686-linux-gnu` 与 `wasm32-wasi` 在索引中没有 基座载荷与编译器运行时,保持 `planned` 与未登记。iOS 模拟器的两行以 `simctl-run` 为运行器,`enabled = false`。 - `x86_64-macos` 在 Apple silicon 的运行器上经 Rosetta 测定(探针工作流),其层级按测定结果确定。 + `x86_64-macos` 在 Apple silicon 的运行器上经 Rosetta 测定(探针工作流):链接原先不带 `--target`,按 arm64 链接 x86_64 + 的目标文件而找不到 `main`;链接改为凡编译指名目标即指名之后,C 程序链接为 x86_64 并在 Rosetta 下运行。C++ 程序仍不能 + 链接:LLVM 载荷的 `libc++.a` 只有 arm64,链接器跳过它而不报警,libc++ 的符号全部未定义。该行因此保持 `planned`, + 所缺的事实是 x86_64(或通用)的 libc++ 载荷;macOS 的 CI 断言 C 程序的链接与运行。 10. **存储的根(§3.11,M7)。** 根的最后使用时间是链接自身的时间;读取它需要不跟随链接的状态查询,由 mcpplibs.os 0.4.8 的 `fs::stamp_of(node, false)` 给出。根的登记点是构建图写出之处(图文本中指名的存储路径)与复用图的构建(图旁的 `roots.list`),以及 `mcpp toolchain install`;`mcpp cache gc` 在回收之前先为没有根的 home 登记根,登记失败时不回收。 +11. **平台定义的行的打包(§3.21,M11)。** DJGPP 行上的拒绝不是平台包少写了陈述:djgpp-platform 0.2.0 已陈述 + `linkage = "static"`,是引擎只从内置表读取行的缺省链接方式。同一测定发现路径平台的提供者在选择中全部落选(引用文本 + `path:` 不被解析),两处一并修复;改动后,以路径平台定义行的各 e2e 套件重新运行。 +12. **运行时闭包的 `$ORIGIN`(D1 的测定)。** mcpp-index 在 mcpp 2026.11.22.1 之下的 LLVM 一路拒绝 `cuda-curand` 的测试程序 + (`libgcc_s.so.1 not found`),而该程序直接运行成功。glibc 对经链接打开的库,以打开它的路径所在目录展开 `$ORIGIN` + (`LD_DEBUG=libs` 测得 `libgcc_s.so.1` 取自链接农场),闭包模型却先把找到的路径解析为链接的目标,再在目标的目录展开。 + 模型改为:对象以其文件为身份,以打开它的目录为 `$ORIGIN`。农场中的 `libgcc_s.so.1` 仍然需要:LLVM 构建的程序不装载它, + 而 `libcurand.so.10` 的 DT_RUNPATH 只有 `$ORIGIN`。 diff --git a/.github/workflows/ci-macos-ios.yml b/.github/workflows/ci-macos-ios.yml index 67fa609df..dba56aaee 100644 --- a/.github/workflows/ci-macos-ios.yml +++ b/.github/workflows/ci-macos-ios.yml @@ -395,6 +395,26 @@ jobs: grep -qx '1-2-3' <<<"$out" || { echo "FAIL: the program's output line '1-2-3' is absent"; exit 1; } echo "ok: the row's runner is refused until enabled, and enabled it runs the program in the simulator" + # THE LINK NAMES THE TARGET THE COMPILE NAMES. `x86_64-macos` is planned + # (the LLVM payload's libc++ is arm64 only, so a C++ link finds none of + # its symbols); a C program, opted in by naming the toolchain, links for + # x86_64 and runs under Rosetta. Before, the link carried no `--target`, + # linked for arm64 and found no `main` among the x86_64 objects. + - name: "x86_64-macos: a C program links for its target and runs under Rosetta" + run: | + set -uo pipefail + arch -x86_64 /usr/bin/true || { echo "SKIP: this runner has no Rosetta"; exit 0; } + rm -rf /tmp/xm && mkdir -p /tmp/xm/src && cd /tmp/xm + printf '[package]\nname = "xm"\nversion = "0.1.0"\n\n[targets.xm]\nkind = "bin"\nmain = "src/main.c"\n' > mcpp.toml + printf '#include \nint main(void) { printf("xm %%d\\n", (int)sizeof(long)); return 6; }\n' > src/main.c + out=$("$MCPP_FRESH" run --target x86_64-macos --toolchain "llvm@${MCPP_LLVM_VER}" 2>&1) && rc=0 || rc=$? + printf '%s\n' "$out" | tail -8 + [ "$rc" -eq 6 ] || { echo "FAIL: the run exited $rc, not the program's 6"; exit 1; } + grep -qx 'xm 8' <<<"$out" || { echo "FAIL: the program's line 'xm 8' is absent"; exit 1; } + bin=$(find target -type f -name xm -perm -u+x | head -1) + file "$bin" | grep -q x86_64 || { echo "FAIL: $bin is not an x86_64 program: $(file "$bin")"; exit 1; } + echo "ok: the link names x86_64-macos and the program runs under Rosetta" + # THE THIRD ROW, BUILT HERE AND RUN ELSEWHERE (design 2026-10-23 §2.6, # S15). A simulator runs the host's architecture and this runner is # Apple silicon, so this job proves the artefact and the SDK's slice; the diff --git a/CHANGELOG.md b/CHANGELOG.md index a32b341d9..0a9825d08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,24 @@ under `--strict`. They now complete the graph and reach the link on every row (docs/35); `link.flags` that reaches no program says so, and `carrier`, a form of a platform's image, is a warning there (`platform/carrier`). +- A row a platform package defines takes the linkage its provider states. `i586-dos-djgpp` + (djgpp-platform, `linkage = "static"`) is linked statically, and `mcpp pack` in its default mode + packs its programs: a static program whose format is neither ELF, PE nor Mach-O has no runtime + closure, so none is asked for. A dynamic program of such a format is still refused, naming the + format (mcpp#1007). +- The provider of a platform named by a path (`platform = { path = "" }`) is selected. Its + package reference `path:` was read as a payload without a version, so the selection left + it out, and what only the provider states, such as its `linkage`, did not apply (mcpp#1007). +- The runtime-closure check expands `$ORIGIN` at the directory a library was opened in, as the + loader does, not at the target of the link it was reached through. A program whose libraries are + links in a farm, each finding its dependencies beside it (compat.curand under LLVM), was refused + with `libgcc_s.so.1 not found` and ran when started. +- On a macOS host, the link of a target other than the host's names the target, as its compile + does. `x86_64-macos` on Apple silicon linked its x86_64 objects for arm64 and found no `main`; + a C program now links and runs under Rosetta. The row stays `planned`: the LLVM payload's + libc++ is arm64 only. +- `mcpp pack --all-programs` on `wasm32-emscripten` packs each program's module beside its + launcher. Before, only the program named after the package had its `.wasm` (mcpp#1007). ## [2026.11.22.1] - 2026-11-22 diff --git a/docs/10-pack-and-release.md b/docs/10-pack-and-release.md index 1b0aa9f09..377feb80c 100644 --- a/docs/10-pack-and-release.md +++ b/docs/10-pack-and-release.md @@ -726,6 +726,13 @@ not work: an ELF program's closure is resolved by the target's own dynamic linker, which a Windows host has no way to run. A Mach-O program's closure is read from the file, so a macOS program packs from any host. +A program whose format is none of the three (a DJGPP program is COFF under a +go32 stub) has a closure only when it is linked statically: then it has none, +and the default mode packs it. The row's linkage is the one its provider +states, a provider of a platform package included (`linkage = "static"` in +`[[platform.provider]]`). A dynamic program of such a format is refused, and +the refusal names the format. + ### macOS (Mach-O): the dylibs beside the program ``` diff --git a/docs/zh/10-pack-and-release.md b/docs/zh/10-pack-and-release.md index 01e5889d7..dc7c4c997 100644 --- a/docs/zh/10-pack-and-release.md +++ b/docs/zh/10-pack-and-release.md @@ -628,6 +628,10 @@ mcpp pack --target x86_64-windows-gnu # from a Linux host 目标自己的动态链接器解析,而 Windows 宿主没有办法运行它。Mach-O 程序的闭包是 从文件里读出来的,因此一个 macOS 程序可以在任何宿主上打包。 +格式不属于这三种的程序(DJGPP 程序是 go32 引导段之后的 COFF),只有静态链接时才有确定的闭包: +它为空,缺省模式直接打包。行的链接方式取其提供者的陈述,平台包的提供者同样适用 +(`[[platform.provider]]` 中的 `linkage = "static"`)。这类格式的动态程序被拒绝,拒绝写出其格式。 + ### macOS(Mach-O):dylib 与程序放在同一目录 ``` diff --git a/modules/manifest/src/platform.cppm b/modules/manifest/src/platform.cppm index e775b1ae0..afd3949f4 100644 --- a/modules/manifest/src/platform.cppm +++ b/modules/manifest/src/platform.cppm @@ -478,6 +478,16 @@ inline std::expected parse_ref_text(std::string_view te } return r; } + // A DIRECTORY (`path:`): the text a provider of a path platform names + // its package by, read back where the selection filters providers by the + // chosen platform. Read as a payload without its version before, the text + // matched no platform, and the provider of every path platform was left + // out: a row it defines took none of its keys (mcpp#1007, `linkage`). + if (text.starts_with("path:")) { + if (text.size() == 5) return std::unexpected(std::format("'{}' names no directory after `path:`", text)); + r.spec.path = std::string(text.substr(5)); + return r; + } const auto at = text.rfind('@'); // AN ECOSYSTEM PAYLOAD (`xim:linux-headers@6.18.64`): named by its index // and always with its version, the rule `companions` states. diff --git a/modules/toolchain-model/src/triple.cppm b/modules/toolchain-model/src/triple.cppm index dd38382e3..ba01db280 100644 --- a/modules/toolchain-model/src/triple.cppm +++ b/modules/toolchain-model/src/triple.cppm @@ -610,10 +610,15 @@ constexpr const mcpp::toolchain::target::Provider* default_provider_of(std::stri return best; } -constexpr TargetInfo info_of(const mcpp::toolchain::target::Row& r) { +// A row seen through the provider that serves it: the toolchain it pins, the +// C library it brings, its linkage and the platform package that implements it. +// One function for the built-in table, a provider other than the default, and a +// row a platform package defines, so the three cannot disagree on a field. +constexpr TargetInfo view_of(const mcpp::toolchain::target::Row& r, + const mcpp::toolchain::target::Provider* p) { TargetInfo t{ r.triple, r.tier, r.note, {}, {}, false }; t.row = &r; - t.provider = default_provider_of(r.triple); + t.provider = p; if (t.provider) { t.pin = t.provider->toolchain; t.sysroot = t.provider->sysroot == "toolchain" ? std::string_view{} : t.provider->sysroot; @@ -623,6 +628,10 @@ constexpr TargetInfo info_of(const mcpp::toolchain::target::Row& r) { return t; } +constexpr TargetInfo info_of(const mcpp::toolchain::target::Row& r) { + return view_of(r, default_provider_of(r.triple)); +} + inline constexpr auto kKnownTargets = [] { std::array out{}; for (std::size_t i = 0; i < out.size(); ++i) out[i] = info_of(mcpp::toolchain::builtin::kRows[i]); diff --git a/src/build/flags.cppm b/src/build/flags.cppm index 9df9f05be..139f1813e 100644 --- a/src/build/flags.cppm +++ b/src/build/flags.cppm @@ -2425,11 +2425,13 @@ CompileFlags compute_flags_impl(const BuildPlan& plan, bool packageLinkFlags) { // graph-supplied-target replacement below, which assembles its own // `--target=` and `--no-default-config`, and appending them twice // would make the outcome depend on the driver's flag ordering. - std::string apple_cross_ld; - if (appleCross) { - apple_cross_ld = crossTarget; - if (isClangWithCfg) apple_cross_ld += " --no-default-config"; - } + // + // The target is named whenever the compile named it, not only for an + // Apple cross SDK: `x86_64-macos` on an Apple-silicon host compiles + // x86_64 objects, and a link told nothing ran for arm64 and found no + // `main` among them (measured on macos-15-arm64). + std::string apple_cross_ld = crossTarget; + if (appleCross && isClangWithCfg) apple_cross_ld += " --no-default-config"; platformAnchor = macos_sdk + version_min; f.ld = std::format("{}{}{}{} -fuse-ld=lld{}{}{}{}", full_static, b_flag, apple_cross_ld, macos_sdk, version_min, diff --git a/src/build/prepare/toolchain.cpp b/src/build/prepare/toolchain.cpp index 1bbb8fea4..d5900a5fc 100644 --- a/src/build/prepare/toolchain.cpp +++ b/src/build/prepare/toolchain.cpp @@ -717,14 +717,7 @@ step1_resolve_target_triple_request(PrepareState& state, TargetOverrideCtx& ctx) // of its default provider: the toolchain it pins, the C library it brings, // the linkage and the platform package that implements it. if (ctx.known && ctx.sel.provider && ctx.sel.provider != ctx.known->provider) { - auto view = *ctx.known; - auto const* p = ctx.sel.provider; - view.provider = p; - view.pin = p->toolchain; - view.sysroot = p->sysroot == "toolchain" ? std::string_view{} : p->sysroot; - view.defaultStatic = p->linkage == "static"; - view.platform = p->platform; - state.selectedTarget = view; + state.selectedTarget = triple::view_of(*ctx.known->row, ctx.sel.provider); ctx.known = &*state.selectedTarget; } @@ -1285,7 +1278,13 @@ step1_target_row_pin_and_capability_check(PrepareState& state, TargetOverrideCtx ctx.known->pin.empty() ? std::string_view("llvm") : ctx.known->pin)); } } - if (ctx.known && ctx.known->defaultStatic && state.m->buildConfig.linkage.empty()) + // The provider that serves the build states the default linkage, for a + // built-in row and for a row a platform package defines alike: the latter + // is not in the built-in table, and reading the table alone left a static + // platform's programs (DJGPP's) shared in every later step that asks. + const bool defaultStatic = ctx.known ? ctx.known->defaultStatic + : ctx.sel.row && mcpp::toolchain::triple::view_of(*ctx.sel.row, ctx.sel.provider).defaultStatic; + if (defaultStatic && state.m->buildConfig.linkage.empty()) state.m->buildConfig.linkage = "static"; return {}; } diff --git a/src/pack/pack.cppm b/src/pack/pack.cppm index 09e060ca8..357d1d56b 100644 --- a/src/pack/pack.cppm +++ b/src/pack/pack.cppm @@ -308,6 +308,9 @@ struct Plan { // `shared`, or `declared` (each library as it declares itself). Set by the // caller from the build. std::string linkageName = "declared"; + // The build linked the program static (the row's or the project's + // `linkage`): it names no loader and no library, whatever its format. + bool programStatic = false; // The other legs of a tree or a single file (SPEC-014 §3), set by the caller // after `make_plan` as `extraSharedLegs` is. std::vector loadedLegs; @@ -2347,16 +2350,23 @@ run_wasm(const Plan& plan) const auto builtDir = plan.builtBinary.parent_path(); // The module beside the launcher is the row's companion (N33): absent when // the link embedded it (`-sSINGLE_FILE=1`), and removed before every link, - // so a module present here is this launcher's. - auto family = mcpp::pack::emscripten_stem_family(builtDir, plan.binaryName); - for (auto const& name : family.siblings) { - std::error_code fec; - std::filesystem::copy_file(builtDir / name, - plan.stagingRoot / "bin" / name, - std::filesystem::copy_options::overwrite_existing, fec); - if (fec) return std::unexpected(Error{std::format( - "failed to copy {} -> {}: {}", (builtDir / name).string(), - (plan.stagingRoot / "bin" / name).string(), fec.message())}); + // so a module present here is this launcher's. EVERY PROGRAM OF THE + // PACKAGE HAS ITS OWN (mcpp#1007): under `--all-programs` the others were + // staged as files beside the chosen one, launcher alone, and `cmd.exe.js` + // travelled without `cmd.exe.wasm`. + std::vector launchers{ plan.binaryName }; + for (auto const& other : plan.opts.otherPrograms) launchers.push_back(other); + for (auto const& launcher : launchers) { + auto family = mcpp::pack::emscripten_stem_family(builtDir, launcher); + for (auto const& name : family.siblings) { + std::error_code fec; + std::filesystem::copy_file(builtDir / name, + plan.stagingRoot / "bin" / name, + std::filesystem::copy_options::overwrite_existing, fec); + if (fec) return std::unexpected(Error{std::format( + "failed to copy {} -> {}: {}", (builtDir / name).string(), + (plan.stagingRoot / "bin" / name).string(), fec.message())}); + } } if (auto r = stage_runtime_files(plan, stagedJs.parent_path()); !r) return r; @@ -3285,7 +3295,14 @@ run(const Plan& plan, const mcpp::config::GlobalConfig& cfg) " This target links it dynamically whatever the linkage asked; pack it with " "a mode that states its closure (--mode vendored).", plan.binaryName, !f->interp.empty() ? "a loader" : "shared libraries")}); - if (plan.opts.mode != Mode::Static) { + // A STATIC PROGRAM OF A FORMAT WITH NO DYNAMIC LINKER HAS NO CLOSURE + // (mcpp#1007): a DJGPP program, COFF under a go32 stub, is linked whole + // by the row's statement (`linkage = "static"`), and there is no loader + // to ask. The default mode packs it as it packs a static ELF, whose + // closure the file says is empty; a format mcpp reads is still asked. + const bool closureByBuild = plan.programStatic + && mcpp::pack::binfmt::identify(plan.builtBinary).format == mcpp::pack::binfmt::Format::Unknown; + if (plan.opts.mode != Mode::Static && !closureByBuild) { // THE BUILT BINARY, NOT THE STAGED COPY, and the difference is // `$ORIGIN`. // diff --git a/src/pack/pipeline.cppm b/src/pack/pipeline.cppm index 55f05e82d..91c9355be 100644 --- a/src/pack/pipeline.cppm +++ b/src/pack/pipeline.cppm @@ -806,6 +806,7 @@ std::optional member_plan(PackRun& run, GroupJob& g, MemberJob& m) { if (!plan) return Refusal{1, about(run, m, plan.error().message)}; plan->platform = ctx.plan.platform; plan->loadedLegs = std::move(loadedLegs); + plan->programStatic = ctx.plan.manifest.buildConfig.linkage == "static"; plan->linkageName = opts.linkage == mcpp::pack::Linkage::Static ? "static" : opts.linkage == mcpp::pack::Linkage::Shared ? "shared" : opts.mode == mcpp::pack::Mode::Static ? "static" diff --git a/src/runtime/elf.cppm b/src/runtime/elf.cppm index 143dacbcd..3125a88be 100644 --- a/src/runtime/elf.cppm +++ b/src/runtime/elf.cppm @@ -61,6 +61,13 @@ struct ElfRuntimeFacts { // arrival in a closure walk: what the loader adds to its own search when // it carries no DT_RUNPATH. Empty for the walk's artifact. std::vector inheritedRpaths; + // The directory `$ORIGIN` names in this object's search paths: that of the + // path the loader opened it by, which glibc does not resolve through a + // link. Empty for the walk's artifact, whose own directory it is. Measured + // with a farm of links (compat.curand): `libcurand.so.10`, reached as a + // link in the farm, found its `libgcc_s.so.1` in the farm by `$ORIGIN`, + // while a model that expanded `$ORIGIN` at the link's target refused it. + std::filesystem::path origin; // "Is this an executable" is PT_INTERP, not ET_EXEC: a PIE executable is // ET_DYN and therefore indistinguishable from a shared library by type @@ -493,9 +500,9 @@ std::string canonical_text(const std::filesystem::path& path) { return comparable_path(path).generic_string(); } -std::string expand_origin(std::string value, - const std::filesystem::path& object) { - const auto origin = object.parent_path().generic_string(); +std::string expand_origin(std::string value, const ElfRuntimeFacts& object) { + const auto origin = (object.origin.empty() ? object.artifact.parent_path() : object.origin) + .generic_string(); for (auto token : {std::string_view("${ORIGIN}"), std::string_view("$ORIGIN")}) { for (auto pos = value.find(token); pos != std::string::npos; pos = value.find(token, pos + origin.size())) @@ -544,7 +551,7 @@ std::vector search_dirs_of( std::span inheritedRpaths) { std::vector dirs; for (auto const& raw : requester.runpaths) - append_unique_path(dirs, expand_origin(raw, requester.artifact)); + append_unique_path(dirs, expand_origin(raw, requester)); // DT_RPATH IS INHERITED DOWN THE DEPENDENCY CHAIN; DT_RUNPATH IS NOT. // // The loader searches the DT_RPATH of every object on the chain that @@ -564,7 +571,7 @@ std::vector search_dirs_of( if (requester.searchPathTag != SearchPathTag::Runpath && requester.searchPathTag != SearchPathTag::Both) for (auto const& raw : inheritedRpaths) - append_unique_path(dirs, expand_origin(raw, requester.artifact)); + append_unique_path(dirs, expand_origin(raw, requester)); const bool honoursRpath = requester.searchPathTag != SearchPathTag::Runpath && requester.searchPathTag != SearchPathTag::Both; if (honoursRpath) @@ -607,7 +614,7 @@ std::optional resolve_needed( auto candidate = named.is_absolute() ? named : requester.artifact.parent_path() / named; if (std::filesystem::is_regular_file(candidate, ec)) - return comparable_path(candidate); + return candidate.lexically_normal(); return std::nullopt; } @@ -616,7 +623,7 @@ std::optional resolve_needed( auto candidate = dir / named; ec.clear(); if (std::filesystem::is_regular_file(candidate, ec)) - return comparable_path(candidate); + return candidate.lexically_normal(); } return std::nullopt; } @@ -1313,19 +1320,24 @@ RuntimeResolution resolve_runtime_closure( if (std::ranges::find(childRpaths, raw) == childRpaths.end()) childRpaths.push_back(raw); for (auto const& soname : requester.needed) { + // The object is identified by the file it is (`path`), and + // searches from the directory it was opened in (`opened`). std::optional path; + std::filesystem::path opened; if (auto loaded = loadedBySoname.find(soname); loaded != loadedBySoname.end()) { path = loaded->second; } else { - path = detail::resolve_needed( + auto found = detail::resolve_needed( soname, requester, binding, additionalSearchDirs, pending.inheritedRpaths); - if (!path) { + if (!found) { resolution.unresolved.push_back(soname); resolution.unresolvedSonames.push_back(soname); continue; } + opened = *found; + path = detail::comparable_path(*found); loadedBySoname.emplace(soname, *path); } if (soname == "libc.so.6") { @@ -1356,6 +1368,7 @@ RuntimeResolution resolve_runtime_closure( loadedBySoname.emplace(parsed->soname, *path); } parsed->inheritedRpaths = childRpaths; + if (!opened.empty()) parsed->origin = opened.parent_path(); queue.push_back({*parsed, childRpaths}); resolution.objects.push_back(std::move(*parsed)); } diff --git a/tests/e2e/300_a_registered_family_is_not_reported_unknown.sh b/tests/e2e/300_a_registered_family_is_not_reported_unknown.sh index 2e207b190..df1bbc02d 100755 --- a/tests/e2e/300_a_registered_family_is_not_reported_unknown.sh +++ b/tests/e2e/300_a_registered_family_is_not_reported_unknown.sh @@ -30,40 +30,50 @@ printf 'extern "C" int main(int, char**, char**) { return 0; }\n' > src/main.cpp json_for() { "$MCPP" why toolchain --target "$1" --format json 2>/dev/null; } -# ── Half one: a registered-but-planned family ──────────────────────────── +# ── Half one: registered families ───────────────────────────────────────── +# `riscv64-linux`, whose one row is riscv64-linux-musl (preview since the row +# was measured), resolves to that row; whatever the answer is, it is not +# `unknown-target` and it quotes no triple the reader never typed. j="$(json_for riscv64-linux)" reason="$(printf '%s' "$j" | jq -r '.data.reason // "-"' | tr -d '\r')" -msg="$(printf '%s' "$j" | jq -r '.diagnostics[].message' | tr -d '\r')" +msg="$(printf '%s' "$j" | jq -r '.diagnostics[]?.message' | tr -d '\r')" -if [ "$reason" != tier-planned ]; then - echo "FAIL: riscv64-linux refused as '$reason', expected tier-planned" - printf '%s\n' "$msg" | sed 's/^/ /' - exit 1 -fi -echo " ok a registered family refuses as planned, not as unknown" - -# AND THE MESSAGE NAMES A ROW THAT EXISTS. Telling someone their target is -# planned is only actionable once they can see which spelling is the registered -# one — the same rule that made `x86_64-linux` have to work before the -# name/fact warning was worth printing. -if printf '%s\n' "$msg" | grep -q 'riscv64-linux-musl'; then - echo " ok and it names the row that exists" -else - echo "FAIL: the refusal does not name riscv64-linux-musl" +if [ "$reason" = unknown-target ] || [ "$reason" = tier-planned ]; then + echo "FAIL: riscv64-linux refused as '$reason'" printf '%s\n' "$msg" | sed 's/^/ /' exit 1 fi +echo " ok a registered family is not refused as unknown" # AND IT DOES NOT QUOTE A TRIPLE THE READER NEVER TYPED. The old message was # about `riscv64-linux-gnu`, a string that appears nowhere in the command and # nowhere in the vocabulary. if printf '%s\n' "$msg" | grep -q 'riscv64-linux-gnu'; then - echo "FAIL: the refusal quotes 'riscv64-linux-gnu', which the reader never wrote" + echo "FAIL: the answer quotes 'riscv64-linux-gnu', which the reader never wrote" printf '%s\n' "$msg" | sed 's/^/ /' exit 1 fi echo " ok and it does not quote a triple nobody wrote" +# A family whose rows are planned (`i686-linux`) refuses as planned, and the +# message names the row the request resolves to: telling someone their target +# is planned is only actionable once they can see which spelling is registered. +jp="$(json_for i686-linux)" +reasonp="$(printf '%s' "$jp" | jq -r '.data.reason // "-"' | tr -d '\r')" +msgp="$(printf '%s' "$jp" | jq -r '.diagnostics[]?.message' | tr -d '\r')" +if [ "$reasonp" != tier-planned ]; then + echo "FAIL: i686-linux refused as '$reasonp', expected tier-planned" + printf '%s\n' "$msgp" | sed 's/^/ /' + exit 1 +fi +if printf '%s\n' "$msgp" | grep -q 'i686-linux-gnu'; then + echo " ok a planned family refuses as planned and names its row" +else + echo "FAIL: the refusal does not name i686-linux-gnu" + printf '%s\n' "$msgp" | sed 's/^/ /' + exit 1 +fi + # ── Half two: a genuine typo is still unknown, and now carries its code ── j2="$(json_for x86_64-linux-mus)" reason2="$(printf '%s' "$j2" | jq -r '.data.reason // "-"' | tr -d '\r')" diff --git a/tests/e2e/pack/modes.cpp b/tests/e2e/pack/modes.cpp index 4824be036..da0bb734d 100644 --- a/tests/e2e/pack/modes.cpp +++ b/tests/e2e/pack/modes.cpp @@ -1,7 +1,8 @@ // Programs packed: the three modes and their closures, build-machine paths, host // capabilities a self-contained bundle refuses, runtime files, `kind = "app"`, files staged // before the closure, the closure an ELF host pack states, several programs and a dotted -// name, an artifact for another system (formerly tests/e2e/30, 215, 216, 649, 652, 662, 669, +// name, an artifact for another system, a static platform's programs in a format the pack does +// not read (formerly tests/e2e/30, 215, 216, 649, 652, 662, 669, // 1043, 1061). import std; import mcpplibs.mtest; @@ -725,6 +726,76 @@ void _start(void) { (void)away_value(); for (;;) {} } const auto h = s::read_header(tmp / static_exe); expect(h.needed.empty() && !h.elf_interpreter) << "--mode static packed a dynamic program"; }; + "1156 a static platform's programs pack in a format the pack does not read"_test[s::elf] = [] { + // mcpp#1007: a row a platform package defines, whose provider states `linkage = "static"`, + // links its programs statically, and the pack ships every program of a format it does not + // read (a raw image here, as DJGPP's COFF) without a runtime closure. With the provider's + // linkage unstated the same program is dynamic, and the pack refuses and names the format. + const auto tmp = s::case_dir(); + const auto LLVM_VERSION = s::llvm_version(); + const auto platform = [&](std::string_view linkage) { + return std::format(R"cpp([package] +name = "raw-platform" +version = "0.1.0" + +[platform] +toolchain = "llvm@{0}" + +[[platform.define]] +triple = "x86_64-rawos" +clang-triple = "x86_64-unknown-linux-gnu" +object-format = "elf" +family = "unix" +execution = "rawos" + +[[platform.provider]] +serves = ["x86_64-rawos"] +{1} +[platform.build] +cflags = ["-ffreestanding", "-fno-stack-protector"] +ldflags = ["-nostdlib", "-fuse-ld=lld", "-Wl,--oformat=binary"] + +[platform.link] +driver = "compiler" + +[platform.layers] +"kernel-abi" = false +"c-abi" = false +"c++-abi" = false +"compiler-runtime" = false +)cpp", LLVM_VERSION, linkage); + }; + s::project plat{tmp / "plat", {{"mcpp.toml", platform("linkage = \"static\"\n")}}}; + s::project app{tmp / "app", {{"mcpp.toml", R"cpp([package] +name = "raw" +version = "0.1.0" + +[targets.one] +kind = "bin" +main = "src/main.c" + +[targets.two] +kind = "bin" +main = "src/main.c" + +[target.x86_64-rawos] +platform = { path = "../plat" } +)cpp"}, {"src/main.c", "void _start(void) { for (;;) {} }\n"}}}; + auto r = app.mcpp({"pack", "--target", "x86_64-rawos", "--all-programs"}); + expect(fatal(e2e::succeeded(r))) << "the static platform's programs did not pack\n" << s::text(r); + const auto listing = s::tar_list(app.at("target/dist/raw-0.1.0-x86_64-rawos.tar.gz")); + auto listed = [&](std::string_view tail) { return std::ranges::any_of(listing, [&](const std::string& l) { return l.ends_with(tail); }); }; + expect(fatal(listed("/bin/one") && listed("/bin/two"))) << "--all-programs did not ship both programs"; + std::optional exe; + for (const auto& f : s::find_files(app.at("target/x86_64-rawos"), "one")) + if (!exe && f.generic_string().ends_with("/bin/one")) exe = f; + expect(fatal(exe && s::read_file(*exe).substr(0, 4) != "\x7f" "ELF")) << "the program is ELF, so this test tests nothing"; + plat.write("mcpp.toml", platform("")); + app.remove("target"); + r = app.mcpp({"pack", "--target", "x86_64-rawos", "--all-programs"}); + expect(fatal(!r)) << "a dynamic program of an unread format was packed without its closure\n" << s::text(r); + expect(fatal(e2e::contains(s::text(r), "neither ELF, PE nor Mach-O"))) << "the refusal does not name the format\n" << s::text(r); + }; }}; } // namespace diff --git a/tests/e2e/targets/requests.cpp b/tests/e2e/targets/requests.cpp index d3dc9a2da..6148dc1e5 100644 --- a/tests/e2e/targets/requests.cpp +++ b/tests/e2e/targets/requests.cpp @@ -277,19 +277,24 @@ E2E requests{"requests", s::home_fixture, [] { }; "300 a registered family is not reported unknown"_test[s::unix_shell][s::jq] = [] { - // A family the vocabulary registers (riscv64-linux, whose row riscv64-linux-musl is - // planned) is refused as planned, naming the row that exists and no triple nobody wrote; a - // typo is still unknown and keeps its suggestion. The rule is decided in the build's - // preparation (its tier gate), which exports no function that answers it. + // A family the vocabulary registers is never unknown: `riscv64-linux`, whose one row is + // riscv64-linux-musl, resolves to it and quotes no triple nobody wrote; `i686-linux`, whose + // rows are planned, is refused as planned, naming the row it resolves to. A typo is still + // unknown and keeps its suggestion. The rule is decided in the build's preparation (its + // tier gate), which exports no function that answers it. s::project p({{"mcpp.toml", "[package]\nname = \"unkprobe\"\nversion = \"0.1.0\"\n"}, {"src/main.cpp", "extern \"C\" int main(int, char**, char**) { return 0; }\n"}}); auto json_for = [&](std::string_view t) { return s::json(p.mcpp({"why", "toolchain", "--target", std::string(t), "--format", "json"}).out); }; const auto j = json_for("riscv64-linux"); const auto reason = jstr(j, {"data", "reason"}, "-"); const auto msg = messages(j); - expect(fatal(reason == "tier-planned")) << "FAIL: riscv64-linux refused as '" << reason << "', expected tier-planned\n" << msg; - expect(fatal(e2e::contains(msg, "riscv64-linux-musl"))) << "FAIL: the refusal does not name riscv64-linux-musl\n" << msg; - expect(fatal(s::lacks(msg, "riscv64-linux-gnu"))) << "FAIL: the refusal quotes 'riscv64-linux-gnu', which the reader never wrote"; + expect(fatal(reason != "unknown-target" && reason != "tier-planned")) << "FAIL: riscv64-linux refused as '" << reason << "'\n" << msg; + expect(fatal(s::lacks(msg, "riscv64-linux-gnu"))) << "FAIL: the answer quotes 'riscv64-linux-gnu', which the reader never wrote\n" << msg; + const auto jp = json_for("i686-linux"); + const auto reasonp = jstr(jp, {"data", "reason"}, "-"); + const auto msgp = messages(jp); + expect(fatal(reasonp == "tier-planned")) << "FAIL: i686-linux refused as '" << reasonp << "', expected tier-planned\n" << msgp; + expect(fatal(e2e::contains(msgp, "i686-linux-gnu"))) << "FAIL: the refusal does not name the row i686-linux resolves to\n" << msgp; const auto j2 = json_for("x86_64-linux-mus"); const auto reason2 = jstr(j2, {"data", "reason"}, "-"); const auto msg2 = messages(j2); diff --git a/tests/e2e/targets/rows.cpp b/tests/e2e/targets/rows.cpp index c40953d4f..cd4cda2e7 100644 --- a/tests/e2e/targets/rows.cpp +++ b/tests/e2e/targets/rows.cpp @@ -125,10 +125,10 @@ int main() { return 0; } expect(fatal(e2e::contains(s::text(r), "did you mean 'x86_64-linux-musl'"))) << "FAIL: missing did-you-mean suggestion: " << s::text(r); // 2. A planned row is refused, not built for the host; a toolchain named for the build // opts it in (2026.11.13.1), whatever the toolchain then makes of the row. - r = p.mcpp({"build", "--target", "riscv64-linux-musl"}); + r = p.mcpp({"build", "--target", "i686-linux-gnu"}); expect(fatal(!r)) << "FAIL: planned-tier target built: " << s::text(r); expect(fatal(e2e::contains(s::text(r), "not yet supported"))) << "FAIL: missing planned-tier error: " << s::text(r); - r = p.mcpp({"build", "--target", "riscv64-linux-musl", "--toolchain", "gcc@16.1.0"}); + r = p.mcpp({"build", "--target", "i686-linux-gnu", "--toolchain", "gcc@16.1.0"}); expect(fatal(s::lacks(s::text(r), "not yet supported"))) << "FAIL: --toolchain did not opt a planned row in"; // 3. A custom triple with an explicit [target.X] section proceeds. p.write("mcpp.toml", original + "\n[target.myboard-custom-elf]\ntoolchain = \"gcc@16.1.0\"\n"); diff --git a/tests/e2e/web/emscripten.cpp b/tests/e2e/web/emscripten.cpp index 63014a538..41978016c 100644 --- a/tests/e2e/web/emscripten.cpp +++ b/tests/e2e/web/emscripten.cpp @@ -1,7 +1,7 @@ // The Web row (wasm32-emscripten): the executable named `.js` beside its `.wasm`, staged and // run, and `kind = "shared"` refused; a build program compiled by the host's compiler, also from a // fresh home; the profile's level at the link and the wasm exception model; the longjmp model; a -// module with no program start (formerly tests/e2e/650, 657, 981, 1079; 981b is mcpp#981). Each case needs an emsdk payload and skips without one. +// module with no program start; every program of a package packed with its module (formerly tests/e2e/650, 657, 981, 1079; 981b is mcpp#981, 1155 mcpp#1007). Each case needs an emsdk payload and skips without one. import std; import mcpplibs.mtest; import mcpp.test.support; @@ -248,6 +248,19 @@ E2E emscripten{"emscripten", s::home_fixture, [] { expect(fatal(!s::find_file(app.at("target/dist"), "app.wasm").has_value())) << "a module was packed"; }; + "1155 every program of a web package packs with its module"_test[s::elf] = [] { + // mcpp#1007: `--all-programs` on the web row ships each program's launcher with the module + // its link wrote, not the module of the program named after the package alone. + if (!have_emsdk()) skip("1155 -- no emsdk payload installed (looked under xim-x-emsdk/*/emscripten)"); + s::project app(s::case_dir() / "app", {{"mcpp.toml", "[package]\nname = \"app\"\nversion = \"0.1.0\"\n\n[targets.app]\nkind = \"bin\"\nmain = \"src/main.cpp\"\n\n[targets.other]\nkind = \"bin\"\nmain = \"src/main.cpp\"\n"}, + {"src/main.cpp", "import std;\nint main() { std::println(\"ok\"); return 0; }\n"}}); + auto r = app.mcpp({"pack", "--target", "wasm32-emscripten", "--all-programs", "--pkg-format", "dir"}); + expect(fatal(e2e::succeeded(r))) << "the web package's programs did not pack: " << s::text(r); + const auto staged = app.at("target/dist/app-0.1.0-wasm32-emscripten"); + for (const auto* f : {"bin/app.js", "bin/app.wasm", "bin/other.js", "bin/other.wasm"}) + expect(fatal(fs::is_regular_file(staged / f))) << "the staged tree has no " << f; + }; + "981b a web module with no program start links without main"_test[s::elf] = [] { // mcpp#981: a program whose page calls its exported functions states `main = false` on the // Web row. 1 the link takes the row's `link-without-main` (`--no-entry`) and writes the diff --git a/tests/unit/test_elf_runtime.cpp b/tests/unit/test_elf_runtime.cpp index 8d9e291f7..20a2e8ecc 100644 --- a/tests/unit/test_elf_runtime.cpp +++ b/tests/unit/test_elf_runtime.cpp @@ -412,6 +412,37 @@ UTest a_dependency_with_its_own_runpath_does_not_inherit_one{"ElfRuntime/ADepend expect(eq(resolution.unresolvedSonames.front(), "libdeep.so")); }}; +// A LIBRARY REACHED THROUGH A LINK SEARCHES FROM THE LINK'S DIRECTORY. A farm +// of links (compat.curand) holds `libvendor.so.10` -> the payload's file, whose +// DT_RUNPATH is `$ORIGIN`, beside `libdep.so.1`; the payload's own directory +// holds no `libdep.so.1`. glibc expands `$ORIGIN` at the directory it opened the +// link in and finds `libdep.so.1` in the farm (measured with LD_DEBUG=libs). +UTest origin_is_the_directory_a_link_was_opened_in{"ElfRuntime/OriginIsTheDirectoryALinkWasOpenedIn", [] { + if constexpr (!mcpplibs::os::is_linux) + skip("ELF/glibc runtime physics only apply on Linux"); + Tmp t; + auto payload = t.path / "store"; + auto glibc = payload / "2.44" / "lib64"; + auto vendor = t.path / "vendor" / "lib"; + auto farm = t.path / "farm" / "lib"; + auto runtime = t.path / "runtime" / "lib64"; + for (auto const& d : {glibc, vendor, farm, runtime}) std::filesystem::create_directories(d); + + write_elf_fixture(glibc / "libc.so.6", { .needed = {}, .runpath = glibc.string() }); + write_elf_fixture(runtime / "libdep.so.1", { .needed = {}, .noSearchPath = true }); + write_elf_fixture(vendor / "libvendor.so.10.3", { .needed = {"libdep.so.1"}, .runpath = "$ORIGIN" }); + std::filesystem::create_symlink(vendor / "libvendor.so.10.3", farm / "libvendor.so.10"); + std::filesystem::create_symlink(runtime / "libdep.so.1", farm / "libdep.so.1"); + auto app = write_elf_fixture(t.path / "app", { + .needed = {"libvendor.so.10", "libc.so.6"}, + .runpath = farm.string() + ":" + glibc.string(), + .rpathOnly = true, + }); + + auto resolution = elf::resolve_runtime_closure(app, binding_for(payload)); + expect(resolution.unresolvedSonames.empty()) << "libdep.so.1 was searched for beside the link's target"; +}}; + UTest rule_b_rejects_interpreter_and_libc_from_different_payloads{"RuntimePhysics/RuleBRejectsInterpreterAndLibcFromDifferentPayloads", [] { if constexpr (!mcpplibs::os::is_linux) skip("ELF/glibc runtime physics only apply on Linux"); diff --git a/tests/unit/test_platform.cpp b/tests/unit/test_platform.cpp index a1d780c13..2495ed577 100644 --- a/tests/unit/test_platform.cpp +++ b/tests/unit/test_platform.cpp @@ -766,6 +766,12 @@ UTest a_repository_reference_has_a_string_form{"PlatformManifest/ARepositoryRefe expect(deflt->spec.gitRev.empty()); expect(!mp::parse_ref_text("git+https://example.org/x.git#sha=1").has_value()); expect(!mp::parse_ref_text("git+").has_value()); + // The directory form a provider of a path platform names its package by. + auto dir = mp::parse_ref_text("path:/srv/raw-platform"); + expect(fatal(dir.has_value())); + expect(eq(dir->spec.path, "/srv/raw-platform")); + expect(dir->payload.empty()); + expect(!mp::parse_ref_text("path:").has_value()); }}; // A PLATFORM'S STATEMENT IS CHECKED AGAINST THE ROWS AS IT IS READ (SPEC-016 §5): From ec6f8bfa7537fd02cdc5f16132eefa1b800f7a24 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 06:23:59 +0900 Subject: [PATCH 07/33] fix: the provider's collection is asked of an xlings that keeps roots (store_roots, 2026.11.23.1); roots and the kernel probe narrow no path - kXlingsVersion is 2026.11.23.1 and the handshake requires `store_roots` (protocol 1.19): an earlier xlings collects without reading the roots builds register, so it is refused at the handshake rather than asked by `mcpp cache gc`. - mcpp.provider.roots keeps store names and versions as paths and writes them as UTF-8; the kernel-header probe renders its paths with the engine's one spelling (no_escape). - `kernel-abi.packed` is read by a function of its own (loops nest at most two levels); an action's origin is looked up among its inputs with ranges::any_of. --- CHANGELOG.md | 4 ++ modules/buildmcpp/src/directives.cppm | 7 ++- modules/manifest/src/platform_toml.cppm | 36 +++++++----- src/build/prepare/base.cpp | 6 +- src/provider/roots.cppm | 78 +++++++++++++++++-------- src/provider/xlings/xlings.cpp | 2 +- src/provider/xlings/xlings.cppm | 9 ++- tests/e2e/build-program/deps.cpp | 2 +- tests/e2e/cdb/emit.cpp | 2 +- tests/e2e/index/local.cpp | 2 +- tests/e2e/index/refresh.cpp | 2 +- 11 files changed, 100 insertions(+), 50 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a9825d08..38f9ef00e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,10 @@ ### Changed +- xlings 2026.11.23.1 is the pinned provider, and the handshake requires its `store_roots` + feature (protocol 1.19): its collection keeps what a root holds, and its configuration of a + package that states `host_facts` runs again when those host files change (openxlings/xlings#712, + #727). An earlier provider is refused at the handshake, as before for one below the floor. - `mcpp cache gc` collects the package store after the cache: the provider removes the payloads nothing references (`xlings self clean`), and with `--older-than` the roots no build used for that long are released first. Before, payloads were never collected, and `xlings self clean` diff --git a/modules/buildmcpp/src/directives.cppm b/modules/buildmcpp/src/directives.cppm index 90bf1b2bf..b37969fb3 100644 --- a/modules/buildmcpp/src/directives.cppm +++ b/modules/buildmcpp/src/directives.cppm @@ -1672,9 +1672,10 @@ std::string action_error(const Directives& d) { if (auto it = j.find("origin"); it != j.end() && it->is_string()) { const auto origin = it->get(); const bool source = j.value("role", std::string("source")) == "source"; - bool input = false; - if (auto in = j.find("inputs"); in != j.end() && in->is_array()) - for (auto const& v : *in) input = input || (v.is_string() && v.get() == origin); + const auto in = j.find("inputs"); + const bool input = in != j.end() && in->is_array() && std::ranges::any_of(*in, [&](auto const& v) { + return v.is_string() && v.template get() == origin; + }); if (!source || !input) return std::format( "build.mcpp declared an action whose origin \"{}\" {}.\n" diff --git a/modules/manifest/src/platform_toml.cppm b/modules/manifest/src/platform_toml.cppm index d24a49b13..32770f0a2 100644 --- a/modules/manifest/src/platform_toml.cppm +++ b/modules/manifest/src/platform_toml.cppm @@ -534,6 +534,26 @@ Reader::tools(const toml::Value& v, std::string_view where, return {}; } +// `kernel-abi.packed = { macro, bits }`: the macro that packs the version and +// the widths of its fields, stated together. +std::expected read_packed(const mcpp::libs::toml::Value& v, const std::string& key, + SystemSpec::KernelAbi& k) { + if (!v.is_table()) return std::unexpected(std::format("{} must be {{ macro, bits }}", key)); + for (auto const& [pk, pv] : v.as_table()) { + if (pk == "macro" && pv.is_string()) { k.packed = pv.as_string(); continue; } + if (pk != "bits" || !pv.is_array()) + return std::unexpected(std::format("{}: {{ macro = \"\", bits = [, ...] }}", key)); + for (auto const& b : pv.as_array()) { + if (!b.is_int() || b.as_int() <= 0 || b.as_int() > 32) + return std::unexpected(std::format("{}.bits holds widths from 1 to 32", key)); + k.bits.push_back(static_cast(b.as_int())); + } + } + if (k.packed.empty() || k.bits.empty()) + return std::unexpected(std::format("{}: `macro` and `bits` are stated together", key)); + return {}; +} + std::expected Reader::system_kernel_abi(const toml::Value& v, std::string_view where) const { if (!v.is_table()) return std::unexpected(std::format("{} must be a table", where)); @@ -548,21 +568,7 @@ Reader::system_kernel_abi(const toml::Value& v, std::string_view where) const { if (!w) return std::unexpected(w.error()); k.version = std::move(*w); } else if (kk == "packed") { - if (!kv.is_table()) return std::unexpected(std::format("{} must be {{ macro, bits }}", key)); - for (auto const& [pk, pv] : kv.as_table()) { - if (pk == "macro" && pv.is_string()) { k.packed = pv.as_string(); continue; } - if (pk == "bits" && pv.is_array()) { - for (auto const& b : pv.as_array()) { - if (!b.is_int() || b.as_int() <= 0 || b.as_int() > 32) - return std::unexpected(std::format("{}.bits holds widths from 1 to 32", key)); - k.bits.push_back(static_cast(b.as_int())); - } - continue; - } - return std::unexpected(std::format("{}: {{ macro = \"\", bits = [, ...] }}", key)); - } - if (k.packed.empty() || k.bits.empty()) - return std::unexpected(std::format("{}: `macro` and `bits` are stated together", key)); + if (auto r = read_packed(kv, key, k); !r) return std::unexpected(r.error()); } else { if (!kv.is_string() || kv.as_string().empty()) return std::unexpected(std::format("{} must be a non-empty string", key)); diff --git a/src/build/prepare/base.cpp b/src/build/prepare/base.cpp index eae802bbb..f5b2350ce 100644 --- a/src/build/prepare/base.cpp +++ b/src/build/prepare/base.cpp @@ -782,9 +782,9 @@ std::optional measure_kernel_headers(const PrepareState& stat auto probeTc = tc; probeTc.base.kernel = {}; probeTc.base.kernel.dirs = dirs; - const mcpp::toolchain::PathEscape plain = [](const fs::path& p) { return p.string(); }; auto v = driver_base(tc); - for (auto const& t : mcpp::toolchain::resolve_link_model(probeTc).compile_tokens(plain)) v.push_back(t); + for (auto const& t : mcpp::toolchain::resolve_link_model(probeTc).compile_tokens(mcpp::toolchain::no_escape)) + v.push_back(t); // The unit is named by its content and kept in the temporary directory: // it is the same for every build, and a probe writes nothing into a // project's tree. @@ -797,7 +797,7 @@ std::optional measure_kernel_headers(const PrepareState& stat { std::ofstream os(partial); os << text; } fs::rename(partial, unit, ec); } - v.insert(v.end(), {"-E", "-dM", "-x", "c", unit.string()}); + v.insert(v.end(), {"-E", "-dM", "-x", "c", mcpp::toolchain::no_escape(unit)}); auto r = mcpp::run::capture_stdout(v); if (r.exit_code != 0) return std::nullopt; return tb::kernel_version(tb::parse_defines(r.output), k.version, k.packed, k.bits); diff --git a/src/provider/roots.cppm b/src/provider/roots.cppm index d91432f53..b5c6387c4 100644 --- a/src/provider/roots.cppm +++ b/src/provider/roots.cppm @@ -114,6 +114,39 @@ void report_once(std::string_view why) { std::int64_t seconds_of(std::uint64_t ns) { return static_cast(ns / 1'000'000'000ull); } +// A path as UTF-8 text, for a name shown or written to `roots.list`: never +// narrowed through the code page (a store name is one component the walk read). +std::string utf8_of(const fs::path& p) { + const auto u8 = p.generic_u8string(); + return std::string(reinterpret_cast(u8.data()), u8.size()); +} +fs::path path_of(std::string_view utf8) { + return fs::path(std::u8string(reinterpret_cast(utf8.data()), utf8.size())); +} + +// The payload `//` as its two components, or +// nothing when `payload` is not a directory two levels below the store. +std::optional> components_of(const fs::path& store, const fs::path& payload) { + const auto rel = payload.lexically_normal().lexically_relative(store.lexically_normal()); + if (std::distance(rel.begin(), rel.end()) != 2 || *rel.begin() == "..") return std::nullopt; + return std::pair{ *rel.begin(), *std::next(rel.begin()) }; +} + +// The root of one payload, `/@`, made at `at`: a link +// relative to the owner's directory, as the specification recommends, which +// survives a move of the home. +auto link_root(const fs::path& store, const fs::path& dir, const fs::path& storeName, const fs::path& version, + const fs::path& at) { + return mcpplibs::os::fs::create_link(store.lexically_relative(dir) / storeName / version, at, true); +} + +fs::path root_name(const fs::path& storeName, const fs::path& version) { + auto name = storeName; + name += "@"; + name += version; + return name; +} + } // namespace std::vector named_in(std::string_view text) { @@ -122,7 +155,11 @@ std::vector named_in(std::string_view text) { if (!s) return out; const auto plain = unescape_ninja(text); std::set seen; - for (const auto& prefix : {s->generic_string() + "/", s->string() + std::string(1, fs::path::preferred_separator)}) { + // The graph's text is UTF-8 (2026.11.19.1); the store is named in it with + // either separator. + const auto native = s->u8string(); + const std::string nativeText(reinterpret_cast(native.data()), native.size()); + for (const auto& prefix : {utf8_of(*s) + "/", nativeText + std::string(1, static_cast(fs::path::preferred_separator))}) { for (auto at = plain.find(prefix); at != std::string::npos; at = plain.find(prefix, at + prefix.size())) { auto p = payload_at(plain, at + prefix.size()); if (!p.empty() && seen.insert(p).second) out.push_back(std::move(p)); @@ -138,16 +175,15 @@ void use(const std::vector& payloads) { std::error_code ec; fs::create_directories(dir, ec); for (const auto& p : payloads) { - const auto slash = p.find('/'); - if (slash == std::string::npos || !fs::is_directory(*s / p, ec)) continue; - const auto name = p.substr(0, slash) + "@" + p.substr(slash + 1); - // Relative to the owner's directory, as the specification recommends: - // it survives a move of the home. Made under a temporary name and - // renamed over the root, so that the root is never absent and its own - // time is now. - const auto target = s->lexically_relative(dir) / p.substr(0, slash) / p.substr(slash + 1); - const auto staged = dir / std::format(".{}.{:08x}", name, std::random_device{}()); - if (auto made = mcpplibs::os::fs::create_link(target, staged, true); !made) { + const auto parts = components_of(*s, *s / path_of(p)); + if (!parts || !fs::is_directory(*s / path_of(p), ec)) continue; + const auto name = root_name(parts->first, parts->second); + // Made under a temporary name and renamed over the root, so that the + // root is never absent and its own time is now. + auto staged = dir / "."; + staged += name; + staged += std::format(".{:08x}", std::random_device{}()); + if (auto made = link_root(*s, dir, parts->first, parts->second, staged); !made) { report_once(made.error().message()); return; } @@ -163,11 +199,8 @@ void use_dirs(const std::vector& payloadDirs) { const auto s = store(); if (!s) return; std::vector payloads; - for (const auto& d : payloadDirs) { - const auto rel = d.lexically_normal().lexically_relative(s->lexically_normal()); - if (std::distance(rel.begin(), rel.end()) != 2 || rel.begin()->string() == "..") continue; - payloads.push_back(rel.begin()->string() + "/" + std::next(rel.begin())->string()); - } + for (const auto& d : payloadDirs) + if (auto parts = components_of(*s, d)) payloads.push_back(utf8_of(parts->first / parts->second)); use(payloads); } @@ -177,7 +210,7 @@ void hold(const fs::path& outputDir, std::optional graphText) if (graphText) { payloads = named_in(*graphText); std::string text; - for (const auto& p : payloads) text += p + "\n"; + for (const auto& p : payloads) text += p + "\n"; // UTF-8, as the graph's text std::error_code ec; fs::create_directories(outputDir, ec); std::ofstream(list, std::ios::binary | std::ios::trunc) << text; @@ -202,11 +235,10 @@ bool seed() { fs::create_directories(staged, ec); if (ec) { report_once(ec.message()); return false; } for (const auto& e : mcpp::provider::layout().entries(*s)) { - const auto rel = e.dir.lexically_relative(*s); - if (rel.empty() || rel.begin() == rel.end() || std::distance(rel.begin(), rel.end()) != 2) continue; - const auto storeName = rel.begin()->string(), version = std::next(rel.begin())->string(); - const auto target = s->lexically_relative(dir) / storeName / version; - if (auto made = mcpplibs::os::fs::create_link(target, staged / (storeName + "@" + version), true); !made) { + const auto parts = components_of(*s, e.dir); + if (!parts) continue; + if (auto made = link_root(*s, dir, parts->first, parts->second, + staged / root_name(parts->first, parts->second)); !made) { fs::remove_all(staged, ec); report_once(made.error().message()); return false; @@ -225,7 +257,7 @@ std::vector expire(std::int64_t olderThan, bool dryRun) { std::chrono::system_clock::now().time_since_epoch()).count(); std::error_code ec; for (auto it = fs::directory_iterator(dir, ec); !ec && it != fs::directory_iterator{}; it.increment(ec)) { - const auto name = it->path().filename().string(); + const auto name = utf8_of(it->path().filename()); // A root is a link (a junction on a Windows volume without symbolic // links); a file or a directory here is not one. if (name.starts_with(".") || !mcpplibs::os::fs::read_link(it->path())) continue; diff --git a/src/provider/xlings/xlings.cpp b/src/provider/xlings/xlings.cpp index 022335d68..22d267bc2 100644 --- a/src/provider/xlings/xlings.cpp +++ b/src/provider/xlings/xlings.cpp @@ -398,7 +398,7 @@ std::string unmet(const mcpp::provider::ProviderInfo& info) { return std::format("is {}, older than {}", info.version, pinned::kXlingsVersion); for (auto feature : {"index_dir", "index_store", "upstreams", "payload_status", "sync_index", "payload_currency", "binding_state", "network_diagnostics", - "download_socket_budgets", "read_only_queries"}) + "download_socket_budgets", "read_only_queries", "store_roots"}) if (std::ranges::find(info.features, feature) == info.features.end()) return std::format("does not offer `{}`", feature); if (std::ranges::find(info.capabilities, "install_packages") == info.capabilities.end()) diff --git a/src/provider/xlings/xlings.cppm b/src/provider/xlings/xlings.cppm index f4830f574..bf023fe3f 100644 --- a/src/provider/xlings/xlings.cppm +++ b/src/provider/xlings/xlings.cppm @@ -204,7 +204,14 @@ namespace pinned { // --with-index` writes a bundle and `xlings install --from ` installs // from one. `mcpp fetch` and `[build] offline` stand on these (design // 2026-11-21, offline and toolchain defaults §3.1, §3.2). - inline constexpr std::string_view kXlingsVersion = "2026.11.21.1"; + // + // Eighteenth, at 2026.11.23.1 (openxlings/xlings#712, protocol 1.19). The + // store's collection keeps what a root under `data/roots//` holds + // (feature `store_roots`): `mcpp cache gc` asks for a collection after the + // builds have registered their payloads as roots, and an earlier xlings + // reads none and removes them. Measured on one home before roots: `xlings + // self clean --dry-run` listed 154 payloads (16 GB) projects use. + inline constexpr std::string_view kXlingsVersion = "2026.11.23.1"; inline constexpr std::string_view kNasmVersion = "3.02"; } diff --git a/tests/e2e/build-program/deps.cpp b/tests/e2e/build-program/deps.cpp index 93dbd847d..065c04929 100644 --- a/tests/e2e/build-program/deps.cpp +++ b/tests/e2e/build-program/deps.cpp @@ -834,7 +834,7 @@ int main() { fs::create_directory_symlink(xpkgs, registry / "data/xpkgs"); s::write_executable(tmp / "fake-bin/xlings", R"sh(#!/usr/bin/env bash # The handshake mcpp asks of every xlings (docs/25 §5). -[[ "${1:-}" == "interface" && "${2:-}" == "--version" ]] && { echo '{"protocol_version":"1.13","version":"9999.1.1.1","capabilities":["install_packages"],"home_layouts":[2],"features":["index_dir","index_store","upstreams","payload_status","sync_index","payload_currency","binding_state","network_diagnostics","download_socket_budgets","read_only_queries"]}'; exit 0; } +[[ "${1:-}" == "interface" && "${2:-}" == "--version" ]] && { echo '{"protocol_version":"1.13","version":"9999.1.1.1","capabilities":["install_packages"],"home_layouts":[2],"features":["index_dir","index_store","upstreams","payload_status","sync_index","payload_currency","binding_state","network_diagnostics","download_socket_budgets","read_only_queries","store_roots"]}'; exit 0; } set -e if [[ "${1:-}" == "self" && "${2:-}" == "init" ]]; then mkdir -p "${XLINGS_HOME:?}/subos/default" diff --git a/tests/e2e/cdb/emit.cpp b/tests/e2e/cdb/emit.cpp index 433a6cc5e..5b9cc61f3 100644 --- a/tests/e2e/cdb/emit.cpp +++ b/tests/e2e/cdb/emit.cpp @@ -480,7 +480,7 @@ int main() { expect(fatal(e2e::succeeded(s::mcpp(install_default(), s::case_dir(), {.where = s::home::inherited})))) << "the case's home did not install its toolchain"; s::write_executable(out / "bin/xlings", R"(#!/usr/bin/env bash -[[ "${1:-}" == "interface" && "${2:-}" == "--version" ]] && { echo '{"protocol_version":"1.13","version":"9999.1.1.1","capabilities":["install_packages"],"home_layouts":[2],"features":["index_dir","index_store","upstreams","payload_status","sync_index","payload_currency","binding_state","network_diagnostics","download_socket_budgets","read_only_queries"]}'; exit 0; } +[[ "${1:-}" == "interface" && "${2:-}" == "--version" ]] && { echo '{"protocol_version":"1.13","version":"9999.1.1.1","capabilities":["install_packages"],"home_layouts":[2],"features":["index_dir","index_store","upstreams","payload_status","sync_index","payload_currency","binding_state","network_diagnostics","download_socket_budgets","read_only_queries","store_roots"]}'; exit 0; } echo "$*" >> "${STUB_LOG:?}" exit 0 )"); diff --git a/tests/e2e/index/local.cpp b/tests/e2e/index/local.cpp index 1bb42d092..3709eac18 100644 --- a/tests/e2e/index/local.cpp +++ b/tests/e2e/index/local.cpp @@ -47,7 +47,7 @@ default = "{}" )", binary.generic_string(), xlings_home.generic_string(), toolchain)}}); } -constexpr std::string_view handshake = R"HS([[ "${1:-}" == "interface" && "${2:-}" == "--version" ]] && { echo '{"protocol_version":"1.13","version":"9999.1.1.1","capabilities":["install_packages"],"home_layouts":[2],"features":["index_dir","index_store","upstreams","payload_status","sync_index","payload_currency","binding_state","network_diagnostics","download_socket_budgets","read_only_queries"]}'; exit 0; })HS"; +constexpr std::string_view handshake = R"HS([[ "${1:-}" == "interface" && "${2:-}" == "--version" ]] && { echo '{"protocol_version":"1.13","version":"9999.1.1.1","capabilities":["install_packages"],"home_layouts":[2],"features":["index_dir","index_store","upstreams","payload_status","sync_index","payload_currency","binding_state","network_diagnostics","download_socket_budgets","read_only_queries","store_roots"]}'; exit 0; })HS"; std::string lua_package(std::string_view name, std::string_view version, std::string_view description, std::string_view mcpp_segment) { return std::format(R"(package = {{ diff --git a/tests/e2e/index/refresh.cpp b/tests/e2e/index/refresh.cpp index 4c325d94b..7bacdf32b 100644 --- a/tests/e2e/index/refresh.cpp +++ b/tests/e2e/index/refresh.cpp @@ -27,7 +27,7 @@ std::string trimmed(std::string t) { return t; } -constexpr std::string_view handshake = R"HS([[ "${1:-}" == "interface" && "${2:-}" == "--version" ]] && { echo '{"protocol_version":"1.13","version":"9999.1.1.1","capabilities":["install_packages"],"home_layouts":[2],"features":["index_dir","index_store","upstreams","payload_status","sync_index","payload_currency","binding_state","network_diagnostics","download_socket_budgets","read_only_queries"]}'; exit 0; })HS"; +constexpr std::string_view handshake = R"HS([[ "${1:-}" == "interface" && "${2:-}" == "--version" ]] && { echo '{"protocol_version":"1.13","version":"9999.1.1.1","capabilities":["install_packages"],"home_layouts":[2],"features":["index_dir","index_store","upstreams","payload_status","sync_index","payload_currency","binding_state","network_diagnostics","download_socket_budgets","read_only_queries","store_roots"]}'; exit 0; })HS"; // A stub xlings that answers the handshake and records every other command in STUB_LOG. void stub_logging_xlings(const fs::path& file) { From ff99e86d7efce263dc99a04e2fa9614a2ec504aa Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 06:28:09 +0900 Subject: [PATCH 08/33] =?UTF-8?q?design=20record=20=C2=A710:=20the=20colle?= =?UTF-8?q?ction=20asked=20of=20a=20provider=20that=20reads=20roots;=20the?= =?UTF-8?q?=20path-dependency=20CRC=20measurement=20(mcpp#1008)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...-kernel-interface-and-derived-state-ecosystem-design.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md index 7e498ec99..1b22a256e 100644 --- a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md +++ b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md @@ -679,3 +679,10 @@ graph LR (`LD_DEBUG=libs` 测得 `libgcc_s.so.1` 取自链接农场),闭包模型却先把找到的路径解析为链接的目标,再在目标的目录展开。 模型改为:对象以其文件为身份,以打开它的目录为 `$ORIGIN`。农场中的 `libgcc_s.so.1` 仍然需要:LLVM 构建的程序不装载它, 而 `libcurand.so.10` 的 DT_RUNPATH 只有 `$ORIGIN`。 +13. **收集只交给读根的提供者(§3.11,M7)。** 早于 2026.11.23.1 的 xlings 收集时不读根,会删除构建登记为根的载荷。 + xlings 2026.11.23.1 的握手陈述特性 `store_roots`(协议 1.19),mcpp 的握手要求它,并以 2026.11.23.1 为提供者的下限; + 更早的提供者在握手处被拒绝,而不是由 `mcpp cache gc` 去请求一次不读根的收集。 +14. **路径依赖替代版本依赖时的 std CRC 不符(测定,未在本轮修复)。** 以 `{ path }` 指名 mcpplibs.os 构建 mcpp 自身时, + 两个单元以不同的 `std` BMI 编译(`import 'std' has CRC mismatch`);精确的 BMI 截止、关闭构建缓存、删除该 BMI 都不改变 + 结果,以版本依赖与本地 `[indices]` 路径则构建成功。它不属于本方案的任何条款,记为 mcpp#1008。 + From 9e555f76dacc51e40c5a749d8a39d48f80297ee3 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 08:07:45 +0900 Subject: [PATCH 09/33] fix: a bare-metal row a platform defines is compiled and verified for its clang-triple, with or without a machine description; runner = true is a known key - mcpp::freestanding::Spec carries `target`, the row's clang-triple else the row, which every `--target=` of a bare-metal compile, link and the c-abi verification probe uses. A defined bare-metal row with no `march` and no `link-emulation` resolves to a Spec with its target alone; before it resolved to none, and the probe refused riscv64-none-musl. - The unknown-key sweep of a [target.] table asks the key's name, not the value's type: `runner = true` was reported as unsupported. - The handshake unit test names `store_roots`. --- CHANGELOG.md | 6 ++++++ docs/specs/targets-and-providers.md | 4 ++-- modules/manifest/src/toml.cppm | 11 +++++++---- src/build/prepare/target_side.cpp | 2 +- src/freestanding/linkline.cppm | 4 ++-- src/freestanding/target.cppm | 22 +++++++++++++++++++--- tests/unit/test_manifest.cpp | 17 +++++++++++++++++ tests/unit/test_network.cpp | 4 +++- 8 files changed, 57 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38f9ef00e..c9112f7d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -79,6 +79,12 @@ - The provider of a platform named by a path (`platform = { path = "" }`) is selected. Its package reference `path:` was read as a payload without a version, so the selection left it out, and what only the provider states, such as its `linkage`, did not apply (mcpp#1007). +- A bare-metal row a platform defines is compiled, and its C library verified, for its + `clang-triple` (else the row), also when the row states no `march` or `link-emulation`. Before, + such a row (openkal-musl's `riscv64-none-musl`) had no target selection, and the verification + probe refused it. +- `[target.] runner = true` and `runner = false` are read without the warning + "unsupported key 'runner'": the key check asked the value's type, and a boolean is not an array. - The runtime-closure check expands `$ORIGIN` at the directory a library was opened in, as the loader does, not at the target of the link it was reached through. A program whose libraries are links in a farm, each finding its dependencies beside it (compat.curand under LLVM), was refused diff --git a/docs/specs/targets-and-providers.md b/docs/specs/targets-and-providers.md index 5efd86650..ef5c830f1 100644 --- a/docs/specs/targets-and-providers.md +++ b/docs/specs/targets-and-providers.md @@ -45,7 +45,7 @@ - `exact = true` 的行只由写出其全部段的请求得到(Android 的行)。 - `march`、`mabi`、`code-model`、`flags`、`link-emulation` 是行的机器描述,引擎原样使用,**不可**被替换;机器不同的目标以 另一行表达(§5)。 -- `clang-triple` 是交给 clang 的目标拼写,未写时由段推出;它只改变编译器所见的三元组,不改变身份(v1.1)。 +- `clang-triple` 是交给 clang 的目标拼写,未写时由段推出;它只改变编译器所见的三元组,不改变身份(v1.1)。裸机行同样以它为每个编译单元与 C 环境验证探测的 `--target`;平台定义的裸机行未写 `march` 与 `link-emulation` 时,处理器取编译器的缺省,目标照样给出(v1.9)。 - `loader` 是该行的动态程序所写的程序解释器:运行它的机器上的路径(`/lib/ld-linux-aarch64.so.1`)。内置行与平台定义的行 同一读法;引擎不另持有按架构的加载器表(v1.2)。 - `execution` 是产物运行的系统,未写时为 os 段。内核相同而系统不同的行**必须**写出它(Android 的行为 `android`)(v1.2)。 @@ -279,4 +279,4 @@ | 1.6 | 2026-11-19 | mcpp 2026.11.19.1(mcpp#957):§6 执行可达性的谓词之前没有按系统的分支;Apple 的行由同一个谓词判定;系统名检查的词表含三元组的系统谓词 | | 1.7 | 2026-11-20 | mcpp 2026.11.20.1(mcpp#981):行的 `link-without-main`,没有程序起点的可执行映像的链接词;内置 `wasm32-emscripten` 行为 `--no-entry` | | 1.8 | 2026-11-22 | mcpp 2026.11.22.1(设计 2026-11-22 §4):`i686-windows-msvc` 为 preview 行;执行关系表中 `windows-x86_64` 执行 `i686`(§2.4)。 | -| 1.9 | 2026-11-23 | mcpp @RELEASE@(设计 2026-11-22 §3.4、§3.17):系统表的 `kernel-abi`(测量、载荷布局、包)与 `interfaces`;`MCPP_KERNEL_ABI_INTERFACES` 在系统供给该层时取系统表的 `interfaces` | +| 1.9 | 2026-11-23 | mcpp @RELEASE@(设计 2026-11-22 §3.4、§3.17):系统表的 `kernel-abi`(测量、载荷布局、包)与 `interfaces`;`MCPP_KERNEL_ABI_INTERFACES` 在系统供给该层时取系统表的 `interfaces`;裸机行的 `--target` 取 `clang-triple`,平台定义的裸机行不写机器描述时也给出目标(mcpp#1006);平台定义的行取其提供者的 `linkage` | diff --git a/modules/manifest/src/toml.cppm b/modules/manifest/src/toml.cppm index cc6970525..8a7625cd8 100644 --- a/modules/manifest/src/toml.cppm +++ b/modules/manifest/src/toml.cppm @@ -4672,10 +4672,13 @@ std::expected parse_document(const t::Document& documen toml_header_key(triple), key, tables)); continue; } - const std::span known = value.is_array() - ? std::span(kKnownTargetArrays) - : std::span(kKnownTargetScalars); - if (std::ranges::find(known, key) != known.end()) continue; + // A known key's type is its parse site's to check (above): the + // sweep asks the name. Asking by the value's type reported + // `runner = true`, a form the parser reads (2026.11.17.1), as an + // unsupported key, because a boolean is not an array. + if (std::ranges::find(kKnownTargetScalars, key) != std::end(kKnownTargetScalars) + || std::ranges::find(kKnownTargetArrays, key) != std::end(kKnownTargetArrays)) + continue; m.schemaWarnings.push_back(std::format( "[target.{}] has unsupported key '{}' (ignored). Supported keys: " "cxx_runtime, linkage, min_api_level, platform, run_under, runner, sysroot, " diff --git a/src/build/prepare/target_side.cpp b/src/build/prepare/target_side.cpp index 192159d02..42098265d 100644 --- a/src/build/prepare/target_side.cpp +++ b/src/build/prepare/target_side.cpp @@ -583,7 +583,7 @@ step9_resolve_and_realise_cabi(PrepareState& state, TargetSideGather& gather) { auto spec = mcpp::freestanding::resolve(*tt); if (spec) { freestandingFlags.push_back( - "--target=" + std::string(spec->triple)); + "--target=" + std::string(spec->target)); for (auto const& f : mcpp::freestanding::compile_flags(*spec)) freestandingFlags.push_back(f); } diff --git a/src/freestanding/linkline.cppm b/src/freestanding/linkline.cppm index dddeb3b9d..02ac684eb 100644 --- a/src/freestanding/linkline.cppm +++ b/src/freestanding/linkline.cppm @@ -46,7 +46,7 @@ export namespace mcpp::freestanding { inline std::string compile_prefix(const Spec& s, bool targetCxxRuntime = false, bool hostedC = false) { std::string out; - out += " --target=" + std::string(s.triple); + out += " --target=" + std::string(s.target); for (auto const& f : compile_flags(s, targetCxxRuntime, hostedC)) { out += ' '; out += f; } return out; } @@ -81,7 +81,7 @@ inline std::string link_flags(const Spec& s, const LinkInputs& in, const std::filesystem::path&)>& esc) { std::string out; - out += " --target=" + std::string(s.triple); + out += " --target=" + std::string(s.target); // The default `targetCxxRuntime` is deliberate here and not an omission of // the kind fixed in cache_key.cppm: what this list contributes to a LINK // line is the machine description (`-march`, `-mabi`, `-mcmodel`), and the diff --git a/src/freestanding/target.cppm b/src/freestanding/target.cppm index aebf9e875..f5df53156 100644 --- a/src/freestanding/target.cppm +++ b/src/freestanding/target.cppm @@ -82,8 +82,16 @@ struct Spec { // riscv and aarch64 rows: their driver already reaches lld, and changing a // working link to prove a point is how a regression gets introduced. std::string_view lldEmulation; + // The target the compiler is told (`--target=`): the row's `clang-triple` + // where it states one, else the row itself. + std::string_view target; }; +// What `--target=` names for a row: its `clang-triple`, else its identity. +template constexpr std::string_view target_of(const Row& r) { + return r.clangTriple.empty() ? r.triple : r.clangTriple; +} + // THE ROWS ARE DATA (design 2026-11-09; SPEC-016): each bare-metal row of // modules/toolchain-model/data/builtin.toml states its ISA profile -- // `march`, `mabi`, `code-model`, `multilib`, `flags`, `link-emulation` -- with @@ -100,7 +108,7 @@ inline constexpr auto kTable = [] { std::size_t i = 0; for (auto const& r : rows) { if (r.march.empty()) continue; - out[i++] = Spec{ r.triple, r.march, r.mabi, r.codeModel, r.multilib, r.flags, r.linkEmulation }; + out[i++] = Spec{ r.triple, r.march, r.mabi, r.codeModel, r.multilib, r.flags, r.linkEmulation, target_of(r) }; } return out; }(); @@ -119,7 +127,7 @@ inline constexpr auto kTable = [] { inline std::optional defined_spec(std::string_view triple) { auto const* d = mcpp::toolchain::target::defined_row(triple); if (!d || (d->march.empty() && d->linkEmulation.empty())) return std::nullopt; - return Spec{ d->triple, d->march, d->mabi, d->codeModel, d->multilib, d->flags, d->linkEmulation }; + return Spec{ d->triple, d->march, d->mabi, d->codeModel, d->multilib, d->flags, d->linkEmulation, target_of(*d) }; } // The single read point. Returns nullopt for anything that is not a known @@ -130,7 +138,15 @@ inline std::optional resolve(const mcpp::toolchain::triple::Triple& t) { const std::string s = t.str(); for (const auto& row : kTable) if (row.triple == s) return row; - return defined_spec(s); + if (auto spec = defined_spec(s)) return spec; + // A BARE-METAL ROW A PLATFORM DEFINES WITHOUT A MACHINE DESCRIPTION is a + // known bare-metal row all the same: the compiler is told its target and + // keeps its defaults for the processor. Without this its compiles and the + // C library's verification probe ran with no target selection, and the + // probe refused openkal-musl's `riscv64-none-musl` row for it. + if (auto const* d = mcpp::toolchain::target::defined_row(s)) + return Spec{ .triple = d->triple, .target = target_of(*d) }; + return std::nullopt; } // The machine description of a row with an operating system under it: only a diff --git a/tests/unit/test_manifest.cpp b/tests/unit/test_manifest.cpp index 8f16f4e3e..c8b6331e9 100644 --- a/tests/unit/test_manifest.cpp +++ b/tests/unit/test_manifest.cpp @@ -7369,3 +7369,20 @@ UTest a_conditional_test_table_carries_discover_alone{"Manifest/AConditionalTest "[target.'cfg(os = \"emscripten\")'.test]\ndiscover = \"tests/x.cpp\"\n"); expect(fatal(!bad.has_value())); }}; + +// `runner = true` and `runner = false` enable or disable the runner stated for +// the row (2026.11.17.1); a boolean is read, not reported as an unsupported key. +UTest a_boolean_runner_is_a_known_key{"Manifest/ABooleanRunnerIsAKnownKey", [] { + auto m = mcpp::manifest::parse_string(R"( +[package] +name = "r" +version = "0.1.0" + +[target.aarch64-ios-sim] +runner = true +)"); + if (auto&& failed = expect(fatal(m.has_value())); !failed) failed << m.error().format(); + std::string all; + for (auto const& w : m->schemaWarnings) { all += w; all += '\n'; } + expect(all.find("runner") == std::string::npos) << all; +}}; diff --git a/tests/unit/test_network.cpp b/tests/unit/test_network.cpp index fc94ae26e..6a57ff799 100644 --- a/tests/unit/test_network.cpp +++ b/tests/unit/test_network.cpp @@ -232,13 +232,15 @@ UTest legacy_status_and_handshake_do_not_write_the_selected_home{"NetworkCheck/L }}; UTest bootstrap_requires_download_budgets_and_read_only_queries{"NetworkCheck/BootstrapRequiresDownloadBudgetsAndReadOnlyQueries", [] { + // And `store_roots` (xlings 2026.11.23.1): a provider whose collection does + // not read roots is not asked for one. mcpp::provider::ProviderInfo info; info.answered = true; info.version = "9999.1.1.1"; info.capabilities = {"install_packages"}; info.features = {"index_dir", "index_store", "upstreams", "payload_status", "sync_index", "payload_currency", "binding_state"}; - for (const auto* feature : {"network_diagnostics", "download_socket_budgets", "read_only_queries"}) { + for (const auto* feature : {"network_diagnostics", "download_socket_budgets", "read_only_queries", "store_roots"}) { expect(ne(mcpp::provider::xlings::unmet(info).find(feature), std::string::npos)); info.features.push_back(feature); } From 811348bc683ed33a3779fe86160b97aafb7a5957 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 08:12:49 +0900 Subject: [PATCH 10/33] e2e 1157: a bare-metal row a platform defines is compiled for its clang triple --- tests/e2e/openkal/platforms.cpp | 48 ++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/tests/e2e/openkal/platforms.cpp b/tests/e2e/openkal/platforms.cpp index 29402280e..25768e903 100644 --- a/tests/e2e/openkal/platforms.cpp +++ b/tests/e2e/openkal/platforms.cpp @@ -1,7 +1,8 @@ // Platform packages: a class of targets a platform states, its version group and its series, // the default platform release, a target a platform defines, the platform skeleton, and a row a // platform defines taking nothing of the payload's host (formerly tests/e2e/952, 1020, 1021, -// 1025, 1040, 1049, 1057), the package index naming a row's platform (1106), and a platform's +// 1025, 1040, 1049, 1057), a bare-metal row a platform defines compiled for its clang triple +// (1157), the package index naming a row's platform (1106), and a platform's // plugin resolving apart from the project's build program and a series skipping a release the // build cannot use (972). import std; @@ -729,6 +730,51 @@ flags = ["-e", "_start"] const auto h = s::read_header(*exe); expect(fatal(h.kind == s::format::elf && !h.wide)) << "the program is not ELF32"; }; + "1157 a bare metal row a platform defines is compiled for its clang triple"_test[s::elf][s::llvm] = [] { + // A bare-metal row a platform defines with no machine description (`riscv64-none-toy`, + // no `march`, no `link-emulation`): every compile is told the row's clang-triple, and + // the build succeeds. Before, such a row resolved to no bare-metal description, its + // compiles had no `--target`, and the C library's verification probe refused it. + const auto t = s::case_dir(); + s::project(t / "plat", {{"mcpp.toml", std::format(R"([package] +name = "toy-platform" +version = "0.1.0" + +[platform] +toolchain = "llvm@{}" + +[[platform.define]] +triple = "riscv64-none-toy" +clang-triple = "riscv64-unknown-elf" +object-format = "elf" +execution = "toy" + +[[platform.provider]] +serves = ["riscv64-none-toy"] + +[platform.build] +cflags = ["-fno-pic"] +ldflags = ["-nostdlib", "-Wl,-e,_start"] + +[platform.layers] +"kernel-abi" = false +"c-abi" = false +"c++-abi" = false +"compiler-runtime" = false +)", s::llvm_version())}}); + s::project app(t / "app", {{"mcpp.toml", "[package]\nname = \"toy\"\nversion = \"0.1.0\"\n\n[targets.toy]\nkind = \"bin\"\nmain = \"src/main.c\"\n\n[target.riscv64-none-toy]\nplatform = { path = \"../plat\" }\n"}, + {"src/main.c", "#ifndef __riscv\n#error not compiled for riscv\n#endif\nvoid _start(void) { for (;;) {} }\n"}}); + auto r = app.mcpp({"build", "--target", "riscv64-none-toy"}); + expect(fatal(e2e::succeeded(r))) << "the row did not build: " << s::text(r); + r = app.mcpp({"why", "flags", "--target", "riscv64-none-toy"}); + expect(fatal(e2e::succeeded(r) && e2e::contains(s::text(r), "--target=riscv64-unknown-elf"))) + << "the row's clang-triple is not the compiles' target: " << s::text(r); + std::optional exe; + for (const auto& f : s::find_files(app.at("target/riscv64-none-toy"), "toy")) + if (f.parent_path().filename() == "bin") { exe = f; break; } + expect(fatal(exe.has_value())) << "no program"; + expect(fatal(s::read_header(*exe).kind == s::format::elf)) << "the program is not ELF"; + }; "1106 the package index names the platform of a row"_test[s::elf][s::llvm][s::fresh_sandbox] = [] { // A row no table knows, `x86_64-toyos`, a `planned` row, `i686-linux-musl`, a row the // table holds with no platform and no provider here, `x86_64-freebsd`, and the host's From 5ab858d82057f236735c17170a94d100bcbc36d6 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 10:25:08 +0900 Subject: [PATCH 11/33] openkal-platform 0.32.0 is the default platform of the openkal rows --- CHANGELOG.md | 3 +++ docs/50-machine-output.md | 2 +- docs/zh/50-machine-output.md | 2 +- modules/toolchain-model/data/builtin.toml | 6 +++--- tests/fixtures/target-rows.snapshot | 20 ++++++++++---------- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c9112f7d8..c69ee0a86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,9 @@ ### Changed +- openkal-platform 0.32.0 is the default platform of the openkal rows: a program of the firmware + and of DOS starts programs (`openkal.process`), an image on i686 starts an image + (mcpplibs/openkal-image#46), and `riscv64-none-musl` runs over openkal-opensbi. - xlings 2026.11.23.1 is the pinned provider, and the handshake requires its `store_roots` feature (protocol 1.19): its collection keeps what a root holds, and its configuration of a package that states `host_facts` runs again when those host files change (openxlings/xlings#712, diff --git a/docs/50-machine-output.md b/docs/50-machine-output.md index db402b817..af8438133 100644 --- a/docs/50-machine-output.md +++ b/docs/50-machine-output.md @@ -568,7 +568,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.31.2` from 2026.11.20.1, `@0.31.0` in 2026.11.19.1, `@0.29.2` in 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`. +target table selects for it (`mcpplibs.openkal-platform@0.32.0` from @RELEASE@, `@0.31.2` from 2026.11.20.1, `@0.31.0` in 2026.11.19.1, `@0.29.2` in 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 91e2b7e0b..4d298a9e8 100644 --- a/docs/zh/50-machine-output.md +++ b/docs/zh/50-machine-output.md @@ -501,7 +501,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.20.1 起为 `mcpplibs.openkal-platform@0.31.2`,2026.11.19.1 为 `@0.31.0`,2026.11.18.1 为 `@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`。 +(@RELEASE@ 起为 `mcpplibs.openkal-platform@0.32.0`,2026.11.20.1 为 `@0.31.2`,2026.11.19.1 为 `@0.31.0`,2026.11.18.1 为 `@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 27652ac2a..338399a26 100644 --- a/modules/toolchain-model/data/builtin.toml +++ b/modules/toolchain-model/data/builtin.toml @@ -769,7 +769,7 @@ hosts = ["*"] toolchain = "llvm@23.1.3" pairs = ["llvm"] linkage = "static" -platform = "mcpplibs.openkal-platform@0.31.2" +platform = "mcpplibs.openkal-platform@0.32.0" [[platform.provider]] name = "openkal" @@ -779,7 +779,7 @@ hosts = ["*"] toolchain = "llvm@23.1.3" pairs = ["llvm"] linkage = "static" -platform = "mcpplibs.openkal-platform@0.31.2" +platform = "mcpplibs.openkal-platform@0.32.0" # The same arrangement on Windows, whose own interfaces a resource script # compiles against: their headers are the MinGW-w64 base's, which states them @@ -792,7 +792,7 @@ hosts = ["*"] toolchain = "llvm@23.1.3" pairs = ["llvm"] linkage = "static" -platform = "mcpplibs.openkal-platform@0.31.2" +platform = "mcpplibs.openkal-platform@0.32.0" system-headers = "xim:mingw-w64-sysroot@20261104-2" # ── Systems ────────────────────────────────────────────────────────────────── diff --git a/tests/fixtures/target-rows.snapshot b/tests/fixtures/target-rows.snapshot index 2973bdf35..f71185221 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.31.2 + table tier=preview note=PE pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.0 str x86_64-windows-musl llvm x86_64-w64-windows-gnu llvm@15.0 x86_64-w64-windows-gnu @@ -189,7 +189,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.31.2 + table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.0 str aarch64-macos-musl llvm arm64-apple-macos14.0 llvm@15.0 arm64-apple-macos15.0 @@ -227,7 +227,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.31.2 + table tier=planned note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.0 str i686-linux-musl llvm i686-unknown-linux-musl llvm@15.0 i686-unknown-linux-musl @@ -265,7 +265,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.31.2 + table tier=planned note=ok pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.0 str i686-openkal llvm i686-unknown-none-elf llvm@15.0 i686-unknown-none-elf @@ -303,7 +303,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.31.2 + table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.0 str x86_64-macos-musl llvm x86_64-apple-macos14.0 llvm@15.0 x86_64-apple-macos15.0 @@ -360,7 +360,7 @@ row aarch64-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.31.2 + table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.0 str x86_64-freebsd-musl llvm x86_64-unknown-freebsd14.0 llvm@15.0 x86_64-unknown-freebsd14.0 @@ -379,7 +379,7 @@ row x86_64-freebsd-musl 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.31.2 + table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.0 str aarch64-freebsd-musl llvm aarch64-unknown-freebsd14.0 llvm@15.0 aarch64-unknown-freebsd14.0 @@ -836,7 +836,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.31.2 + table tier=verified note=ok pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.0 str x86_64-openkal llvm x86_64-unknown-none-elf llvm@15.0 x86_64-unknown-none-elf @@ -855,7 +855,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.31.2 + table tier=verified note=ok pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.0 str aarch64-openkal llvm aarch64-unknown-none-elf llvm@15.0 aarch64-unknown-none-elf @@ -990,7 +990,7 @@ set linux-musl -> x86_64-linux-musl aarch64-linux-musl riscv64-linux-musl | set windows -> x86_64-windows-gnu aarch64-windows-gnu | set windows-msvc -> x86_64-windows-msvc i686-windows-msvc | set macos -> aarch64-macos | -set openkal -> x86_64-openkal aarch64-openkal | mcpplibs.openkal-platform@0.31.2 +set openkal -> x86_64-openkal aarch64-openkal | mcpplibs.openkal-platform@0.32.0 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 | From d1234d67328cc5b256358ff784aecab5fe18306c Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 16:12:02 +0900 Subject: [PATCH 12/33] ci: every xlings pin is 2026.11.23.1, the provider the handshake requires; the pack launchers build on mcpplibs.os 0.4.8 --- .github/actions/bootstrap-mcpp/action.yml | 2 +- .github/actions/setup-macos-llvm/action.yml | 2 +- .github/workflows/bootstrap-macos.yml | 2 +- .github/workflows/ci-bootstrap.yml | 6 +++--- .github/workflows/ci-fresh-install.yml | 6 +++--- .github/workflows/ci-linux-e2e.yml | 2 +- .github/workflows/cross-build-test.yml | 4 ++-- .github/workflows/release-build.yml | 14 +++++++------- src/pack/distribution.cppm | 2 +- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/actions/bootstrap-mcpp/action.yml b/.github/actions/bootstrap-mcpp/action.yml index edf4c576c..36f49f491 100644 --- a/.github/actions/bootstrap-mcpp/action.yml +++ b/.github/actions/bootstrap-mcpp/action.yml @@ -33,7 +33,7 @@ inputs: # `package.name`, so one of the two was simply unreachable — and which one # depended on the machine, which is why CI failed on `compat:lua` on # Windows and `mcpplibs.capi:lua` on Linux. Never pin below that. - default: '2026.11.21.1' + default: '2026.11.23.1' outputs: sandbox-key: diff --git a/.github/actions/setup-macos-llvm/action.yml b/.github/actions/setup-macos-llvm/action.yml index 5a1e6aa6c..389916cac 100644 --- a/.github/actions/setup-macos-llvm/action.yml +++ b/.github/actions/setup-macos-llvm/action.yml @@ -15,7 +15,7 @@ inputs: # Floor imposed by the index, not a routine bump — see # .github/actions/bootstrap-mcpp/action.yml for why 0.4.69 is required # (two packages named `lua` in one repo need openxlings/xlings#381). - default: '2026.11.21.1' + default: '2026.11.23.1' image: description: > The runner label the job runs on (macos-15, xcode-27). It is part of the diff --git a/.github/workflows/bootstrap-macos.yml b/.github/workflows/bootstrap-macos.yml index 52d1d9ba4..a00c500f5 100644 --- a/.github/workflows/bootstrap-macos.yml +++ b/.github/workflows/bootstrap-macos.yml @@ -17,7 +17,7 @@ jobs: # Dormant (workflow_dispatch only), but kept in step with the rest — # check_version_pins.sh holds it there. Floor: 0.4.69, below which the # index cannot resolve two packages that share a short name. - XLINGS_VERSION: '2026.11.21.1' + XLINGS_VERSION: '2026.11.23.1' steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/ci-bootstrap.yml b/.github/workflows/ci-bootstrap.yml index d9bf59ab9..aa2f1abd4 100644 --- a/.github/workflows/ci-bootstrap.yml +++ b/.github/workflows/ci-bootstrap.yml @@ -41,7 +41,7 @@ jobs: os: [ubuntu-24.04, macos-15, windows-2025] env: XLINGS_NON_INTERACTIVE: '1' - XLINGS_VERSION: '2026.11.21.1' + XLINGS_VERSION: '2026.11.23.1' steps: - uses: actions/checkout@v4 @@ -50,7 +50,7 @@ jobs: shell: bash run: | set -euo pipefail - curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.11.21.1 + curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.11.23.1 echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH" echo "$HOME/.xlings/bin" >> "$GITHUB_PATH" @@ -124,7 +124,7 @@ jobs: shell: bash run: | set -euo pipefail - curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.11.21.1 + curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.11.23.1 echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH" - name: Install the newest release and build the tree with it (mcpp build --strict) diff --git a/.github/workflows/ci-fresh-install.yml b/.github/workflows/ci-fresh-install.yml index dbd7babca..7405580d6 100644 --- a/.github/workflows/ci-fresh-install.yml +++ b/.github/workflows/ci-fresh-install.yml @@ -182,7 +182,7 @@ jobs: env: XLINGS_NON_INTERACTIVE: '1' run: | - curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.11.21.1 + curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.11.23.1 echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH" - name: Install mcpp and config mirror @@ -311,7 +311,7 @@ jobs: - name: Install xlings + mcpp run: | - curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.11.21.1 + curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.11.23.1 # Deliberately NOT writing to $GITHUB_PATH here. On container # images that declare no PATH in their config (opensuse/ # tumbleweed), appending a single dir to GITHUB_PATH makes the @@ -460,7 +460,7 @@ jobs: # (older ones carry minos=15 and refuse to start). # v0.4.51+: in-process sha256 — this image has no sha256sum # binary, so pinned fetches failed before it. - curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.11.21.1 + curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.11.23.1 echo "$HOME/.xlings/subos/current/bin" >> "$GITHUB_PATH" - name: Install mcpp and config mirror diff --git a/.github/workflows/ci-linux-e2e.yml b/.github/workflows/ci-linux-e2e.yml index 8194a9a5e..d4155c270 100644 --- a/.github/workflows/ci-linux-e2e.yml +++ b/.github/workflows/ci-linux-e2e.yml @@ -469,7 +469,7 @@ jobs: - name: Bootstrap xlings + released mcpp run: | - curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.11.21.1 + curl -fsSL https://raw.githubusercontent.com/openxlings/xlings/main/tools/other/quick_install.sh | bash -s v2026.11.23.1 export PATH="$HOME/.xlings/subos/current/bin:$PATH" xlings update xlings install mcpp -y -g diff --git a/.github/workflows/cross-build-test.yml b/.github/workflows/cross-build-test.yml index 0030f4644..6213ca5fb 100644 --- a/.github/workflows/cross-build-test.yml +++ b/.github/workflows/cross-build-test.yml @@ -132,7 +132,7 @@ jobs: # release assets were uploaded in a broken state (records present, # blobs missing → 404 on GET); re-uploaded clean. The stale-INDEX # half is handled by the marker-clear below. - XLINGS_VERSION: '2026.11.21.1' + XLINGS_VERSION: '2026.11.23.1' run: | tarball="xlings-${XLINGS_VERSION}-linux-x86_64.tar.gz" bash "$GITHUB_WORKSPACE/.github/tools/fetch_release.sh" \ @@ -322,7 +322,7 @@ jobs: - name: Bootstrap mcpp via xlings env: XLINGS_NON_INTERACTIVE: '1' - XLINGS_VERSION: '2026.11.21.1' + XLINGS_VERSION: '2026.11.23.1' run: | tarball="xlings-${XLINGS_VERSION}-linux-x86_64.tar.gz" bash "$GITHUB_WORKSPACE/.github/tools/fetch_release.sh" \ diff --git a/.github/workflows/release-build.yml b/.github/workflows/release-build.yml index b4d038945..9c27e26e2 100644 --- a/.github/workflows/release-build.yml +++ b/.github/workflows/release-build.yml @@ -88,7 +88,7 @@ jobs: # Pin xlings to a known-good version. The upstream install # script always grabs `latest` (no version override), so we # download + self-install manually to avoid broken releases. - XLINGS_VERSION: '2026.11.21.1' + XLINGS_VERSION: '2026.11.23.1' run: | # BY VERSION, NOT BY PRESENCE. A restored ~/.xlings holds the # xlings of an earlier release, and this binary is the one the @@ -314,7 +314,7 @@ jobs: - name: Bootstrap mcpp via xlings env: XLINGS_NON_INTERACTIVE: '1' - XLINGS_VERSION: '2026.11.21.1' + XLINGS_VERSION: '2026.11.23.1' run: | tarball="xlings-${XLINGS_VERSION}-linux-x86_64.tar.gz" bash "$GITHUB_WORKSPACE/.github/tools/fetch_release.sh" \ @@ -383,7 +383,7 @@ jobs: # below are pinned to the same version as XLINGS_VERSION; they are # NOT interpolated from it, so check_version_pins.sh scans for them # explicitly (they were absent from the old lock-step comment). - XLA="xlings-2026.11.21.1-linux-aarch64.tar.gz" + XLA="xlings-2026.11.23.1-linux-aarch64.tar.gz" # NOT fetch_release.sh: this asset is OPTIONAL and the `if` is the # point — an arch with no prebuilt xlings must fall through quietly, # while the helper retries a 404 five times before giving up. The one @@ -392,9 +392,9 @@ jobs: # cover it. if curl -fsSL --retry 3 --retry-delay 2 --retry-all-errors \ --connect-timeout 20 --max-time 600 -o "/tmp/$XLA" \ - "https://github.com/openxlings/xlings/releases/download/v2026.11.21.1/$XLA"; then + "https://github.com/openxlings/xlings/releases/download/v2026.11.23.1/$XLA"; then tar -xzf "/tmp/$XLA" -C /tmp - XLBIN=$(find /tmp/xlings-2026.11.21.1-linux-aarch64 -path '*/bin/xlings' -type f | head -1) + XLBIN=$(find /tmp/xlings-2026.11.23.1-linux-aarch64 -path '*/bin/xlings' -type f | head -1) if [ -n "$XLBIN" ]; then mkdir -p "$STAGING/$WRAPPER/registry/bin" cp "$XLBIN" "$STAGING/$WRAPPER/registry/bin/xlings" @@ -467,7 +467,7 @@ jobs: - name: Bootstrap mcpp via xlings env: XLINGS_NON_INTERACTIVE: '1' - XLINGS_VERSION: '2026.11.21.1' + XLINGS_VERSION: '2026.11.23.1' run: | # By version, not by presence (see the Linux job). have=$("$HOME/.xlings/subos/default/bin/xlings" --version 2>/dev/null | awk '{print $2}') @@ -653,7 +653,7 @@ jobs: shell: bash env: XLINGS_NON_INTERACTIVE: '1' - XLINGS_VERSION: '2026.11.21.1' + XLINGS_VERSION: '2026.11.23.1' run: | # Captured before the `cd` below, in POSIX form: this step never # returns to the workspace, and GITHUB_WORKSPACE is a backslash diff --git a/src/pack/distribution.cppm b/src/pack/distribution.cppm index ab6877bba..8c6dd3d8c 100644 --- a/src/pack/distribution.cppm +++ b/src/pack/distribution.cppm @@ -96,7 +96,7 @@ std::string exe_launcher_main(const Launch& l); // When the two shared one resolution, this had to be the release the plugin // linked (0.4.5, through mcpp.plugins 0.26.1): 0.4.4 and 0.4.6 were refused as // irreconcilable (e2e 988, the canaries' pack cells). -inline constexpr std::string_view kLauncherOs = "0.4.7"; +inline constexpr std::string_view kLauncherOs = "0.4.8"; // ─── mcpp-package.json (SPEC-014 §4.5) ──────────────────────────────────── From 1e515b593ff7428b8b7b6f05f1d188388c5b454f Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 16:12:02 +0900 Subject: [PATCH 13/33] 2026.11.23.1: the kernel headers are the kernel-abi layer's, platform keys on every row, a row's interfaces, a generated unit's origin, store roots, riscv64-linux-musl and the iOS simulator runner, openkal-platform 0.32.0 (mcpp#988, #1004, #1005, #1007, #1009) --- CHANGELOG.md | 4 +++- docs/09-commands-by-scenario.md | 2 +- docs/20-toolchains.md | 2 +- docs/22-target-side.md | 6 +++--- docs/30-build-mcpp.md | 2 +- docs/35-platforms.md | 2 +- docs/41-devices.md | 2 +- docs/50-machine-output.md | 10 +++++----- docs/specs/README.md | 12 ++++++------ docs/specs/build-database.md | 8 ++++---- docs/specs/manifest-semantics.md | 6 +++--- docs/specs/platforms.md | 6 +++--- docs/specs/target-side.md | 6 +++--- docs/specs/targets-and-providers.md | 4 ++-- docs/specs/toolchain-management.md | 6 +++--- docs/zh/09-commands-by-scenario.md | 2 +- docs/zh/20-toolchains.md | 2 +- docs/zh/22-target-side.md | 6 +++--- docs/zh/30-build-mcpp.md | 2 +- docs/zh/35-platforms.md | 2 +- docs/zh/41-devices.md | 2 +- docs/zh/50-machine-output.md | 10 +++++----- mcpp.toml | 2 +- modules/versioning/src/version.cppm | 2 +- 24 files changed, 55 insertions(+), 53 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c69ee0a86..a8c14dbed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ > Each `## []` section is that release's notes. Entries are written in English > from 2026.9.28.3 on; earlier entries remain as written. -## [@RELEASE@] - @DATE@ +## [2026.11.23.1] - 2026-11-23 ### Added @@ -55,6 +55,8 @@ feature (protocol 1.19): its collection keeps what a root holds, and its configuration of a package that states `host_facts` runs again when those host files change (openxlings/xlings#712, #727). An earlier provider is refused at the handshake, as before for one below the floor. + mcpp builds on mcpplibs.os 0.4.8, which reads a link's own time, and so do the launchers a + pack builds. - `mcpp cache gc` collects the package store after the cache: the provider removes the payloads nothing references (`xlings self clean`), and with `--older-than` the roots no build used for that long are released first. Before, payloads were never collected, and `xlings self clean` diff --git a/docs/09-commands-by-scenario.md b/docs/09-commands-by-scenario.md index 3a46ae8e3..862a3fef2 100644 --- a/docs/09-commands-by-scenario.md +++ b/docs/09-commands-by-scenario.md @@ -111,7 +111,7 @@ warning states both (2026.11.8.1+). `mcpp cache prune` and `mcpp cache gc --older-than` collect `std` module entries by age as well; `gc --max-size` budgets packages and host tools, not `std` modules (2026.11.8.1+). -**The store's payloads (@RELEASE@+).** A build holds each payload of mcpp's +**The store's payloads (2026.11.23.1+).** A build holds each payload of mcpp's package store that its graph names -- the toolchain, its base and companions, the packages and tools it wires -- as a **root**: a link `registry/data/roots/mcpp/@` to the payload, renewed by diff --git a/docs/20-toolchains.md b/docs/20-toolchains.md index 6c72a9dc2..52b5c4472 100644 --- a/docs/20-toolchains.md +++ b/docs/20-toolchains.md @@ -240,7 +240,7 @@ features by that binutils when it was built. `companions` names binutils only; the kernel headers are the target's `kernel-abi` layer, stated with `[target..layers] kernel-abi` ([22 — The Target Side](22-target-side.md)); without a statement, over a base that carries none, -they follow the toolchain payload's declaration (mcpp @RELEASE@+). +they follow the toolchain payload's declaration (mcpp 2026.11.23.1+). ## Switching the Default Toolchain diff --git a/docs/22-target-side.md b/docs/22-target-side.md index ca9afb9eb..037bca515 100644 --- a/docs/22-target-side.md +++ b/docs/22-target-side.md @@ -1208,7 +1208,7 @@ conditions and combinators. mcpp before 2026.11.10.2 reads only `linux`, `macos` without enumerating the ones it is not. `interface` (mcpp 2026.11.13.1) is the kernel-abi layer's second answer: an interface its provider states in `[kernel-abi] provides-interfaces`, or, where the layer is the system itself, the system - row's `interfaces` (mcpp @RELEASE@), compared by membership as `accelerator` + row's `interfaces` (mcpp 2026.11.23.1), compared by membership as `accelerator` is. A provider or a system that states no list provides every interface; a graph without the layer provides none. On `aarch64-ios` the answer for `openkal.process` is false: an application of iOS starts no program. A package selects its sources by what the implementation @@ -1380,7 +1380,7 @@ this returns. To branch on the resolved layer, use a layer predicate: Side](22-target-side.md)). This paragraph said "which C library was resolved" until 2026.9.1.1, which was the wrong one of the two. -### `layers.kernel-abi` — the kernel headers (mcpp @RELEASE@+) +### `layers.kernel-abi` — the kernel headers (mcpp 2026.11.23.1+) Linux publishes its kernel headers apart from its C library, so on a Linux row they are a prebuilt supplier of the `kernel-abi` layer and can be stated: @@ -1424,7 +1424,7 @@ The forms are refused where they do not apply (`target-base`): on macOS, Windows and FreeBSD the kernel interface is part of the base (`sysroot`), and no other layer takes a prebuilt form. On an openkal row the layer is the openkal implementation: a second supplier is refused by rule one. A manifest that uses -the forms states `[package] mcpp = ">=@RELEASE@"`; an older mcpp ignores the +the forms states `[package] mcpp = ">=2026.11.23.1"`; an older mcpp ignores the key on a row without a platform. ### `abi` — a switch the whole artefact shares (mcpp 2026.9.12.2+) diff --git a/docs/30-build-mcpp.md b/docs/30-build-mcpp.md index 889ac7e28..0004e5fc8 100644 --- a/docs/30-build-mcpp.md +++ b/docs/30-build-mcpp.md @@ -871,7 +871,7 @@ relative path among them is relative to `cwd`. A variable's value is part of the edge's command line, and changing it re-runs the action. An action that declares neither keeps the protocol 12 command line byte for byte. -#### The authored file of a generated unit: `.origin()` (@RELEASE@+) +#### The authored file of a generated unit: `.origin()` (2026.11.23.1+) An action that writes a transformed copy of a file a person edits (a source with its imports rewritten, a module unit with a prologue added) names that diff --git a/docs/35-platforms.md b/docs/35-platforms.md index 535837c18..012519117 100644 --- a/docs/35-platforms.md +++ b/docs/35-platforms.md @@ -109,7 +109,7 @@ a package of the graph already provides is left to that package and reported `graph`. The package of the C++ run-time also provides the compiler run-time, so `"c++-abi" = false` takes effect only with `compiler-runtime = false` beside it. -The tables apply on a row without a platform too (mcpp @RELEASE@): such a row +The tables apply on a row without a platform too (mcpp 2026.11.23.1): such a row has an empty platform statement, and `layers`, `tools` and `link` written for it complete the graph and reach the link as they would over a platform. Before, they were accepted and had no effect. `carrier` is a form of a platform's image, diff --git a/docs/41-devices.md b/docs/41-devices.md index 32bcaf749..d77110bc8 100644 --- a/docs/41-devices.md +++ b/docs/41-devices.md @@ -166,7 +166,7 @@ runner: the emulator package serves no aarch64 machine. MCPP_TARGET_X86_64_LINUX_ANDROID_RUNNER_ENABLED=true mcpp run --target x86_64-linux-android ``` -**An iOS simulator program runs in the simulator (@RELEASE@+).** On a Mac, once +**An iOS simulator program runs in the simulator (2026.11.23.1+).** On a Mac, once enabled, `aarch64-ios-sim` and `x86_64-ios-sim` run through `simctl-run` (`xim:apple-simulator-tools`): it chooses an available device, boots it when none is booted, spawns the program and returns its status. A simulator runs the diff --git a/docs/50-machine-output.md b/docs/50-machine-output.md index af8438133..e51421a70 100644 --- a/docs/50-machine-output.md +++ b/docs/50-machine-output.md @@ -568,7 +568,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.32.0` from @RELEASE@, `@0.31.2` from 2026.11.20.1, `@0.31.0` in 2026.11.19.1, `@0.29.2` in 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`. +target table selects for it (`mcpplibs.openkal-platform@0.32.0` from 2026.11.23.1, `@0.31.2` from 2026.11.20.1, `@0.31.0` in 2026.11.19.1, `@0.29.2` in 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 @@ -593,7 +593,7 @@ It resolves and reports; it does not build. `data` is: | `compiler` | `{family, version, driver, chosenBy}` — the driver that would run, and why | | `triple` | `{requested, toolchain, llvm}` | | `cLibrary` | `{mode, path, origin, suppliesTarget}` — `mode` is `sysroot` / `payload-first` / `none`; `origin` is `payload` / `subos` / `host` / `none` | -| `layers[]` | the five target-side layers: `{layer, interface, impl, origin, subset, version, interfaces}`; `version` is the kernel-abi layer's measured version where the system publishes its kernel headers as a package (empty otherwise), `interfaces` the layer's interfaces (`null`: unstated, every one) *(@RELEASE@+)* | +| `layers[]` | the five target-side layers: `{layer, interface, impl, origin, subset, version, interfaces}`; `version` is the kernel-abi layer's measured version where the system publishes its kernel headers as a package (empty otherwise), `interfaces` the layer's interfaces (`null`: unstated, every one) *(2026.11.23.1+)* | **`compiler.chosenBy` answers "why this one".** `{origin, requiredBy, replaced}` — `origin` is the same phrase the build's status line uses @@ -657,7 +657,7 @@ a program classifying the outcome reads `reason`: | `payload-request` | a build program asked for a payload no manifest of this build declares `provision = "on-request"`, or asked again in three consecutive runs *(2026.10.1.3+)* | | `lto-export-discovery` | a PE shared library whose exports are discovered would be compiled by cl.exe into `/GL` objects, which hold no symbol table: `windows_auto_export = true` stated under `lto = true`, or `/GL` written into the flags of a package it links *(2026.10.5.2+)* | | `local-toolchain` | a toolchain named by path, or stated by a build program's toolchain phase, cannot be used: no driver, a contradicting family, a missing tool, or `spec` stated with a key only a toolchain named by path has *(2026.10.1.3+)* | -| `target-base` | the target base (`sysroot`) cannot serve this build: a spelling the row does not take, a path that does not exist, a directory that supplies no C library, a C library older than the compiler's runtime requires, a native base without its loader, or a second C library supplier in the graph *(2026.10.24.1+)*; the kernel headers: a prebuilt `layers` form on a row or layer that takes none, a payload without the target architecture's headers, no headers to answer the default, or a measurement that contradicts the statement *(@RELEASE@+)* | +| `target-base` | the target base (`sysroot`) cannot serve this build: a spelling the row does not take, a path that does not exist, a directory that supplies no C library, a C library older than the compiler's runtime requires, a native base without its loader, or a second C library supplier in the graph *(2026.10.24.1+)*; the kernel headers: a prebuilt `layers` form on a row or layer that takes none, a payload without the target architecture's headers, no headers to answer the default, or a measurement that contradicts the statement *(2026.11.23.1+)* | | `convention-unreplaced` | the convention was overridden and nothing replaced it | | `os-mismatch` | the requested and resolved triples name different systems | | `layer-requirement` | a package requires a layer the resolution did not give it | @@ -737,7 +737,7 @@ writes nothing into the project. `data` is: | field | | |---|---| -| `spec` | `{"name": "s1", "version": "0.4.0"}` (0.3.0 before @RELEASE@, 0.2.0 before 2026.9.28.1), or `{"name": "compile-commands"}` with `--spec compile-commands` | +| `spec` | `{"name": "s1", "version": "0.4.0"}` (0.3.0 before 2026.11.23.1, 0.2.0 before 2026.9.28.1), or `{"name": "compile-commands"}` with `--spec compile-commands` | | `database` | the document of that specification: an S1 build database, or the entries `mcpp build --configure-only` writes to `compile_commands.json` | | `watch` | the inputs whose change can change the document: paths and glob patterns relative to the workspace root, or absolute paths | | `inputs-fingerprint` | `fnv1a:<16 hex digits>`, a digest of those inputs, the mcpp version and the selectors | @@ -753,7 +753,7 @@ action, so such a file does not exist yet in the directory the document names. Each entry gives the path a `mcpp build` of the same selection writes (`build-path`) and the step that writes it, so that an editor can say "generated, build once" instead of reporting a missing header. -Since @RELEASE@ an entry of `kind` `source` also carries `origin` when its +Since 2026.11.23.1 an entry of `kind` `source` also carries `origin` when its action states one with `.origin(...)` ([30](30-build-mcpp.md)): the authored file the generated unit is a transformed copy of (S1 0.4.0 section 7.2). diff --git a/docs/specs/README.md b/docs/specs/README.md index 5d7235436..2017cfb1a 100644 --- a/docs/specs/README.md +++ b/docs/specs/README.md @@ -31,21 +31,21 @@ | 编号 | 标题 | 状态 | 最后修改 | 对应实现 | |---|---|---|---|---| | [SPEC-001](package-identity.md) | 包身份(`package.namespace` / `package.name`)、`[dependencies]` 选择器与匹配机制 | 评审中 v1.13 | 2026-11-21 | mcpp >= 0.0.106;§3.5 与 §10.4 mcpp >= 2026.11.19.1;§4.5、§3.5 的 `installed_manifest` 与 §10.4 第 7 条 mcpp >= 2026.11.21.1 | -| [SPEC-002](target-side.md) | 目标侧模型与能力声明(`mcpp:` 保留命名空间、五层、三条规则、目标侧执行、一个进程一套 C++ 运行时) | 评审中 v1.12 | 2026-11-23 | mcpp >= 2026.8.24.2;§2.4 与 §6 mcpp >= 2026.10.24.1;§2.2 的对象形式与 §7 mcpp >= 2026.10.26.1;§2.5 与 §3.8 mcpp >= 2026.11.10.1;§3.6 以目标的解析判断 mcpp >= 2026.11.19.1;§3.9 与 §3.10 mcpp >= @RELEASE@ | +| [SPEC-002](target-side.md) | 目标侧模型与能力声明(`mcpp:` 保留命名空间、五层、三条规则、目标侧执行、一个进程一套 C++ 运行时) | 评审中 v1.12 | 2026-11-23 | mcpp >= 2026.8.24.2;§2.4 与 §6 mcpp >= 2026.10.24.1;§2.2 的对象形式与 §7 mcpp >= 2026.10.26.1;§2.5 与 §3.8 mcpp >= 2026.11.10.1;§3.6 以目标的解析判断 mcpp >= 2026.11.19.1;§3.9 与 §3.10 mcpp >= 2026.11.23.1 | | [SPEC-003](exit-codes.md) | 退出码契约(分类、语义、稳定性承诺) | 评审中 v1.2 | 2026-10-26 | mcpp >= 2026.9.1.1;`5` 与信号 mcpp >= 2026.10.26.1 | -| [SPEC-004](manifest-semantics.md) | `mcpp.toml` 的平面划分、条件化形状、解析轴与命名规约 | 草案 v1.29 | 2026-11-23 | 条件化形状 mcpp >= 2026.8.29.1;目标轴 mcpp >= 2026.9.6.4;`linkage` 默认值 mcpp >= 2026.9.15.2;链接 flag 的词读法 mcpp >= 2026.9.26.2;条件化的 `dialect_cxxflags` 与 `-p` 的包身份 mcpp >= 2026.9.28.1;条件表按具体程度生效 mcpp >= 2026.9.28.2;平台前缀规约 mcpp >= 2026.10.5.1;根包的继承、根位置的 profile、链接 flag 的作用域、链接期优化与导出发现 mcpp >= 2026.10.5.2;架构段的 `x86` 即 `i686` mcpp >= 2026.10.5.3;前缀即语义与工作空间层 mcpp >= 2026.10.10.1;依赖的库与配置(§12) mcpp >= 2026.10.11.1;值的四档层次与 `run_under` mcpp >= 2026.10.24.1;§12 第 3 条一个程序一个版本 mcpp >= 2026.11.19.1;§9 第 21 至 23 条与 §16 mcpp >= 2026.11.21.1;v1.29 条款 mcpp >= @RELEASE@ | -| [SPEC-005](build-database.md) | 构建数据库:`mcpp emit build-database` 的内容、取值规则与不写工程目录的保证 | 评审中 v1.10 | 2026-11-23 | mcpp >= 2026.9.15.1;v1.3 条款 mcpp >= 2026.9.26.2;v1.4 条款 mcpp >= 2026.9.27.1;v1.5 条款 mcpp >= 2026.9.28.1;v1.6 条款 mcpp >= 2026.9.29.5;v1.7 条款 mcpp >= 2026.9.30.2;v1.8 条款 mcpp >= 2026.10.11.1;v1.10 条款 mcpp >= @RELEASE@ | -| [SPEC-006](toolchain-management.md) | 工具链管理:身份、来源、选择与载荷契约 | 草案 v0.14 | 2026-11-23 | 逐条标注;已实现条款 mcpp >= 2026.9.24.1;§3.7 mcpp >= 2026.9.28.1;§3.7.1 mcpp >= 2026.9.28.2;§2.2.1 与 §3.3 的非缺省来源 mcpp >= 2026.10.1.3;§3.8 mcpp >= 2026.10.8.1;§3.9 至 §3.11 mcpp >= 2026.10.24.1;v0.11 条款 mcpp >= 2026.11.10.1;v0.14 条款 mcpp >= @RELEASE@ | +| [SPEC-004](manifest-semantics.md) | `mcpp.toml` 的平面划分、条件化形状、解析轴与命名规约 | 草案 v1.29 | 2026-11-23 | 条件化形状 mcpp >= 2026.8.29.1;目标轴 mcpp >= 2026.9.6.4;`linkage` 默认值 mcpp >= 2026.9.15.2;链接 flag 的词读法 mcpp >= 2026.9.26.2;条件化的 `dialect_cxxflags` 与 `-p` 的包身份 mcpp >= 2026.9.28.1;条件表按具体程度生效 mcpp >= 2026.9.28.2;平台前缀规约 mcpp >= 2026.10.5.1;根包的继承、根位置的 profile、链接 flag 的作用域、链接期优化与导出发现 mcpp >= 2026.10.5.2;架构段的 `x86` 即 `i686` mcpp >= 2026.10.5.3;前缀即语义与工作空间层 mcpp >= 2026.10.10.1;依赖的库与配置(§12) mcpp >= 2026.10.11.1;值的四档层次与 `run_under` mcpp >= 2026.10.24.1;§12 第 3 条一个程序一个版本 mcpp >= 2026.11.19.1;§9 第 21 至 23 条与 §16 mcpp >= 2026.11.21.1;v1.29 条款 mcpp >= 2026.11.23.1 | +| [SPEC-005](build-database.md) | 构建数据库:`mcpp emit build-database` 的内容、取值规则与不写工程目录的保证 | 评审中 v1.10 | 2026-11-23 | mcpp >= 2026.9.15.1;v1.3 条款 mcpp >= 2026.9.26.2;v1.4 条款 mcpp >= 2026.9.27.1;v1.5 条款 mcpp >= 2026.9.28.1;v1.6 条款 mcpp >= 2026.9.29.5;v1.7 条款 mcpp >= 2026.9.30.2;v1.8 条款 mcpp >= 2026.10.11.1;v1.10 条款 mcpp >= 2026.11.23.1 | +| [SPEC-006](toolchain-management.md) | 工具链管理:身份、来源、选择与载荷契约 | 草案 v0.14 | 2026-11-23 | 逐条标注;已实现条款 mcpp >= 2026.9.24.1;§3.7 mcpp >= 2026.9.28.1;§3.7.1 mcpp >= 2026.9.28.2;§2.2.1 与 §3.3 的非缺省来源 mcpp >= 2026.10.1.3;§3.8 mcpp >= 2026.10.8.1;§3.9 至 §3.11 mcpp >= 2026.10.24.1;v0.11 条款 mcpp >= 2026.11.10.1;v0.14 条款 mcpp >= 2026.11.23.1 | | [SPEC-007](build-plugins.md) | 构建插件:配置、施工与校验的分工,运行时与规划期的义务 | 草案 v0.16 | 2026-11-21 | 逐条标注;mcpp >= 2026.9.26.2;v0.3 条款 mcpp >= 2026.9.27.1;v0.4 条款 mcpp >= 2026.9.28.1;v0.5 条款 mcpp >= 2026.9.28.2;v0.6(§9)mcpp >= 2026.9.28.3;R3.9、R3.10 mcpp >= 2026.10.10.1;§10 mcpp >= 2026.10.11.1;§3.1 协议 18 mcpp >= 2026.11.5.1;协议 19 mcpp >= 2026.11.16.1;协议 20、R10.7 mcpp >= 2026.11.19.1;协议 21、R10.8–R10.10 mcpp >= 2026.11.21.1 | | [SPEC-008](library-interface.md) | 库的接口:公开模块、发布闭包与两种形态的一致 | 草案 v0.2 | 2026-10-11 | 第一阶段(只警告)mcpp >= 2026.9.28.3;v0.2 mcpp >= 2026.10.11.1 | | [SPEC-009](toolchain-maintenance.md) | 工具链的支持与维护:版本线、默认值、来源、移动与退役 | 草案 v0.7 | 2026-11-21 | 逐条标注;本版只有规范,多数条款未实现;§6.4 mcpp >= 2026.10.8.1 | | [SPEC-010](home-initialization.md) | home 选择、单跳入口、初始化、网络边界、单次运行的 `--home` 与来自目录的 home | 草案 v0.3 | 2026-11-21 | mcpp >= 2026.10.19.1;网络能力逐条标注;§6 mcpp >= 2026.10.26.1、xlings >= 2026.10.26.1 | | [SPEC-011](concurrency.md) | 并发运行:三段、构建目录锁、原子发布、`mcpp.lock` 的乐观写入、取消;编译执行器的恢复、发布、记录与文本 | 评审中 v1.2 | 2026-11-19 | mcpp >= 2026.10.26.1;§5.1 mcpp >= 2026.11.7.1;§5.1 第 6 条的不可观察单元与第 8 至 12 条 mcpp >= 2026.11.19.1 | | [SPEC-012](human-output.md) | 面向人的输出:两条流、两种介质、行的种类、颜色、程序的文本 | 评审中 v1.1 | 2026-11-19 | mcpp >= 2026.10.26.1;§5 mcpp >= 2026.11.19.1 | -| [SPEC-013](platforms.md) | 平台:`[platform]` 的七组键、版本组与 `hosted`,三种写法与层次,目标图与宿主图的选择,`cfg(platform)`,依赖图的补全,链接、命名与封装,运行器与载体,平台阶段与协议 17 | 评审中 v1.17 | 2026-11-23 | mcpp >= 2026.10.27.1;§10 的执行宿主与 §11 的载体架构 mcpp >= 2026.10.29.1;§7.5 版本组参与解析与 §14 平台系列 mcpp >= 2026.11.7.1;§14 内置平台为确切版本 mcpp >= 2026.11.7.2;v1.7 条款 mcpp >= 2026.11.10.1;§14 索引的平台列 mcpp >= 2026.11.17.1;§14 系列取可用的最新版本与 §15.1 的 `+b` 条目 mcpp >= 2026.11.19.1;v1.17 条款 mcpp >= @RELEASE@ | +| [SPEC-013](platforms.md) | 平台:`[platform]` 的七组键、版本组与 `hosted`,三种写法与层次,目标图与宿主图的选择,`cfg(platform)`,依赖图的补全,链接、命名与封装,运行器与载体,平台阶段与协议 17 | 评审中 v1.17 | 2026-11-23 | mcpp >= 2026.10.27.1;§10 的执行宿主与 §11 的载体架构 mcpp >= 2026.10.29.1;§7.5 版本组参与解析与 §14 平台系列 mcpp >= 2026.11.7.1;§14 内置平台为确切版本 mcpp >= 2026.11.7.2;v1.7 条款 mcpp >= 2026.11.10.1;§14 索引的平台列 mcpp >= 2026.11.17.1;§14 系列取可用的最新版本与 §15.1 的 `+b` 条目 mcpp >= 2026.11.19.1;v1.17 条款 mcpp >= 2026.11.23.1 | | [SPEC-014](packaging.md) | 打包与分发:链接、闭包、容器三个维度与构建腿,腿的合并,暂存树与 `mcpp-package.json`,平台的树、运行覆盖、单文件、polyglot、容器列表、签名、压缩、合并与分发描述 | 评审中 v2.2 | 2026-11-10 | mcpp >= 2026.10.31.1;逐条标注;v2.2 条款 mcpp >= 2026.11.10.1 | | [SPEC-015](target-sets.md) | 目标集合与腿:集合的写法与展开,命令对多条腿的语义,串行规划与一起构建,测试归档,机器输出 | 评审中 v1.0 | 2026-10-30 | mcpp >= 2026.10.30.1 | -| [SPEC-016](targets-and-providers.md) | 目标与提供者:行、提供者、选择规则、平台定义的行、C 环境与执行、报告、机器输出与锁 | 评审中 v1.9 | 2026-11-23 | mcpp >= 2026.11.9.1;v1.1 条款 mcpp >= 2026.11.10.1;v1.9 条款 mcpp >= @RELEASE@ | +| [SPEC-016](targets-and-providers.md) | 目标与提供者:行、提供者、选择规则、平台定义的行、C 环境与执行、报告、机器输出与锁 | 评审中 v1.9 | 2026-11-23 | mcpp >= 2026.11.9.1;v1.1 条款 mcpp >= 2026.11.10.1;v1.9 条款 mcpp >= 2026.11.23.1 | | [SPEC-017](test.md) | mcpp 测试规范:测试程序、测试协议、记录、存储、启动描述与框架声明;基础能力 B1–B6 与可选能力 O1–O12 | 评审中 v2.6 | 2026-11-21 | mcpp >= 2026.11.8.1;逐条标注;B5、B6 的新键、O3 的运行器一侧、O8 mcpp >= 2026.11.10.1;O9 mtest >= 0.6.0;O10 mcpp >= 2026.11.13.1;O11、O12 与 P5.6 mcpp >= 2026.11.21.1 | | [SPEC-018](module-rebuilds.md) | 模块的重编译:按 BMI 内容截断,GCC 的时间戳与行映射,`bmi_cutoff`,构建目录的记录 | 评审中 v1.0 | 2026-11-17 | mcpp >= 2026.11.17.2 | | [SPEC-019](build-optimizations.md) | 构建优化:登记表、级别、接缝、总开关,私有模块片段作为独立单元,构建后的建议 | 评审中 v1.0 | 2026-11-17 | mcpp >= 2026.11.17.2 | diff --git a/docs/specs/build-database.md b/docs/specs/build-database.md index 7813f7474..e22dad8ff 100644 --- a/docs/specs/build-database.md +++ b/docs/specs/build-database.md @@ -7,7 +7,7 @@ | 状态 | 评审中 v1.10 | | 版本 | 1.10 | | 最后修改 | 2026-11-23 | -| 对应实现 | mcpp >= 2026.9.15.1;v1.3 修改的 R2.5、R3.7、R3.8、R4.1、R5.2 为 mcpp >= 2026.9.26.2;v1.4 修改的 R2.5 为 mcpp >= 2026.9.27.1;v1.5 修改的 R3.7、R3.12、R5.1、R5.2 为 mcpp >= 2026.9.28.1;v1.6 修改的 R2.1、R3.3、R3.4、R3.5、R4.1、R5.2 为 mcpp >= 2026.9.29.5;v1.7 新增的 R3.8a 为 mcpp >= 2026.9.30.2;v1.8 新增的 R3.13 为 mcpp >= 2026.10.11.1;v1.9 明确的 R6.1a 为 mcpp >= 2026.10.21.1;v1.10 的 R3.9、R3.12a 与 R5.1 的 S1 0.4.0 为 mcpp >= @RELEASE@ | +| 对应实现 | mcpp >= 2026.9.15.1;v1.3 修改的 R2.5、R3.7、R3.8、R4.1、R5.2 为 mcpp >= 2026.9.26.2;v1.4 修改的 R2.5 为 mcpp >= 2026.9.27.1;v1.5 修改的 R3.7、R3.12、R5.1、R5.2 为 mcpp >= 2026.9.28.1;v1.6 修改的 R2.1、R3.3、R3.4、R3.5、R4.1、R5.2 为 mcpp >= 2026.9.29.5;v1.7 新增的 R3.8a 为 mcpp >= 2026.9.30.2;v1.8 新增的 R3.13 为 mcpp >= 2026.10.11.1;v1.9 明确的 R6.1a 为 mcpp >= 2026.10.21.1;v1.10 的 R3.9、R3.12a 与 R5.1 的 S1 0.4.0 为 mcpp >= 2026.11.23.1 | | 相关设计文档 | `.agents/docs/2026-09-14-636-build-database-and-the-latest-xlings.md`
`.agents/docs/2026-09-26-compile-database-and-issue-699-design.md` | | 相关 issue | #636, #648, #655, #699, #702, #707, #732, #797 | | 依据的外部规范 | S1「C++ Build Database: IDE Profile」profile 0.4.0(§7.2 的 `origin`,Sunrisepeak/mcpp-language-server#98;0.3.0 的 §7.2 `generated`,Sunrisepeak/mcpp-language-server#28;此前为 0.2.0)与 S2 0.2.0 §3.4,取自 https://github.com/Sunrisepeak/lsp-mcpp-private 提交 `b82859d`(schema 自提交 `28ecd6e` 起未变);S2 0.3.0 §3.4 的部分回答(S2-3.4-12、S2-3.4-13,Sunrisepeak/mcpp-language-server#25);JSON Compilation Database | @@ -148,7 +148,7 @@ mcpp 输出的 S1 文档满足 S1 等级 2,不输出 `ide.options`。等级 3 | `module M:P;` | `module-partition-implementation` | | `module M;` | `module-implementation` | | `scan_overrides` 声明的单元;P1689 扫描中无法区分实现单元与导入者的单元 | `unknown` | - | 构建程序的 action 生成、并以 `provides` 声明模块主名(不含 `:`)的单元 | `module-interface`(只有接口单元提供主名;mcpp >= @RELEASE@) | + | 构建程序的 action 生成、并以 `provides` 声明模块主名(不含 `:`)的单元 | `module-interface`(只有接口单元提供主名;mcpp >= 2026.11.23.1) | **已实现** - **R3.9a** 没有被 `sources` glob 匹配的目标入口源文件(发现的测试、glob 之外的 @@ -188,7 +188,7 @@ mcpp 输出的 S1 文档满足 S1 等级 2,不输出 `ide.options`。等级 3 `inputs` 推断它。`origin` 不在 `inputs` 中、或陈述在 `role` 不是 `source` 的 action 上时,构建程序的指令被拒绝。 同一模块由生成的单元与其 `origin` 一同提供时(工程把编写的文件也列在 `sources` 中),扫描器的重复提供者错误写明 二者的这一关系。不写 `line-mapping`:生成文件中的 `#line` 指令本身是事实,由消费方读取。S1 0.4.0 §7.2 的增量 - 字段。**已实现**(mcpp >= @RELEASE@,mcpp#1004) + 字段。**已实现**(mcpp >= 2026.11.23.1,mcpp#1004) ### 3.6 构建程序 @@ -214,7 +214,7 @@ mcpp 输出的 S1 文档满足 S1 等级 2,不输出 `ide.options`。等级 3 ## 5. 信封 - **R5.1** `kind` 为 `mcpp.build-database`,`kindVersion` 为 1。`data` 含 `spec` - (`{"name": "s1", "version": "0.4.0"}`,@RELEASE@ 之前为 0.3.0;或 `{"name": "compile-commands"}`)、 + (`{"name": "s1", "version": "0.4.0"}`,2026.11.23.1 之前为 0.3.0;或 `{"name": "compile-commands"}`)、 `database`、`watch` 与 `inputs-fingerprint`。**已实现** - **R5.2** 一个成员规划失败只影响它自己,不影响其余成员的集合(#699 第 1 项)。命令 按配置规划被选中的成员;一个配置的规划失败时,该配置的成员逐个规划,因此失败仍归于 diff --git a/docs/specs/manifest-semantics.md b/docs/specs/manifest-semantics.md index c16316f78..bdcfa008d 100644 --- a/docs/specs/manifest-semantics.md +++ b/docs/specs/manifest-semantics.md @@ -198,8 +198,8 @@ feature-deps feature-xlings ← 限定词是门 | `[target..xlings…]` | 目标 | **已实现**(2026.9.6.4) | | `[target.].sysroot` | 目标 | **已实现** | | `[target.].run_under` | 目标(执行宿主) | **已实现**(2026.10.24.1) | -| `[target.]` 的 `platform`、`layers`、`tools`、`link`、`carrier` | 目标 | **已实现**(2026.10.27.1,SPEC-013);没有平台的行上同样生效(@RELEASE@,SPEC-013 §6) | -| `[target..layers] kernel-abi` 的预制形式 `"<索引>:<名>@<版本>"`、`{ path = "<目录>" }` | 目标 | **已实现**(@RELEASE@,SPEC-002 §3.9) | +| `[target.]` 的 `platform`、`layers`、`tools`、`link`、`carrier` | 目标 | **已实现**(2026.10.27.1,SPEC-013);没有平台的行上同样生效(2026.11.23.1,SPEC-013 §6) | +| `[target..layers] kernel-abi` 的预制形式 `"<索引>:<名>@<版本>"`、`{ path = "<目录>" }` | 目标 | **已实现**(2026.11.23.1,SPEC-002 §3.9) | | `[host] platform` | 宿主 | **已实现**(2026.10.27.1,SPEC-013 §4) | `layers.<层>` 的值有四种形式:依赖图中的包(包引用)、`false`、生态载荷 `"<索引>:<名>@<版本>"` 与不带 `mcpp.toml` 的 @@ -964,4 +964,4 @@ mcpp 2026.10.10.1,#785、#786;第 14 至 16 条与第 13 条的依赖位置为 m | 1.26 | 2026-11-21 | mcpp 2026.11.21.1(mcpp#990,设计 2026-11-21 离线与缺省 §3.2):§9 第 22 条 `[build] offline` 与第 23 条 `[xlings] archives`,两者按 §2 的四层取值,一次运行陈述为一个变量。 | | 1.27 | 2026-11-21 | mcpp 2026.11.21.1(mcpp#992):新增 §16,特性的 `description`、一个目录项与查询回答的三种状态。 | | 1.28 | 2026-11-22 | mcpp 2026.11.22.1(设计 2026-11-22 §6.2):§9 第 12 条,生效的 `[indices]` 中一个位置只有一个名字,两项指向同一位置时拒绝(`index-location-named-twice`)。 | -| 1.29 | 2026-11-23 | mcpp @RELEASE@(设计 2026-11-22 内核接口与派生状态 §3.1、§3.2):`layers.<层>` 的四种值,载荷与目录两种预制形式;平台键在没有平台的行上生效。 | +| 1.29 | 2026-11-23 | mcpp 2026.11.23.1(设计 2026-11-22 内核接口与派生状态 §3.1、§3.2):`layers.<层>` 的四种值,载荷与目录两种预制形式;平台键在没有平台的行上生效。 | diff --git a/docs/specs/platforms.md b/docs/specs/platforms.md index bd6836055..a6efdb6ae 100644 --- a/docs/specs/platforms.md +++ b/docs/specs/platforms.md @@ -7,7 +7,7 @@ | 状态 | 评审中 v1.17 | | 版本 | 1.17 | | 最后修改 | 2026-11-23 | -| 对应实现 | mcpp >= 2026.10.27.1;§10 的执行宿主与 §11 的载体架构 mcpp >= 2026.10.29.1;`runner.hosts`、载体列表、`descriptor_keys` 与 `universal` 的弃用 mcpp >= 2026.10.30.1;§7.5 版本组参与解析、§14 平台系列与 §15.1 系列的锁 mcpp >= 2026.11.7.1;§14 内置平台为确切版本与提示 mcpp >= 2026.11.7.2;v1.7 条款 mcpp >= 2026.11.10.1;v1.10 条款 mcpp >= 2026.11.16.1;v1.11 条款(§14 索引的平台列) mcpp >= 2026.11.17.1;v1.15 条款(§14 系列取本次构建可用的最新版本,§15.1 构建程序的版本条目) mcpp >= 2026.11.19.1;v1.16 条款(§14 平台列未命中的刷新条件) mcpp >= 2026.11.22.1;v1.17 条款(§6 没有平台的行、§7.2 预制形式) mcpp >= @RELEASE@;逐条标注 | +| 对应实现 | mcpp >= 2026.10.27.1;§10 的执行宿主与 §11 的载体架构 mcpp >= 2026.10.29.1;`runner.hosts`、载体列表、`descriptor_keys` 与 `universal` 的弃用 mcpp >= 2026.10.30.1;§7.5 版本组参与解析、§14 平台系列与 §15.1 系列的锁 mcpp >= 2026.11.7.1;§14 内置平台为确切版本与提示 mcpp >= 2026.11.7.2;v1.7 条款 mcpp >= 2026.11.10.1;v1.10 条款 mcpp >= 2026.11.16.1;v1.11 条款(§14 索引的平台列) mcpp >= 2026.11.17.1;v1.15 条款(§14 系列取本次构建可用的最新版本,§15.1 构建程序的版本条目) mcpp >= 2026.11.19.1;v1.16 条款(§14 平台列未命中的刷新条件) mcpp >= 2026.11.22.1;v1.17 条款(§6 没有平台的行、§7.2 预制形式) mcpp >= 2026.11.23.1;逐条标注 | | 相关设计文档 | `.agents/docs/2026-11-16-ecosystem-gap-supplement-part2-design.md`、`.agents/docs/2026-11-15-ecosystem-gap-supplement-design.md`、`.agents/docs/2026-10-28-platforms-design.md`、`.agents/docs/2026-10-28-platforms-part2-packaging-and-distribution-design.md`、`.agents/docs/2026-10-29-openkal-run-test-pack-design.md` | | 相关 issue | mcpp#846、mcpp#847、mcpp#848 | | 相关规范 | [SPEC-002](target-side.md)(目标侧的层)、[SPEC-004](manifest-semantics.md)(条件化形状)、[SPEC-006](toolchain-management.md)(工具链选择)、[SPEC-007](build-plugins.md)(构建程序与协议)、[SPEC-011](concurrency.md)(原子发布)、[SPEC-014](packaging.md)(打包) | @@ -221,7 +221,7 @@ mcpp **必须**给出警告(`manifest/platform-selector`),并指出按三元组 | `runner`、`runners` 的每个名字 | `cmd`、`requires` 与 `enabled` 是一条陈述,随 `cmd` 一起替换,未写的 `enabled` 为真;`host`、`hosts`、`exclusive`、`longlived`、`built-as` 各自独立替换。只写 argv 的覆盖保留平台的 `host` 与 `exclusive`;覆盖层(本机配置、工程)不含 `cmd` 的表只改它写出的键(v1.10) | | 其余 | 按字段替换 | -**没有平台的行同样合并(v1.17,mcpp >= @RELEASE@)。** 未选平台包的行有一份空的平台陈述,`config.toml` 与工程的 +**没有平台的行同样合并(v1.17,mcpp >= 2026.11.23.1)。** 未选平台包的行有一份空的平台陈述,`config.toml` 与工程的 `[target.]` 按上表并入其中,§7.2、§7.3 的补全照常进行;读取字段的步骤(链接规划、标志、后端)读字段本身, 只有含义来自平台包的步骤(平台包的身份、版本组、平台插件)以选定了平台包为前提。此前这些键在没有平台的行上被接受而 不起作用。`carrier` 是平台映像的形式(§11),在没有平台的行上以警告报告(`platform/carrier`)而不使构建失败。 @@ -665,4 +665,4 @@ openkal-platform 的 `targets` 因此不含 WebAssembly。Web 经 `wasm32-emscri | 1.14 | 2026-11-19 | mcpp 2026.11.19.1(mcpp#967):§14 索引的平台列第 6 条,一行的未命中按依赖未命中的策略刷新索引并重新扫描,拒绝写出是否已刷新。 | | 1.15 | 2026-11-20 | mcpp 2026.11.19.1(mcpp#972,设计 2026-11-19 §21 A3、A5):§14 平台系列第 3 条,版本组不容许本次构建的请求时取范围内更早的版本并写出跳过的版本与请求,全部不可用时拒绝;§15.1 构建程序取得的另一版本为 `+b` 条目并写出 `programs`。 | | 1.16 | 2026-11-22 | mcpp 2026.11.22.1(mcpp#996):§14 索引的平台列第 6 条,没有平台也能构建的请求(段定义的自定义三元组、命名了工具链的 `planned` 行)的未命中不刷新索引;表中的 `platform = "none"` 结束平台列的查询。 | -| 1.17 | 2026-11-23 | mcpp @RELEASE@(设计 2026-11-22 §3.2):§6 没有平台的行有一份空的平台陈述,本机与工程的 `[target.]` 并入其中,`carrier` 在这样的行上为警告;§7.2 层的预制形式不加入依赖图(SPEC-002 §3.9)。 | +| 1.17 | 2026-11-23 | mcpp 2026.11.23.1(设计 2026-11-22 §3.2):§6 没有平台的行有一份空的平台陈述,本机与工程的 `[target.]` 并入其中,`carrier` 在这样的行上为警告;§7.2 层的预制形式不加入依赖图(SPEC-002 §3.9)。 | diff --git a/docs/specs/target-side.md b/docs/specs/target-side.md index 89043ff71..063a97dea 100644 --- a/docs/specs/target-side.md +++ b/docs/specs/target-side.md @@ -232,7 +232,7 @@ hosted 与否是 C 环境的一个声明:提供 `hosted-standard-library` 的 sy 它需要的层。例:写在 C 库之上的 kernel-abi 实现(需要 `mcpp:c-abi`)与写在 kernel-abi 之上的 C 库(需要 `mcpp:kernel-abi`)不能同处一图;二者相互调用的递归在运行时才出现。 -### 3.9 内核头文件 已实现(mcpp >= @RELEASE@) +### 3.9 内核头文件 已实现(mcpp >= 2026.11.23.1) 系统行为 `kernel-abi` 给出测量方式(SPEC-016 §2.3)的系统,其内核头文件是与 C 库分开发布的包, 是 `mcpp:kernel-abi=<系统名>` 的预制供给者(当前为 `linux`)。 @@ -259,7 +259,7 @@ hosted 与否是 C 环境的一个声明:提供 `hosted-standard-library` 的 sy 7. **报告。** 目标侧报告与 `mcpp why toolchain` 的 `layers[]` 写出实现、测得的版本(`version`)、供给者与来源; 头文件目录进入缓存键(`targetHeaderSet`)。 -### 3.10 `kernel-abi` 的接口 已实现(mcpp >= @RELEASE@) +### 3.10 `kernel-abi` 的接口 已实现(mcpp >= 2026.11.23.1) `cfg(interface = "<接口名>")` 按成员关系回答 `kernel-abi` 层所提供的接口:依赖图供给该层时取其包的 `[kernel-abi] provides-interfaces`,该层是系统自身时取系统行的 `interfaces`(SPEC-016 §2.3)。不陈述清单的包或 @@ -456,4 +456,4 @@ hosted 与否是 C 环境的一个声明:提供 `hosted-standard-library` 的 sy | v1.8 | 2026-11-12 | 随 mcpp 2026.11.12.1:§2.5 基座包只有一种读法(带清单即包根 sysroot,布局只对无清单的目录探测)。 | | v1.10 | 2026-11-19 | 随 mcpp 2026.11.19.1:§2.5 基座的 C++ 层与依赖图供给的层的隔离词在每个宿主上写出,与载荷旁有无驱动的配置文件无关;`-stdlib=` 取该层的库名(mcpp#965)。 | | v1.11 | 2026-11-20 | 随 mcpp 2026.11.19.1:§3.6 缺省以目标的解析判断,只被构建程序持有的包不为目标提供能力(设计 2026-11-19 §21 A1)。 | -| v1.12 | 2026-11-23 | 随 mcpp @RELEASE@(设计 2026-11-22):新增 §3.9 内核头文件(预制陈述、缺省的两个回答者、测量、接线、布局)与 §3.10 `kernel-abi` 的接口;§3.3 不再补上生态的内核头文件。 | +| v1.12 | 2026-11-23 | 随 mcpp 2026.11.23.1(设计 2026-11-22):新增 §3.9 内核头文件(预制陈述、缺省的两个回答者、测量、接线、布局)与 §3.10 `kernel-abi` 的接口;§3.3 不再补上生态的内核头文件。 | diff --git a/docs/specs/targets-and-providers.md b/docs/specs/targets-and-providers.md index ef5c830f1..28e3cc16a 100644 --- a/docs/specs/targets-and-providers.md +++ b/docs/specs/targets-and-providers.md @@ -7,7 +7,7 @@ | 状态 | 评审中 v1.9 | | 版本 | 1.9 | | 最后修改 | 2026-11-23 | -| 对应实现 | 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;v1.7 条款 mcpp >= 2026.11.20.1;v1.8 条款 mcpp >= 2026.11.22.1;v1.9 条款 mcpp >= @RELEASE@ | +| 对应实现 | 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;v1.7 条款 mcpp >= 2026.11.20.1;v1.8 条款 mcpp >= 2026.11.22.1;v1.9 条款 mcpp >= 2026.11.23.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`、`.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-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)(目标集合) | @@ -279,4 +279,4 @@ | 1.6 | 2026-11-19 | mcpp 2026.11.19.1(mcpp#957):§6 执行可达性的谓词之前没有按系统的分支;Apple 的行由同一个谓词判定;系统名检查的词表含三元组的系统谓词 | | 1.7 | 2026-11-20 | mcpp 2026.11.20.1(mcpp#981):行的 `link-without-main`,没有程序起点的可执行映像的链接词;内置 `wasm32-emscripten` 行为 `--no-entry` | | 1.8 | 2026-11-22 | mcpp 2026.11.22.1(设计 2026-11-22 §4):`i686-windows-msvc` 为 preview 行;执行关系表中 `windows-x86_64` 执行 `i686`(§2.4)。 | -| 1.9 | 2026-11-23 | mcpp @RELEASE@(设计 2026-11-22 §3.4、§3.17):系统表的 `kernel-abi`(测量、载荷布局、包)与 `interfaces`;`MCPP_KERNEL_ABI_INTERFACES` 在系统供给该层时取系统表的 `interfaces`;裸机行的 `--target` 取 `clang-triple`,平台定义的裸机行不写机器描述时也给出目标(mcpp#1006);平台定义的行取其提供者的 `linkage` | +| 1.9 | 2026-11-23 | mcpp 2026.11.23.1(设计 2026-11-22 §3.4、§3.17):系统表的 `kernel-abi`(测量、载荷布局、包)与 `interfaces`;`MCPP_KERNEL_ABI_INTERFACES` 在系统供给该层时取系统表的 `interfaces`;裸机行的 `--target` 取 `clang-triple`,平台定义的裸机行不写机器描述时也给出目标(mcpp#1006);平台定义的行取其提供者的 `linkage` | diff --git a/docs/specs/toolchain-management.md b/docs/specs/toolchain-management.md index 9b28c503a..9748e710d 100644 --- a/docs/specs/toolchain-management.md +++ b/docs/specs/toolchain-management.md @@ -124,9 +124,9 @@ - 写明的 binutils 低于工具链载荷声明的版本时**必须**拒绝,原因标记 `companion-too-old`:GCC 在构建时按所用的 binutils 选定汇编器的能力。 - 内核头文件不在工具链的陈述中覆盖,它们是目标的 `kernel-abi` 层(`[target..layers] kernel-abi`,SPEC-002 §3.9)。 基座不带内核头文件(共享视图、载荷布局的 glibc)时,缺省取工具链载荷声明的版本,读法同上;载荷没有声明时不取 store 中的 - 最新版本,而是拒绝并给出陈述的写法。引擎**禁止**向共享视图写入内核头文件(mcpp >= @RELEASE@)。 + 最新版本,而是拒绝并给出陈述的写法。引擎**禁止**向共享视图写入内核头文件(mcpp >= 2026.11.23.1)。 -### 2.10 存储的根 已实现(@RELEASE@ 起) +### 2.10 存储的根 已实现(2026.11.23.1 起) - 构建**必须**为其图所指名的、mcpp 包存储中的每个载荷登记一个根:提供者为 mcpp 给出的根目录中一个指向该载荷的链接,名为 `<存储名>@<版本>`(xlings 的存储根规范)。根以临时名创建后改名覆盖,因此每次使用都更新链接自身的时间;复用其图的构建按图旁 @@ -463,7 +463,7 @@ doctor 如实报告这一点。它同时报告 mcpp 的包 home 中指向不存 | v0.10 | 2026-10-23 | 随 mcpp 2026.10.24.1:§1 定义目标基座与执行宿主;新增 §3.9 目标基座(一次解析、四档写法与优先级、测量与声明、不写入、运行时语义)、§3.10 自备输入、§3.11 核心知识判据;§2.2.1 工具链阶段可陈述 `spec` 与 `sysroot`,`spec` 与路径专属键同时出现时拒绝;§3.1 补全读者名单;§3.3 增加主体 `sysroot` 与 `run_under`;§3.5 clang 行接受 `{ path }`;§4.3 要求被陈述的 gnu-sysroot 基座把 `--sysroot` 交给链接器;新增附录 A。 | | v0.11 | 2026-11-10 | 随 mcpp 2026.11.10.1:§3.9.2 引擎默认档为所选提供者的 `sysroot` 列,为包时按工程陈述的规则解析;附录 A 的 `*-windows-gnu` 接受基座包与 `{ path }`,新增 `*-freebsd` 行(基座包见 SPEC-002 §2.5)。 | | v0.13 | 2026-11-22 | 随 mcpp 2026.11.22.1:§2.9 配套载荷的声明依次取自载荷安装时的描述文件与索引的描述文件,取 store 持有的第一个。 | -| v0.14 | 2026-11-23 | 随 mcpp @RELEASE@(设计 2026-11-22 内核接口与派生状态 §3.3、§3.11):§2.9 内核头文件是目标的 `kernel-abi` 层;基座不带时缺省取工具链载荷的声明,没有声明时拒绝;引擎不向共享视图写入内核头文件。新增 §2.10 存储的根。 | +| v0.14 | 2026-11-23 | 随 mcpp 2026.11.23.1(设计 2026-11-22 内核接口与派生状态 §3.3、§3.11):§2.9 内核头文件是目标的 `kernel-abi` 层;基座不带时缺省取工具链载荷的声明,没有声明时拒绝;引擎不向共享视图写入内核头文件。新增 §2.10 存储的根。 | | v0.9 | 2026-10-17 | 随 mcpp 2026.10.17.1:新增 §4.7,已安装的修订在构建中继续使用,`floor` 决定是否必须替换,`toolchain install` 取当前修订;§6.4 doctor 只读,报告构建实际使用的工具链与包 home 的一致性。 | --- diff --git a/docs/zh/09-commands-by-scenario.md b/docs/zh/09-commands-by-scenario.md index d4dda371a..a900bec6a 100644 --- a/docs/zh/09-commands-by-scenario.md +++ b/docs/zh/09-commands-by-scenario.md @@ -90,7 +90,7 @@ host 工具条目。一份 `std` BMI 被机器上每个工程共享,实现以" 与 `mcpp cache gc --older-than` 也按年龄收集 `std` 模块条目;`gc --max-size` 只对包与宿主工具做 预算(2026.11.8.1+)。 -**存储中的载荷(@RELEASE@+)。** 构建把其图所指名的 mcpp 包存储中的每个载荷(工具链、其基座与伴随包、它接线的包与工具) +**存储中的载荷(2026.11.23.1+)。** 构建把其图所指名的 mcpp 包存储中的每个载荷(工具链、其基座与伴随包、它接线的包与工具) 作为一个**根**持有:一个指向该载荷的链接 `registry/data/roots/mcpp/<存储名>@<版本>`,该图的每次构建都更新它,因此它的 时间就是该载荷的最后使用时间。`mcpp toolchain install` 持有它安装的工具链。此前的 home 为它所持有的每个载荷建立一次根。 `mcpp cache gc` 在缓存之后请包提供者回收存储(`xlings self clean`):没有任何引用的载荷(没有环境、没有环境中的链接、不是 diff --git a/docs/zh/20-toolchains.md b/docs/zh/20-toolchains.md index 4297c22ad..f6319c852 100644 --- a/docs/zh/20-toolchains.md +++ b/docs/zh/20-toolchains.md @@ -193,7 +193,7 @@ default = { package = "gcc@16.2.0", companions = { binutils = "xim:binutils@2.47 构建安装该包,输出 `Companion binutils 2.47 ()`,并把它的目录交给编译器驱动。低于 GCC 载荷所声明版本的 binutils 被拒绝 (`companion-too-old`):GCC 在构建时按所用的 binutils 选定汇编器的能力。`companions` 只有 binutils 一项;内核头文件是目标的 `kernel-abi` 层,以 `[target..layers] kernel-abi` 陈述([22 —— 目标侧](22-target-side.md));没有陈述、基座又不带内核头文件时, -它们随工具链载荷的声明(mcpp @RELEASE@+)。 +它们随工具链载荷的声明(mcpp 2026.11.23.1+)。 ## 切换默认工具链 diff --git a/docs/zh/22-target-side.md b/docs/zh/22-target-side.md index fc85fc66b..67b0cfb28 100644 --- a/docs/zh/22-target-side.md +++ b/docs/zh/22-target-side.md @@ -1013,7 +1013,7 @@ arch/env 条件与组合子用 `cfg(...)`。2026.11.10.2 之前的 mcpp 仅将 ` `accelerator = "none"` 是一种写法,用来说明「本次构建没有命名任何后端」, 而不必枚举它不是的那些后端。`interface`(mcpp 2026.11.13.1)是 kernel-abi 层的第二个回答: 该层的提供者在 `[kernel-abi] provides-interfaces` 里陈述的接口,该层是系统自身时为 - 系统行的 `interfaces`(mcpp @RELEASE@),与 `accelerator` 一样按成员判定。未陈述列表的 + 系统行的 `interfaces`(mcpp 2026.11.23.1),与 `accelerator` 一样按成员判定。未陈述列表的 提供者或系统提供全部接口;没有该层的图不提供任何接口。`aarch64-ios` 上 `openkal.process` 的回答为假:iOS 的应用不启动程序。包据此按其下实现提供的接口选择源文件,而不命名任何实现: `[target.'cfg(not(interface = "openkal.fs"))'.build] sources = [...]`。裸词 `linux` / `macos` / `windows` / `unix` @@ -1149,7 +1149,7 @@ Windows 行([21](21-the-target-triple.md))。索引中还有 `xim:aarch64-li (见 [22 —— 目标侧](22-target-side.md))。这一段在 2026.9.1.1 之前写的是 「解析到的是哪份 C 库」,那是两者里错的那一个。 -### `layers.kernel-abi` —— 内核头文件(mcpp @RELEASE@+) +### `layers.kernel-abi` —— 内核头文件(mcpp 2026.11.23.1+) Linux 的内核头文件与 C 库分开发布,因此在 Linux 的行上它们是 `kernel-abi` 层的预制供给者,可以陈述: @@ -1178,7 +1178,7 @@ kernel-abi = "xim:linux-headers@6.18.64" # 生态的载荷,总是带版本 这两种形式在不适用处被拒绝(`target-base`):macOS、Windows 与 FreeBSD 的内核接口属于基座(`sysroot`),其他层也不接受 预制形式。openkal 的行上该层是 openkal 的实现,第二个供给者按规则一被拒绝。使用这两种形式的清单写出 -`[package] mcpp = ">=@RELEASE@"`;较旧的 mcpp 在没有平台的行上忽略该键。 +`[package] mcpp = ">=2026.11.23.1"`;较旧的 mcpp 在没有平台的行上忽略该键。 ### `abi` —— 整个产物共享的开关(mcpp 2026.9.12.2+) diff --git a/docs/zh/30-build-mcpp.md b/docs/zh/30-build-mcpp.md index 5a439c4d5..e639f7e1c 100644 --- a/docs/zh/30-build-mcpp.md +++ b/docs/zh/30-build-mcpp.md @@ -727,7 +727,7 @@ a.env("GEN_MODE", "release") 命令行,值改变时该 action 重新运行。两者都未声明的 action,其命令行与 protocol 12 逐字节 相同。 -#### 生成单元的编写文件:`.origin()`(@RELEASE@+) +#### 生成单元的编写文件:`.origin()`(2026.11.23.1+) 写出某个人工编辑文件之变换副本的 action(改写了 import 的源文件、加了前置内容的模块单元),以 `.origin(...)` 指名该文件。该文件是 action 的输入之一,action 的角色为 `source`: diff --git a/docs/zh/35-platforms.md b/docs/zh/35-platforms.md index c41e350dc..bdb8c3e28 100644 --- a/docs/zh/35-platforms.md +++ b/docs/zh/35-platforms.md @@ -93,7 +93,7 @@ runner = ["my-okrun", "{}"] 同样的表也可以写在 `~/.mcpp/config.toml` 中,对一台机器生效。图中已有包提供的层交给该包,报告为 `graph`。 C++ 运行时的包同时提供编译器运行时,因此 `"c++-abi" = false` 只有与 `compiler-runtime = false` 同时写出才生效。 -这些表在没有平台的行上同样生效(mcpp @RELEASE@):这样的行有一份空的平台陈述,为它写的 `layers`、`tools` 与 `link` +这些表在没有平台的行上同样生效(mcpp 2026.11.23.1):这样的行有一份空的平台陈述,为它写的 `layers`、`tools` 与 `link` 像在平台之上一样补全依赖图、到达链接。此前它们被接受而不起作用。`carrier` 是平台映像的形式,在这样的行上以警告报告 (`platform/carrier`)而不使用。 diff --git a/docs/zh/41-devices.md b/docs/zh/41-devices.md index b31b8164c..81a2397de 100644 --- a/docs/zh/41-devices.md +++ b/docs/zh/41-devices.md @@ -131,7 +131,7 @@ runner 是什么(`cmd`、`requires`、`host`)由其数据陈述:提供者 MCPP_TARGET_X86_64_LINUX_ANDROID_RUNNER_ENABLED=true mcpp run --target x86_64-linux-android ``` -**iOS 模拟器的程序在模拟器中运行(@RELEASE@+)。** 在 Mac 上启用后,`aarch64-ios-sim` 与 `x86_64-ios-sim` 经 +**iOS 模拟器的程序在模拟器中运行(2026.11.23.1+)。** 在 Mac 上启用后,`aarch64-ios-sim` 与 `x86_64-ios-sim` 经 `simctl-run`(`xim:apple-simulator-tools`)运行:它选择一个可用的设备,没有已启动的设备时启动它,在其中启动程序并返回其 状态。模拟器运行本机的架构(`same-arch`)。`aarch64-ios` 没有 runner:程序只有经开发者签名才能在设备上运行。 diff --git a/docs/zh/50-machine-output.md b/docs/zh/50-machine-output.md index 4d298a9e8..013ba64bc 100644 --- a/docs/zh/50-machine-output.md +++ b/docs/zh/50-machine-output.md @@ -501,7 +501,7 @@ mcpp toolchain list --format json 的形状是 `{target, note, toolchain, pin, status, default}`,`status` 取 `installed` / `available` / `via dependency graph` / `planned` 之一。 目标行另有 `platform`(2026.10.27.1+):目标表为该目标选择的平台包 -(@RELEASE@ 起为 `mcpplibs.openkal-platform@0.32.0`,2026.11.20.1 为 `@0.31.2`,2026.11.19.1 为 `@0.31.0`,2026.11.18.1 为 `@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`。 +(2026.11.23.1 起为 `mcpplibs.openkal-platform@0.32.0`,2026.11.20.1 为 `@0.31.2`,2026.11.19.1 为 `@0.31.0`,2026.11.18.1 为 `@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` 只承载目标 @@ -524,7 +524,7 @@ mcpp why toolchain [--target ] [--toolchain ] --format json | `compiler` | `{family, version, driver, chosenBy}` —— 真正会运行的驱动器,以及选中它的原因 | | `triple` | `{requested, toolchain, llvm}` | | `cLibrary` | `{mode, path, origin, suppliesTarget}` —— `mode` 取 `sysroot` / `payload-first` / `none`,`origin` 取 `payload` / `subos` / `host` / `none` | -| `layers[]` | 目标侧的五个层:`{layer, interface, impl, origin, subset, version, interfaces}`;`version` 为系统把内核头文件作为包发布时 kernel-abi 层测得的版本(其他情形为空),`interfaces` 为该层的接口(`null`:未陈述,即全部)*(@RELEASE@+)* | +| `layers[]` | 目标侧的五个层:`{layer, interface, impl, origin, subset, version, interfaces}`;`version` 为系统把内核头文件作为包发布时 kernel-abi 层测得的版本(其他情形为空),`interfaces` 为该层的接口(`null`:未陈述,即全部)*(2026.11.23.1+)* | **`compiler.chosenBy` 回答「为什么是它」。** `{origin, requiredBy, replaced}` —— `origin` 与构建的状态行使用的是同一句话 @@ -583,7 +583,7 @@ replaced}` —— `origin` 与构建的状态行使用的是同一句话 | `payload-request` | 构建程序请求了本次构建中没有任何清单声明 `provision = "on-request"` 的载荷,或连续三次运行都在请求 *(2026.10.1.3+)* | | `lto-export-discovery` | 导出需要被发现的 PE 共享库会被 cl.exe 编译成没有符号表的 `/GL` 对象:在 `lto = true` 下陈述了 `windows_auto_export = true`,或在它所链接的包的 flag 中写了 `/GL` *(2026.10.5.2+)* | | `local-toolchain` | 由路径命名的工具链,或构建程序工具链阶段陈述的工具链无法使用:没有驱动、族与驱动矛盾、缺少某个工具,或 `spec` 与只属于路径工具链的键一同陈述 *(2026.10.1.3+)* | -| `target-base` | 目标基座(`sysroot`)无法服务本次构建:该行不接受的写法、不存在的路径、不供给 C 库的目录、低于编译器运行库要求的 C 库、缺少 loader 的本机基座,或依赖图中的第二个 C 库供给者 *(2026.10.24.1+)*;内核头文件:不接受预制形式的行或层上写了 `layers` 的预制形式、载荷不带目标架构的头文件、缺省没有回答者、测量与陈述不符 *(@RELEASE@+)* | +| `target-base` | 目标基座(`sysroot`)无法服务本次构建:该行不接受的写法、不存在的路径、不供给 C 库的目录、低于编译器运行库要求的 C 库、缺少 loader 的本机基座,或依赖图中的第二个 C 库供给者 *(2026.10.24.1+)*;内核头文件:不接受预制形式的行或层上写了 `layers` 的预制形式、载荷不带目标架构的头文件、缺省没有回答者、测量与陈述不符 *(2026.11.23.1+)* | | `convention-unreplaced` | 约定被推翻了,而没有任何东西接替它 | | `os-mismatch` | 请求的三元组与解析出的三元组命名不同的系统 | | `layer-requirement` | 某个包要求的层,解析结果没有提供 | @@ -659,7 +659,7 @@ mcpp emit build-database [--spec s1|compile-commands] --format json | 字段 | | |---|---| -| `spec` | `{"name": "s1", "version": "0.4.0"}`(@RELEASE@ 之前为 0.3.0,2026.9.28.1 之前为 0.2.0);使用 `--spec compile-commands` 时为 `{"name": "compile-commands"}` | +| `spec` | `{"name": "s1", "version": "0.4.0"}`(2026.11.23.1 之前为 0.3.0,2026.9.28.1 之前为 0.2.0);使用 `--spec compile-commands` 时为 `{"name": "compile-commands"}` | | `database` | 该规范对应的文档:一份 S1 构建数据库,或者 `mcpp build --configure-only` 写入 `compile_commands.json` 的那些条目 | | `watch` | 一旦发生变化就可能改变这份文档的输入:相对工作区根目录的路径与 glob,或绝对路径 | | `inputs-fingerprint` | `fnv1a:<16 位十六进制>`,对上述输入、mcpp 版本与选择器求出的摘要 | @@ -672,7 +672,7 @@ mcpp emit build-database [--spec s1|compile-commands] --format json (S1 0.3.0 §7.2)。命令不运行任何 action,所以这样的文件在文档所指的目录中尚不存在。 每一项给出同一组选择下 `mcpp build` 写入的路径(`build-path`)以及写出它的步骤, 编辑器因此可以说明“这是生成的文件,构建一次即可”,而不是报告缺少头文件。 -自 @RELEASE@ 起,`kind` 为 `source` 的一项在其 action 以 `.origin(...)` 陈述时另有 +自 2026.11.23.1 起,`kind` 为 `source` 的一项在其 action 以 `.origin(...)` 陈述时另有 `origin`([30](30-build-mcpp.md)):生成的单元作为其变换副本的那个编写的文件(S1 0.4.0 §7.2)。 `emit` 独立规划每一个被选中的成员(#699 第 1 项):一个成员的规划失败不会 diff --git a/mcpp.toml b/mcpp.toml index 578766525..c5453e4dc 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -1,6 +1,6 @@ [package] name = "mcpp" -version = "2026.11.22.1" +version = "2026.11.23.1" description = "Modern C++ build & package management tool" license = "Apache-2.0" authors = ["mcpp-community"] diff --git a/modules/versioning/src/version.cppm b/modules/versioning/src/version.cppm index 8dbd49580..e81e4c3bd 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.22.1"; +inline constexpr std::string_view MCPP_VERSION = "2026.11.23.1"; } // namespace mcpp From a27ab1d20e98edf01495473edccedc775fb67962 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 16:38:09 +0900 Subject: [PATCH 14/33] test: a planned row answers a pattern whose rows are all planned, i686 linux (riscv64-linux-musl is preview) --- modules/toolchain-model/tests/test_target_select.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/toolchain-model/tests/test_target_select.cpp b/modules/toolchain-model/tests/test_target_select.cpp index e2e6adf90..0f0036581 100644 --- a/modules/toolchain-model/tests/test_target_select.cpp +++ b/modules/toolchain-model/tests/test_target_select.cpp @@ -117,9 +117,10 @@ UTest android_is_reached_by_name_only{"TargetSelect/AndroidIsReachedByNameOnly", }}; UTest a_planned_row_is_the_answer_only_when_alone{"TargetSelect/APlannedRowIsTheAnswerOnlyWhenAlone", [] { - auto s = on("linux-x86_64", {"riscv64-linux", "riscv64", "linux", "gnu"}); + // Every row of i686 linux is planned, so the pattern's answer is one. + auto s = on("linux-x86_64", {"i686-linux", "i686", "linux", "gnu"}); expect(fatal(s.row != nullptr)); - expect(eq(s.identity(), "riscv64-linux-musl")); + expect(eq(s.identity(), "i686-linux-gnu")); expect(eq(s.row->tier, "planned")); // x86_64-macos is planned; the musl identity beside it is not. expect(eq(on("macos-x86_64", {"x86_64-macos", "x86_64", "macos", ""}).identity(), "x86_64-macos-musl")); From 12bf326dd55232b3b2d53a905a7863e9ec4f3bf9 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 17:39:36 +0900 Subject: [PATCH 15/33] test: the bases fixture copies the kernel headers' content, which the arch layout links (xim-pkgindex#1251); the surface golden names cache gc --dry-run --- tests/e2e/golden/surface.txt | 1 + tests/e2e/openkal/bases.cpp | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/e2e/golden/surface.txt b/tests/e2e/golden/surface.txt index 0ba3f313f..e612cc1e3 100644 --- a/tests/e2e/golden/surface.txt +++ b/tests/e2e/golden/surface.txt @@ -119,6 +119,7 @@ flag cache clean --deps flag cache clean --legacy flag cache clean --std flag cache clean --tools +flag cache gc --dry-run flag cache gc --max-size flag cache gc --older-than flag cache list --format diff --git a/tests/e2e/openkal/bases.cpp b/tests/e2e/openkal/bases.cpp index b59ad3344..81f4f54d7 100644 --- a/tests/e2e/openkal/bases.cpp +++ b/tests/e2e/openkal/bases.cpp @@ -36,7 +36,7 @@ std::optional newest_version_dir(std::string_view package) { return best; } -// tests/e2e/_sysroot_fixture.sh's make_glibc_sysroot: a glibc sysroot in crosstool-ng's layout +// A glibc sysroot in crosstool-ng's layout // (usr/include, usr/lib64, lib64 -> usr/lib64) assembled from the home's glibc and linux-headers // payloads, the linker scripts' absolute paths made sysroot-relative. The glibc version // ("2.44"), or nothing when no payload is installed. @@ -49,7 +49,10 @@ std::optional make_glibc_sysroot(const fs::path& dest) { fs::create_directory_symlink("usr/lib64", dest / "lib64"); constexpr auto copy = fs::copy_options::recursive | fs::copy_options::copy_symlinks | fs::copy_options::overwrite_existing; fs::copy(*g / "include", dest / "usr/include", copy); - fs::copy(*h / "include", dest / "usr/include", copy); + // The headers' payload links `include/asm` (and the headers only some + // architectures install) into `arch//include` (xim-pkgindex#1251): + // copied as links they would dangle in the sysroot, so their content is. + fs::copy(*h / "include", dest / "usr/include", fs::copy_options::recursive | fs::copy_options::overwrite_existing); // `find /lib/ -maxdepth 1 \( -type f -o -type l \) -exec cp -a {} usr/lib64/ \;` for (const auto& e : fs::directory_iterator(*g / "lib")) { if (e.is_symlink()) fs::copy_symlink(e.path(), dest / "usr/lib64" / e.path().filename()); From 59c4f5e97921cd9ec226f35b7e595700c5cf7937 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 17:39:36 +0900 Subject: [PATCH 16/33] fix: a present root is exchanged, not renamed over (refused on Windows); e2e 1154 D and 1158 assert every build registers its roots --- src/provider/roots.cppm | 20 +++++++++++++++----- tests/e2e/cache/entries.cpp | 23 ++++++++++++++++++++++- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/provider/roots.cppm b/src/provider/roots.cppm index b5c6387c4..4a1f29541 100644 --- a/src/provider/roots.cppm +++ b/src/provider/roots.cppm @@ -16,6 +16,7 @@ import std; import mcpp.provider; import mcpp.provider.select; import mcpp.diag; +import mcpplibs.os.error; import mcpplibs.os.fs; export namespace mcpp::provider::roots { @@ -178,8 +179,11 @@ void use(const std::vector& payloads) { const auto parts = components_of(*s, *s / path_of(p)); if (!parts || !fs::is_directory(*s / path_of(p), ec)) continue; const auto name = root_name(parts->first, parts->second); - // Made under a temporary name and renamed over the root, so that the - // root is never absent and its own time is now. + // Made under a temporary name and exchanged with the root, so that its + // own time is now. A rename over a directory's link is refused on + // Windows (measured: `permission denied` on every build after the + // first), so a present root is exchanged, atomically where the volume + // can; the previous root is then removed. auto staged = dir / "."; staged += name; staged += std::format(".{:08x}", std::random_device{}()); @@ -187,9 +191,15 @@ void use(const std::vector& payloads) { report_once(made.error().message()); return; } - if (auto moved = mcpplibs::os::fs::rename(staged, dir / name, true); !moved) { - fs::remove(staged, ec); - report_once(moved.error().message()); + const auto root = dir / name; + const bool present = fs::symlink_status(root, ec).type() != fs::file_type::not_found; + auto placed = present ? mcpplibs::os::fs::exchange(staged, root) : mcpplibs::os::fs::place(staged, root); + // Another build placed it in between. + if (!placed && !present && placed.error().code == mcpplibs::os::errc::exists) + placed = mcpplibs::os::fs::exchange(staged, root); + fs::remove(staged, ec); + if (!placed) { + report_once(placed.error().message()); return; } } diff --git a/tests/e2e/cache/entries.cpp b/tests/e2e/cache/entries.cpp index b5830c8ba..5d52289e0 100644 --- a/tests/e2e/cache/entries.cpp +++ b/tests/e2e/cache/entries.cpp @@ -1,7 +1,7 @@ // The global build cache: an entry shared across projects and keyed by what it was compiled // against, the cache modes and the maintenance commands, an entry's layout, a hit's std BMI, and // the age of a std module, and the store's roots a build holds (formerly tests/e2e/172, 174, 184, -// 212, 959, 1029; 1154). +// 212, 959, 1029; 1154, 1158). import std; import mcpplibs.mtest; import mcpp.test.support; @@ -525,5 +525,26 @@ E2E entries{"entries", s::home_fixture, [] { expect(fatal(e2e::succeeded(r))) << "C: " << s::text(r); expect(fatal(e2e::contains(s::text(r), "Would release the store's root " + aged.filename().string()))) << "C: " << s::text(r); expect(fatal(fs::is_symlink(aged))) << "C: a dry run released the root"; + // D: the next build renews the root it holds, so it is no longer unused. + r = p.mcpp({"build"}, home); + expect(fatal(e2e::succeeded(r))) << "D: " << s::text(r); + expect(fatal(s::lacks(s::text(r), "were not registered"))) << "D: " << s::text(r); + r = p.mcpp({"cache", "gc", "--older-than", "30d", "--dry-run"}, home); + expect(fatal(e2e::succeeded(r))) << "D: " << s::text(r); + expect(fatal(s::lacks(s::text(r), "Would release the store's root " + aged.filename().string()))) << "D: " << s::text(r); + }; + + "1158 every build registers its roots, a present root too"_test[s::fresh_sandbox] = [] { + // Design 2026-11-22 §3.11: a root already present is replaced by the next build's on every + // system; a rename over a directory's link is refused on Windows, so it is exchanged. + const s::options home{.where = s::home::inherited}; + s::project p({{"mcpp.toml", "[package]\nname = \"held\"\nversion = \"0.1.0\"\n"}, + {"src/main.cpp", "import std;\nint main() { std::println(\"held\"); }\n"}}); + for (int build = 1; build <= 2; ++build) { + if (build == 2) p.write("src/main.cpp", "import std;\nint main() { std::println(\"held again\"); }\n"); + auto r = p.mcpp({"build"}, home); + expect(fatal(e2e::succeeded(r))) << "build " << build << ": " << s::text(r); + expect(fatal(s::lacks(s::text(r), "were not registered"))) << "build " << build << ": " << s::text(r); + } }; }}; From 93df062694a7748a4d3ac0e7b6ca5b89f2b25a09 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 17:39:36 +0900 Subject: [PATCH 17/33] fix: the held refusal of a target this host cannot serve is released before the kernel headers are decided --- src/build/prepare/target_side.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/build/prepare/target_side.cpp b/src/build/prepare/target_side.cpp index 42098265d..ac00fc34c 100644 --- a/src/build/prepare/target_side.cpp +++ b/src/build/prepare/target_side.cpp @@ -1194,16 +1194,21 @@ step9_layering_and_requirement_checks(PrepareState& state, TargetSideGather& gat if (auto conflict = cabi_identity(state); !conflict) return std::unexpected(conflict.error()); if (auto why = tsd::check_request(state.resolvedTargetSide)) mcpp::diag::warning("target", *why); + return {}; +} - // The refusal held since toolchain resolution, released now that the - // other half of its question has an answer. A payload on this machine - // does not produce this target; if the graph does not supply the - // target's system either, then nothing does and the diagnosis stands. - if (!state.unservedTargetDiagnosis.empty() - && !state.resolvedTargetSide.system_from_graph()) { - refusal::record(refusal::Code::HostCannotServe); - return std::unexpected(state.unservedTargetDiagnosis); - } +// The refusal held since toolchain resolution, released as soon as the other +// half of its question has an answer: the target side. A payload on this +// machine does not produce this target; if the graph does not supply the +// target's system either, then nothing does and the diagnosis stands. It comes +// before every decision that presumes a system to build for -- the kernel +// headers above all, which would otherwise refuse first and name a remedy that +// cannot help (e2e 890 on a macOS host). +static std::expected step9_host_cannot_serve(PrepareState& state) { + if (!state.unservedTargetDiagnosis.empty() && !state.resolvedTargetSide.system_from_graph()) { + refusal::record(refusal::Code::HostCannotServe); + return std::unexpected(state.unservedTargetDiagnosis); + } return {}; } @@ -2142,6 +2147,7 @@ std::expected phase9_target_side(PrepareState& state) { if (!gather) return std::unexpected(gather.error()); if (auto r = step9_resolve_and_realise_cabi(state, *gather); !r) return std::unexpected(r.error()); + if (auto r = step9_host_cannot_serve(state); !r) return std::unexpected(r.error()); if (auto r = step9_kernel_headers(state); !r) return std::unexpected(r.error()); step9_kernel_abi_interfaces(state); if (auto r = step9_target_side_include_broadcast(state, *gather); !r) From 4a8762f84eccc4e3382f530cc7f006d3d0e9cafe Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 19:04:23 +0900 Subject: [PATCH 18/33] fix: a compiler-run generation is renamed out of use before it is removed, and a cut removal's remainder is removed by the next build (e2e 936 H) --- CHANGELOG.md | 5 +++ src/build/schedule/compiler_transaction.cppm | 12 +++++- src/build/schedule/detach_codegen.cppm | 40 ++++++++++++++++---- tests/unit/test_compiler_transaction.cpp | 9 +++++ 4 files changed, 56 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8c14dbed..85c244bf0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -100,6 +100,11 @@ libc++ is arm64 only. - `mcpp pack --all-programs` on `wasm32-emscripten` packs each program's module beside its launcher. Before, only the program named after the package had its `.wasm` (mcpp#1007). +- A build ended by a signal while it removed its compiler-run state no longer leaves the + configuration unbuildable. The removal could be cut short and leave a compiler unit without its + prepared transaction, which every later build refused ("compiler unit without prepared + transaction") until `mcpp clean`. The state is now renamed out of use before it is removed, and + such a remainder from an earlier version is removed by the next build. ## [2026.11.22.1] - 2026-11-22 diff --git a/src/build/schedule/compiler_transaction.cppm b/src/build/schedule/compiler_transaction.cppm index 67adc8257..55f4a6325 100644 --- a/src/build/schedule/compiler_transaction.cppm +++ b/src/build/schedule/compiler_transaction.cppm @@ -707,8 +707,16 @@ std::expected recover_generation(const fs::path& generatio if(!prepared)return std::unexpected(prepared.error()); if(!*prepared) { // Preparation's atomic record precedes every modification. - // An empty, unreferenced staging directory has no outputs. - if(fs::exists(entry.path()/"unit",ec)||fs::exists(entry.path()/"admitted",ec))return std::unexpected("compiler unit without prepared transaction"); + // An empty, unreferenced staging directory has no outputs. An + // attempt with a unit and no preparation is therefore what a + // removal cut short left of a generation recovered before it + // (a build ended by a signal while it retired one, up to + // 2026.11.22.1): nothing of it is pending, and it goes. It was + // refused, and every later build of the configuration with it. + if(fs::exists(entry.path()/"unit",ec)||fs::exists(entry.path()/"admitted",ec)) { + fs::remove_all(entry.path(),ec); + if(ec)return std::unexpected("cannot remove the remainder of a retired compiler transaction"); + } continue; } auto attempt=Attempt::load(entry.path());if(!attempt)return std::unexpected(attempt.error()); diff --git a/src/build/schedule/detach_codegen.cppm b/src/build/schedule/detach_codegen.cppm index 475eb0126..c5930fccc 100644 --- a/src/build/schedule/detach_codegen.cppm +++ b/src/build/schedule/detach_codegen.cppm @@ -344,6 +344,33 @@ bool drain_actors(const std::filesystem::path& generation) { return false; } +// A GENERATION IS RETIRED BY A RENAME, THEN REMOVED. Its removal is not +// atomic, and a build ended by a signal can end inside it: the signal's thread +// ends the process while the build's thread retires the generation. A removal +// cut short left an attempt whose `unit` outlived its `prepared` record, which +// recovery refuses ("compiler unit without prepared transaction", e2e 936 H), +// and every later build of the configuration with it. Renamed out of the +// `run-` names first, the generation is no longer one recovery reads; what a +// cut removal leaves is swept by the next build. +std::expected retire_generation(const std::filesystem::path& generation) { + auto retired = generation.parent_path() / "retired-"; + retired += generation.filename(); + std::error_code ec; + std::filesystem::rename(generation, retired, ec); + if (ec) return std::unexpected(std::format("cannot retire {}: {}", mcpp::home::spelling(generation), ec.message())); + std::filesystem::remove_all(retired, ec); + return {}; +} + +// What a removal cut short left: no build reads it, so a removal that fails +// again (a file still held on Windows) is retried by the next build. +void sweep_retired(const std::filesystem::path& root) { + std::error_code ec; + for (const auto& entry : std::filesystem::directory_iterator(root, ec)) + if (entry.path().filename().native().starts_with(std::filesystem::path("retired-").native())) + std::filesystem::remove_all(entry.path(), ec); +} + void withdraw_outputs(const std::filesystem::path& slot, const std::filesystem::path& object = {}) { std::error_code ec; @@ -768,9 +795,7 @@ struct RunScope::State { } auto recovered = transactions::recover_generation(generation,witnesses ? &witnesses->observers() : nullptr); if (!recovered) { failure=recovered.error(); return std::unexpected(failure); } - std::error_code ec; - std::filesystem::remove_all(generation, ec); - if(ec) {failure="cannot retire completed compiler runtime state";return std::unexpected(failure);} + if(auto retired=retire_generation(generation);!retired) {failure=retired.error();return std::unexpected(failure);} if(witnesses&&witnesses->failed()) { failure="a compiler controller ended before completion; incomplete outputs were recovered"; return std::unexpected(failure); @@ -831,10 +856,9 @@ std::expected retire_compiler_runs(const std::filesystem::pat "an mcpp is building {}: the helpers of {} hold its locks; it was not cleaned", mcpp::home::spelling(outputDir), mcpp::home::spelling(entry.path()))); } - std::filesystem::remove_all(entry.path(), ec); - if (ec) return std::unexpected(std::format("cannot retire {}: {}", - mcpp::home::spelling(entry.path()), ec.message())); + if (auto retired = retire_generation(entry.path()); !retired) return std::unexpected(retired.error()); } + sweep_retired(located->root); return {}; } @@ -882,9 +906,9 @@ std::expected RunScope::begin(const std::filesystem::path recovered->unobservable, recovered->unobservable==1?"":"s", mcpp::home::spelling(entry.path())), "a compiler that outlived its controller in that process space is not found; a late " "write is caught by the next build, which compiles that unit again"); - std::filesystem::remove_all(entry.path(), ec); - if (ec) return std::unexpected("cannot retire previous compiler-run state"); + if (auto retired = retire_generation(entry.path()); !retired) return std::unexpected(retired.error()); } + sweep_retired(state->root); // Old owners, actors and units are quiet before cached output recovery; // no Ninja reader from this generation has started yet. // What the recovered attempts wrote below themselves goes with them diff --git a/tests/unit/test_compiler_transaction.cpp b/tests/unit/test_compiler_transaction.cpp index 1c301ba80..9597cddc6 100644 --- a/tests/unit/test_compiler_transaction.cpp +++ b/tests/unit/test_compiler_transaction.cpp @@ -130,6 +130,15 @@ UTest unobservable_admitted_unit_retains_its_reservation_and_every_output{"Compi auto available=tx::reservation_available(t.reservation);expect(fatal(bool(available)));expect(!(*available)); expect(eq(Transaction::contents(t.object), "still writable"));expect(fs::exists(t.reservation)); }}; +UTest a_unit_without_preparation_is_the_remainder_of_a_retired_generation{"CompilerTransaction/AUnitWithoutPreparationIsTheRemainderOfARetiredGeneration", [] { + // A removal cut short after recovery left `unit` without `prepared`: the + // next recovery removes it rather than refusing every later build. + Transaction t;auto a=t.prepare();t.admitted(a); + fs::remove(a.directory/"prepared"); + auto recovered=tx::recover_generation(t.generation); + expect(fatal(bool(recovered))) << (recovered ? std::string() : recovered.error()); + expect(!fs::exists(a.directory)); +}}; UTest malformed_certificate_never_releases_capacity{"CompilerTransaction/MalformedCertificateNeverReleasesCapacity", [] { Transaction t;auto a=t.prepare();t.admitted(a); expect(fatal(bool(tx::publish(a.directory/"retired","mcpp-retired-v1",{"not-a-status","missing","missing"})))); From e14244ede8fc46a77d25c0639faf888bcc108aaf Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 20:21:08 +0900 Subject: [PATCH 19/33] ci: the release's full run (ci:full, ci:canaries) From d7d73379d0d2cf96ae21cbbbf0e983d0484cd2de Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 21:35:20 +0900 Subject: [PATCH 20/33] ci: the upgrade lane spells 2026.11.23.1, the matrix declares the measured riscv64-linux-musl cells, the iOS row check reads only stated keys A Linux compile names the kernel headers it was decided to use, so a dependency interface cached by 2026.11.22.1 is compiled once more: the lane's spelling moves to this release. The matrix states the riscv64-linux-musl cells each host measured; the graph mode skips riscv64 Linux rows, since openkal-linux implements no riscv64 Linux. The iOS step that removes the fixture's runner checks keys, not the comment that names simctl-run. --- ...face-and-derived-state-ecosystem-design.md | 2 +- .github/tools/upgrade_lane.sh | 10 ++++---- .github/workflows/ci-macos-ios.yml | 2 +- CHANGELOG.md | 2 ++ tests/matrix/expected.tsv | 23 ++++++++----------- tests/matrix/scan.sh | 16 +++++++++++++ 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md index 1b22a256e..027e0dfc1 100644 --- a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md +++ b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md @@ -662,7 +662,7 @@ graph LR 自己的请求(版本组参与解析,§7.5)。K1 因此不改动 openkal-platform,K4 不依赖它。 9. **索引中的行(§3.19)。** `riscv64-linux-musl`:x86_64 上的 musl 交叉载荷构建、静态链接,并在 qemu-user 下运行;该载荷的 sysroot 不带内核头文件(`aarch64-linux-musl-gcc` 带 4.19.88),由其描述文件声明 `linux-headers` 6.18.64,修订 1 带 - riscv64 的头文件。行升为 `preview`,运行器为 `xim:qemu-user-riscv64`。`i686-linux-gnu` 与 `wasm32-wasi` 在索引中没有 + riscv64 的头文件。行升为 `preview`,运行器为 `xim:qemu-user-riscv64`。支持矩阵的测定:载荷模式下 linux-x86_64 × gcc 为 `ok`,其余宿主与编译器各以其拒绝理由给出;图模式(openkal-musl 0.3.5 与 openkal-llvm-runtime 0.1.3)不服务该行,openkal-linux 0.5.4 只实现 x86_64 与 aarch64(0.27.0 加 i386),构建在其 `sys.h` 的架构断言处失败,矩阵的图模式因此略过 `riscv64-linux-*`,理由写在 `tests/matrix/scan.sh`。`i686-linux-gnu` 与 `wasm32-wasi` 在索引中没有 基座载荷与编译器运行时,保持 `planned` 与未登记。iOS 模拟器的两行以 `simctl-run` 为运行器,`enabled = false`。 `x86_64-macos` 在 Apple silicon 的运行器上经 Rosetta 测定(探针工作流):链接原先不带 `--target`,按 arm64 链接 x86_64 的目标文件而找不到 `main`;链接改为凡编译指名目标即指名之后,C 程序链接为 x86_64 并在 Rosetta 下运行。C++ 程序仍不能 diff --git a/.github/tools/upgrade_lane.sh b/.github/tools/upgrade_lane.sh index 87277bad8..52af7885b 100644 --- a/.github/tools/upgrade_lane.sh +++ b/.github/tools/upgrade_lane.sh @@ -263,10 +263,12 @@ if [ "$VARIANT" = modules ]; then # A BMI of another spelling is not read: the dependency is rebuilt once (its # cache key carries the spelling), then served from the cache. The spelling # moved in 2026.10.26.2 (the module map's `$root`), in 2026.11.19.1 (a - # package instance's directory, mcpp#953) and in 2026.11.21.1 (an instance - # is its configuration's, mcpp#986); a previous release from the last move - # on spells as this one, and its entry is served at once. - spelled_since=2026.11.21.1 + # package instance's directory, mcpp#953), in 2026.11.21.1 (an instance + # is its configuration's, mcpp#986) and in 2026.11.23.1 (a Linux compile + # names the kernel headers it was decided to use, design 2026-11-22 §3.1); a + # previous release from the last move on spells as this one, and its entry + # is served at once. + spelled_since=2026.11.23.1 # The directory a served BMI is staged into: `./` before # 2026.11.21.1, `_//` from it (mcpp#986). Either # is the dependency's; the staging, not the directory's name, is asserted. diff --git a/.github/workflows/ci-macos-ios.yml b/.github/workflows/ci-macos-ios.yml index dba56aaee..be42711dd 100644 --- a/.github/workflows/ci-macos-ios.yml +++ b/.github/workflows/ci-macos-ios.yml @@ -384,7 +384,7 @@ jobs: s = re.sub(r'\[target\.aarch64-ios-sim\.xlings\.workspace\]\n"xim:apple-simulator-tools" = ""\n', '', s) open("mcpp.toml", "w").write(s) PY - if grep -q simctl-run mcpp.toml; then echo "FAIL: the fixture still states a runner"; exit 1; fi + if grep -qE '^[^#]*(simctl-run|apple-simulator-tools)' mcpp.toml; then echo "FAIL: the fixture still states a runner"; exit 1; fi out=$("$MCPP_FRESH" run --target aarch64-ios-sim 2>&1) && rc=0 || rc=$? printf '%s\n' "$out" | tail -8 [ "$rc" -eq 2 ] || { echo "FAIL: a run before consent exited $rc, not 2"; exit 1; } diff --git a/CHANGELOG.md b/CHANGELOG.md index 85c244bf0..7a1aca814 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -68,6 +68,8 @@ was built with, instead of the 5.11.1 the home's shared view linked to. The shared view is no longer read for kernel headers, and mcpp no longer writes kernel headers into it; with neither answer the build is refused before it compiles and names the statement to write. + A Linux compile names the headers it was decided to use, so a dependency's module interface + cached by an earlier version is compiled once more, then served from the cache. ### Fixed diff --git a/tests/matrix/expected.tsv b/tests/matrix/expected.tsv index a93e6c4e9..e5ad5b65c 100644 --- a/tests/matrix/expected.tsv +++ b/tests/matrix/expected.tsv @@ -18,6 +18,8 @@ # unsupported / std-module-precompile std 模块预编译不过 # unsupported / platform-version-group 图里有平台版本组之外的同族版本(graph 模式钉的 openkal-musl 0.3.5 与 # openkal-llvm-runtime 0.1.3,ok 映像行的平台是 openkal-platform) +# unsupported / platform-target-unserved 选定的平台不服务这个目标(不在它的 `targets` 中,也没有宿主三元组的 +# `[platform.hosted]`) # # 这张表里**没有 `other`**,而这是一条不变量而不是巧合。`other` 在 # `src/build/refusal.cppm` 里的定义是「拒绝了而这一处分支还没有名字」,所以一行 @@ -122,8 +124,6 @@ graph linux-aarch64 i686-linux-musl gcc@16.1.0 - - - - - unsupported capability- graph linux-aarch64 i686-linux-musl llvm@23.1.3 - - - - - unsupported platform-version-group graph linux-aarch64 i686-openkal gcc@16.1.0 - - - - - unsupported capability-pin graph linux-aarch64 i686-openkal llvm@23.1.3 - - - - - unsupported platform-version-group -graph linux-aarch64 riscv64-linux-musl gcc@16.1.0 - - - - - unsupported tier-planned -graph linux-aarch64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported tier-planned graph linux-aarch64 wasm32-emscripten gcc@16.1.0 - - - - - unsupported capability-pin graph linux-aarch64 wasm32-emscripten llvm@23.1.3 - - - - - unsupported capability-pin graph linux-aarch64 x86_64-freebsd-musl gcc@16.1.0 - - - - - unsupported capability-pin @@ -158,8 +158,6 @@ graph linux-x86_64 i686-linux-musl gcc@16.1.0 - - - - - unsupported capability-p graph linux-x86_64 i686-linux-musl llvm@23.1.3 - - - - - unsupported platform-version-group graph linux-x86_64 i686-openkal gcc@16.1.0 - - - - - unsupported capability-pin graph linux-x86_64 i686-openkal llvm@23.1.3 - - - - - unsupported platform-version-group -graph linux-x86_64 riscv64-linux-musl gcc@16.1.0 - - - - - unsupported tier-planned -graph linux-x86_64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported tier-planned graph linux-x86_64 wasm32-emscripten gcc@16.1.0 - - - - - unsupported capability-pin graph linux-x86_64 wasm32-emscripten llvm@23.1.3 - - - - - unsupported capability-pin graph linux-x86_64 x86_64-freebsd-musl gcc@16.1.0 - - - - - unsupported capability-pin @@ -189,7 +187,6 @@ graph macos-arm64 aarch64-windows-gnu llvm@23.1.3 - - - - - unsupported std-modu graph macos-arm64 i686-linux-gnu llvm@23.1.3 - - - - - unsupported tier-planned graph macos-arm64 i686-linux-musl llvm@23.1.3 - - - - - unsupported platform-version-group graph macos-arm64 i686-openkal llvm@23.1.3 - - - - - unsupported platform-version-group -graph macos-arm64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported tier-planned graph macos-arm64 wasm32-emscripten llvm@23.1.3 - - - - - unsupported capability-pin graph macos-arm64 x86_64-freebsd-musl llvm@23.1.3 - - - - - unsupported platform-version-group graph macos-arm64 x86_64-linux-android llvm@23.1.3 - - - - - unsupported capability-pin @@ -217,8 +214,6 @@ graph windows-x86_64 i686-linux-musl llvm@23.1.3 - - - - - unsupported platform- graph windows-x86_64 i686-linux-musl msvc@system - - - - - unsupported capability-pin graph windows-x86_64 i686-openkal llvm@23.1.3 - - - - - unsupported platform-version-group graph windows-x86_64 i686-openkal msvc@system - - - - - unsupported capability-pin -graph windows-x86_64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported tier-planned -graph windows-x86_64 riscv64-linux-musl msvc@system - - - - - unsupported tier-planned graph windows-x86_64 wasm32-emscripten llvm@23.1.3 - - - - - unsupported capability-pin graph windows-x86_64 wasm32-emscripten msvc@system - - - - - unsupported capability-pin graph windows-x86_64 x86_64-freebsd-musl llvm@23.1.3 - - - - - unsupported platform-version-group @@ -267,8 +262,8 @@ payload linux-aarch64 i686-openkal gcc@16.1.0 - - - - - unsupported capability-p payload linux-aarch64 i686-openkal llvm@23.1.3 i686-unknown-none-elf payload musl(platform) libc++(platform) openkal-llvm-runtime@0.20.3 ok none payload linux-aarch64 riscv32-none-elf gcc@16.1.0 - - - - - unsupported capability-pin payload linux-aarch64 riscv32-none-elf llvm@23.1.3 riscv32-none-elf payload - - - ok none -payload linux-aarch64 riscv64-linux-musl gcc@16.1.0 - - - - - unsupported tier-planned -payload linux-aarch64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported tier-planned +payload linux-aarch64 riscv64-linux-musl gcc@16.1.0 - - - - - unsupported host-cannot-serve +payload linux-aarch64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported platform-target-unserved payload linux-aarch64 riscv64-none-elf gcc@16.1.0 - - - - - unsupported capability-pin payload linux-aarch64 riscv64-none-elf llvm@23.1.3 riscv64-none-elf payload - - - ok none payload linux-aarch64 thumbv6m-none-eabi gcc@16.1.0 - - - - - unsupported capability-pin @@ -331,8 +326,8 @@ payload linux-x86_64 i686-openkal gcc@16.1.0 - - - - - unsupported capability-pi payload linux-x86_64 i686-openkal llvm@23.1.3 i686-unknown-none-elf payload musl(platform) libc++(platform) openkal-llvm-runtime@0.20.3 ok none payload linux-x86_64 riscv32-none-elf gcc@16.1.0 - - - - - unsupported capability-pin payload linux-x86_64 riscv32-none-elf llvm@23.1.3 riscv32-none-elf payload - - - ok none -payload linux-x86_64 riscv64-linux-musl gcc@16.1.0 - - - - - unsupported tier-planned -payload linux-x86_64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported tier-planned +payload linux-x86_64 riscv64-linux-musl gcc@16.1.0 riscv64-unknown-linux-musl payload musl(payload) libstdc++(payload) - ok none +payload linux-x86_64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported convention-unreplaced payload linux-x86_64 riscv64-none-elf gcc@16.1.0 - - - - - unsupported capability-pin payload linux-x86_64 riscv64-none-elf llvm@23.1.3 riscv64-none-elf payload - - - ok none payload linux-x86_64 thumbv6m-none-eabi gcc@16.1.0 - - - - - unsupported capability-pin @@ -387,7 +382,7 @@ payload macos-arm64 i686-linux-musl llvm@23.1.3 i686-unknown-linux-musl host mus payload macos-arm64 i686-none-elf llvm@23.1.3 i686-none-elf host - - - ok none payload macos-arm64 i686-openkal llvm@23.1.3 i686-unknown-none-elf host musl(platform) libc++(platform) openkal-llvm-runtime@0.20.3 ok none payload macos-arm64 riscv32-none-elf llvm@23.1.3 riscv32-none-elf host - - - ok none -payload macos-arm64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported tier-planned +payload macos-arm64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported platform-target-unserved payload macos-arm64 riscv64-none-elf llvm@23.1.3 riscv64-none-elf host - - - ok none payload macos-arm64 thumbv6m-none-eabi llvm@23.1.3 thumbv6m-none-eabi host - - - ok none payload macos-arm64 thumbv7em-none-eabi llvm@23.1.3 thumbv7em-none-eabi host - - - ok none @@ -435,8 +430,8 @@ payload windows-x86_64 i686-openkal llvm@23.1.3 i686-unknown-none-elf none musl( payload windows-x86_64 i686-openkal msvc@system - - - - - unsupported capability-pin payload windows-x86_64 riscv32-none-elf llvm@23.1.3 riscv32-none-elf none - - - ok none payload windows-x86_64 riscv32-none-elf msvc@system - - - - - unsupported capability-pin -payload windows-x86_64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported tier-planned -payload windows-x86_64 riscv64-linux-musl msvc@system - - - - - unsupported tier-planned +payload windows-x86_64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported platform-target-unserved +payload windows-x86_64 riscv64-linux-musl msvc@system - - - - - unsupported convention-unreplaced payload windows-x86_64 riscv64-none-elf llvm@23.1.3 riscv64-none-elf none - - - ok none payload windows-x86_64 riscv64-none-elf msvc@system - - - - - unsupported capability-pin payload windows-x86_64 thumbv6m-none-eabi llvm@23.1.3 thumbv6m-none-eabi none - - - ok none diff --git a/tests/matrix/scan.sh b/tests/matrix/scan.sh index a95f59af8..04027fc4d 100755 --- a/tests/matrix/scan.sh +++ b/tests/matrix/scan.sh @@ -209,6 +209,22 @@ scan_cell() { return fi + # riscv64 的 Linux 行同理,理由同样是一条实测,属于这套依赖而不属于 mcpp。 + # + # 实测 2026-11-23(linux-x86_64,llvm@23.1.3):目标侧解析给出 musl(graph), + # 构建进入 openkal-musl 0.3.5 在 Linux 上依赖的 openkal-linux 0.5.4,而它 + # 只实现两种架构: + # + # openkal-linux-0.5.4/src/sys.h:178:2: error: "openkal-linux supports x86_64 and aarch64" + # + # 当前的 0.27.0 实现 x86_64、aarch64 与 i386,仍不含 riscv64。这一行由 musl + # 交叉载荷服务(payload 模式实测 `ok / none`);openkal 这一族没有 riscv64 的 + # Linux 实现,图供给不了它。判据是那条诊断与 openkal-linux 的架构集合。 + if [ "$MODE" = graph ] && printf '%s' "$t" | grep -qE -- '^riscv64-linux-'; then + echo "scan: 略过 graph × $t —— openkal-linux 没有 riscv64 的实现(0.5.4 为 x86_64/aarch64,0.27.0 加 i386),见 scan.sh 注释" >&2 + return + fi + # The compiler is the project's default, for the query and the build alike. A toolchain named # for the build (`--toolchain`) opts a planned row in (2026.11.13.1), so a query that named it # would answer a question the build below does not ask. From 7d2c6ff1717732d4ae5a536b0ccd4d34e06c669c Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 22:04:16 +0900 Subject: [PATCH 21/33] fix: a compiler's registration is answered on the one connection while the build holds it The controller awaited the answer for two seconds and then sent the request again within a ten-second grace, so under load each retry queued a duplicate on the owner, which answers one registration at a time, and a registration failed while its owner was alive (Windows CI, the target matrix's x86_64-macos cell). The answer is awaited on the connection that carries the request until the owner answers or closes it; a closed connection is sent again within the grace. --- src/build/schedule/compiler_transaction.cppm | 47 +++++++++++++------ tests/unit/test_compiler_transaction.cpp | 48 ++++++++++++++++++++ 2 files changed, 81 insertions(+), 14 deletions(-) diff --git a/src/build/schedule/compiler_transaction.cppm b/src/build/schedule/compiler_transaction.cppm index 55f4a6325..baf0001fe 100644 --- a/src/build/schedule/compiler_transaction.cppm +++ b/src/build/schedule/compiler_transaction.cppm @@ -378,15 +378,28 @@ std::string_view describe(Controller c) { return c==Controller::running ? "running" : c==Controller::ended ? "ended" : "unknown"; } -std::expected receive(os::ipc::connection& connection,std::chrono::milliseconds bound) { - const auto limit=std::chrono::steady_clock::now()+bound; +// One frame of the registration channel. A bounded read (the owner reading a +// request) ends at its bound; an unbounded one (a controller awaiting its +// answer) waits while the peer holds the connection, which only a live owner +// does, and ends when the peer closes it. +std::expected receive(os::ipc::connection& connection, + std::optional bound) { + const auto limit=std::chrono::steady_clock::now()+bound.value_or(std::chrono::milliseconds(0)); auto exact=[&](std::size_t n)->std::expected { std::string bytes; while(bytes.size()(limit-std::chrono::steady_clock::now()); - if(left.count()<=0)return std::unexpected("compiler registration acknowledgement timed out"); + auto left=std::chrono::milliseconds(1000); + if(bound) { + left=std::chrono::duration_cast(limit-std::chrono::steady_clock::now()); + if(left.count()<=0)return std::unexpected("compiler registration acknowledgement timed out"); + } auto got=connection.read_for(left,n-bytes.size()); - if(!got||!*got||(**got).empty())return std::unexpected("compiler registration channel closed or timed out"); + if(!got)return std::unexpected("compiler registration channel failed: "+got.error().message()); + if(!*got) { + if(bound)return std::unexpected("compiler registration acknowledgement timed out"); + continue; // the owner holds the connection and has not answered yet + } + if((**got).empty())return std::unexpected("compiler registration channel closed"); bytes+=**got; } return bytes; @@ -411,20 +424,26 @@ std::expected Attempt::register_unit(os::process::owned_unit& auto transport=read(generation/"transport","mcpp-unit-transport-v1"); if(!transport||!*transport||(**transport).size()!=2)return std::unexpected("missing compiler-run registration channel"); // THE OWNER ANSWERS ONE REGISTRATION AT A TIME, between its audits of the - // units it holds, so under load an answer can take longer than one wait for - // it (macOS CI: "compiler registration channel closed or timed out" on a scan - // of a two-configuration workspace). A registration the owner accepted the - // connection of and did not answer is sent again within the startup grace; - // the owner admits a unit under its attempt's name, so a late first answer - // and a second registration admit the same unit once. An owner that accepts - // no connection has ended (a build killed with its controllers still - // starting), and the controller ends at once, as the next build waits for + // units it holds, so under load an answer takes as long as the requests + // before it. The answer is awaited on the connection that carries the + // request for as long as the owner holds that connection: a live owner + // answers every request it reads, and a connection it has not yet accepted + // waits in its queue. A controller that gave up after a fixed wait and sent + // the request again added a duplicate to that queue with every retry, and a + // registration failed while its owner was alive and working through them + // (macOS CI on a two-configuration workspace; Windows CI, the target + // matrix's x86_64-macos cell: "compiler registration channel closed or + // timed out" after the startup grace). A closed connection is sent again + // within the startup grace: the owner closes one whose request it could not + // read within its own bound, and admits a unit under its attempt's name, so + // a repeated request admits it once. An owner that has ended accepts no + // connection, and the controller ends at once, as the next build waits for // it. A refusal is final. const auto deadline=std::chrono::steady_clock::now()+kStartupGrace; for(;;) { auto connection=os::ipc::connection::connect(named((**transport)[0]),(**transport)[1]); if(!connection||!send(*connection,spelling(directory)))return std::unexpected("cannot register the compiler unit"); - auto ack=receive(*connection,std::chrono::seconds(2)); + auto ack=receive(*connection,std::nullopt); if(ack&&*ack=="ACK")return {}; // THE OWNER SAYS WHY (§10.3 F): `REFUSED `. A record it // could not yet read is retried within the startup grace, as an diff --git a/tests/unit/test_compiler_transaction.cpp b/tests/unit/test_compiler_transaction.cpp index 9597cddc6..757977327 100644 --- a/tests/unit/test_compiler_transaction.cpp +++ b/tests/unit/test_compiler_transaction.cpp @@ -7,6 +7,7 @@ import mcpp.invocation; import mcpp.runtime.elf; import mcpplibs.os.platform; import mcpplibs.os.fs; +import mcpplibs.os.ipc; using namespace mcpplibs::mtest; @@ -439,3 +440,50 @@ UTest an_unobservable_unit_is_settled_when_the_caller_holds_the_locks{"CompilerT expect(fatal(bool(settled)));expect(*settled);expect(eq(met.unobservable, 1u)); expect(eq(Transaction::contents(t.bmi), "verified old BMI")); }}; + +// A REGISTRATION IS ANSWERED ON THE CONNECTION THAT CARRIES IT. The owner answers +// one registration at a time, so an answer can take longer than any fixed wait; +// the controller awaits it there for as long as the owner holds the connection, +// and sends nothing again (Windows CI: a controller that resent its request after +// two seconds of silence queued duplicates and failed while its owner lived). +UTest a_late_answer_is_received_on_the_one_connection{"CompilerTransaction/ALateAnswerIsReceivedOnTheOneConnection", [] { + Transaction t; + auto listener=mcpplibs::os::ipc::listener::listen(t.root,"late"); + expect(fatal(bool(listener))); + std::atomic accepted{0}; + std::jthread owner([&] { + auto c=listener->accept(); + if(!c)return; + ++accepted; + auto request=tx::receive(*c,std::chrono::milliseconds(2000)); + std::this_thread::sleep_for(std::chrono::milliseconds(2500)); // past the old two-second wait + if(request&&*request=="register")tx::send(*c,"ACK"); + }); + auto c=mcpplibs::os::ipc::connection::connect(t.root,"late"); + expect(fatal(bool(c))); + expect(fatal(tx::send(*c,"register"))); + auto answer=tx::receive(*c,std::nullopt); + if (auto&& failed = expect(fatal(bool(answer))); !failed) failed <accept(); + if(!c)return; + (void)tx::receive(*c,std::chrono::milliseconds(2000)); + std::this_thread::sleep_for(std::chrono::milliseconds(300)); + }); // the connection closes as the owner's handle goes + auto c=mcpplibs::os::ipc::connection::connect(t.root,"closed"); + expect(fatal(bool(c))); + expect(fatal(tx::send(*c,"register"))); + auto answer=tx::receive(*c,std::nullopt); + expect(!answer); + owner.join(); +}}; From 277e0a819e561eeee76547faf0b3f9496ba45f63 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 23:10:18 +0900 Subject: [PATCH 22/33] fix: mcpp test over several legs names a leg that did not build, in its section and in the summary --- src/build/execute.cppm | 18 +++++++++++++----- tests/e2e/openkal/sets.cpp | 13 ++++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/build/execute.cppm b/src/build/execute.cppm index b89f60f3a..8b37f5bed 100644 --- a/src/build/execute.cppm +++ b/src/build/execute.cppm @@ -7909,7 +7909,7 @@ export int run_test_legs(std::span passthrough, // ── run, one leg after another ── int rc = 0; - int passed = 0, failed = 0, notRun = 0, builtNotRun = 0; + int passed = 0, failed = 0, notRun = 0, builtNotRun = 0, unbuilt = 0; std::vector reasons; auto worse = [&](int r) { // 1 (a test failed) outranks 2 (an answer not established), which @@ -7924,6 +7924,7 @@ export int run_test_legs(std::span passthrough, else mcpp::ui::info("Testing", std::format("on {}", l.triple)); if (l.programsFailed) { mcpp::ui::error(std::format("the {} leg: the package's programs did not build", l.triple)); + ++unbuilt; worse(1); continue; } @@ -7931,8 +7932,13 @@ export int run_test_legs(std::span passthrough, if (json) std::println("{{\"error\":\"package\",\"compile_output\":\"{}\"}}", test_json_escape(l.packageError->diagnosticOutput)); - if (!l.packageError->reported) mcpp::ui::error(l.packageError->message); + // A build error reported as it happened is named again here, where the + // leg's section would otherwise be empty. + if (!l.packageError->reported) + mcpp::ui::error(std::format("the {} leg: {}", l.triple, l.packageError->message)); + else mcpp::ui::error(std::format("the {} leg did not build (reported above)", l.triple)); mcpp::ui::block(l.packageError->diagnosticOutput); + ++unbuilt; worse(1); continue; } @@ -7962,8 +7968,8 @@ export int run_test_legs(std::span passthrough, const bool noneRan = !testOpts.noRun && passed + failed == 0 && rc != 1; if (json) { std::println("{{\"legs_summary\":{{\"legs\":{},\"passed\":{},\"failed\":{}," - "\"not_run\":{},\"built\":{},\"none_ran\":{}}}}}", - legs.size(), passed, failed, notRun, builtNotRun, noneRan ? "true" : "false"); + "\"not_run\":{},\"built\":{},\"unbuilt\":{},\"none_ran\":{}}}}}", + legs.size(), passed, failed, notRun, builtNotRun, unbuilt, noneRan ? "true" : "false"); std::fflush(libc::stdout()); } if (noneRan) { @@ -7974,8 +7980,10 @@ export int run_test_legs(std::span passthrough, return 1; } if (!json) - mcpp::ui::result("legs result", std::format("{} legs; {} passed; {} failed{}{}", + mcpp::ui::result("legs result", std::format("{} legs; {} passed; {} failed{}{}{}", legs.size(), passed, failed, + unbuilt ? std::format("; {} {} did not build", unbuilt, unbuilt == 1 ? "leg" : "legs") + : std::string{}, builtNotRun ? std::format("; {} built, not run", builtNotRun) : std::string{}, notRun ? std::format("; {} not run", notRun) : std::string{})); if (rc != 0 || testOpts.archive.empty()) return rc; diff --git a/tests/e2e/openkal/sets.cpp b/tests/e2e/openkal/sets.cpp index ab2aec83b..e58e1e376 100644 --- a/tests/e2e/openkal/sets.cpp +++ b/tests/e2e/openkal/sets.cpp @@ -84,7 +84,8 @@ E2E sets{"sets", s::home_fixture, timeout{std::chrono::minutes{45}}, [] { // leg; C run runs this machine's leg and says which, and --print-launch describes the // selected leg; D test runs this machine's leg and reports the other built, not run; E // legs that ran no test fail; F self env reports both legs; G refusals: `none`, - // `linux-msvc`, a set in [build] target. + // `linux-msvc`, a set in [build] target; H a leg whose build fails is named in its + // section and counted in the summary. needs_image_row(); const std::string ht = std::string(host_arch) + "-openkal", ot = std::string(other_arch) + "-openkal"; const auto tmp = s::case_dir(); @@ -156,6 +157,16 @@ E2E sets{"sets", s::home_fixture, timeout{std::chrono::minutes{45}}, [] { s::project bt(tmp / "bt", {{"mcpp.toml", "[package]\nname = \"bt\"\nversion = \"0.1.0\"\n[build]\ntarget = \"openkal\"\n"}, {"src/main.cpp", "int main() {}\n"}}); r = bt.mcpp({"build"}); expect(fatal(failed(r) && e2e::contains(s::text(r), "names a target set"))) << "G: a set in [build] target is not refused: " << s::text(r); + // H + s::project half(tmp / "half", {{"mcpp.toml", "[package]\nname = \"half\"\nversion = \"0.1.0\"\n"}, + {"src/half.cppm", std::format("module;\n#if defined(__{}__)\n#error \"this leg does not build\"\n#endif\n" + "export module half;\nexport int half(int x) {{ return x / 2; }}\n", other_arch)}, + {"tests/smoke.cpp", "import half;\nint main() { return half(4) == 2 ? 0 : 1; }\n"}}); + r = half.mcpp({"test", "--target", "openkal"}); + out = s::text(r); + expect(fatal(r.started && r.status == 1)) << "H: a test whose other leg did not build exited " << r.status << ": " << out; + expect(fatal(e2e::contains(out, "the " + ot + " leg"))) << "H: the leg's section does not name it: " << out; + expect(fatal(e2e::contains(out, "1 leg did not build"))) << "H: the summary does not count it: " << out; }; "964 tests built once run from an archive"_test[s::llvm][s::python3] = [] { From d6ab3112fb387e7a07983f8e309ca7be910cc512 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Mon, 23 Nov 2026 23:10:18 +0900 Subject: [PATCH 23/33] openkal-platform 0.32.1 is the default: riscv64-linux-musl in its hosted arrangement over openkal-linux 0.27.1 and openkal-musl 0.30.2 --- ...face-and-derived-state-ecosystem-design.md | 29 +++++++++++++++++-- CHANGELOG.md | 15 ++++++++-- docs/50-machine-output.md | 2 +- docs/zh/50-machine-output.md | 2 +- modules/toolchain-model/data/builtin.toml | 6 ++-- tests/matrix/scan.sh | 9 +++--- 6 files changed, 49 insertions(+), 14 deletions(-) diff --git a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md index 027e0dfc1..094872f2a 100644 --- a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md +++ b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md @@ -420,6 +420,9 @@ xlings 的规则"派生的状态可以由任何流程重建"与"读不到不等 解析映像名,或 32 位上的长度与缓冲),修复它;复制出的进程启动失败时,把原因写到标准错误,再以 127 结束,与宿主程序 启动失败的约定相同。`examples/starts` 加入 i686 的运行行,作为该行 `openkal.process` 的回归测试。修复随 openkal-image 的补丁发布与平台版本组的修订进入本轮(K5)。 +- **riscv64 的 Linux 实现。** openkal-musl 已带 riscv64 的架构目录与生成的头文件,而 openkal-linux 只实现 x86_64、aarch64 + 与 i386,`riscv64-linux-musl` 因此只能由 musl 交叉载荷服务,openkal 平台不服务它。openkal-linux 按规范补上 riscv64 的 + 系统调用层,平台把该行加入宿主安排(§10 第 15 条)。 - 它们随家族的一次发布与版本组的修订进入索引;mcpp 内置的缺省平台版本随之更新。 ### 3.21 平台定义的行的打包(mcpp,mcpp#1007) @@ -662,7 +665,7 @@ graph LR 自己的请求(版本组参与解析,§7.5)。K1 因此不改动 openkal-platform,K4 不依赖它。 9. **索引中的行(§3.19)。** `riscv64-linux-musl`:x86_64 上的 musl 交叉载荷构建、静态链接,并在 qemu-user 下运行;该载荷的 sysroot 不带内核头文件(`aarch64-linux-musl-gcc` 带 4.19.88),由其描述文件声明 `linux-headers` 6.18.64,修订 1 带 - riscv64 的头文件。行升为 `preview`,运行器为 `xim:qemu-user-riscv64`。支持矩阵的测定:载荷模式下 linux-x86_64 × gcc 为 `ok`,其余宿主与编译器各以其拒绝理由给出;图模式(openkal-musl 0.3.5 与 openkal-llvm-runtime 0.1.3)不服务该行,openkal-linux 0.5.4 只实现 x86_64 与 aarch64(0.27.0 加 i386),构建在其 `sys.h` 的架构断言处失败,矩阵的图模式因此略过 `riscv64-linux-*`,理由写在 `tests/matrix/scan.sh`。`i686-linux-gnu` 与 `wasm32-wasi` 在索引中没有 + riscv64 的头文件。行升为 `preview`,运行器为 `xim:qemu-user-riscv64`。支持矩阵的测定:载荷模式下 linux-x86_64 × gcc 为 `ok`,其余宿主与编译器各以其拒绝理由给出;图模式钉的 openkal-musl 0.3.5 在 Linux 上依赖 openkal-linux 0.5.x,它只实现 x86_64 与 aarch64,构建在其 `sys.h` 的架构断言处失败;openkal 家族的 riscv64 Linux 实现见第 15 条。`i686-linux-gnu` 与 `wasm32-wasi` 在索引中没有 基座载荷与编译器运行时,保持 `planned` 与未登记。iOS 模拟器的两行以 `simctl-run` 为运行器,`enabled = false`。 `x86_64-macos` 在 Apple silicon 的运行器上经 Rosetta 测定(探针工作流):链接原先不带 `--target`,按 arm64 链接 x86_64 的目标文件而找不到 `main`;链接改为凡编译指名目标即指名之后,C 程序链接为 x86_64 并在 Rosetta 下运行。C++ 程序仍不能 @@ -685,4 +688,26 @@ graph LR 14. **路径依赖替代版本依赖时的 std CRC 不符(测定,未在本轮修复)。** 以 `{ path }` 指名 mcpplibs.os 构建 mcpp 自身时, 两个单元以不同的 `std` BMI 编译(`import 'std' has CRC mismatch`);精确的 BMI 截止、关闭构建缓存、删除该 BMI 都不改变 结果,以版本依赖与本地 `[indices]` 路径则构建成功。它不属于本方案的任何条款,记为 mcpp#1008。 - +15. **openkal-linux 的 riscv64(§3.20)。** 矩阵测得 `riscv64-linux-musl` 的 LLVM 一路在 openkal 平台上为 + `platform-target-unserved`,图模式在 openkal-linux 的架构断言处失败;缺的是 openkal-linux 的 riscv64 系统调用层,openkal-musl + 已具备 riscv64。openkal-linux 0.27.1 按规范补上: + - **门与编号。** `ecall`,编号在 `a7`,参数在 `a0` 至 `a5`;编号取内核与体系结构无关的表,与 aarch64 共用一份。riscv64 + 没有 `renameat`,替换式的改名经 `okl::renameat` 以不带标志的 `renameat2` 完成,与其他体系结构经同一函数到达。 + - **内核的记录。** `O_DIRECTORY` 与 `O_NOFOLLOW` 取体系结构无关头文件的值(x86_64 与 i386 相同,aarch64 另有其值); + 处理函数的记录没有 restorer 字段(内核经 vDSO 的 `__vdso_rt_sigreturn` 返回),凡安装处理函数之处都经 + `okl::handler_action` 构造记录;时钟取 vDSO 的 `__vdso_clock_gettime`。 + - **线程指针与入口。** `tp` 指向线程存储的首字节(variant I,无间隙);`_start` 先以不松弛的 `lla` 设置全局指针;`clone` + 为通用的参数顺序。 + - **上下文与帧链。** 采样与故障报告从上下文读 `pc`、`sp` 与 `s0`;帧记录位于帧指针之下两个字。 + - **指令缓存。** 实现在环境以自身调用提供维护时执行它(openkal-linux 的既有规则),riscv64 的内核提供 + `riscv_flush_icache`,发布指令后调用之。 + - **没有 `process_vm_readv` 时的帧链。** 未启用 CROSS_MEMORY_ATTACH 的内核与 qemu 的用户态翻译器(8.2.2 测得)对它 + 回答 ENOSYS,采样与故障报告此前停在第一帧;此时帧的字经该次读取自有的管道读出,管道的写入对不可读的地址回答 EFAULT。 + + `tools/arch-check.sh`(原 `word32-check.sh`)以同一程序 `tests/arch/runs.cpp` 在 x86_64 上运行 i386、在 qemu-user 下运行 + riscv64:越过 4 GiB 的文件、节点的种类与大小、目录的建立、打开与列举、改名、带线程存储的任务、时钟、处理器时间、 + 含上层帧的采样、发布的指令,两种体系结构全部成立。平台的 CI 在 qemu-user 下测得规范的一致性测试套件链接失败(`undefined symbol: __riscv_flush_icache`):riscv64 Linux 上编译器把 `__builtin___clear_cache` 降为对它的调用,由 C 库定义,而 openkal-musl 因 vDSO 的依赖排除了 musl 自己的定义。openkal-musl 0.30.2 补上它:openkal 之上指令只从 openkal.exec 发布的内存执行,维护在发布时由实现执行,该调用回答成功。openkal-platform 0.32.1 以 openkal-linux 0.27.1 与 openkal-musl 0.30.2 修订版本组,把 + `riscv64-linux-musl` 加入宿主安排,并以提供者条目陈述 Linux x86_64 上的运行器 `qemu-riscv64-static` + (`xim:qemu-user-riscv64`,与内置的交叉载荷行相同,无需开启);平台的 CI 在 qemu-user 下运行宿主程序与规范的一致性测试 + 套件。mcpp 的缺省平台随之为 0.32.1,矩阵按测得的单元更新。图模式钉的旧依赖(openkal-linux 0.5.x)不含 riscv64, + 矩阵的图模式仍略过 `riscv64-linux-*`,理由写在 `tests/matrix/scan.sh`。 diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a1aca814..bb68591e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,9 +48,11 @@ ### Changed -- openkal-platform 0.32.0 is the default platform of the openkal rows: a program of the firmware +- openkal-platform 0.32.1 is the default platform of the openkal rows: a program of the firmware and of DOS starts programs (`openkal.process`), an image on i686 starts an image - (mcpplibs/openkal-image#46), and `riscv64-none-musl` runs over openkal-opensbi. + (mcpplibs/openkal-image#46), `riscv64-none-musl` runs over openkal-opensbi, and + `riscv64-linux-musl` is served by the platform's hosted arrangement over openkal-linux 0.27.1's + riscv64 layer, run under qemu-user. - xlings 2026.11.23.1 is the pinned provider, and the handshake requires its `store_roots` feature (protocol 1.19): its collection keeps what a root holds, and its configuration of a package that states `host_facts` runs again when those host files change (openxlings/xlings#712, @@ -107,6 +109,15 @@ prepared transaction, which every later build refused ("compiler unit without prepared transaction") until `mcpp clean`. The state is now renamed out of use before it is removed, and such a remainder from an earlier version is removed by the next build. +- A compiler's registration with its build no longer fails while the build is busy. The answer + was awaited for two seconds and the request then sent again, ten seconds in all, so under load + every retry queued a duplicate and the build failed with "compiler registration channel closed + or timed out" (measured on Windows and macOS CI). The answer is now awaited on the one + connection for as long as the build holds it. +- `mcpp test` over several legs names a leg whose build failed, in the leg's section and in the + summary (`1 leg did not build`; `unbuilt` in the JSON summary). A build error reported as it + happened left the leg's section empty, and the summary counted no failure, although the run + ended with status 1. ## [2026.11.22.1] - 2026-11-22 diff --git a/docs/50-machine-output.md b/docs/50-machine-output.md index e51421a70..f433b26bf 100644 --- a/docs/50-machine-output.md +++ b/docs/50-machine-output.md @@ -568,7 +568,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.32.0` from 2026.11.23.1, `@0.31.2` from 2026.11.20.1, `@0.31.0` in 2026.11.19.1, `@0.29.2` in 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`. +target table selects for it (`mcpplibs.openkal-platform@0.32.1` from 2026.11.23.1, `@0.31.2` from 2026.11.20.1, `@0.31.0` in 2026.11.19.1, `@0.29.2` in 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 013ba64bc..3febb1f6b 100644 --- a/docs/zh/50-machine-output.md +++ b/docs/zh/50-machine-output.md @@ -501,7 +501,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.23.1 起为 `mcpplibs.openkal-platform@0.32.0`,2026.11.20.1 为 `@0.31.2`,2026.11.19.1 为 `@0.31.0`,2026.11.18.1 为 `@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`。 +(2026.11.23.1 起为 `mcpplibs.openkal-platform@0.32.1`,2026.11.20.1 为 `@0.31.2`,2026.11.19.1 为 `@0.31.0`,2026.11.18.1 为 `@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 338399a26..255d5eeda 100644 --- a/modules/toolchain-model/data/builtin.toml +++ b/modules/toolchain-model/data/builtin.toml @@ -769,7 +769,7 @@ hosts = ["*"] toolchain = "llvm@23.1.3" pairs = ["llvm"] linkage = "static" -platform = "mcpplibs.openkal-platform@0.32.0" +platform = "mcpplibs.openkal-platform@0.32.1" [[platform.provider]] name = "openkal" @@ -779,7 +779,7 @@ hosts = ["*"] toolchain = "llvm@23.1.3" pairs = ["llvm"] linkage = "static" -platform = "mcpplibs.openkal-platform@0.32.0" +platform = "mcpplibs.openkal-platform@0.32.1" # The same arrangement on Windows, whose own interfaces a resource script # compiles against: their headers are the MinGW-w64 base's, which states them @@ -792,7 +792,7 @@ hosts = ["*"] toolchain = "llvm@23.1.3" pairs = ["llvm"] linkage = "static" -platform = "mcpplibs.openkal-platform@0.32.0" +platform = "mcpplibs.openkal-platform@0.32.1" system-headers = "xim:mingw-w64-sysroot@20261104-2" # ── Systems ────────────────────────────────────────────────────────────────── diff --git a/tests/matrix/scan.sh b/tests/matrix/scan.sh index 04027fc4d..43562c18e 100755 --- a/tests/matrix/scan.sh +++ b/tests/matrix/scan.sh @@ -209,7 +209,7 @@ scan_cell() { return fi - # riscv64 的 Linux 行同理,理由同样是一条实测,属于这套依赖而不属于 mcpp。 + # riscv64 的 Linux 行同理,理由同样是一条实测,属于这套依赖钉的版本而不属于 mcpp。 # # 实测 2026-11-23(linux-x86_64,llvm@23.1.3):目标侧解析给出 musl(graph), # 构建进入 openkal-musl 0.3.5 在 Linux 上依赖的 openkal-linux 0.5.4,而它 @@ -217,11 +217,10 @@ scan_cell() { # # openkal-linux-0.5.4/src/sys.h:178:2: error: "openkal-linux supports x86_64 and aarch64" # - # 当前的 0.27.0 实现 x86_64、aarch64 与 i386,仍不含 riscv64。这一行由 musl - # 交叉载荷服务(payload 模式实测 `ok / none`);openkal 这一族没有 riscv64 的 - # Linux 实现,图供给不了它。判据是那条诊断与 openkal-linux 的架构集合。 + # riscv64 的实现自 openkal-linux 0.27.1 起才有,经 openkal-platform 0.32.1 的宿主 + # 安排服务这一行(payload 模式测量它)。这套依赖钉的 0.5.x 没有它。判据是那条诊断。 if [ "$MODE" = graph ] && printf '%s' "$t" | grep -qE -- '^riscv64-linux-'; then - echo "scan: 略过 graph × $t —— openkal-linux 没有 riscv64 的实现(0.5.4 为 x86_64/aarch64,0.27.0 加 i386),见 scan.sh 注释" >&2 + echo "scan: 略过 graph × $t —— 这套依赖钉的 openkal-linux 0.5.x 没有 riscv64 的实现(0.27.1 起有),见 scan.sh 注释" >&2 return fi From 89621bdb5a0c7909dc266e435efe67ab7da9a015 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 24 Nov 2026 01:20:29 +0900 Subject: [PATCH 24/33] docs: riscv64-linux-musl's conformance suite under qemu-user, and the three member fixes it measured --- ...face-and-derived-state-ecosystem-design.md | 20 ++++++++++++++++++- CHANGELOG.md | 5 +++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md index 094872f2a..64836fcaf 100644 --- a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md +++ b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md @@ -706,7 +706,25 @@ graph LR `tools/arch-check.sh`(原 `word32-check.sh`)以同一程序 `tests/arch/runs.cpp` 在 x86_64 上运行 i386、在 qemu-user 下运行 riscv64:越过 4 GiB 的文件、节点的种类与大小、目录的建立、打开与列举、改名、带线程存储的任务、时钟、处理器时间、 - 含上层帧的采样、发布的指令,两种体系结构全部成立。平台的 CI 在 qemu-user 下测得规范的一致性测试套件链接失败(`undefined symbol: __riscv_flush_icache`):riscv64 Linux 上编译器把 `__builtin___clear_cache` 降为对它的调用,由 C 库定义,而 openkal-musl 因 vDSO 的依赖排除了 musl 自己的定义。openkal-musl 0.30.2 补上它:openkal 之上指令只从 openkal.exec 发布的内存执行,维护在发布时由实现执行,该调用回答成功。openkal-platform 0.32.1 以 openkal-linux 0.27.1 与 openkal-musl 0.30.2 修订版本组,把 + 含上层帧的采样、发布的指令,两种体系结构全部成立。平台的 CI 在 qemu-user 下测得规范的一致性测试套件链接失败(`undefined symbol: __riscv_flush_icache`):riscv64 Linux 上编译器把 `__builtin___clear_cache` 降为对它的调用,由 C 库定义,而 openkal-musl 因 vDSO 的依赖排除了 musl 自己的定义。openkal-musl 0.30.2 补上它:openkal 之上指令只从 openkal.exec 发布的内存执行,维护在发布时由实现执行,该调用回答成功。 + + 链接通过后,一致性测试套件在 qemu-user 8.2.2 下测得三处,均在成员中按根因修复: + - **处理函数记录的长度(openkal-linux 0.27.2)。** 内核的 riscv64 记录为 24 字节(handler、flags、mask);qemu 的 + 通用 `TARGET_SA_RESTORER` 使其按带 restorer 的 32 字节布局,返回旧动作时写 32 字节、新动作的掩码从第四个字读取。 + 24 字节的记录之后 8 字节被覆盖:启动映像重置各信号动作的循环每次查询后回到第一个信号,启动永不结束。记录增加第四个字, + 与 musl 给同一记录的长度相同;实现安装的动作都不陈述掩码,内核与翻译器读到同一个空掩码。`tests/arch/runs.cpp` + 检查查询动作后记录之后的字保持不变(未修复时在 qemu 下失败)。 + - **已结束程序的记录(openkal-linux 0.27.2)。** 未回收的已结束程序的用量是 `waitid` 的第五个参数;qemu 8.2 不传递它, + 留下的零被读成没有处理器时间、峰值为零。记录的峰值预置为内核不会写出的值,未写出的记录由此可辨:程序尚未回收, + 处理器时间经程序的时钟、缺页数经 `/proc//stat` 读取(与运行中的程序同一途径,缺页的读取收敛为一个函数); + 峰值只在记录中,报告为不可得而非零。 + - **`__tls_get_addr`(openkal-musl 0.30.3)。** musl 的实现从自身描述符前的向量作答,而本移植把程序的线程存储交给内核层, + 向量为空,答案只剩偏移。x86_64、i386 与 aarch64 的静态链接把一般动态访问改写为局部执行,riscv64 的链接保留调用, + 套件的第一次这类访问因而失效。静态程序只有一个模块,其块始于线程指针(variant I,无控制块),地址为 + `tp + offset + DTP_OFFSET`;`DTP_OFFSET`(riscv64 为 0x800)写入本移植替换的 `pthread_arch.h`,与 musl 自己的 + 体系结构头文件一致。其他体系结构上没有访问到达该函数,到达者经 `kal_abort` 拒绝。 + + 三处修复后套件在 riscv64 下 411 条成立、0 条不成立。openkal-platform 0.32.1 以 openkal-linux 0.27.2 与 openkal-musl 0.30.3 修订版本组,把 `riscv64-linux-musl` 加入宿主安排,并以提供者条目陈述 Linux x86_64 上的运行器 `qemu-riscv64-static` (`xim:qemu-user-riscv64`,与内置的交叉载荷行相同,无需开启);平台的 CI 在 qemu-user 下运行宿主程序与规范的一致性测试 套件。mcpp 的缺省平台随之为 0.32.1,矩阵按测得的单元更新。图模式钉的旧依赖(openkal-linux 0.5.x)不含 riscv64, diff --git a/CHANGELOG.md b/CHANGELOG.md index bb68591e4..ea6511e42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,8 +51,9 @@ - openkal-platform 0.32.1 is the default platform of the openkal rows: a program of the firmware and of DOS starts programs (`openkal.process`), an image on i686 starts an image (mcpplibs/openkal-image#46), `riscv64-none-musl` runs over openkal-opensbi, and - `riscv64-linux-musl` is served by the platform's hosted arrangement over openkal-linux 0.27.1's - riscv64 layer, run under qemu-user. + `riscv64-linux-musl` is served by the platform's hosted arrangement over openkal-linux 0.27.2's + riscv64 layer and openkal-musl 0.30.3, run under qemu-user, where the specification's + conformance suite holds in every observation it makes. - xlings 2026.11.23.1 is the pinned provider, and the handshake requires its `store_roots` feature (protocol 1.19): its collection keeps what a root holds, and its configuration of a package that states `host_facts` runs again when those host files change (openxlings/xlings#712, From dd6a4ca4aa64cc2b3fe3323c0f89d63c4e4a2fc2 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 24 Nov 2026 03:54:56 +0900 Subject: [PATCH 25/33] matrix: riscv64-linux-musl with llvm is served by openkal-platform 0.32.1 on the hosts the gcc payload does not serve --- tests/matrix/expected.tsv | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/matrix/expected.tsv b/tests/matrix/expected.tsv index e5ad5b65c..22d2f53d7 100644 --- a/tests/matrix/expected.tsv +++ b/tests/matrix/expected.tsv @@ -263,7 +263,7 @@ payload linux-aarch64 i686-openkal llvm@23.1.3 i686-unknown-none-elf payload mus payload linux-aarch64 riscv32-none-elf gcc@16.1.0 - - - - - unsupported capability-pin payload linux-aarch64 riscv32-none-elf llvm@23.1.3 riscv32-none-elf payload - - - ok none payload linux-aarch64 riscv64-linux-musl gcc@16.1.0 - - - - - unsupported host-cannot-serve -payload linux-aarch64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported platform-target-unserved +payload linux-aarch64 riscv64-linux-musl llvm@23.1.3 riscv64-unknown-linux-musl payload musl(platform) libc++(platform) openkal-llvm-runtime@0.20.3 ok none payload linux-aarch64 riscv64-none-elf gcc@16.1.0 - - - - - unsupported capability-pin payload linux-aarch64 riscv64-none-elf llvm@23.1.3 riscv64-none-elf payload - - - ok none payload linux-aarch64 thumbv6m-none-eabi gcc@16.1.0 - - - - - unsupported capability-pin @@ -382,7 +382,7 @@ payload macos-arm64 i686-linux-musl llvm@23.1.3 i686-unknown-linux-musl host mus payload macos-arm64 i686-none-elf llvm@23.1.3 i686-none-elf host - - - ok none payload macos-arm64 i686-openkal llvm@23.1.3 i686-unknown-none-elf host musl(platform) libc++(platform) openkal-llvm-runtime@0.20.3 ok none payload macos-arm64 riscv32-none-elf llvm@23.1.3 riscv32-none-elf host - - - ok none -payload macos-arm64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported platform-target-unserved +payload macos-arm64 riscv64-linux-musl llvm@23.1.3 riscv64-unknown-linux-musl host musl(platform) libc++(platform) openkal-llvm-runtime@0.20.3 ok none payload macos-arm64 riscv64-none-elf llvm@23.1.3 riscv64-none-elf host - - - ok none payload macos-arm64 thumbv6m-none-eabi llvm@23.1.3 thumbv6m-none-eabi host - - - ok none payload macos-arm64 thumbv7em-none-eabi llvm@23.1.3 thumbv7em-none-eabi host - - - ok none @@ -430,7 +430,7 @@ payload windows-x86_64 i686-openkal llvm@23.1.3 i686-unknown-none-elf none musl( payload windows-x86_64 i686-openkal msvc@system - - - - - unsupported capability-pin payload windows-x86_64 riscv32-none-elf llvm@23.1.3 riscv32-none-elf none - - - ok none payload windows-x86_64 riscv32-none-elf msvc@system - - - - - unsupported capability-pin -payload windows-x86_64 riscv64-linux-musl llvm@23.1.3 - - - - - unsupported platform-target-unserved +payload windows-x86_64 riscv64-linux-musl llvm@23.1.3 riscv64-unknown-linux-musl none musl(platform) libc++(platform) openkal-llvm-runtime@0.20.3 ok none payload windows-x86_64 riscv64-linux-musl msvc@system - - - - - unsupported convention-unreplaced payload windows-x86_64 riscv64-none-elf llvm@23.1.3 riscv64-none-elf none - - - ok none payload windows-x86_64 riscv64-none-elf msvc@system - - - - - unsupported capability-pin From 68d08781544afe02c78b465e714d44eff027a390 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 24 Nov 2026 04:06:16 +0900 Subject: [PATCH 26/33] test: the registration cases wait for events, not for a time --- tests/unit/test_compiler_transaction.cpp | 41 +++++++++++++++--------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/tests/unit/test_compiler_transaction.cpp b/tests/unit/test_compiler_transaction.cpp index 757977327..d5ec6a84d 100644 --- a/tests/unit/test_compiler_transaction.cpp +++ b/tests/unit/test_compiler_transaction.cpp @@ -445,28 +445,40 @@ UTest an_unobservable_unit_is_settled_when_the_caller_holds_the_locks{"CompilerT // one registration at a time, so an answer can take longer than any fixed wait; // the controller awaits it there for as long as the owner holds the connection, // and sends nothing again (Windows CI: a controller that resent its request after -// two seconds of silence queued duplicates and failed while its owner lived). +// two seconds of silence queued duplicates and failed while its owner lived). The +// owner answers only once the controller has entered its wait, and then reads the +// connection to its end: one request, and nothing after the answer. UTest a_late_answer_is_received_on_the_one_connection{"CompilerTransaction/ALateAnswerIsReceivedOnTheOneConnection", [] { Transaction t; auto listener=mcpplibs::os::ipc::listener::listen(t.root,"late"); expect(fatal(bool(listener))); - std::atomic accepted{0}; + std::atomic waiting{false}; + std::atomic requests{0}; + std::atomic ended{false}; std::jthread owner([&] { auto c=listener->accept(); if(!c)return; - ++accepted; - auto request=tx::receive(*c,std::chrono::milliseconds(2000)); - std::this_thread::sleep_for(std::chrono::milliseconds(2500)); // past the old two-second wait - if(request&&*request=="register")tx::send(*c,"ACK"); + auto request=tx::receive(*c,std::nullopt); + if(request&&*request=="register")++requests; + waiting.wait(false); + tx::send(*c,"ACK"); + auto after=tx::receive(*c,std::nullopt); + if(after)++requests; + else ended=true; }); - auto c=mcpplibs::os::ipc::connection::connect(t.root,"late"); - expect(fatal(bool(c))); - expect(fatal(tx::send(*c,"register"))); - auto answer=tx::receive(*c,std::nullopt); - if (auto&& failed = expect(fatal(bool(answer))); !failed) failed <accept(); if(!c)return; - (void)tx::receive(*c,std::chrono::milliseconds(2000)); - std::this_thread::sleep_for(std::chrono::milliseconds(300)); + (void)tx::receive(*c,std::nullopt); }); // the connection closes as the owner's handle goes auto c=mcpplibs::os::ipc::connection::connect(t.root,"closed"); expect(fatal(bool(c))); From b31e1da2e1b750ab53b461b927642b29c07d052f Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 24 Nov 2026 04:50:58 +0900 Subject: [PATCH 27/33] fix: what the build deploys beside the program is a root of the pack's runtime closure (mcpp#1011) An object of the program's format and machine that [runtime] deploy or mcpp::deploy places beside the program (a plugin loaded at run time, a helper program, another program under --all-programs) is read as the program is, on ELF, PE, Mach-O and Android. On ELF a deployed shared object is preloaded into the program's loader trace, and its search path in the tree becomes the bundle's lib/. SPEC-014 v2.7, docs/10, design section 3.22. --- ...face-and-derived-state-ecosystem-design.md | 28 +++ CHANGELOG.md | 7 + docs/10-pack-and-release.md | 30 +++ docs/specs/packaging.md | 17 +- docs/zh/10-pack-and-release.md | 24 ++ src/pack/pack.cppm | 229 ++++++++++++++++-- tests/e2e/pack/modes.cpp | 69 +++++- tests/unit/test_pack_closure.cpp | 50 ++++ 8 files changed, 428 insertions(+), 26 deletions(-) diff --git a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md index 64836fcaf..21dc7f202 100644 --- a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md +++ b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md @@ -446,6 +446,33 @@ xlings 的规则"派生的状态可以由任何流程重建"与"读不到不等 回归由两个 e2e 覆盖:路径平台的静态提供者下,两个原始映像格式的程序都被打包,去掉 `linkage` 后被拒绝并写出格式; Web 行上两个程序各带其模块。 +### 3.22 部署对象的运行时闭包(mcpp,mcpp#1011) + +`mcpp pack` 的运行时闭包只从程序出发。构建以 `mcpp::deploy` 或 `[runtime] deploy` 放在程序旁的共享对象被暂存,而它自己 +需要的库不进入闭包:只经 `dlopen` 装载的插件(Qt 的平台插件与 QML 插件等)随包交付时缺少其库,在没有这些库的机器上 +失败。以 `xim:qt` 6.11.1 测得:部署的 `bin/platforms/libqxcb.so` 需要 `libQt6XcbQpa.so.6`,包中没有。这是闭包的缺陷, +不是插件包少写了陈述;插件包中链接这些库的做法是绕行。 + +- **根。** 部署的文件中,程序自身格式与机器的对象(由文件内容判定)与程序一样是闭包的根;其他文件是程序打开的文件。 + `--all-programs` 的其余程序同在部署列表中,同一规则使它们的闭包此前同样缺失的部分得到补全。没有装载器的程序(静态 + 程序)不向自身进程装载对象,其部署对象不是根。 +- **一个读取函数。** 闭包的读取(`read_closure`)接受根的列表,PE、Mach-O 与 Android 三条规则都从程序与根出发,名字按 + 同一规则解析;Mach-O 的根继承程序的 rpath,与 dyld 对程序装载的映像所做的相同。选择根的函数(`deployed_objects`) + 只有一个,各格式的打包都调用它。 +- **本机的 ELF 仍询问装载器。** 部署的共享对象经 `LD_PRELOAD` 预装入程序的追踪:装载器在程序的进程中、以程序的搜索 + 路径与已装载的库解析其名字,与程序 `dlopen` 它时相同;glibc 不把可执行文件装入另一进程,部署的程序单独追踪。名字按 + soname 合并,程序的在先。另一系统的 ELF 按程序的规则读取根的 `DT_NEEDED`。 +- **树中的搜索路径。** 部署对象的搜索路径是它自己的(带 DT_RUNPATH 的对象不经程序的搜索路径查找其库),构建时指向本机的 + 存储或 SDK;暂存后改为相对其位置的 `lib/`,部署的程序同时取程序的解释器。携带的库为空时,与程序一样清除。 +- **不沉默。** `LD_PRELOAD` 以 `:` 与空白分隔条目且无转义,路径含这些字符的对象无法交给装载器;装载器拒绝装载的对象 + (`cannot be preloaded`)同样写出名字与原因,闭包记为不完整。 +- **边界。** 构建时的 `place-dlls`(SPEC-007 R4.3)为从构建目录直接启动的 Windows 程序放置 DLL,其命令行按 #723 不含 + 部署列表;部署插件的导入在 `mcpp run` 中经 `PATH` 找到。该机制不属于打包,本条不改变它。 + +回归由一个 e2e 与两个单元测试覆盖:本机 ELF 上部署的插件需要程序不链接的库,打包后该库位于 `lib/`、插件的搜索路径为 +`$ORIGIN/../../lib`,构建机器上的库目录移走后打包的程序装载插件成功(修复前 `lib/` 不存在);PE 的部署 DLL 与 Mach-O +的部署映像各自的闭包。 + ## 4. 跨平台 | 行 | `kernel-abi` 的供给者 | 写 `layers.kernel-abi` 的结果 | @@ -503,6 +530,7 @@ Web 行上两个程序各带其模块。 - 目标侧模型:`kernel-abi` 带上版本、来源与接口,并写入报告与 `fields`; - 存储:根的登记、home 格式的一步、`mcpp cache gc` 调用 xlings 的回收;捆绑的 xlings 版本; - 构建程序的接口与构建数据库:`mcpp::action` 的 `origin`、生成条目的字段、角色与重复提供者的消息; +- 打包:部署对象作为闭包的根(§3.22),SPEC-014 §1.2、docs/10 的中英文; - 规范:SPEC-002、SPEC-004、SPEC-005、SPEC-006、SPEC-013、SPEC-016;用法:docs/04、docs/09、docs/20、docs/22、docs/50 的 中英文;CHANGELOG。 diff --git a/CHANGELOG.md b/CHANGELOG.md index ea6511e42..a585307cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -103,6 +103,13 @@ does. `x86_64-macos` on Apple silicon linked its x86_64 objects for arm64 and found no `main`; a C program now links and runs under Rosetta. The row stays `planned`: the LLVM payload's libc++ is arm64 only. +- `mcpp pack` carries the libraries of what the build deploys beside the program. An object of the + program's format and machine that `[runtime] deploy` or `mcpp::deploy` places (a plugin loaded + at run time, a helper program, another program under `--all-programs`) is a root of the runtime + closure as the program is, on ELF, PE, Mach-O and Android. A Qt platform plugin's + `libQt6XcbQpa.so.6`, which the program does not link, was left out of the package. On ELF a + deployed shared object is preloaded into the program's loader trace and its search path in the + tree becomes the bundle's `lib/` (docs/10, mcpp#1011). - `mcpp pack --all-programs` on `wasm32-emscripten` packs each program's module beside its launcher. Before, only the program named after the package had its `.wasm` (mcpp#1007). - A build ended by a signal while it removed its compiler-run state no longer leaves the diff --git a/docs/10-pack-and-release.md b/docs/10-pack-and-release.md index 377feb80c..d56970b58 100644 --- a/docs/10-pack-and-release.md +++ b/docs/10-pack-and-release.md @@ -638,6 +638,36 @@ own resolution, say — use `--mode vendored` instead. It repoints `PT_INTERP` at the host loader, at the cost of requiring the host's glibc to be at least as new as the one the artifact was built against. +### What the build deploys beside the program (2026.11.23.1+) + +A file that `[runtime] deploy`, `deploy_files` or a build program's `mcpp::deploy` places beside +the program is staged at the same path below `bin/`. When that file is an object of the program's +own format and machine (a plugin the program loads at run time, a helper program it starts, or, +under `--all-programs`, another program of the package), it is a root of the runtime closure as +the program is. The libraries it needs are carried by the same mode rules, including the ones the +program itself does not link (mcpp#1011): + +| Format | Resolution of a deployed object's needs | Staging location | +|---|---|---| +| ELF, this machine's | a shared object is preloaded into the program's loader trace (`LD_PRELOAD`), so its names resolve in the program's process, as a `dlopen` from the program resolves them; a deployed program is traced as the program is | `lib/`; the object's search path becomes `$ORIGIN/` | +| ELF, another system | its `DT_NEEDED`, by the rule of the program (beside it, or in `../lib`) | `lib/` | +| PE | its import table, in the program's search directories | beside the program, where the loader searches for a loaded DLL's imports | +| Mach-O | its load commands; `@rpath` through its own rpaths and then the program's | as for the program's own dylibs | +| Android | its `DT_NEEDED`, in the leg's directories | the leg's `lib//` | + +``` +target/dist/viewer-0.1.0-x86_64-linux-gnu/ +├── bin/viewer +├── bin/platforms/libqxcb.so ← deployed; RUNPATH=$ORIGIN/../../lib +└── lib/libQt6XcbQpa.so.6 ← needed only by the plugin +``` + +A deployed file of another format is a file the program opens and has no closure. A program with +no loader (a static program) loads no object into its process, so its deployed objects are not +roots. `LD_PRELOAD` separates its entries by `:` and white space, so an object whose path below the +program's directory holds one of them cannot be traced; the pack names it rather than shipping it +without its libraries. + ### WebAssembly (`wasm32-emscripten`): the stem family ``` diff --git a/docs/specs/packaging.md b/docs/specs/packaging.md index a66f11b40..8b9d73338 100644 --- a/docs/specs/packaging.md +++ b/docs/specs/packaging.md @@ -4,10 +4,10 @@ |---|---| | 规范编号 | SPEC-014 | | 标题 | 打包与分发:链接、闭包、容器三个维度与构建腿,腿的合并,暂存树与包元数据,运行覆盖、单文件、容器列表、签名、压缩、合并与分发描述 | -| 状态 | 评审中 v2.5 | -| 版本 | 2.5 | -| 最后修改 | 2026-11-16 | -| 对应实现 | mcpp >= 2026.10.31.1;v2.2 条款 mcpp >= 2026.11.10.1;v2.3 条款 mcpp >= 2026.11.12.1;v2.4 条款 mcpp >= 2026.11.13.1;v2.5 条款 mcpp >= 2026.11.16.1 | +| 状态 | 评审中 v2.7 | +| 版本 | 2.7 | +| 最后修改 | 2026-11-23 | +| 对应实现 | mcpp >= 2026.10.31.1;v2.2 条款 mcpp >= 2026.11.10.1;v2.3 条款 mcpp >= 2026.11.12.1;v2.4 条款 mcpp >= 2026.11.13.1;v2.5 条款 mcpp >= 2026.11.16.1;v2.6 条款 mcpp >= 2026.11.17.1;v2.7 条款 mcpp >= 2026.11.23.1 | | 相关设计文档 | `.agents/docs/2026-11-15-ecosystem-gap-supplement-design.md`(§5)、`.agents/docs/2026-10-30-ecosystem-part2-ide-and-language-service-design.md`(§19.6)、`.agents/docs/2026-10-29-ecosystem-target-sets-packaging-and-editors-design.md`(§4、§13)、`.agents/docs/2026-10-28-platforms-part2-packaging-and-distribution-design.md`(§2–§7、§14)、`.agents/docs/2026-10-28-platforms-design.md`(§4.7)、`.agents/docs/2026-10-29-openkal-run-test-pack-design.md`(§2.2、§2.6) | | 相关 issue | mcpp#847、mcpp#849、mcpp#860 | | 相关规范 | [SPEC-007](build-plugins.md)(包格式提供者、artifact action)、[SPEC-011](concurrency.md)(原子发布)、[SPEC-013](platforms.md)(平台、运行器、载体)、[SPEC-015](target-sets.md)(目标集合与腿) | @@ -62,6 +62,14 @@ openkal 目标上 `static` 为一个 `.oke`、无 `.okso`,`shared` 为 `.oke` `DT_NEEDED`),**禁止**运行本机加载器:本构建产出、位于程序旁(`bin`、`../lib`)的库随包携带,其余名字属于目标系统, 记为平台需求。C 库由平台或基座包描述的行支持全静态链接。 +**部署的对象(v2.7)。** 构建放在程序旁的文件(`[runtime] deploy`、`deploy_files`、构建程序的 `mcpp::deploy`)中, +程序自身格式与机器的对象(由文件内容判定,不由文件名)**必须**与程序一样作为闭包的根,其需求按程序的规则解析、按同一 +模式携带:本机的 ELF 上,共享对象**必须**预装入程序的装载器追踪,使其名字在程序的进程中解析,部署的程序与程序一样追踪, +携带的库位于 `lib/`,对象的搜索路径改为相对其暂存位置的 `lib/`;另一系统的 ELF 读取其 `DT_NEEDED`;PE 读取其导入表, +库放在程序旁;Mach-O 读取其装载命令,`@rpath` 先经自身的 rpath、再经程序的;Android 在该腿的目录中解析。没有装载器的 +程序不是其部署对象的装载者,这些对象不作为根。无法交给装载器追踪的对象(其路径含 `LD_PRELOAD` 的分隔符,或装载器拒绝 +装载)**必须**写出其名字与原因,闭包记为不完整。 + **静态的核对(v2.2)。** `--mode static` 的原生程序**必须**以全静态方式链接;打包前读取产物文件,带解释器或共享库需求的 程序**必须**被拒绝并写出其需求,不以 `-static` 的名字打包。 @@ -517,3 +525,4 @@ openkal 目标的单文件:载体携带一条腿的映像本身(映像不引用 | 2.4 | 2026-11-14 | mcpp 2026.11.13.1:§4.4 平台定义的行即该系统的程序之行(行名可带环境段),`built-as` 指向定义的行时在平台之上构建;strip 不读的封装容器按封装结果打包。 | | 2.6 | 2026-11-17 | mcpp 2026.11.17.1(设计 2026-11-16 §4.3):新增 §4.5.1 许可证文件,全部打包方式按包放置并报告缺失,取代只在 `self-contained` 中按固定文件名查找且不报告的做法。 | | 2.5 | 2026-11-16 | mcpp 2026.11.16.1(设计 2026-11-15 N11、N20):§4.3 携带运行器的包不回落到 `PATH`,本机没有时以 126 退出并写出所含各项;`` 取系统表的 `uname`;`--all-programs` 的树中每个程序有自己的启动器;§6 `mcpp::pack_program` 与提供者不提交的原因(N30)。 | +| 2.7 | 2026-11-23 | mcpp 2026.11.23.1(mcpp#1011):§1.2 部署的对象是闭包的根,其需求按程序的规则解析与携带。 | diff --git a/docs/zh/10-pack-and-release.md b/docs/zh/10-pack-and-release.md index dc7c4c997..8ecb48b53 100644 --- a/docs/zh/10-pack-and-release.md +++ b/docs/zh/10-pack-and-release.md @@ -548,6 +548,30 @@ if (!base) { `--mode vendored`。它把 `PT_INTERP` 重新指向宿主的 loader,代价是要求宿主的 glibc 版本不低于产物构建时所用的那份。 +### 构建放在程序旁的对象(2026.11.23.1+) + +`[runtime] deploy`、`deploy_files` 或构建程序的 `mcpp::deploy` 放在程序旁的文件,按同一相对路径暂存在 `bin/` 之下。 +该文件是程序自身格式与机器的对象时(程序在运行时装载的插件、它启动的辅助程序,或 `--all-programs` 下包的另一个程序), +它与程序一样是运行时闭包的根;它需要的库按同一模式规则携带,包括程序自身不链接的库(mcpp#1011): + +| 格式 | 部署对象的需求的解析 | 暂存位置 | +|---|---|---| +| 本机的 ELF | 共享对象预装入程序的装载器追踪(`LD_PRELOAD`),其名字在程序的进程中解析,与程序 `dlopen` 时相同;部署的程序与程序一样追踪 | `lib/`;对象的搜索路径改为 `$ORIGIN/<到 lib/ 的路径>` | +| 另一系统的 ELF | 其 `DT_NEEDED`,按程序的规则(程序旁或 `../lib`) | `lib/` | +| PE | 其导入表,在程序的搜索目录中 | 程序旁,即装载器为已装载 DLL 的导入搜索之处 | +| Mach-O | 其装载命令;`@rpath` 先经自身的 rpath,再经程序的 | 与程序自身的 dylib 相同 | +| Android | 其 `DT_NEEDED`,在该腿的目录中 | 该腿的 `lib//` | + +``` +target/dist/viewer-0.1.0-x86_64-linux-gnu/ +├── bin/viewer +├── bin/platforms/libqxcb.so ← 部署的文件;RUNPATH=$ORIGIN/../../lib +└── lib/libQt6XcbQpa.so.6 ← 只有插件需要 +``` + +其他格式的部署文件是程序打开的文件,没有闭包。没有装载器的程序(静态程序)不向自身进程装载对象,其部署对象不是根。 +`LD_PRELOAD` 以 `:` 与空白分隔条目,程序目录之下的路径含有这些字符的对象无法追踪;打包写出其名字,而不是不带其库地交付。 + ### WebAssembly(`wasm32-emscripten`):词干家族 ``` diff --git a/src/pack/pack.cppm b/src/pack/pack.cppm index 357d1d56b..f0f7c00e8 100644 --- a/src/pack/pack.cppm +++ b/src/pack/pack.cppm @@ -209,8 +209,9 @@ struct Options { // What the build placed relative to the executable, from // `runtime.deploy_files` and `runtime.deploy` (#615), as paths relative to // the executable's directory. Each is staged at the same relative path - // beside the packed executable, in every mode: these are files a program - // opens, not libraries a closure decides about. + // beside the packed executable, in every mode. One that is an object of + // the program's format and machine is also a root of the closure + // (`deployed_objects`, mcpp#1011); the rest are files a program opens. std::vector runtimeFiles; // Does the RESOLVED C++ runtime contract require the toolchain's own // runtime to travel WITH the artifact — i.e. `cxx_runtime = @@ -463,6 +464,13 @@ struct ClosureReadInput { // each resolves again where it came from instead of shadowing a newer // version there. `mcpp pack` leaves it empty. std::vector notInFirstDir; + // THE OTHER ROOTS (mcpp#1011): objects the build placed relative to + // `object`'s directory, as paths relative to it. Each is read as `object` + // is and its names resolve by the same rule -- a plugin the program loads + // at run time needs its libraries in the tree as much as the program does. + // A Mach-O root inherits the program's rpaths, as an image the program + // loads does. + std::vector deployed; }; // A name that resolved to a file, and where that file is staged: `dest` is @@ -1018,10 +1026,16 @@ bool soname_matches(std::string_view soname, struct LddClosure { std::vector found; std::vector notFound; + // A deployed object the loader could not load into the program's trace, + // with its reason (mcpp#1011): its closure is unknown, which is said. + std::vector notLoaded; }; +// `preload`: deployed shared objects, relative to `binary`'s directory, which +// the loader loads into the trace (see `trace_closure`). std::expected -ldd_parse(const std::filesystem::path& binary) +ldd_parse(const std::filesystem::path& binary, + const std::vector& preload = {}) { // Don't shell out to `ldd` directly — many distros (and our own // xim:glibc sandbox) ship `ldd` as a shell script that tries to @@ -1031,11 +1045,19 @@ ldd_parse(const std::filesystem::path& binary) // executing main(). This routes through the binary's *own* // PT_INTERP so it works even when our sandbox's ldd wrapper is // broken or missing. - auto out = run_capture({ binary.string() }, { { "LD_TRACE_LOADED_OBJECTS", "1" } }); - if (!out) return std::unexpected(out.error()); + mcpp::run::Env env{ { "LD_TRACE_LOADED_OBJECTS", "1" } }; + std::string preloadList; + for (auto const& rel : preload) + preloadList += (preloadList.empty() ? "./" : ":./") + rel.generic_string(); + if (!preloadList.empty()) env.push_back({ "LD_PRELOAD", preloadList }); + const std::vector argv{ binary.string() }; + auto r = mcpp::run::execute(argv, { .env = env, + .cwd = preloadList.empty() ? std::string{} : binary.parent_path().string() }); + if (r.exit_code != 0) return std::unexpected(std::format( + "command exited with {}: {}", r.exit_code, mcpp::build::command_line::display(argv))); LddClosure deps; - std::istringstream is{*out}; + std::istringstream is{r.output}; std::string line; while (std::getline(is, line)) { // Trim leading whitespace. @@ -1043,6 +1065,18 @@ ldd_parse(const std::filesystem::path& binary) while (i < line.size() && (line[i] == ' ' || line[i] == '\t')) ++i; line.erase(0, i); if (line.empty()) continue; + // glibc's words for a preloaded object it did not load: `ERROR: ld.so: + // object './' from LD_PRELOAD cannot be preloaded (): ignored.` + if (auto at = line.find("from LD_PRELOAD cannot be preloaded"); at != std::string::npos) { + const auto open = line.find("'./"), close = line.find('\'', open + 3); + const auto why0 = line.find('(', at), why1 = line.find(')', why0); + deps.notLoaded.push_back(std::format("{}: the loader does not load it into the program ({})", + open == std::string::npos || close == std::string::npos ? line + : line.substr(open + 3, close - open - 3), + why0 == std::string::npos || why1 == std::string::npos ? std::string("no reason given") + : line.substr(why0 + 1, why1 - why0 - 1))); + continue; + } if (line.starts_with("statically linked")) return deps; // no deps // Skip vDSO (no on-disk file). if (line.starts_with("linux-vdso")) continue; @@ -1073,6 +1107,57 @@ ldd_parse(const std::filesystem::path& binary) return deps; } +// THE LOADER'S CLOSURE OF A PROGRAM AND OF WHAT THE BUILD DEPLOYED BESIDE IT +// (mcpp#1011). A deployed shared object is preloaded into the program's trace: +// the loader then resolves its names in the program's process, with the +// program's search path and the libraries the program already loads, which is +// what a `dlopen` from the program finds. A deployed program has a loader of +// its own (glibc loads no executable into another process) and is traced as +// the program is. An object with neither a loader nor a needed library has no +// closure. Names are merged by soname, the program's first. +// +// `LD_PRELOAD` separates its entries by `:` and white space and has no escape, +// so an object whose path below the program's directory holds one cannot be +// named to the loader; it is reported, not dropped. +std::expected +trace_closure(const std::filesystem::path& program, + const std::vector& deployed) +{ + const auto dir = program.parent_path(); + std::vector preload, programs; + LddClosure merged; + for (auto const& rel : deployed) { + const auto facts = mcpp::runtime::elf::inspect_elf_runtime(dir / rel); + if (facts && facts->interp.empty() && facts->needed.empty()) continue; + if (facts && !facts->interp.empty()) { programs.push_back(rel); continue; } + if (rel.generic_string().find_first_of(": \t\n") != std::string::npos) { + merged.notLoaded.push_back(std::format( + "{}: its path holds a character LD_PRELOAD separates entries by", rel.generic_string())); + continue; + } + preload.push_back(rel); + } + std::set found, notFound; + auto merge = [&](LddClosure&& c) { + for (auto& d : c.found) + if (found.insert(d.soname).second) merged.found.push_back(std::move(d)); + for (auto& n : c.notFound) + if (notFound.insert(n).second) merged.notFound.push_back(std::move(n)); + for (auto& n : c.notLoaded) merged.notLoaded.push_back(std::move(n)); + }; + auto first = ldd_parse(program, preload); + if (!first) return std::unexpected(first.error()); + merge(std::move(*first)); + for (auto const& rel : programs) { + auto other = ldd_parse(dir / rel); + if (!other) return std::unexpected(std::format("{}: {}", rel.generic_string(), other.error())); + merge(std::move(*other)); + } + // A name some trace resolved is not missing because another did not. + std::erase_if(merged.notFound, [&](const std::string& n) { return found.contains(n); }); + return merged; +} + // Sandbox-local patchelf path via xlings module. Fail soft if the // bootstrap step left it uninstalled. std::filesystem::path @@ -1370,6 +1455,12 @@ write_topentry_wrapper(const std::filesystem::path& stagingRoot, return write_executable_script(stagingRoot / std::string(binaryName), body); } +// Where the target distribution keeps the loader `soname` names (the LSB +// layout: `/lib64/` for x86_64's, `/lib/` elsewhere). +std::string distro_loader(std::string_view soname) { + return (soname == "ld-linux-x86-64.so.2" ? "/lib64/" : "/lib/") + std::string(soname); +} + // Find the dynamic linker's SONAME in `deps` (something like // "ld-linux-x86-64.so.2"). Empty when not found, e.g. for static. std::string find_loader_soname(const std::vector& deps) { @@ -1466,6 +1557,41 @@ stage_runtime_files(const Plan& plan, const std::filesystem::path& stagedExeDir, return {}; } +// THE DEPLOYED FILES THAT ARE ROOTS OF THE CLOSURE (mcpp#1011): the runtime +// files in `dir`, the directory `program` lies in, that are objects of the +// program's own format and machine -- a plugin the program loads, a helper it +// starts, another program of the package. Paths relative to `dir`. Every other +// deployed file is one the program opens, and has no closure. +// +// The format is read from the file, not from its name: a Qt plugin is +// `libqxcb.so` and a helper program has no suffix at all. +std::vector +deployed_objects(const Plan& plan, const std::filesystem::path& program, + const std::filesystem::path& dir) +{ + namespace bf = mcpp::pack::binfmt; + std::vector out; + const auto own = bf::identify(program); + if (own.format == bf::Format::Unknown) return out; + for (auto const& rel : plan.opts.runtimeFiles) { + const auto id = bf::identify(dir / rel); + if (id.format != own.format) continue; + // Mach-O's identity states no machine (a fat file has several), and + // its magic is also a Java class file's: the file is one of the + // program's when its load commands read for the program's slice. + if (own.format == bf::Format::MachO) { + auto t = mcpp::toolchain::triple::parse(plan.triple); + if (!bf::macho_needed(dir / rel, t ? t->arch + : std::string(mcpp::toolchain::platform::host_arch))) + continue; + } else if (id.arch != own.arch) { + continue; + } + out.push_back(rel); + } + return out; +} + // Steps 1-3 of `run`'s generic (non-PE, non-wasm, non-shared-object) path: // wipe and recreate the staging root, copy the program into `bin/`, stage the // files `[runtime] deploy` / `deploy_files` declared (#615), and copy @@ -2028,18 +2154,26 @@ ClosureRead read_closure(const ClosureReadInput& in) // loader does. std::set seen; + const auto objectDir = in.object.parent_path(); if (in.rule != ClosureRule::MachO) { - std::vector queue{in.object}; + // The roots are read first, the program last, so that the program's + // own names are the ones resolved first (the queue is a stack). + std::vector queue; + for (auto const& rel : in.deployed) queue.push_back(objectDir / rel); + queue.push_back(in.object); + const std::set rootSet(queue.begin(), queue.end()); while (!queue.empty()) { auto current = queue.back(); queue.pop_back(); auto names = bf::needed_names(current); if (!names) { - // The object itself was chosen by the caller, so an unreadable - // one is reported; a member that cannot be read was already - // staged and contributes nothing further. - if (current == in.object) - out.unresolved.push_back({current.filename().string(), names.error()}); + // A root was chosen by the caller, so an unreadable one is + // reported; a member that cannot be read was already staged + // and contributes nothing further. + if (rootSet.contains(current)) + out.unresolved.push_back({current == in.object + ? current.filename().generic_string() + : current.lexically_relative(objectDir).generic_string(), names.error()}); continue; } for (auto const& name : *names) { @@ -2101,8 +2235,18 @@ ClosureRead read_closure(const ClosureReadInput& in) const auto programDir = in.object.parent_path(); const auto programRpaths = first->rpaths; std::set seenDest; - std::vector queue{ - Image{in.object, {}, std::move(first->names), std::move(first->rpaths)}}; + // The roots below the program on the stack, as on the other rules. + std::vector queue; + for (auto const& rel : in.deployed) { + auto root = bf::macho_needed(objectDir / rel, in.arch); + if (!root) { + out.unresolved.push_back({rel.generic_string(), root.error()}); + continue; + } + queue.push_back(Image{objectDir / rel, rel.parent_path(), + std::move(root->names), std::move(root->rpaths)}); + } + queue.push_back(Image{in.object, {}, std::move(first->names), std::move(first->rpaths)}); // `@loader_path/` -> ``; nullopt when `s` does not begin // with the token followed by a separator. @@ -2287,6 +2431,7 @@ run_pe(const Plan& plan) in.rule = ClosureRule::Pe; in.searchDirs = plan.searchDirs; in.forceBundle = plan.forceBundleLibs; + in.deployed = deployed_objects(plan, stagedExe, stagedExe.parent_path()); const auto read = read_closure(in); // PE's rule resolves every name (see `ClosureRule`); what can remain // is an executable the reader could not parse, which no format can @@ -3075,6 +3220,7 @@ run_shared_program(const Plan& plan) in.rule = ClosureRule::Android; in.searchDirs = leg.searchDirs; in.platformDirs = leg.platformDirs; + in.deployed = deployed_objects(plan, leg.artifact, leg.artifact.parent_path()); const auto read = read_closure(in); std::vector> copies; if (auto r = stage_closure(plan, read, leg.dir, needs, unresolved, prefix, @@ -3217,6 +3363,7 @@ run(const Plan& plan, const mcpp::config::GlobalConfig& cfg) in.rule = ClosureRule::MachO; auto t = mcpp::toolchain::triple::parse(plan.triple); in.arch = t ? t->arch : std::string(mcpp::toolchain::platform::host_arch); + in.deployed = deployed_objects(plan, plan.builtBinary, plan.builtBinary.parent_path()); const auto read = read_closure(in); if (auto r = stage_closure(plan, read, plan.stagingRoot / "bin", needs, unresolved, {}); !r) @@ -3365,11 +3512,22 @@ run(const Plan& plan, const mcpp::config::GlobalConfig& cfg) return t && !t->loads_on_host(); }(); std::vector targetSystemNames; + // The objects the build deployed beside the program are roots of + // the closure as the program is (mcpp#1011), read by the same rule. + // A program with no loader loads none of them into its process. + const auto deployed = selfContained ? std::vector{} + : deployed_objects(plan, plan.builtBinary, plan.builtBinary.parent_path()); auto foreign_closure = [&]() -> std::expected { LddClosure c; if (!facts) return c; const auto bin = plan.builtBinary.parent_path(); - for (auto const& name : facts->needed) { + std::vector names = facts->needed; + for (auto const& rel : deployed) + if (auto f = mcpp::runtime::elf::inspect_elf_runtime(bin / rel)) + names.insert(names.end(), f->needed.begin(), f->needed.end()); + std::set seen; + for (auto const& name : names) { + if (!seen.insert(name).second) continue; std::error_code ec; std::filesystem::path found; for (auto const& dir : {bin, bin.parent_path() / "lib"}) @@ -3379,9 +3537,9 @@ run(const Plan& plan, const mcpp::config::GlobalConfig& cfg) } return c; }; - auto deps = selfContained ? decltype(ldd_parse(plan.builtBinary)){} + auto deps = selfContained ? std::expected{} : foreignSystem ? foreign_closure() - : ldd_parse(plan.builtBinary); + : trace_closure(plan.builtBinary, deployed); if (!deps) return std::unexpected(Error{std::format( "ldd failed on {}: {}", plan.builtBinary.string(), deps.error())}); @@ -3431,6 +3589,8 @@ run(const Plan& plan, const mcpp::config::GlobalConfig& cfg) needs.push_back({name, ClosureNeed::Kind::Unresolved, {}}); unresolved.push_back(name + ": the loader finds no file for it"); } + if (bundling) + unresolved.insert(unresolved.end(), deps->notLoaded.begin(), deps->notLoaded.end()); if (!unresolved.empty()) unresolvedText = unresolved_reason(plan.binaryName, unresolved, "The loader looks through the program's run-time search path " @@ -3463,6 +3623,11 @@ run(const Plan& plan, const mcpp::config::GlobalConfig& cfg) if (toBundle.empty()) { if (auto r = mcpp::pack::relocate::strip_search_paths(bundledBinary); !r) return std::unexpected(Error{r.error()}); + // The deployed objects of the closure, by the same rule. + for (auto const& rel : deployed) + if (auto r = mcpp::pack::relocate::strip_search_paths( + bundledBinary.parent_path() / rel); !r) + return std::unexpected(Error{r.error()}); } auto patchelf = sandbox_patchelf(cfg); @@ -3474,6 +3639,31 @@ run(const Plan& plan, const mcpp::config::GlobalConfig& cfg) patchelf); !r) return std::unexpected(Error{r.error()}); } + // A DEPLOYED OBJECT FINDS THE BUNDLED LIBRARIES AS THE PROGRAM + // DOES (mcpp#1011). Its search path is its own when it has one + // (DT_RUNPATH hides the program's from the libraries it needs), + // and the build's points into this machine's store or SDK; it + // becomes the bundle's `lib/`, relative to where the object is + // staged. A deployed program takes the program's form and loader. + for (auto const& rel : deployed) { + const auto staged = bundledBinary.parent_path() / rel; + const auto facts = mcpp::runtime::elf::inspect_elf_runtime(staged); + if (!facts || (facts->interp.empty() && facts->needed.empty())) continue; + const bool program = !facts->interp.empty(); + if (!toBundle.empty()) { + const auto up = (plan.stagingRoot / "lib") + .lexically_relative(staged.parent_path()).generic_string(); + if (auto r = set_search_path(staged, "$ORIGIN/" + up, + program ? mcpp::build::loader::Form::Executable + : mcpp::build::loader::Form::SharedLibrary, + patchelf); !r) + return std::unexpected(Error{r.error()}); + } + if (program && (plan.opts.mode == Mode::BundleProject || plan.opts.mode == Mode::None)) + if (auto soname = find_loader_soname(deps->found); !soname.empty()) + if (auto r = set_interpreter(staged, distro_loader(soname), patchelf); !r) + return std::unexpected(Error{r.error()}); + } // EVERY BUNDLED LIBRARY, not just the executable. // @@ -3522,10 +3712,7 @@ run(const Plan& plan, const mcpp::config::GlobalConfig& cfg) // loader directly. if (plan.opts.mode == Mode::BundleProject || plan.opts.mode == Mode::None) { if (auto soname = find_loader_soname(deps->found); !soname.empty()) { - auto distroLoader = - (soname == "ld-linux-x86-64.so.2" ? "/lib64/" : "/lib/") - + soname; - if (auto r = set_interpreter(bundledBinary, distroLoader, + if (auto r = set_interpreter(bundledBinary, distro_loader(soname), patchelf); !r) return std::unexpected(Error{r.error()}); } diff --git a/tests/e2e/pack/modes.cpp b/tests/e2e/pack/modes.cpp index da0bb734d..2c2aa60f2 100644 --- a/tests/e2e/pack/modes.cpp +++ b/tests/e2e/pack/modes.cpp @@ -2,7 +2,7 @@ // capabilities a self-contained bundle refuses, runtime files, `kind = "app"`, files staged // before the closure, the closure an ELF host pack states, several programs and a dotted // name, an artifact for another system, a static platform's programs in a format the pack does -// not read (formerly tests/e2e/30, 215, 216, 649, 652, 662, 669, +// not read, a deployed plugin's libraries (formerly tests/e2e/30, 215, 216, 649, 652, 662, 669, // 1043, 1061). import std; import mcpplibs.mtest; @@ -796,6 +796,73 @@ platform = { path = "../plat" } expect(fatal(!r)) << "a dynamic program of an unread format was packed without its closure\n" << s::text(r); expect(fatal(e2e::contains(s::text(r), "neither ELF, PE nor Mach-O"))) << "the refusal does not name the format\n" << s::text(r); }; + "1159 a deployed plugin's libraries are packed with it"_test[s::pack][s::patchelf][s::elf][s::gcc] = [] { + // mcpp#1011: a shared object the build deploys beside the program and the program only + // loads at run time is a root of the closure as the program is. Its library, which the + // program does not link, is bundled under lib/; the plugin's search path in the tree is + // the bundle's lib/ relative to where it is staged, not the build machine's directory; + // and the packed program loads the plugin with that directory gone. + const auto tmp = s::case_dir(); + const auto cc = s::host_cc(); + expect(fatal(cc.has_value())) << "no host C compiler links a shared object"; + s::project ext{tmp / "ext", {{"dep.c", "int dep_value(void) { return 7; }\n"}, + {"plug.c", "int dep_value(void);\nint plug(void) { return dep_value(); }\n"}}}; + fs::create_directories(ext.at("lib")); + auto built = e2e::run({.argv = {cc->string(), "-shared", "-fPIC", "-Wl,-soname,libdep.so", "-o", + ext.at("lib/libdep.so").string(), ext.at("dep.c").string()}}); + expect(fatal(e2e::succeeded(built))) << "the host C compiler failed\n" << s::text(built); + s::project app{tmp / "app", {{"mcpp.toml", R"cpp([package] +name = "app" +version = "0.1.0" + +[targets.app] +kind = "bin" +main = "src/main.c" + +[toolchain] +linux = "gcc@16.1.0" + +[runtime] +deploy = [ { from = "vendor/libplug.so", to = "plugins" } ] +)cpp"}, {"src/main.c", R"cpp(#define _DEFAULT_SOURCE +#include +#include +#include +#include +int main(void) { + char self[4096]; + ssize_t n = readlink("/proc/self/exe", self, sizeof self - 32); + if (n <= 0) return 2; + self[n] = 0; + strcpy(strrchr(self, '/') + 1, "plugins/libplug.so"); + void* h = dlopen(self, RTLD_NOW); + if (!h) { printf("dlopen: %s\n", dlerror()); return 1; } + int (*plug)(void) = (int (*)(void))dlsym(h, "plug"); + printf("plug=%d\n", plug()); + return plug() == 7 ? 0 : 1; +} +)cpp"}}}; + fs::create_directories(app.at("vendor")); + built = e2e::run({.argv = {cc->string(), "-shared", "-fPIC", "-o", app.at("vendor/libplug.so").string(), + ext.at("plug.c").string(), "-L" + ext.at("lib").string(), "-ldep", + "-Wl,--enable-new-dtags,-rpath," + ext.at("lib").string()}}); + expect(fatal(e2e::succeeded(built))) << "the host C compiler failed\n" << s::text(built); + auto r = app.mcpp({"pack", "--pkg-format", "dir"}); + expect(fatal(e2e::succeeded(r))) << "mcpp pack failed\n" << s::text(r); + const auto tree = dist_dir(app, "app-0.1.0-"); + expect(fatal(tree.has_value())) << "no staged tree\n" << s::text(r); + const fs::path manifest = tree->string() + ".stage-manifest"; + expect(fatal(fs::is_regular_file(*tree / "bin/plugins/libplug.so"))) << "the plugin is not deployed in the tree"; + expect(fatal(fs::is_regular_file(*tree / "lib/libdep.so"))) << "the plugin's library is not bundled\n" << s::read_file(manifest); + expect(fatal(has_exact_line(manifest, "needs\tlibdep.so\tlib/libdep.so"))) << "the manifest does not state libdep.so at lib/libdep.so\n" << s::read_file(manifest); + const auto plug = s::read_header(*tree / "bin/plugins/libplug.so"); + expect(fatal(plug.runpath == "$ORIGIN/../../lib")) << "the plugin's search path in the tree is '" << plug.runpath << "'"; + fs::rename(ext.at("lib"), ext.at("lib.away")); + auto run = s::run(*tree / "bin/app"); + fs::rename(ext.at("lib.away"), ext.at("lib")); + expect(fatal(e2e::succeeded(run))) << "the packed program does not load its plugin\n" << s::text(run); + expect(fatal(s::has_line(s::text(run), "^plug=7$"))) << "the plugin did not answer\n" << s::text(run); + }; }}; } // namespace diff --git a/tests/unit/test_pack_closure.cpp b/tests/unit/test_pack_closure.cpp index 3fdf2f2bb..f714d7ab6 100644 --- a/tests/unit/test_pack_closure.cpp +++ b/tests/unit/test_pack_closure.cpp @@ -286,6 +286,36 @@ UTest force_bundle_reaches_the_system_list{"PackClosurePe/ForceBundleReachesTheS expect(with.platform.empty()); }}; +UTest a_deployed_dll_is_a_root_of_the_closure{"PackClosurePe/ADeployedDllIsARootOfTheClosure", [] { + // mcpp#1011: a plugin the program loads at run time imports what the + // program does not; its names resolve as the program's do and are staged + // beside the program, where the loader searches for a loaded DLL's imports. + Tree t; + auto exe = t.write("bin/app.exe", pe_importing({"core.dll"})); + t.write("bin/platforms/qwin.dll", pe_importing({"gui.dll", "KERNEL32.dll"})); + t.write("deps/core.dll", pe_importing({})); + t.write("deps/gui.dll", pe_importing({"core.dll"})); + + mcpp::pack::ClosureReadInput in; + in.object = exe; + in.rule = mcpp::pack::ClosureRule::Pe; + in.searchDirs = {t.root / "bin", t.root / "deps"}; + auto without = mcpp::pack::read_closure(in); + expect(eq(member_dests(without), (Names{"core.dll"}))); + + in.deployed = {"platforms/qwin.dll"}; + auto with = mcpp::pack::read_closure(in); + expect(eq(member_dests(with), (Names{"core.dll", "gui.dll"}))); + expect(eq(with.platform, (Names{"KERNEL32.dll"}))); + expect(with.unresolved.empty()); + + // A deployed root that cannot be read is named by its path. + t.write("bin/platforms/broken.dll", "MZ"); + in.deployed = {"platforms/broken.dll"}; + auto broken = mcpp::pack::read_closure(in); + expect(eq(unresolved_names(broken), (Names{"platforms/broken.dll"}))); +}}; + // ── SPEC-007 R4.2/R4.3: one destination, one writer (#723 self-review) ── // // `place_runtime_dlls` is the function behind the `place-dlls` ninja edge. @@ -468,6 +498,26 @@ UTest a_loader_path_subdirectory_is_staged_at_that_subdirectory{"PackClosureMach expect(r.unresolved.empty()); }}; +UTest a_deployed_bundle_inherits_the_programs_rpaths{"PackClosureMachO/ADeployedBundleInheritsTheProgramsRpaths", [] { + // mcpp#1011: an image the program loads at run time is a root; its + // `@rpath` names resolve through the program's rpaths as dyld resolves + // them, and its `@loader_path` names below its own staged directory. + Tree t; + auto app = t.write("bin/app", macho_naming({}, {"@loader_path"})); + t.write("bin/plugins/libp.dylib", + macho_naming({"@rpath/libdep.dylib", "@loader_path/libq.dylib"}, {})); + t.write("bin/libdep.dylib", macho_naming({}, {})); + t.write("bin/plugins/libq.dylib", macho_naming({}, {})); + + mcpp::pack::ClosureReadInput in; + in.object = app; + in.rule = mcpp::pack::ClosureRule::MachO; + in.deployed = {"plugins/libp.dylib"}; + auto r = mcpp::pack::read_closure(in); + expect(eq(member_dests(r), (Names{"libdep.dylib", "plugins/libq.dylib"}))); + expect(r.unresolved.empty()); +}}; + UTest a_name_outside_the_programs_directory_is_unresolved{"PackClosureMachO/ANameOutsideTheProgramsDirectoryIsUnresolved", [] { Tree t; t.write("Frameworks/libz.dylib", macho_naming({}, {})); From cff18450cfa974ef6f64a9e938397694727ece3e Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 24 Nov 2026 04:56:22 +0900 Subject: [PATCH 28/33] fix: the program's own trace comes before the preloaded one A preloaded object answers every later request for its soname, so a deployed library the program also links left the program's resolution of that name, and so lib/, when the program was traced only with the deployed objects preloaded. --- ...erface-and-derived-state-ecosystem-design.md | 9 ++++++--- src/pack/pack.cppm | 13 ++++++++++++- tests/e2e/pack/modes.cpp | 17 ++++++++++++++++- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md index 21dc7f202..1e082dc29 100644 --- a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md +++ b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md @@ -460,8 +460,10 @@ Web 行上两个程序各带其模块。 同一规则解析;Mach-O 的根继承程序的 rpath,与 dyld 对程序装载的映像所做的相同。选择根的函数(`deployed_objects`) 只有一个,各格式的打包都调用它。 - **本机的 ELF 仍询问装载器。** 部署的共享对象经 `LD_PRELOAD` 预装入程序的追踪:装载器在程序的进程中、以程序的搜索 - 路径与已装载的库解析其名字,与程序 `dlopen` 它时相同;glibc 不把可执行文件装入另一进程,部署的程序单独追踪。名字按 - soname 合并,程序的在先。另一系统的 ELF 按程序的规则读取根的 `DT_NEEDED`。 + 路径与已装载的库解析其名字,与程序 `dlopen` 它时相同;glibc 不把可执行文件装入另一进程,部署的程序单独追踪。程序先 + 单独追踪:预装的对象回答之后对其 soname 的每次请求,程序也链接的部署库会被记为预装的路径,程序自身对该名字的解析 + (`lib/` 应携带的文件)随之从追踪中消失(glibc 2.39 测得)。名字按 soname 合并,程序的在先。另一系统的 ELF 按程序的 + 规则读取根的 `DT_NEEDED`。 - **树中的搜索路径。** 部署对象的搜索路径是它自己的(带 DT_RUNPATH 的对象不经程序的搜索路径查找其库),构建时指向本机的 存储或 SDK;暂存后改为相对其位置的 `lib/`,部署的程序同时取程序的解释器。携带的库为空时,与程序一样清除。 - **不沉默。** `LD_PRELOAD` 以 `:` 与空白分隔条目且无转义,路径含这些字符的对象无法交给装载器;装载器拒绝装载的对象 @@ -470,7 +472,8 @@ Web 行上两个程序各带其模块。 部署列表;部署插件的导入在 `mcpp run` 中经 `PATH` 找到。该机制不属于打包,本条不改变它。 回归由一个 e2e 与两个单元测试覆盖:本机 ELF 上部署的插件需要程序不链接的库,打包后该库位于 `lib/`、插件的搜索路径为 -`$ORIGIN/../../lib`,构建机器上的库目录移走后打包的程序装载插件成功(修复前 `lib/` 不存在);PE 的部署 DLL 与 Mach-O +`$ORIGIN/../../lib`,构建机器上的库目录移走后打包的程序装载插件成功(修复前 `lib/` 不存在),程序也链接的部署库仍在 +`lib/` 中;PE 的部署 DLL 与 Mach-O 的部署映像各自的闭包。 ## 4. 跨平台 diff --git a/src/pack/pack.cppm b/src/pack/pack.cppm index f0f7c00e8..d254d86d0 100644 --- a/src/pack/pack.cppm +++ b/src/pack/pack.cppm @@ -1116,6 +1116,12 @@ ldd_parse(const std::filesystem::path& binary, // the program is. An object with neither a loader nor a needed library has no // closure. Names are merged by soname, the program's first. // +// THE PROGRAM IS TRACED ALONE FIRST. A preloaded object satisfies every later +// request for its soname, so a deployed library the program also links would +// be resolved as the preloaded path and leave the program's own resolution of +// that name -- the file `lib/` must carry -- out of the trace (measured with +// glibc 2.39). +// // `LD_PRELOAD` separates its entries by `:` and white space and has no escape, // so an object whose path below the program's directory holds one cannot be // named to the loader; it is reported, not dropped. @@ -1145,9 +1151,14 @@ trace_closure(const std::filesystem::path& program, if (notFound.insert(n).second) merged.notFound.push_back(std::move(n)); for (auto& n : c.notLoaded) merged.notLoaded.push_back(std::move(n)); }; - auto first = ldd_parse(program, preload); + auto first = ldd_parse(program); if (!first) return std::unexpected(first.error()); merge(std::move(*first)); + if (!preload.empty()) { + auto loaded = ldd_parse(program, preload); + if (!loaded) return std::unexpected(loaded.error()); + merge(std::move(*loaded)); + } for (auto const& rel : programs) { auto other = ldd_parse(dir / rel); if (!other) return std::unexpected(std::format("{}: {}", rel.generic_string(), other.error())); diff --git a/tests/e2e/pack/modes.cpp b/tests/e2e/pack/modes.cpp index 2c2aa60f2..3f1c2b26b 100644 --- a/tests/e2e/pack/modes.cpp +++ b/tests/e2e/pack/modes.cpp @@ -801,7 +801,8 @@ platform = { path = "../plat" } // loads at run time is a root of the closure as the program is. Its library, which the // program does not link, is bundled under lib/; the plugin's search path in the tree is // the bundle's lib/ relative to where it is staged, not the build machine's directory; - // and the packed program loads the plugin with that directory gone. + // and the packed program loads the plugin with that directory gone. A deployed library the + // program also links stays the program's member of lib/. const auto tmp = s::case_dir(); const auto cc = s::host_cc(); expect(fatal(cc.has_value())) << "no host C compiler links a shared object"; @@ -822,14 +823,20 @@ main = "src/main.c" [toolchain] linux = "gcc@16.1.0" +[build] +ldflags = ["-L@VENDOR@", "-lown", "-Wl,-rpath,$ORIGIN"] + [runtime] +deploy_files = ["vendor/libown.so"] deploy = [ { from = "vendor/libplug.so", to = "plugins" } ] )cpp"}, {"src/main.c", R"cpp(#define _DEFAULT_SOURCE #include #include #include #include +int own_value(void); int main(void) { + if (own_value() != 5) return 3; char self[4096]; ssize_t n = readlink("/proc/self/exe", self, sizeof self - 32); if (n <= 0) return 2; @@ -847,6 +854,13 @@ int main(void) { ext.at("plug.c").string(), "-L" + ext.at("lib").string(), "-ldep", "-Wl,--enable-new-dtags,-rpath," + ext.at("lib").string()}}); expect(fatal(e2e::succeeded(built))) << "the host C compiler failed\n" << s::text(built); + app.write("vendor/own.c", "int own_value(void) { return 5; }\n"); + auto toml = app.read("mcpp.toml"); + toml.replace(toml.find("@VENDOR@"), 8, app.at("vendor").generic_string()); + app.write("mcpp.toml", toml); + built = e2e::run({.argv = {cc->string(), "-shared", "-fPIC", "-Wl,-soname,libown.so", "-o", + app.at("vendor/libown.so").string(), app.at("vendor/own.c").string()}}); + expect(fatal(e2e::succeeded(built))) << "the host C compiler failed\n" << s::text(built); auto r = app.mcpp({"pack", "--pkg-format", "dir"}); expect(fatal(e2e::succeeded(r))) << "mcpp pack failed\n" << s::text(r); const auto tree = dist_dir(app, "app-0.1.0-"); @@ -855,6 +869,7 @@ int main(void) { expect(fatal(fs::is_regular_file(*tree / "bin/plugins/libplug.so"))) << "the plugin is not deployed in the tree"; expect(fatal(fs::is_regular_file(*tree / "lib/libdep.so"))) << "the plugin's library is not bundled\n" << s::read_file(manifest); expect(fatal(has_exact_line(manifest, "needs\tlibdep.so\tlib/libdep.so"))) << "the manifest does not state libdep.so at lib/libdep.so\n" << s::read_file(manifest); + expect(fatal(has_exact_line(manifest, "needs\tlibown.so\tlib/libown.so"))) << "the deployed library the program links left lib/\n" << s::read_file(manifest); const auto plug = s::read_header(*tree / "bin/plugins/libplug.so"); expect(fatal(plug.runpath == "$ORIGIN/../../lib")) << "the plugin's search path in the tree is '" << plug.runpath << "'"; fs::rename(ext.at("lib"), ext.at("lib.away")); From ace5e032ed248a3219b22c508f8332a20e2bc88c Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 24 Nov 2026 04:59:06 +0900 Subject: [PATCH 29/33] test: the target-rows snapshot records openkal-platform 0.32.1, the default --- tests/fixtures/target-rows.snapshot | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tests/fixtures/target-rows.snapshot b/tests/fixtures/target-rows.snapshot index f71185221..5e09b05a2 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.32.0 + table tier=preview note=PE pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.1 str x86_64-windows-musl llvm x86_64-w64-windows-gnu llvm@15.0 x86_64-w64-windows-gnu @@ -189,7 +189,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.32.0 + table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.1 str aarch64-macos-musl llvm arm64-apple-macos14.0 llvm@15.0 arm64-apple-macos15.0 @@ -227,7 +227,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.32.0 + table tier=planned note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.1 str i686-linux-musl llvm i686-unknown-linux-musl llvm@15.0 i686-unknown-linux-musl @@ -265,7 +265,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.32.0 + table tier=planned note=ok pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.1 str i686-openkal llvm i686-unknown-none-elf llvm@15.0 i686-unknown-none-elf @@ -303,7 +303,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.32.0 + table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.1 str x86_64-macos-musl llvm x86_64-apple-macos14.0 llvm@15.0 x86_64-apple-macos15.0 @@ -360,7 +360,7 @@ row aarch64-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.32.0 + table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.1 str x86_64-freebsd-musl llvm x86_64-unknown-freebsd14.0 llvm@15.0 x86_64-unknown-freebsd14.0 @@ -379,7 +379,7 @@ row x86_64-freebsd-musl 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.32.0 + table tier=preview note= pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.1 str aarch64-freebsd-musl llvm aarch64-unknown-freebsd14.0 llvm@15.0 aarch64-unknown-freebsd14.0 @@ -836,7 +836,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.32.0 + table tier=verified note=ok pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.1 str x86_64-openkal llvm x86_64-unknown-none-elf llvm@15.0 x86_64-unknown-none-elf @@ -855,7 +855,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.32.0 + table tier=verified note=ok pin=llvm@23.1.3 sysroot= static=1 platform=mcpplibs.openkal-platform@0.32.1 str aarch64-openkal llvm aarch64-unknown-none-elf llvm@15.0 aarch64-unknown-none-elf @@ -990,7 +990,7 @@ set linux-musl -> x86_64-linux-musl aarch64-linux-musl riscv64-linux-musl | set windows -> x86_64-windows-gnu aarch64-windows-gnu | set windows-msvc -> x86_64-windows-msvc i686-windows-msvc | set macos -> aarch64-macos | -set openkal -> x86_64-openkal aarch64-openkal | mcpplibs.openkal-platform@0.32.0 +set openkal -> x86_64-openkal aarch64-openkal | mcpplibs.openkal-platform@0.32.1 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 | From 8b236846d497b1f1d5f1f631eb6a69d309f372f7 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 24 Nov 2026 05:13:42 +0900 Subject: [PATCH 30/33] test: the Windows matrix cell of riscv64-linux-musl with msvc is the measured host-tool-toolchain --- tests/matrix/expected.tsv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/matrix/expected.tsv b/tests/matrix/expected.tsv index 22d2f53d7..23e10d3e1 100644 --- a/tests/matrix/expected.tsv +++ b/tests/matrix/expected.tsv @@ -431,7 +431,7 @@ payload windows-x86_64 i686-openkal msvc@system - - - - - unsupported capability payload windows-x86_64 riscv32-none-elf llvm@23.1.3 riscv32-none-elf none - - - ok none payload windows-x86_64 riscv32-none-elf msvc@system - - - - - unsupported capability-pin payload windows-x86_64 riscv64-linux-musl llvm@23.1.3 riscv64-unknown-linux-musl none musl(platform) libc++(platform) openkal-llvm-runtime@0.20.3 ok none -payload windows-x86_64 riscv64-linux-musl msvc@system - - - - - unsupported convention-unreplaced +payload windows-x86_64 riscv64-linux-musl msvc@system - - - - - unsupported host-tool-toolchain payload windows-x86_64 riscv64-none-elf llvm@23.1.3 riscv64-none-elf none - - - ok none payload windows-x86_64 riscv64-none-elf msvc@system - - - - - unsupported capability-pin payload windows-x86_64 thumbv6m-none-eabi llvm@23.1.3 thumbv6m-none-eabi none - - - ok none From 6c457bb9b8892c885a33435e1c2aebe72a870471 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 24 Nov 2026 07:04:38 +0900 Subject: [PATCH 31/33] ci: every e2e shard divides the suite by the history and coverage map the plan resolved once Each shard computed its part from the stores and coverage map it downloaded itself, and a failed download silently divided by count. One macOS shard of a #1006 run divided by count while three divided by history, and test 1033 fell in no part. The plan now resolves both runs once and passes them to every shard; a run that keeps the artifacts but cannot be read fails the step after three attempts (.github/tools/run_artifacts.sh). --- ...face-and-derived-state-ecosystem-design.md | 16 ++++- .github/actions/e2e-mtest/action.yml | 61 ++++++++++++++++--- .github/tools/run_artifacts.sh | 43 +++++++++++++ .github/workflows/ci-linux-e2e.yml | 10 +++ .github/workflows/ci-macos-e2e.yml | 10 +++ .github/workflows/ci-windows-e2e.yml | 10 +++ .github/workflows/ci.yml | 11 ++++ 7 files changed, 149 insertions(+), 12 deletions(-) create mode 100755 .github/tools/run_artifacts.sh diff --git a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md index 1e082dc29..6396023fd 100644 --- a/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md +++ b/.agents/docs/2026-11-22-kernel-interface-and-derived-state-ecosystem-design.md @@ -473,8 +473,19 @@ Web 行上两个程序各带其模块。 回归由一个 e2e 与两个单元测试覆盖:本机 ELF 上部署的插件需要程序不链接的库,打包后该库位于 `lib/`、插件的搜索路径为 `$ORIGIN/../../lib`,构建机器上的库目录移走后打包的程序装载插件成功(修复前 `lib/` 不存在),程序也链接的部署库仍在 -`lib/` 中;PE 的部署 DLL 与 Mach-O -的部署映像各自的闭包。 +`lib/` 中;PE 的部署 DLL 与 Mach-O 的部署映像各自的闭包。 + +### 3.23 e2e 分片的划分输入(mcpp CI) + +每个 e2e 分片自行计算自己的部分(`mtest run --shard`),依据是 main 最近一次成功运行保存的历史(各主机的 store)与覆盖 +映射。各分片的部分合起来覆盖全部测试,前提是它们读取同一份输入;此前每个分片自行查找这两次运行,下载失败时静默改为按数量 +划分。#1006 的一次运行中,macOS 的一个分片未能下载历史而按数量划分,其余三个按历史划分,测试 1033 不在任何部分中,覆盖 +检查因此失败(四个部分合计 22 个程序,全集为 18 个)。 + +- **输入只解析一次。** 计划任务(`e2e-plan`)解析历史与覆盖映射所在的运行,作为输出交给各主机的分片;分片读取这两次 + 运行,不再自行查找。没有这样的运行时记为 `none`,计划与分片同按数量划分。 +- **读取失败不沉默。** 一次运行保存了所需的产物而读取失败时,下载重试三次后该步骤失败;只有运行未保存该产物时才按数量 + 划分(`.github/tools/run_artifacts.sh` 区分这两种情况)。 ## 4. 跨平台 @@ -534,6 +545,7 @@ Web 行上两个程序各带其模块。 - 存储:根的登记、home 格式的一步、`mcpp cache gc` 调用 xlings 的回收;捆绑的 xlings 版本; - 构建程序的接口与构建数据库:`mcpp::action` 的 `origin`、生成条目的字段、角色与重复提供者的消息; - 打包:部署对象作为闭包的根(§3.22),SPEC-014 §1.2、docs/10 的中英文; +- CI:e2e 分片的划分输入由计划任务解析一次(§3.23),`.github/actions/e2e-mtest`、`.github/tools/run_artifacts.sh`; - 规范:SPEC-002、SPEC-004、SPEC-005、SPEC-006、SPEC-013、SPEC-016;用法:docs/04、docs/09、docs/20、docs/22、docs/50 的 中英文;CHANGELOG。 diff --git a/.github/actions/e2e-mtest/action.yml b/.github/actions/e2e-mtest/action.yml index 57e445cdb..d8cf5b7c8 100644 --- a/.github/actions/e2e-mtest/action.yml +++ b/.github/actions/e2e-mtest/action.yml @@ -6,6 +6,12 @@ description: > `--shard` divides the suite by measured time and a run orders its tests longest first. Exports E2E_MTEST for run_all.sh. A run with no store of main divides by count, and its own store becomes the next run's history. + Every shard computes its own part, so the parts cover the suite only when + every shard reads the same history and the same coverage map: ci.yml's plan + resolves both runs once (outputs `history`, `coverage`) and passes them to + each shard, and a run that kept them but cannot be read fails the step + rather than dividing by other data (CI, 2026-11-23: one macOS shard divided + by count, three by history, and test 1033 fell in no part). inputs: host: @@ -13,11 +19,31 @@ inputs: the host's name in the stores' artifact names (linux, macos, windows), or `*` for every host's (the plan of ci.yml) required: true + history: + description: > + the run whose stores are the history (the plan's `history` output); + `none` when main has no such run; empty to resolve it here + required: false + default: '' + coverage: + description: > + the run whose coverage map selects the `pr` set (the plan's `coverage` + output); `none` when there is no map; empty to resolve it here + required: false + default: '' token: description: a token that reads this repository's actions required: false default: ${{ github.token }} +outputs: + history: + description: the run whose stores were read, or `none` + value: ${{ steps.history.outputs.run }} + coverage: + description: the run whose coverage map was read, or `none` + value: ${{ steps.coverage.outputs.run }} + runs: using: composite steps: @@ -35,36 +61,51 @@ runs: git fetch --no-tags --depth=1 origin "+refs/heads/${{ github.base_ref }}:refs/remotes/origin/${{ github.base_ref }}" || true git fetch --no-tags --deepen=1 origin || true - name: The stores of main's last CI run + id: history shell: bash env: GH_TOKEN: ${{ inputs.token }} HOST: ${{ inputs.host }} + RUN: ${{ inputs.history }} run: | set -euo pipefail - run=$(bash .github/tools/main_run.sh) # main's, or the run it registered (design 2026-11-20 §5.22) - if [ -z "$run" ]; then echo "no successful run of main: the suite is divided by count"; exit 0; fi + # main's, or the run it registered (design 2026-11-20 §5.22) + [ -n "$RUN" ] || RUN=$(bash .github/tools/main_run.sh) + [ -n "$RUN" ] || RUN=none + echo "run=$RUN" >> "$GITHUB_OUTPUT" + if [ "$RUN" = none ]; then echo "no successful run of main: the suite is divided by count"; exit 0; fi rm -rf "$RUNNER_TEMP/e2e-stores" - if ! gh run download "$run" -R "$GITHUB_REPOSITORY" -p "e2e-store-$HOST-*" -D "$RUNNER_TEMP/e2e-stores" 2>/dev/null; then - echo "main's run $run kept no store for $HOST: the suite is divided by count"; exit 0 + bash .github/tools/run_artifacts.sh "$RUN" "e2e-store-$HOST-" "$RUNNER_TEMP/e2e-stores" + if [ ! -d "$RUNNER_TEMP/e2e-stores" ]; then + echo "main's run $RUN kept no store for $HOST: the suite is divided by count"; exit 0 fi for store in "$RUNNER_TEMP"/e2e-stores/*/; do (cd tests/e2e && "$E2E_MTEST" store import --from "$store") done - echo "history of main's run $run: $(ls "$RUNNER_TEMP/e2e-stores" | wc -l) store(s)" + echo "history of main's run $RUN: $(ls "$RUNNER_TEMP/e2e-stores" | wc -l) store(s)" # The coverage map of the last nightly measurement (e2e-coverage.yml), on # the host it was measured on: the sources each test's run executed there. # Another host's own sources (src/native/windows/...) run on no Linux test, # so its suite has no map and every test of it is affected. - name: The coverage map + id: coverage if: inputs.host == 'linux' || inputs.host == '*' shell: bash env: GH_TOKEN: ${{ inputs.token }} + RUN: ${{ inputs.coverage }} run: | set -euo pipefail - run=$(gh run list -R "$GITHUB_REPOSITORY" --workflow e2e-coverage.yml --status success --limit 1 \ - --json databaseId -q '.[0].databaseId' 2>/dev/null || true) - if [ -z "$run" ]; then echo "no coverage map: every test is affected"; exit 0; fi + if [ -z "$RUN" ]; then + RUN=$(gh run list -R "$GITHUB_REPOSITORY" --workflow e2e-coverage.yml --status success --limit 1 \ + --json databaseId -q '.[0].databaseId') + [ -n "$RUN" ] || RUN=none + fi + echo "run=$RUN" >> "$GITHUB_OUTPUT" + if [ "$RUN" = none ]; then echo "no coverage map: every test is affected"; exit 0; fi rm -rf "$RUNNER_TEMP/e2e-coverage" - gh run download "$run" -R "$GITHUB_REPOSITORY" -n e2e-coverage-linux -D "$RUNNER_TEMP/e2e-coverage" || exit 0 - (cd tests/e2e && "$E2E_MTEST" coverage import --from "$RUNNER_TEMP/e2e-coverage/coverage.json") + bash .github/tools/run_artifacts.sh "$RUN" "e2e-coverage-linux" "$RUNNER_TEMP/e2e-coverage" + if [ ! -d "$RUNNER_TEMP/e2e-coverage" ]; then + echo "the coverage run $RUN kept no map: every test is affected"; exit 0 + fi + (cd tests/e2e && "$E2E_MTEST" coverage import --from "$RUNNER_TEMP"/e2e-coverage/*/coverage.json) diff --git a/.github/tools/run_artifacts.sh b/.github/tools/run_artifacts.sh new file mode 100755 index 000000000..1d1de2af3 --- /dev/null +++ b/.github/tools/run_artifacts.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# run_artifacts.sh -- download the artifacts of a workflow run +# whose names match , one directory each below . A run that kept no +# such artifact leaves absent and exits 0; a run that kept one that cannot +# be read after three attempts exits 1. The caller tells "nothing to read" from +# "could not read" by that difference, never by a silenced failure: the e2e +# shards each divide the suite by what they read, and a shard that read less +# than the others divided it differently (CI, 2026-11-23). Reads +# GITHUB_REPOSITORY and GH_TOKEN. +set -uo pipefail +run="${1:?run_artifacts.sh: no run}" +glob="${2:?run_artifacts.sh: no name pattern}" +dir="${3:?run_artifacts.sh: no directory}" +repo="${GITHUB_REPOSITORY:?run_artifacts.sh: GITHUB_REPOSITORY is not set}" + +names="" +for attempt in 1 2 3; do + if names=$(gh api --paginate "repos/$repo/actions/runs/$run/artifacts?per_page=100" \ + -q '.artifacts[] | select(.expired | not) | .name'); then + break + fi + names="" + [ "$attempt" = 3 ] && { echo "::error::the artifacts of run $run cannot be listed"; exit 1; } + sleep 15 +done + +matched=0 +while read -r name; do + # shellcheck disable=SC2053 # the pattern is a glob by intent + [[ -n "$name" && "$name" == $glob ]] && matched=1 +done <<<"$names" +[ "$matched" = 1 ] || exit 0 + +for attempt in 1 2 3; do + rm -rf "$dir" + if gh run download "$run" -R "$repo" -p "$glob" -D "$dir"; then + exit 0 + fi + sleep 15 +done +rm -rf "$dir" +echo "::error::run $run keeps artifacts matching '$glob', and they cannot be downloaded" +exit 1 diff --git a/.github/workflows/ci-linux-e2e.yml b/.github/workflows/ci-linux-e2e.yml index d4155c270..3d1afb354 100644 --- a/.github/workflows/ci-linux-e2e.yml +++ b/.github/workflows/ci-linux-e2e.yml @@ -31,6 +31,14 @@ on: description: whether the set gives this host any case type: boolean default: true + history: + description: the run whose stores the plan divided by (`none` for none); empty to resolve it + type: string + default: '' + coverage: + description: the run whose coverage map the plan read (`none` for none); empty to resolve it + type: string + default: '' jobs: e2e: @@ -105,6 +113,8 @@ jobs: - uses: ./.github/actions/e2e-mtest with: host: linux + history: ${{ inputs.history }} + coverage: ${{ inputs.coverage }} - name: E2E suite # About twice the shard's budget of ten minutes (R4): reached only by a diff --git a/.github/workflows/ci-macos-e2e.yml b/.github/workflows/ci-macos-e2e.yml index d355b341c..82643859b 100644 --- a/.github/workflows/ci-macos-e2e.yml +++ b/.github/workflows/ci-macos-e2e.yml @@ -33,6 +33,14 @@ on: description: whether the set gives this host any case type: boolean default: true + history: + description: the run whose stores the plan divided by (`none` for none); empty to resolve it + type: string + default: '' + coverage: + description: the run whose coverage map the plan read (`none` for none); empty to resolve it + type: string + default: '' jobs: e2e: @@ -74,6 +82,8 @@ jobs: - uses: ./.github/actions/e2e-mtest with: host: ${{ matrix.image == 'macos-15' && 'macos' || matrix.image }} + history: ${{ inputs.history }} + coverage: ${{ inputs.coverage }} - name: E2E suite # Twice a shard's budget of about nine minutes (R4); the per-test 600 s diff --git a/.github/workflows/ci-windows-e2e.yml b/.github/workflows/ci-windows-e2e.yml index 53838f8a7..6e732883f 100644 --- a/.github/workflows/ci-windows-e2e.yml +++ b/.github/workflows/ci-windows-e2e.yml @@ -29,6 +29,14 @@ on: description: whether the set gives this host any case type: boolean default: true + history: + description: the run whose stores the plan divided by (`none` for none); empty to resolve it + type: string + default: '' + coverage: + description: the run whose coverage map the plan read (`none` for none); empty to resolve it + type: string + default: '' jobs: e2e: @@ -119,6 +127,8 @@ jobs: - uses: ./.github/actions/e2e-mtest with: host: windows + history: ${{ inputs.history }} + coverage: ${{ inputs.coverage }} - name: E2E suite shell: bash diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8f0e2fe5c..1cf8bda1c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -167,9 +167,14 @@ jobs: windows: ${{ steps.plan.outputs.windows }} windows_work: ${{ steps.plan.outputs.windows_work }} windows_count: ${{ steps.plan.outputs.windows_count }} + # The history and the coverage map the plan divided by: every shard reads + # these two runs, so that each computes its part of one division. + history: ${{ steps.mtest.outputs.history }} + coverage: ${{ steps.mtest.outputs.coverage }} steps: - uses: actions/checkout@v4 - uses: ./.github/actions/e2e-mtest + id: mtest with: host: '*' - name: The plan @@ -439,6 +444,8 @@ jobs: shards: ${{ needs.e2e-plan.outputs.linux || '[1,2,3]' }} count: ${{ needs.e2e-plan.outputs.linux_count || '3' }} work: ${{ needs.e2e-plan.outputs.linux_work != 'false' }} + history: ${{ needs.e2e-plan.outputs.history }} + coverage: ${{ needs.e2e-plan.outputs.coverage }} macos: needs: [build-macos, changes] @@ -456,6 +463,8 @@ jobs: shards: ${{ needs.e2e-plan.outputs.macos || '[1,2,3]' }} count: ${{ needs.e2e-plan.outputs.macos_count || '3' }} work: ${{ needs.e2e-plan.outputs.macos_work != 'false' }} + history: ${{ needs.e2e-plan.outputs.history }} + coverage: ${{ needs.e2e-plan.outputs.coverage }} macos-ios: needs: [build-macos, changes] @@ -478,6 +487,8 @@ jobs: shards: ${{ needs.e2e-plan.outputs.windows || '[1,2,3]' }} count: ${{ needs.e2e-plan.outputs.windows_count || '3' }} work: ${{ needs.e2e-plan.outputs.windows_work != 'false' }} + history: ${{ needs.e2e-plan.outputs.history }} + coverage: ${{ needs.e2e-plan.outputs.coverage }} windows-msvc-xlings: needs: [build-windows, changes] From b18ec60c0e355f6163b0e685a7a4faf6c5b6fc81 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 24 Nov 2026 08:36:51 +0900 Subject: [PATCH 32/33] test: the surface ledger waives no use of target..carrier, which targets/kernel exercises --- tests/e2e/mtest.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/e2e/mtest.toml b/tests/e2e/mtest.toml index 027f42199..5d9d9d878 100644 --- a/tests/e2e/mtest.toml +++ b/tests/e2e/mtest.toml @@ -64,6 +64,3 @@ reason = "reached on Windows only, by a build program under msvc@system with a c [[ledger.surface.waiver]] item = "reason msvc-redist-unavailable" reason = "reached on Windows only, by an MSVC toolset whose layout has no redistributable; no Windows case states it" -[[ledger.surface.waiver]] -item = "key target..carrier" -reason = "a project's carrier of a loader-dependent image (SPEC-013 §11) needs a carrier package of its own; no case builds one" From c088fdd1a30ae016a263df991ed143d17715c297 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 24 Nov 2026 08:38:26 +0900 Subject: [PATCH 33/33] ci: the stores' name pattern ends in a wildcard, so that a shard reads every store of its host --- .github/actions/e2e-mtest/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/e2e-mtest/action.yml b/.github/actions/e2e-mtest/action.yml index d8cf5b7c8..ff10d1e85 100644 --- a/.github/actions/e2e-mtest/action.yml +++ b/.github/actions/e2e-mtest/action.yml @@ -75,7 +75,7 @@ runs: echo "run=$RUN" >> "$GITHUB_OUTPUT" if [ "$RUN" = none ]; then echo "no successful run of main: the suite is divided by count"; exit 0; fi rm -rf "$RUNNER_TEMP/e2e-stores" - bash .github/tools/run_artifacts.sh "$RUN" "e2e-store-$HOST-" "$RUNNER_TEMP/e2e-stores" + bash .github/tools/run_artifacts.sh "$RUN" "e2e-store-$HOST-*" "$RUNNER_TEMP/e2e-stores" if [ ! -d "$RUNNER_TEMP/e2e-stores" ]; then echo "main's run $RUN kept no store for $HOST: the suite is divided by count"; exit 0 fi