diff --git a/.agents/docs/2026-11-22-test-round-wrap-up-plan.md b/.agents/docs/2026-11-22-test-round-wrap-up-plan.md new file mode 100644 index 000000000..89bd52f2d --- /dev/null +++ b/.agents/docs/2026-11-22-test-round-wrap-up-plan.md @@ -0,0 +1,273 @@ +--- +subject: plan +status: active +--- + +# 测试与 CI 一轮的收尾:平台列未命中的刷新条件(mcpp#996)、`i686-windows-msvc` 行、工作区索引与引号键的迁移、索引的全量验证 + +**日期:** 2026-11-22 · **版本:** v2(2026-11-22 评审确定第 4 节的登记、第 6.2 节的结构与拒绝、第 7 节的封装修订随本轮发布、第 10 节 GLOBAL 的源集合,后者在实施中按第 10 节所述修正) · **基线:** mcpp main `b9b63865`(2026.11.21.1 之后,含 #998、#999、#1000)、 +mcpp-index 拉取请求 #873(`8676bc2`)、xim-pkgindex `6c55431` · **规范:** SPEC-013 §14 第 6 条(平台列的未命中)、 +SPEC-004 §9 第 12 条(工作区的镜像表)、SPEC-016 §2(目标行)、docs/51(弃用表) · **所属:** +[生态的测试与 CI 方案](2026-11-20-test-architecture-upgrade-design.md) 的收尾。 + +## 1. 范围 + +本方案收拢 2026.11.21.1 发布之后未闭合的事项与新报告的 mcpp#996。每项给出事实、决定、实现、测试与文档, +并按仓库各一个拉取请求编排(第 11 节)。已合入的部分不再重述:#998(单元分片数按主干上次运行的时长)、 +#999(索引刷新在另一进程旁的等待条件,套件按用例计数)、#1000(graph/860 按 ninja 边判定成员的并行)、 +xim-pkgindex #1222(slint 声明 libXrender)。 + +## 2. 现状 + +| 项 | 状态 | +|---|---| +| mcpp main CI(`b9b63865`) | 73 个作业中 1 个失败:macOS e2e 作业 323 个程序通过、1 个失败,即 `RunExec/QueuedErrorOutputRenewsIdleAfterALineHandler`(exit 137、`timed_out`、0 行);同一运行中 stdout 变体通过,该提交的拉取请求运行中两者都通过 | +| mcpp-index #873(pin mcpp 2026.11.21.1) | 全量运行 19 个分片成功、5 个失败、4 个在 90 分钟上限处取消(pin 改变后缓存为冷) | +| mcpp#996 | 未处理 | +| mcpp-index 根的 `[indices]` | 由 `workspace-position` 读取,该读取 2027.1 移除 | +| mcpp-index 的引号依赖键 | `quoted-dotted-dependency-key`,2027.2 移除 | +| mtest CI 的 mcpp(`.github/versions.env`) | 2026.11.14.1 | +| mcpp `.xlings.json` 的引导版本 | 2026.11.13.1 | +| mcpp 脚手架的 mtest(`kMtestRelease`) | 0.11.2;0.11.3 已发布 | + +## 3. mcpp#996:平台列的未命中只在构成拒绝时刷新 + +### 3.1 事实 + +- SPEC-013 §14 第 6 条:本地索引副本没有认领一行、且没有答案时该行被拒绝(引擎不认识的行、`planned` 行), + 这是一次索引未命中,按依赖未命中的策略决定是否刷新;没有平台也能构建的行未命中时不刷新。 +- 实现把两类不被拒绝的请求当作拒绝: + 1. 引擎不认识、由项目的 `[target.]` 段定义的行。段是自定义三元组的出口(docs/20), + `step1_validate_target_tier` 对它不拒绝;`define_early_platform`(`src/build/prepare/platform.cpp`)对没有选择 + 平台的不认识行一律以 `refreshOnMiss = true` 查询平台列。#996 的 `i686-windows-msvc` 属于这一类。 + 2. 命名了工具链的 `planned` 行(`[target.] toolchain`、`--toolchain`、消费者的子构建,即 `toolchainNamed`)。 + 拒绝门不拒绝它;`step1_select_platform` 与 `named_provider` 以 `planned_row(t)` 决定刷新,不读 `toolchainNamed`。 +- 项目表中的 `platform = "none"`:`define_early_platform` 只在选择不是 `none` 时记下 `chosen`,因此 `none` 之后仍查询 + 平台列并可能刷新;`--platform none`(`chosenText` 非空)不查询。 +- 刷新的去抖为 120 s(`kIndexRefreshDebounceSeconds`),未命中只在进程内记住(`g_columnMisses`),所以相隔超过两分钟的 + 每次构建各刷新一次。#996 记录的三次构建各执行一次 `sync_index` 与 `update_packages`,共 12 至 19 s。 + +### 3.2 决定 + +- **一个谓词。** "没有平台时这一请求被拒绝"由一个函数回答:行不被认识、没有 `[target.]` 段且不由平台定义; + 或行为 `planned` 且没有命名工具链。三个查询点(`define_early_platform`、`named_provider`、`step1_select_platform`) + 以它的回答为 `refreshOnMiss`。谓词所读的事实与拒绝门所读的相同:段的查找(解析后按规范拼写比较,现在写在 + `toolchain.cpp` 的 `TargetOverrideCtx` 初始化中)与 `toolchainNamed` 各提取为一个共享函数,拒绝门与刷新决定调用 + 同一函数,两者不能分叉。 +- **平台列照常读取。** 不构成拒绝的未命中不刷新,本地副本中的平台列仍然回答:以段定义、而本地索引列出其平台的行, + 仍取得该平台。 +- **`none` 是一个选择。** 表中的 `platform = "none"` 与 `--platform none` 一样结束平台列的查询。 +- **不增加持久的未命中记忆。** 有了谓词,刷新只伴随一次被拒绝的构建,行为与依赖未命中相同(去抖、每个进程至多一次)。 + 持久记忆是第二套"何时不刷新"的机制,与依赖未命中的策略不一致,不采用。 + +### 3.3 测试 + +- 单元:谓词对四种输入的回答(不认识且有段、不认识且无段、`planned` 且命名工具链、`planned` 且未命名)。 +- e2e(Linux,隔离的 home,`--offline -v`):`--target x86_64-toyos` 有 `[target.x86_64-toyos]` 段时输出不含平台列的 + 刷新决定;无段时拒绝消息写出未刷新及原因(offline);`--target i686-linux-gnu --toolchain ` 不含刷新决定; + 表中 `platform = "none"` 时不含刷新决定。 + +### 3.4 文档 + +SPEC-013 §14 第 6 条写明两类不被拒绝的请求与 `none`,并标注实现版本;docs/35 的对应段(中英);CHANGELOG 的 Fixed +一条(mcpp#996)。 + +## 4. `i686-windows-msvc` 登记为目标行 + +### 4.1 事实 + +- msvc 探测已把 i686 映射为 MSVC 的 `x86`(`src/toolchain/msvc.cppm` 的 `triple_for_arch` 与 `Host*/x86` 目录); + Windows CI 的 e2e(`tests/e2e/windows/msvc.cpp`)以 `[target.i686-windows-msvc]` 段构建并运行该目标。 +- docs/20 写明它不是目标表的行,构建它的项目声明 `[target.i686-windows-msvc]`。2026-10-06 的方案(O3)把登记移出了 + 当时的范围。 +- #996 的第一项期望:它是与 `x86_64-windows-msvc` 一样不需要平台包的原生目标。 + +### 4.2 决定 + +登记为 `preview` 行:`modules/toolchain-model/data/builtin.toml` 增加 `triple = "i686-windows-msvc"`(`note = "PE"`、 +`standard = true`),`msvc` 提供者的 `serves` 增加该行。行的事实在数据中,引擎不改。层级取 `preview`,因为它的覆盖是 +一个 e2e 用例与本节新增的矩阵行和金丝雀行。项目写的段(如 `sysroot = "msvc@14.44"`)照常作用于已登记的行。 + +### 4.3 随之更新 + +- `tests/matrix/expected.tsv`:windows-x86_64 上 graph 与 payload 两种模式、llvm 与 msvc 两个编译器的四行,取拉取请求 + 运行的 target-matrix 的测量。 +- `tests/canary/matrix.tsv`:c、cxx 两个金丝雀在 windows-x86_64 上 build、static、run、test、pack 的十行,取带 + `ci:canaries` 标签的测量。 +- README、README.zh-CN 与 docs/21(中英)的层级表(`check_target_tiers.py` 比对)。 +- docs/20(中英)删去"不是目标表的行"一段,协程的说明保留。 +- e2e `msvc.cpp` 增加不写段的构建与运行,带段的用例保留。 +- CHANGELOG 的 Added 一条。 + +## 5. `RunExec/QueuedErrorOutputRenewsIdleAfterALineHandler` 的界 + +### 5.1 事实 + +- 用例的生产者是测试程序自身(`self_exe_path`):先在 stdout 写就绪行,关闭 stdout,再在 stderr 每 30 ms 写一行, + 共 48 行,以 7 退出。父进程 idle 500 ms、total 3 s,行处理器在就绪行上睡 750 ms。 +- 失败:exit 137、`timed_out`、0 行、`error_output` 为空。 +- 运行循环(`src/run/run.cpp`)在判定空闲之前先读两个流:处理器返回后,队列中的 stderr 由 `drain_error` 读入并更新 + `lastOutput`。0 行意味着停止时管道中没有任何一行,即生产者在界内没有写出:或在启动后 500 ms 内没写出就绪行(idle + 从启动算起),或在处理器的 750 ms 内没写出 stderr 的第一行。两者都是生产者进程在负载下的时间超出了用例的界。 + +### 5.2 决定 + +- 用例的界与被测性质分开:idle 2 s,处理器睡 idle 加 250 ms,total 10 s。48 行(1.44 s)在处理器睡眠期间入队,处理器 + 返回时队列不为空,被测的性质(队列中的输出更新空闲计时)不变。stdout 变体取同样的界。 +- 失败消息写出启动到就绪行的时间与停止时已读的行数,复现时可区分超出的是哪一段。 +- 两个用例的时间各增加约 1.5 s。 + +## 6. mcpp-index 的工作区索引(2027.1) + +### 6.1 事实 + +- 根 `mcpp.toml` 的 `[indices] compat = { path = "." }` 由 `workspace-position` 读取(docs/51:2026.10.10.1 弃用, + 2027.1 移除),每个成员的构建都报告弃用。 +- 285 个成员中:149 个不写 `[indices]`,按位置接受根的 `compat`;79 个写非空的 `[indices]`,以另一个名字指向同一 + 检出(如 `mcpplibs = { path = "../../.." }`);57 个写空的 `[indices]` 以避开根的重定向(mwrap 成员,使用测试 home + 中预备的完整候选内置索引;`tests/test_prepare_mwrap_indices.py` 断言该空表)。没有成员在自己的表中以两个名字指向 + 同一位置。 +- `[workspace.indices]` 按名字合并(`src/project.cppm` 的 `inherit_workspace_indices`),成员不能去掉一个工作区索引。 + 把 `compat` 移入 `[workspace.indices]` 后,79 个成员得到同一检出的两个名字,xlings 报告 + `package ':@' is ambiguous`(已测:包的命名空间取自描述符,同一检出注册两次,同一限定名有两个候选)。 + 57 个成员会同时得到检出与预备索引中的同名包。 + +### 6.2 决定 + +- **mcpp-index 不再有工作区级的索引。** 删去根的 `[indices]`;149 个成员各自写 `compat = { path = "<到检出的相对路径>" }`, + 与 79 个成员已有的写法相同。三类成员的索引集合都由各自的清单陈述,不依赖位置读取,也不需要合并语义的例外。 + `docs/mwrap.md` 关于保留旧重定向的一段与 `tests/test_prepare_mwrap_indices.py` 随之改写。 +- **mcpp 的合并语义不变**(按名字合并,已发布)。 +- **同一位置的两个名字被拒绝。** 合并之后(以及同一份清单之内)两个索引项指向同一位置(路径按规范化后的路径,git 按 + 地址与修订)时,mcpp 拒绝,消息写出该位置、两个名字、后果(该位置的每个包成为两个候选)与修正(保留一个名字), + 并带原因 token(docs/50)。此前这一情况到 xlings 安装时才以 ambiguous 失败,消息不指明原因。规范写入 SPEC-004 + §9 第 12 条,用法写入 docs/07(中英)。 +- 考虑过而不采用:成员退出工作区索引的新键(为一个仓库的布局增加清单词汇);按位置去重、由近者命名(解决 79 个成员, + 不解决 57 个);成员的 `[indices]` 整表替换工作区的(改变已发布的合并语义)。 + +## 7. 引号依赖键(2027.2) + +### 7.1 事实 + +- docs/51:`quoted-dotted-dependency-key` 2026.11.8.1 弃用,2027.2 移除;父包与子包并存时的唯一写法不在其列。 +- mcpp-index 的 30 个成员清单以引号写依赖键(如 `"mcpplibs.mwrap.imgui" = "1.92.8"`),都不属于上述例外。 +- 13 个 mwrap 包已发布的模板写引号键,模板归档不可变(安装模板检查的说明行):fribidi 1.0.16、imgui 1.92.8、 + libarchive 3.8.7、libpng 1.6.43、lua 5.4.7、miniaudio 0.11.25、pocketpy 2.2.0、quickjs_ng 0.17.0、sdl3 3.4.18、 + xxhash 0.8.3、xz 5.8.3.1、zlib 1.3.2、zstd 1.5.7。 + +### 7.2 决定 + +- 30 个成员清单改为不加引号的选择器(#873)。 +- 13 个封装仓库各发布一个封装修订(`docs/mwrap.md` 的修订规则:`1.0.16` 之后为 `1.0.16.1`,`5.8.3.1` 之后为 + `5.8.3.2`),模板写不加引号的选择器;#873 在描述符中加入这些版本,安装模板检查以新版本为对象, + `check_installed_template.py` 中引号键的放行随之删除。 + +## 8. mcpp-index #873 的完成 + +全量运行与上一次每周全量运行逐成员比较。上一次运行本身大面积失败,可比的成员结果为 267 个。 + +| 成员 | 现象 | 决定 | +|---|---|---| +| linux llvm `cuda-curand`(引入) | `libcurand.so.10` 需要 `libgcc_s.so.1`,按 2026.11.21.1 的 DT_RUNPATH 规则在 LLVM 工具链下不可达(`runtime/dlopen-unreachable`) | xim-pkgindex 的 libcurand 描述符声明 GCC 运行时依赖并加修订;其它 CUDA 组件以同一闭包检查测量,需要者一并声明 | +| windows `archive`、`libarchive-bundle` | 测试程序在 0.01 s 内以 133 退出 | 以下各项在同一 runner 上以前一 pin(2026.11.20.1)复测,区分引擎的回归与包的问题:引擎回归在 mcpp 的拉取请求中修正,包的问题在描述符、封装或测试成员中修正 | +| windows `sdl2` | SDL 2.32.10 的 `SDL_endian.h:40` 在 clang 23 下 `definition of builtin function '_m_prefetch'` | 同上 | +| windows `taskflow-module` | taskflow 4.1.0 的 `tfprof.hpp:339` `definition with same mangled name` | 同上 | +| linux `sqlitecpp` | 失败 | 同上 | +| slint 的安装模板检查 | libXrender 不可达(`--strict` 下的一条降级) | #1222 已发布,新安装的 RUNPATH 含 libXrender;重跑中复核 | +| 4 个取消的分片 | 90 分钟上限 | 缓存热后重跑 | + +#873 的 pin 取本轮 mcpp 的新版本(第 9 节),合入前的一次全量运行中每个成员在每条腿上 ok,或为 n/a 并写明原因。 + +## 9. 版本与 pin + +- mcpp 发布一个版本(下称 R,版本号按发布当日),包含:CHANGELOG `[Unreleased]` 中 #999 的两条 Fixed;第 3、4、5 节; + 第 6.2 节的拒绝;脚手架的 `kMtestRelease` 改为 0.11.3,docs/05(中英)的示例同步。`.xlings.json` 保持 2026.11.13.1: + 以 2026.11.21.1 引导时,hermetic 作业在缓存恢复的 home 中得不到 binutils(第 13 节),该缺陷由 R 修正,因此引导版本在 R + 发布、镜像并进入索引之后按发布流程移到 R。 +- R 发布之后:合入 xim-pkgindex 的 bot 拉取请求;mcpp 的 `.xlings.json` 移到 R(发布流程的引导版本收尾);mtest 的 `.github/versions.env` 的 `MCPP_VERSION` 改为 R;mcpp-index + #873 的四处 pin 改为 R。 + +## 10. xlings + +- **`test_root_mount`。** 在 mount namespace 的属主不可得的主机上(`ioctl(NS_GET_USERNS)` 返回 EPERM,如嵌套的用户命名 + 空间),normalize 进入"derive captured mount namespace owner"的分支而失败;CI 的主机上通过。决定:testkit 增加能力 + `mntns-owner`(探测 `NS_GET_USERNS`),该用例以它为前提,前提不成立时以原因跳过;Linux 单元测试的线声明它,在那里缺失 + 即失败;产品在 EPERM 时的拒绝写出原因。 +- **镜像。** GitHub runner 上 `mirror = GLOBAL` 时,xlings 的下载仍以 `ghfast.top` 为第一个源(mcpp 显示的是 xlings + 事件中的 `sourceHost`)。实施中读到的事实:`mirror` 未设时即为 GLOBAL,它选择 xlings 自己资源的区域(github 或 + gitcode);配方的 GitHub 地址另有第三方代理回退,由 `mirror_fallback`(`auto` 缺省、`off`、`force`)控制,`auto` 下 + 写明 sha256 的候选按连接延迟排序(xlings 设计 2026-06-04)。评审时确定的"GLOBAL 的源集合不含 CN 代理"会使未作配置的 + 中国大陆用户失去代理回退,因而改为:语义不变,xlings 的文档(中英)写明代理回退及其控制。 + +## 11. 仓库、拉取请求与顺序 + +| 仓库 | 拉取请求 | 内容 | 前置 | +|---|---|---|---| +| mcpp | 一个(发布 R) | 第 3、4、5 节,第 6.2 节的拒绝,第 9 节的发布项 | — | +| xlings | 一个 | 第 10 节 | — | +| xim-pkgindex | 一个,另有 R 的 bot 拉取请求 | libcurand 与测得的 CUDA 组件声明 GCC 运行时 | bot 拉取请求在 R 发布之后 | +| 13 个 mwrap 封装仓库 | 各一个 | 模板不加引号,发布封装修订 | — | +| mtest | 一个 | `MCPP_VERSION` 改为 R | R 进入索引 | +| mcpp-index | #873 | pin 改为 R;第 6.2 节的结构;第 7 节的 30 个清单与 13 个新版本;第 8 节的修正 | R 进入索引;封装修订已发布;xim-pkgindex 已合入 | + +```mermaid +graph LR + mcpp[mcpp: R] --> bot[xim-pkgindex: R 的 bot] + bot --> mtest[mtest: pin R] + bot --> index[mcpp-index #873] + curand[xim-pkgindex: CUDA 运行时] --> index + wraps[13 个封装修订] --> index + index --> verify[生态的真实验证] + xlings[xlings] --> verify + mtest --> verify +``` + +mcpp、xlings、xim-pkgindex 的 CUDA 修正与 13 个封装修订之间没有依赖,并行进行;第 8 节的复测在等待 CI 时进行。 + +## 12. 验收 + +- 每个拉取请求的必需检查全部通过;mcpp 的拉取请求另带 `ci:canaries`,target-matrix 与金丝雀矩阵的每一格与声明一致; + 合入后 mcpp main 的 CI 通过。 +- mcpp-index:一次全量运行,没有取消的分片,每个成员在每条腿上 ok 或为写明原因的 n/a。 +- 干净环境:以 xlings 安装 R;以自定义三元组的段构建两次、间隔超过去抖时长,第二次不刷新索引;`i686-windows-msvc` 不写 + 段时在 Windows 上构建并运行(CI 的 e2e)。 +- R 发布后,mcpp#996 以说明关闭。 + +## 13. 实施中发现 + +- **配套载荷读了索引的描述文件。** 引导版本移到 2026.11.21.1 后,hermetic e2e 作业以缓存恢复的 home 构建,gcc@16.1.0 得不到 + binutils,构建停在 "cannot execute 'as'"。xim 的 gcc 配方于 2026-11-21 把 binutils 由 2.42.1 改为 2.47;2026.11.21.1 按 + 索引当前的描述文件取配套载荷的版本,store 中只有该载荷安装时的 2.42.1。设计 2026-11-21 §3.5 规定版本取自"载荷的安装记录", + 实现读的是索引。只读安装时的描述文件也不对:以 `[xlings] upstream` 链接载荷的 home(e2e 的 inherited home)中,载荷目录是 + 上游的链接,旁边是上游的描述文件(2.42.1),配套载荷却按索引安装(store 中只有 2.47)。修正:两份声明依次读取,安装时的 + 描述文件在前、索引的在后,取 store 持有的第一个;`companion-too-old` 比较的仍是载荷自身的声明(第一个)。单元测试覆盖两种 + home;e2e 的 inherited home 中不再报告降级。这是 2026.11.21.1 对已有 home 的升级缺陷,随本轮发布修正。 +- **Windows 上 archive 与 libarchive-bundle 在启动时崩溃,根因是 lld-link 与包的静态宏。** 退出状态 133 即访问违例;cdb 显示 + 调用跳到映像首字节。逐版本探测:2026.11.8.1 通过,2026.11.9.1 起失败;2026.11.9.1 起测试单元按函数分节、测试以回收无引用节的 + 方式链接。`lzma.h` 与 `archive.h` 在未定义 `LZMA_API_STATIC`、`LIBARCHIVE_STATIC` 时声明 dllimport,compat.xz 与 + compat.libarchive 是静态库,宏只在包自己的单元中(或根本没有);消费者经 lld-link 为本地定义造的 `__imp_` 槽调用,回收时 + 槽后的函数被丢弃。最小复现测得:MSVC 的 link.exe 在 `/OPT:REF` 下保留该函数(退出 42),lld-link 20.1.8 访问违例, + `/OPT:NOREF` 时退出 42;本地 lld 20.1.7、22.1.8、23.1.3 的槽均为映像基址。lld 的缺陷记为 mcpp#1002(upstream-bug)。 + 修正在包:静态库为每个包含其头文件的单元陈述静态 API 宏,即由 `default` 蕴含的 `staticlib` feature(feature 的 `defines` + 经包含目录的边到达消费者,compat.curl 与 compat.c-ares 已如此)。同类的 compat.fribidi(宏只在 Windows 的私有 cflags)、 + compat.libcoro(私有 `defines`)一并改正;compat.cpptrace、compat.libassert、compat.yaml-cpp 原以 `#include_next` 垫片传递 + 宏,改为同一 feature 并删去垫片(垫片不能用于 cl.exe)。索引的模式文档原称 feature 的 `defines` 只作用于包自身,与引擎不符, + 已改正。探测中以 compat.xz 的修正复测,libarchive-bundle 通过,archive 仍崩溃,其余部分由 `LIBARCHIVE_STATIC` 解释。 +- **sdl2 与 taskflow-module 是包的问题。** clang 23 把 `_m_prefetch` 作为内建函数,SDL 2.32.10 的 `SDL_endian.h` 在 MSVC + ABI 的 clang 下定义它;上游 SDL2 分支已以 `!_SDL_HAS_BUILTIN(_m_prefetch)` 保护,尚无发布,compat.sdl2 在 install() 中移植 + 这一行(修订 1)。taskflow 4.1.0 的 `tfprof.hpp` 以 `static inline` 定义两个命名空间作用域的函数,两个模块分区的全局模块片段 + 各包含一次,MSVC ABI 下修饰名相同;taskflow.taskflow 在 install() 中改为 `inline`(修订 1)。二者自 mcpp-index 的 Windows + 腿于 2026-10-25 改用 llvm@23.1.3 起未在全量运行中被执行过(此前的每周运行在 Windows 的准备阶段即失败)。 +- **CUDA 组件声明 GCC 运行库。** libcurand、libcudart、libnvrtc-builtins、libnvtx3interop、libcufft、libcusparse、libcusolver、 + libcublas 的 DT_NEEDED 含 `libgcc_s.so.1`(部分含 `libstdc++.so.6`),xim-pkgindex 的配方声明 `xim:gcc-runtime` 并把各版本 + 记为修订 1;libnvjitlink 两者都不需要。 +- **两个 e2e 夹具以两个索引名指向一个目录。** names/162 与 lock/203 的夹具如此书写,`index-location-named-twice` 拒绝后失败; + 改为每个索引名一个目录,断言不变。拒绝只在登记索引的命令(构建、`mcpp index update`)中发生,只读索引文件的 `mcpp add` + 不登记,SPEC-004 §9 第 12 条写明这一点。 +- **封装修订的镜像。** 13 个封装修订发布于 GitHub;原有 GitCode 镜像的 7 个包(imgui、libarchive、miniaudio、xxhash、xz、 + zlib、zstd)在 `mcpp-res/mwrap-<名>` 发布同一字节,逐个以重新下载的 sha256 核对;其余 6 个包沿用只有 GitHub 的写法。 +- **写引号键的模板不止 13 个。** §7.1 的清单来自引号键的放行所报告的成员,放行被删去后安装模板检查逐个核对,另有 15 个封装包 + 最新版本的模板写 `"{{self.name}}"`:accesskit、box2d、concurrentqueue、dr_libs、freetype、godot_cpp、harfbuzz、libc、libvpx、 + libwebp、llamacpp、md4c、mimalloc、opus、sheenbidi(以各包最新标签的 `templates/**/mcpp.toml.in` 测得;ffmpeg、onnxruntime、 + opencv 5.0.0.1 写 `{{template.package.selector}}`,不加引号)。它们同样各发布一个封装修订,#873 一并加入。 + diff --git a/.agents/docs/README.md b/.agents/docs/README.md index eaec1c17d..09ed746d9 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 --- ``` -371 records. +372 records. ## By subject @@ -135,6 +135,7 @@ Records that declare one. Everything else is listed by date below. ### plan +- [测试与 CI 一轮的收尾:平台列未命中的刷新条件(mcpp#996)、`i686-windows-msvc` 行、工作区索引与引号键的迁移、索引的全量验证](2026-11-22-test-round-wrap-up-plan.md) — active - [Eight reports after 2026.9.27.1: implementation plan](2026-09-27-eight-reports-implementation-plan.md) — active - [#690: implementation plan](2026-09-25-issue-690-implementation-plan.md) — landed - [工具链选择与载荷可信度:实施计划](2026-09-24-toolchain-selection-implementation-plan.md) — landed @@ -213,6 +214,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 - [包的特性作为机器可读的回答:一个目录项,两种来源,三种状态(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/CHANGELOG.md b/CHANGELOG.md index 799c97320..ddf0e28a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,21 @@ > Each `## []` section is that release's notes. Entries are written in English > from 2026.9.28.3 on; earlier entries remain as written. -## [Unreleased] +## [2026.11.22.1] - 2026-11-22 + +### Added + +- `i686-windows-msvc`, the 32-bit x86 Microsoft ABI, is a `preview` row of the target table, + served by the msvc provider as `x86_64-windows-msvc` is; x86_64 Windows runs its programs + (WOW64). A project needs no `[target.i686-windows-msvc]` section to build it, and no platform is + looked up for it. `--target i686-windows` and `x86-windows-msvc` select it; before, they + selected no row. Under clang 23 its `import std` builds at C++20 only (docs/20) (mcpp#996). + +### Changed + +- The framework mcpp scaffolds tests with and suggests where a package has none is mtest 0.11.3 + (`mtest gate` judges a ledger only for a set that runs every case; the library is + source-compatible with 0.11.2). ### Fixed @@ -14,6 +28,26 @@ not yet filled is absent. Before, only the declared directories were judged, by existence, so a reader beside a first fetch skipped the refresh and reported no local package index (mcpp#927, design 2026-11-12 §18 P3). +- A request built without a platform refreshed the package index on every build more than the + debounce apart: a miss of the index's platform column refreshed for every row the engine does + not know and every `planned` one, and a custom triple a `[target.]` section defines, or + a `planned` row built with a named toolchain, is not refused for want of a platform (12 to 19 s + a build for `i686-windows-msvc` with a section). Only a request refused without a platform + refreshes now, judged by the facts the refusal reads; `platform = "none"` in a table ends the + lookup as `--platform none` does (SPEC-013 §14, mcpp#996). +- Two entries of a project's effective `[indices]` that name one location -- a member's beside + its workspace's `[workspace.indices]`, or two in one manifest -- registered the location twice, + and installing any package of it stopped at the provider as ambiguous, naming neither entry. + The build and `mcpp index update` refuse it now, naming both entries, the location and the + remedy (`index-location-named-twice`, SPEC-004 §9). +- An installed GCC's companions (binutils, the Linux headers) were read from the index's current + descriptor of the toolchain, not from the descriptor the payload was installed with. When xim's + gcc recipe moved binutils from 2.42.1 to 2.47, a gcc@16.1.0 installed beside binutils 2.42.1 was + given no binutils after `mcpp index update`, and its builds stopped at "cannot execute 'as'". The + installed descriptor is read first now, then the index's, and the first declaration the store + holds decides: a home that links the payload from an `[xlings] upstream` holds the companions + the index names, beside the upstream's descriptor (SPEC toolchain-management §2.9, design + 2026-11-21 §3.5). - `mcpp test` counts a suite run as a case by its cases on the program's line as the summary does: an mtest program of one suite and seven cases read `8 cases` on its line and `7 passed` in the summary. diff --git a/README.md b/README.md index 466fd4e08..ab30c4288 100644 --- a/README.md +++ b/README.md @@ -444,6 +444,7 @@ list` reports for this machine): | `aarch64-linux-musl` | gcc 16, fully static — cross from x86_64 (qemu) or native | verified | | `x86_64-windows-gnu` | gcc 16 MinGW-w64 — native on Windows, cross from Linux (wine) *(Windows default without Visual Studio)* | verified | | `x86_64-windows-msvc` | `msvc@system` (detected VS/BuildTools) or llvm ¹ *(Windows default with Visual Studio)* | verified | +| `i686-windows-msvc` | `msvc@system` or llvm ¹ — 32-bit x86, run by WOW64 on x86_64 Windows | preview | | `x86_64-windows-musl` | llvm 23 — a PE with a musl C library, which no gcc emits; the system comes from the dependency graph | preview | | `aarch64-macos` | llvm *(macOS default)* | verified | | `aarch64-macos-musl` · `x86_64-macos-musl` | llvm 23 — a Mach-O with a musl C library from the dependency graph, built on any host *(what `aarch64-macos` is off macOS)* | preview | diff --git a/README.zh-CN.md b/README.zh-CN.md index cb61423a5..bc95ca6d1 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -393,6 +393,7 @@ mcpp 的身份模型有两条正交的轴:**工具链**是 `family@version`( | `aarch64-linux-musl` | gcc 16,全静态;从 x86_64 交叉编译(qemu)或原生构建 | verified | | `x86_64-windows-gnu` | gcc 16 MinGW-w64;Windows 上原生构建,Linux 上交叉编译(wine)(*无 Visual Studio 时的 Windows 默认*) | verified | | `x86_64-windows-msvc` | `msvc@system`(探测 VS/BuildTools)或 llvm ¹(*有 Visual Studio 时的 Windows 默认*) | verified | +| `i686-windows-msvc` | `msvc@system` 或 llvm ¹;32 位 x86,在 x86_64 Windows 上由 WOW64 运行 | preview | | `x86_64-windows-musl` | llvm 23;带 musl C 库的 PE,gcc 无法产出;系统部分由依赖图提供 | preview | | `aarch64-macos` | llvm(*macOS 默认*) | verified | | `aarch64-macos-musl` · `x86_64-macos-musl` | llvm 23;带 musl C 库的 Mach-O,系统部分由依赖图提供,任意宿主可构建(*非 macOS 宿主上的 `aarch64-macos`*) | preview | diff --git a/bench/mcpp.toml b/bench/mcpp.toml index 35b850155..febaa164c 100644 --- a/bench/mcpp.toml +++ b/bench/mcpp.toml @@ -21,4 +21,4 @@ windows = "llvm@23.1.3" # small fixture. `mcpp build` ignores [dev-dependencies], so the harness itself # still takes nothing beyond `import std;`. [dev-dependencies] -mcpplibs.mtest = "0.11.2" +mcpplibs.mtest = "0.11.3" diff --git a/docs/05-dependencies.md b/docs/05-dependencies.md index ffa44e0ec..1bfe7d52a 100644 --- a/docs/05-dependencies.md +++ b/docs/05-dependencies.md @@ -67,8 +67,8 @@ not deprecated: ```toml [dev-dependencies] -mcpplibs.mtest = "0.11.2" -"mcpplibs.mtest.gtest" = "0.11.2" +mcpplibs.mtest = "0.11.3" +"mcpplibs.mtest.gtest" = "0.11.3" ``` ```toml @@ -483,7 +483,7 @@ refreshing it reads the local index at once, unless an index the home reads (the provider's own, `xim`, or one the home declares) has no packages yet; it then waits for that refresh and reads what it fetched, instead of reporting no local package index *(2026.11.13.1+; the provider's own index and a directory not yet -filled, @NEXT@+, mcpp#927)*. +filled, 2026.11.22.1+, mcpp#927)*. Run any command with `-v` to see the decision for each dependency and why. diff --git a/docs/07-workspace.md b/docs/07-workspace.md index 2564f4c42..75055b91e 100644 --- a/docs/07-workspace.md +++ b/docs/07-workspace.md @@ -239,6 +239,15 @@ and a member reached as a dependency does not (mcpp 2026.10.11.1+; before that release a member reached as a dependency received it and was refused for stating an override). +`[workspace.indices]` merges with a member's `[indices]` by name, the member's +entry of a name first. When two entries of the result name one location (one +directory, or one repository at one pin), the build and `mcpp index update` +refuse it with `index-location-named-twice`: the location would be registered +twice, and each of its packages would be two candidates of one name. The remedy keeps one name: drop one entry, or, when one +of them is a workspace entry, state the index in the members that use it +instead *(2026.11.22.1+; before, the install failed as ambiguous and named neither +entry)*. + A conditional row counts as it evaluates for the target being built: a `dialect_cxxflags` or `.abi` row for another target does not separate a member from the others (§5.4), and one that holds is applied when the member is built diff --git a/docs/20-toolchains.md b/docs/20-toolchains.md index 78695dc53..d7b8a052f 100644 --- a/docs/20-toolchains.md +++ b/docs/20-toolchains.md @@ -213,10 +213,18 @@ compared nor remembered. A managed toolchain's companions -- the binutils GCC assembles and links with, the Linux kernel headers of the glibc base, GCC's runtime libraries -- are the -versions its payload declares as runtime dependencies for this host. A store -that holds several versions answers with the declared one; without a -declaration, with the newest. A declared version the store does not hold is -reported as a degradation; `mcpp toolchain install` installs it again. +versions its payload declares as runtime dependencies for this host. Two +descriptors declare them, read in order: the one the payload was installed with, +which the installer keeps beside it, then the index's current one; the first +declaration the store holds decides *(2026.11.22.1+)*. An index update that moves the +declaration does not take the companions from an installed toolchain; before, +an installed GCC lost its binutils when xim's recipe moved to a version the +store did not hold. A home that links the payload from an `[xlings] upstream` +holds the companions the index names, beside the upstream's descriptor, and +takes those. A store that holds several versions answers with the declared one; +without a declaration, with the newest. Declarations the store holds none of +are reported as a degradation; `mcpp toolchain install` installs what they +name. A project may state the binutils beside a GCC: @@ -1648,8 +1656,10 @@ dialect_cxxflags = ["-D__cpp_impl_coroutine=201902L"] In `cxxflags` the std module's precompile does not see it. -`i686-windows-msvc` is not a row of the target table; a project that builds -for it declares `[target.i686-windows-msvc]`, as for any custom triple. +`i686-windows-msvc` is a `preview` row of the target table *(2026.11.22.1+, +mcpp#996)*, served by the msvc provider as `x86_64-windows-msvc` is; x86_64 +Windows runs its programs (WOW64). A project needs no `[target.i686-windows-msvc]` +section to build it. Before, it was a custom triple that required the section. ## Known Toolchain Limitation: GCC Modules Under a Non-ASCII Path (gcc 16) diff --git a/docs/21-the-target-triple.md b/docs/21-the-target-triple.md index 9bba9acc9..5383988c2 100644 --- a/docs/21-the-target-triple.md +++ b/docs/21-the-target-triple.md @@ -106,7 +106,7 @@ what every `else` branch in the tree assumes. So the format is now one answer: |---|---| | `x86_64-linux-gnu`, `aarch64-linux-android`, `riscv64-none-elf`, `x86_64-openkal` | ELF | | `aarch64-macos`, `aarch64-ios` | Mach-O | -| `x86_64-windows-gnu`, `x86_64-windows-msvc` | PE | +| `x86_64-windows-gnu`, `x86_64-windows-msvc`, `i686-windows-msvc` | PE | | `wasm32-emscripten` | wasm | It is **not** the same question as "is there an operating system to link @@ -551,6 +551,7 @@ provider's runner ([41](41-devices.md)). | `aarch64-windows-gnu` | preview | `llvm@23.1.3` | base | base | base | base | | `x86_64-windows-musl` | preview | `llvm@23.1.3` | graph | graph | graph | payload | | `x86_64-windows-msvc` | verified | — | — | — | — | system | +| `i686-windows-msvc` | preview | — | — | — | — | system | | `aarch64-macos` | verified | — | — | — | SDK | — | | `x86_64-macos` | planned | — | planned | planned | planned | planned | | `aarch64-macos-musl` | preview | `llvm@23.1.3` | graph | graph | graph | graph | @@ -599,6 +600,7 @@ vocabulary, nothing wired yet. | `*-freebsd` | every host, through a platform | the rows are built-in; a platform names each identity's FreeBSD base package (`xim:x86_64-freebsd-sysroot`, `xim:aarch64-freebsd-sysroot`) and is selected with `[target.] platform`, or by any selector the row meets (`[target.freebsd]`, `cfg(os = "freebsd")`); another platform package's provider does not compete with the chosen platform | | `*-freebsd-musl` | every host, through the graph | openkal-platform's hosted part (0.28.0): openkal-musl over openkal-freebsd standalone, one static program; a request of `-freebsd` with no platform selected for it takes this identity (2026.11.10.2+), as `aarch64-macos` takes the musl identity on a host that is not a Mac | | `x86_64-windows-msvc` | Windows | MSVC is located on the machine | +| `i686-windows-msvc` | Windows | the same; x86_64 Windows runs the programs (WOW64), and under clang 23 its `import std` builds at C++20 only ([20](20-toolchains.md)) | | `x86_64-windows-musl` | Windows by payload; anywhere by graph | no gcc emits PE+musl, and LLVM cannot spell the triple | | `aarch64-macos` | macOS | the SDK is the machine's | | `*-none-elf` | every host | clang and lld are cross-compilers by construction | diff --git a/docs/35-platforms.md b/docs/35-platforms.md index 30b3a66d7..b86771db3 100644 --- a/docs/35-platforms.md +++ b/docs/35-platforms.md @@ -280,6 +280,14 @@ again. A refusal that follows says whether the index was refreshed, and why not. Before, a row listed after the local copy was taken was refused as an unknown target until `mcpp index update`. +A request that is built without a platform is not refused, so a miss of the +column for it does not refresh the index *(2026.11.22.1+, mcpp#996)*: a custom triple +a `[target.]` section defines, a `planned` row built with a named +toolchain (`[target.] toolchain`, `--toolchain`), and a request a table +answers with `platform = "none"`, which ends the lookup as `--platform none` +does. The column is still read for the first two. Before, each such build more +than the debounce apart refreshed the index. + ## Writing a platform package A platform package is a package with a `[platform]` section. openkal-platform, diff --git a/docs/50-machine-output.md b/docs/50-machine-output.md index b7a5e4117..14bd14fdb 100644 --- a/docs/50-machine-output.md +++ b/docs/50-machine-output.md @@ -676,6 +676,7 @@ a program classifying the outcome reads `reason`: | `offline-download-required` | the run is offline and the plan needs a download: a toolchain, a package, a git revision or the package index; from 2026.11.21.1, with no archive directory named *(2026.9.16.1+)* | | `artifact-unavailable-offline` | the run is offline, archive directories are named, and neither they nor the download cache hold an archive the plan needs; the message carries the provider's list *(2026.11.21.1+)* | | `bundle-older-than-lock` | `mcpp fetch --from`: the bundle lacks a version `mcpp.lock` records *(2026.11.21.1+)* | +| `index-location-named-twice` | two entries of the effective `[indices]` (a manifest's, or a member's beside its workspace's) name one directory, or one repository at one pin; the message names both and the location *(2026.11.22.1+)* | | `package-cycle` | the dependency graph contains a cycle of packages; the message names its edges *(2026.9.16.1+)* | | `program-cxx-runtime-split` | a program or test that states a self-contained C++ runtime loads a C++ shared library of the build that couples to a shared one *(2026.9.16.1+)* | | `static-package-in-two-images` | a static package several images of the build reach, on a target where an image cannot use another image's copy *(2026.9.16.1+)* | diff --git a/docs/specs/manifest-semantics.md b/docs/specs/manifest-semantics.md index 67b104f0b..5ee53a8ea 100644 --- a/docs/specs/manifest-semantics.md +++ b/docs/specs/manifest-semantics.md @@ -5,7 +5,7 @@ | **规范编号** | SPEC-004 | | **标题** | `mcpp.toml` 的平面划分、条件化形状、解析轴与命名规约 | | **状态** | **草案(Draft)** | -| **版本** | 1.27 | +| **版本** | 1.28 | | **最后修改** | 2026-11-21 | | **最低实现版本** | 条件化形状:mcpp **2026.8.29.1**(`[target..build-dependencies]` 起齐备);目标轴:mcpp **2026.9.6.4** | | **作者/维护** | mcpp-community | @@ -659,6 +659,11 @@ mcpp 2026.9.26.2,#703)。** `[runtime]`,选择器的 `.build`、`.abi`、`.runtime`、`.targets`、`.dependencies`)不作用于 任何包,实现**必须**给出警告,`--strict` 下**必须**拒绝;同一张表在这样的根上同时写在根位置 与 `[workspace.X]` **必须**被拒绝。 + 合并之后,生效的 `[indices]` 中两项指向同一位置(规范化后的同一目录,或同一仓库的同一 pin)时, + 该位置被向提供者登记两次,它的每个包成为同一名字的两个候选;登记索引的命令(构建与 + `mcpp index update`)**必须**拒绝,只读索引文件的 `mcpp add` 不登记,不受此限。消息写出两项、该位置与修正,原因 + token 为 `index-location-named-twice`(docs/50)。**已实现**(mcpp >= 2026.11.22.1;此前到提供者安装时 + 才以 ambiguous 失败,不指明两项)。 13. **按位置读取(兼容,自 mcpp 2026.10.10.1 弃用,自 mcpp 2027.1 移除;docs/51 的弃用登记表, `workspace-position`)。** 工作空间根上没有 `[workspace.X]` 写法的 `[toolchain]`、 `[indices]`、`[profile.]`、`[target.]` 标量行与 `[xlings]`、 @@ -953,3 +958,4 @@ mcpp 2026.10.10.1,#785、#786;第 14 至 16 条与第 13 条的依赖位置为 m | 1.25 | 2026-11-21 | mcpp 2026.11.21.1(mcpp#990):§9 第 21 条 `[build] allow_host_tools`。 | | 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`)。 | diff --git a/docs/specs/platforms.md b/docs/specs/platforms.md index aefed2a9e..152250c5d 100644 --- a/docs/specs/platforms.md +++ b/docs/specs/platforms.md @@ -4,10 +4,10 @@ |---|---| | 规范编号 | SPEC-013 | | 标题 | 平台:一类目标的可复用配置,其声明、选择、合并、对依赖图的补全、链接与封装、运行器与载体 | -| 状态 | 评审中 v1.15 | -| 版本 | 1.15 | +| 状态 | 评审中 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;逐条标注 | +| 对应实现 | 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;逐条标注 | | 相关设计文档 | `.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)(打包) | @@ -503,6 +503,11 @@ package = { 刷新后**必须**重新扫描,扫描的缓存随之作废;仍未命中时拒绝,消息写出索引是否已刷新及未刷新的原因。内置表持有、 没有平台也能构建的行(如以自己的 sysroot 构建的 `x86_64-freebsd`)未命中时不刷新。**已实现**(mcpp >= 2026.11.19.1, mcpp#967;此前在本地副本取得之后才列入索引的行被拒绝为未知目标,直到 `mcpp index update`)。 + 没有平台也能构建的请求不被拒绝,其未命中**禁止**刷新索引:`[target.]` 段定义的引擎不认识的行、命名了工具链 + (`[target.] toolchain`、`--toolchain`、消费者的子构建)的 `planned` 行;平台列对它们照常读取。表中的 + `platform = "none"` 是一个选择,与 `--platform none` 一样结束平台列的查询。"被拒绝"由拒绝门所读的同一事实判定(段的 + 查找与工具链的命名)。**已实现**(mcpp >= 2026.11.22.1,mcpp#996;此前这两类请求与表中的 `none` 按拒绝处理,相隔超过去抖 + 时长的每次构建刷新一次索引)。 每条命令至多扫描一次索引的条目,且只在内置表没有答案时扫描(约 400 个条目时整个拒绝过程 0.05 s)。**已实现** @@ -653,3 +658,4 @@ openkal-platform 的 `targets` 因此不含 WebAssembly。Web 经 `wasm32-emscri | 1.13 | 2026-11-19 | mcpp 2026.11.19.1(mcpp#956):§7.5 版本组的约束进入合并,结果与请求到达的先后无关;拒绝列出每一个请求者。 | | 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"` 结束平台列的查询。 | diff --git a/docs/specs/toolchain-management.md b/docs/specs/toolchain-management.md index e00402d3b..20ac07a38 100644 --- a/docs/specs/toolchain-management.md +++ b/docs/specs/toolchain-management.md @@ -4,8 +4,8 @@ |---|---| | 规范编号 | SPEC-006 | | 标题 | 工具链管理:身份、来源、选择与载荷契约 | -| 状态 | 草案 v0.12 | -| 最后修改 | 2026-11-21 | +| 状态 | 草案 v0.13 | +| 最后修改 | 2026-11-22 | | 对应实现 | 逐条标注;标为「已实现」的条款对应 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 | @@ -113,7 +113,12 @@ - 工具链所用的配套载荷(GCC 的 binutils、glibc 基础层的 Linux 内核头文件、GCC 的运行库)**必须**取工具链载荷的描述文件为本宿主声明的 运行依赖:声明为一个键时取该键,声明为要求(`>=2.39`)时取 store 中满足它的最新版本。没有声明时取 store 中的最新版本。 - **禁止**按目录遍历的次序选择。声明的版本不在 store 中时以 `degraded` 报告,不以另一个版本代替。 + **禁止**按目录遍历的次序选择。声明的版本都不在 store 中时以 `degraded` 报告,不以另一个版本代替。 +- 声明**必须**依次取自两个描述文件:载荷安装时的描述文件(安装器保存在载荷旁的 `.xpkg.lua`),然后是索引中的描述文件;取 store + 持有的第一个声明。从 `[xlings] upstream` 链接载荷的 home 按索引安装配套载荷,载荷旁是上游的描述文件,因此两者都需要读。一个声明也 + 不满足时以 `degraded` 报告,两个声明都写出。工具链载荷自身的声明(`companion-too-old` 的比较)是第一个。**已实现** + (mcpp >= 2026.11.22.1;2026.11.21.1 读索引的描述文件,xim 的 gcc 配方把 binutils 由 2.42.1 改为 2.47 之后,已安装的 gcc@16.1.0 在 + `mcpp index update` 之后得不到 binutils,构建停在 "cannot execute 'as'")。 - 工程可以在工具链的陈述旁写明 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 选定汇编器的能力。 @@ -444,6 +449,7 @@ doctor 如实报告这一点。它同时报告 mcpp 的包 home 中指向不存 | v0.8 | 2026-10-16 | 随 mcpp 2026.10.16.1:§4.3 改为「安装后不改写」,载荷只由提供者写入;工具链运行在提供者按 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.9 | 2026-10-17 | 随 mcpp 2026.10.17.1:新增 §4.7,已安装的修订在构建中继续使用,`floor` 决定是否必须替换,`toolchain install` 取当前修订;§6.4 doctor 只读,报告构建实际使用的工具链与包 home 的一致性。 | --- diff --git a/docs/zh/05-dependencies.md b/docs/zh/05-dependencies.md index 4cb6f4626..f19efef0b 100644 --- a/docs/zh/05-dependencies.md +++ b/docs/zh/05-dependencies.md @@ -62,8 +62,8 @@ mcpp 把它读作这些点所拼写的选择器,警告该拼法已弃用(自 ```toml [dev-dependencies] -mcpplibs.mtest = "0.11.2" -"mcpplibs.mtest.gtest" = "0.11.2" +mcpplibs.mtest = "0.11.3" +"mcpplibs.mtest.gtest" = "0.11.3" ``` ```toml @@ -403,7 +403,7 @@ mcpp index status # local state: state, age and revision 共用一个 home 的进程只刷新一次索引。发现另一个进程正在刷新的进程立即读取本地 索引,除非 home 读取的某个索引(provider 自己的 `xim`,或 home 声明的)还没有 任何包;这时它等待那次刷新结束,读取其取回的内容,而不是报告没有本地索引 -(2026.11.13.1 起;provider 自己的索引与尚未写入的目录,@NEXT@ 起,mcpp#927)。 +(2026.11.13.1 起;provider 自己的索引与尚未写入的目录,2026.11.22.1 起,mcpp#927)。 对任意命令加 `-v`,可以看到每个依赖的判定结果与原因。 diff --git a/docs/zh/07-workspace.md b/docs/zh/07-workspace.md index f2a294455..47f0f489e 100644 --- a/docs/zh/07-workspace.md +++ b/docs/zh/07-workspace.md @@ -226,6 +226,11 @@ default = "llvm@23.1.3" `[workspace.toolchain]` 一样属于构建的根:成员作为一次构建的根时接收它,作为依赖到达时 不接收(mcpp 2026.10.11.1+;此前作为依赖到达的成员会收到它,随后因声明了 override 被拒绝)。 +`[workspace.indices]` 按名字与成员的 `[indices]` 合并,成员的同名项在前。合并后两项指向同一位置 +(同一目录,或同一仓库的同一 pin)时构建与 `mcpp index update` 拒绝,原因为 +`index-location-named-twice`:该位置会被登记两次,它的每个包会成为同一名字的两个候选。修正是保留一个名字:去掉其中一项,或者在其中一项是工作区项时,改由 +用到它的成员各自声明该索引(*2026.11.22.1 起*;此前到安装时才以 ambiguous 失败,不指明两项)。 + 条件行按所构建的目标求值后计入:其他目标上的 `dialect_cxxflags` 或 `.abi` 行不会把成员与 其他成员分开(§5.4);对当前目标成立的行,在成员于工作空间的根下构建时生效。 diff --git a/docs/zh/20-toolchains.md b/docs/zh/20-toolchains.md index 3a5957c79..61ed189bd 100644 --- a/docs/zh/20-toolchains.md +++ b/docs/zh/20-toolchains.md @@ -178,8 +178,10 @@ note: the default toolchain (`mcpp toolchain default`) is now gcc@16.2.0; this p ## 配套载荷(2026.11.21.1+) 一个由包提供的工具链的配套载荷——GCC 用以汇编与链接的 binutils、glibc 基础层的 Linux 内核头文件、GCC 的运行库——取工具链载荷为本宿主声明的 -运行依赖的版本。store 中有多个版本时取声明的版本;没有声明时取最新版本。声明的版本不在 store 中时报告为 degraded;`mcpp toolchain install` -重新安装它。 +运行依赖的版本。两个描述文件给出声明,依次读取:载荷安装时的描述文件(安装器把它保存在载荷旁),然后是索引当前的描述文件;store 持有的 +第一个声明决定(*2026.11.22.1 起*)。索引更新改变了声明时,已安装的工具链不因此失去配套载荷;此前 xim 的配方改到 store 中没有的版本后,已安装的 +GCC 失去 binutils。从 `[xlings] upstream` 链接载荷的 home 持有索引所声明的配套载荷,载荷旁是上游的描述文件,取前者。store 中有多个版本时 +取声明的版本;没有声明时取最新版本。store 一个声明也不满足时报告为 degraded;`mcpp toolchain install` 安装声明的版本。 工程可以在 GCC 旁写明 binutils: @@ -1461,8 +1463,9 @@ dialect_cxxflags = ["-D__cpp_impl_coroutine=201902L"] 写在 `cxxflags` 中时,std 模块的预编译看不到它。 -`i686-windows-msvc` 不是目标表中的一行;为它构建的项目需要声明 -`[target.i686-windows-msvc]`,与其他自定义三元组相同。 +`i686-windows-msvc` 是目标表中的一个 `preview` 行(*2026.11.22.1 起,mcpp#996*),与 +`x86_64-windows-msvc` 一样由 msvc 提供者供给;x86_64 Windows 运行它的程序(WOW64)。为它 +构建不需要 `[target.i686-windows-msvc]` 段。此前它是自定义三元组,需要声明该段。 ## 已知工具链限制:非 ASCII 路径下的 GCC 模块(gcc 16) diff --git a/docs/zh/21-the-target-triple.md b/docs/zh/21-the-target-triple.md index f3be1fe50..ea9295b49 100644 --- a/docs/zh/21-the-target-triple.md +++ b/docs/zh/21-the-target-triple.md @@ -96,7 +96,7 @@ LLVM 词表里「非 MSVC 那套 ABI」的标签,继承自 MinGW,而 clang |---|---| | `x86_64-linux-gnu`、`aarch64-linux-android`、`riscv64-none-elf`、`x86_64-openkal` | ELF | | `aarch64-macos`、`aarch64-ios` | Mach-O | -| `x86_64-windows-gnu`、`x86_64-windows-msvc` | PE | +| `x86_64-windows-gnu`、`x86_64-windows-msvc`、`i686-windows-msvc` | PE | | `wasm32-emscripten` | wasm | 它与「有没有一个操作系统可供链接」**不是**同一个问题。一个裸机 RISC-V @@ -501,6 +501,7 @@ docs/22。 | `aarch64-windows-gnu` | preview | `llvm@23.1.3` | 基座 | 基座 | 基座 | 基座 | | `x86_64-windows-musl` | preview | `llvm@23.1.3` | 图 | 图 | 图 | 载荷 | | `x86_64-windows-msvc` | verified | — | — | — | — | 系统 | +| `i686-windows-msvc` | preview | — | — | — | — | 系统 | | `aarch64-macos` | verified | — | — | — | SDK | — | | `x86_64-macos` | planned | — | planned | planned | planned | planned | | `aarch64-macos-musl` | preview | `llvm@23.1.3` | 图 | 图 | 图 | 图 | @@ -547,6 +548,7 @@ system · `系统` 在机器上被找到,不是 mcpp 安装的 · `SDK` 平台 | `*-freebsd` | 每一台宿主,经平台 | 行是内置的;平台为每个身份指名 FreeBSD 基座包(`xim:x86_64-freebsd-sysroot`、`xim:aarch64-freebsd-sysroot`),以 `[target.<行>] platform` 或该行满足的任一选择器(`[target.freebsd]`、`cfg(os = "freebsd")`)选择;其他平台包的提供者不与所选平台竞争 | | `*-freebsd-musl` | 每一台宿主,经依赖图 | openkal-platform 的 hosted 部分(0.28.0):openkal-freebsd 的 standalone 形态之上的 openkal-musl,一个静态程序;未为 `-freebsd` 选平台时,该请求取这一身份(2026.11.10.2+),正如非 Mac 宿主上的 `aarch64-macos` 取 musl 身份 | | `x86_64-windows-msvc` | Windows | MSVC 是在机器上被找到的 | +| `i686-windows-msvc` | Windows | 同上;x86_64 Windows 运行其程序(WOW64),clang 23 下 `import std` 只能以 C++20 构建([20](20-toolchains.md)) | | `x86_64-windows-musl` | payload 只在 Windows 上;图则任意宿主 | 没有 gcc 能发出 PE + musl,且 LLVM 拼不出这个三元组 | | `aarch64-macos` | macOS | SDK 是那台机器自己的 | | `*-none-elf` | 每一台宿主 | clang 与 lld 按构造就是交叉编译器 | diff --git a/docs/zh/35-platforms.md b/docs/zh/35-platforms.md index e61adad22..cf7188311 100644 --- a/docs/zh/35-platforms.md +++ b/docs/zh/35-platforms.md @@ -221,6 +221,10 @@ package = { 见 [05](05-dependencies.md))刷新一次索引,再读平台列。随后的拒绝写出索引是否已刷新及未刷新的原因。此前,在本地 副本取得之后才列入的行被拒绝为未知目标,直到 `mcpp index update`。 +没有平台也能构建的请求不被拒绝,它的平台列未命中不刷新索引 *(2026.11.22.1 起,mcpp#996)*:`[target.]` 段定义的 +自定义三元组,命名了工具链(`[target.] toolchain`、`--toolchain`)的 `planned` 行,以及表以 `platform = "none"` +回答的请求;后者与 `--platform none` 一样结束查询。前两者仍读平台列。此前,这样的构建每隔超过去抖时长就刷新一次索引。 + ## 编写平台包 平台包是带 `[platform]` 段的包。openkal-platform 的节选: diff --git a/docs/zh/50-machine-output.md b/docs/zh/50-machine-output.md index 24dda4205..3701d8db8 100644 --- a/docs/zh/50-machine-output.md +++ b/docs/zh/50-machine-output.md @@ -602,6 +602,7 @@ replaced}` —— `origin` 与构建的状态行使用的是同一句话 | `offline-download-required` | 本次运行离线,而规划需要下载某样东西:工具链、包、git 修订,或包索引;2026.11.21.1 起,限于未写明归档目录时 *(2026.9.16.1+)* | | `artifact-unavailable-offline` | 本次运行离线且写明了归档目录,而这些目录与下载缓存都没有规划所需的归档;消息附提供者列出的缺少项 *(2026.11.21.1+)* | | `bundle-older-than-lock` | `mcpp fetch --from`:bundle 缺少 `mcpp.lock` 所记的版本 *(2026.11.21.1+)* | +| `index-location-named-twice` | 生效的 `[indices]`(一份清单的,或成员的与其工作区的)中两项指向同一目录,或同一仓库的同一 pin;消息写出两项与该位置 *(2026.11.22.1+)* | | `package-cycle` | 依赖图中存在一个包的环;消息列出环上的边 *(2026.9.16.1+)* | | `program-cxx-runtime-split` | 一个声明了自含 C++ 运行时的程序或测试,加载了本次构建中耦合到共享运行时的 C++ 共享库 *(2026.9.16.1+)* | | `static-package-in-two-images` | 一个静态包被本次构建的多个映像到达,而在该目标上一个映像不能使用另一个映像里的副本 *(2026.9.16.1+)* | diff --git a/mcpp.toml b/mcpp.toml index e3490361c..2c6531802 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -1,6 +1,6 @@ [package] name = "mcpp" -version = "2026.11.21.1" +version = "2026.11.22.1" description = "Modern C++ build & package management tool" license = "Apache-2.0" authors = ["mcpp-community"] @@ -188,7 +188,7 @@ members = [ # `mcpp build` ignores [dev-dependencies]; only `mcpp test` resolves them. [dev-dependencies] -mcpplibs.mtest = "0.11.2" +mcpplibs.mtest = "0.11.3" # The support of the end-to-end cases (tests/support, design 2026-11-12 §5.9). mcpp.test-support = { path = "tests/support" } diff --git a/modules/build-record/mcpp.toml b/modules/build-record/mcpp.toml index 0c222400e..b4e09eccd 100644 --- a/modules/build-record/mcpp.toml +++ b/modules/build-record/mcpp.toml @@ -17,4 +17,4 @@ license = "Apache-2.0" nlohmann.json = "3.12.0" [dev-dependencies] -mcpplibs.mtest = "0.11.2" +mcpplibs.mtest = "0.11.3" diff --git a/modules/buildmcpp/mcpp.toml b/modules/buildmcpp/mcpp.toml index 5ff355430..54e0e55f1 100644 --- a/modules/buildmcpp/mcpp.toml +++ b/modules/buildmcpp/mcpp.toml @@ -41,4 +41,4 @@ mcpp.source-kind = { path = "../source-kind" } mcpp.toolchain-model = { path = "../toolchain-model" } [dev-dependencies] -mcpplibs.mtest = "0.11.2" +mcpplibs.mtest = "0.11.3" diff --git a/modules/buildopt/mcpp.toml b/modules/buildopt/mcpp.toml index 19f08316d..273042507 100644 --- a/modules/buildopt/mcpp.toml +++ b/modules/buildopt/mcpp.toml @@ -21,4 +21,4 @@ mcpp.manifest = { path = "../manifest" } mcpp.toolchain-model = { path = "../toolchain-model" } [dev-dependencies] -mcpplibs.mtest = "0.11.2" +mcpplibs.mtest = "0.11.3" diff --git a/modules/graph/mcpp.toml b/modules/graph/mcpp.toml index baab61994..7e62b058e 100644 --- a/modules/graph/mcpp.toml +++ b/modules/graph/mcpp.toml @@ -17,4 +17,4 @@ description = "Algorithms over index-addressed directed graphs: topological orde license = "Apache-2.0" [dev-dependencies] -mcpplibs.mtest = "0.11.2" +mcpplibs.mtest = "0.11.3" diff --git a/modules/manifest/mcpp.toml b/modules/manifest/mcpp.toml index da03d5e0a..4d3a947ad 100644 --- a/modules/manifest/mcpp.toml +++ b/modules/manifest/mcpp.toml @@ -31,4 +31,4 @@ mcpplibs.os = "0.4.7" # state its contract in isolation; the root `tests/unit/` states the facts two # layers must agree on. [dev-dependencies] -mcpplibs.mtest = "0.11.2" +mcpplibs.mtest = "0.11.3" diff --git a/modules/notice/mcpp.toml b/modules/notice/mcpp.toml index 67906d6f7..cc9c4e612 100644 --- a/modules/notice/mcpp.toml +++ b/modules/notice/mcpp.toml @@ -17,4 +17,4 @@ description = "The policies of user-visible notices and the record of what a pro license = "Apache-2.0" [dev-dependencies] -mcpplibs.mtest = "0.11.2" +mcpplibs.mtest = "0.11.3" diff --git a/modules/surface/mcpp.toml b/modules/surface/mcpp.toml index 6ca656fb0..0ae88c221 100644 --- a/modules/surface/mcpp.toml +++ b/modules/surface/mcpp.toml @@ -14,4 +14,4 @@ description = "The items of mcpp's surface and the record of those an invocation license = "Apache-2.0" [dev-dependencies] -mcpplibs.mtest = "0.11.2" +mcpplibs.mtest = "0.11.3" diff --git a/modules/toolchain-model/data/builtin.toml b/modules/toolchain-model/data/builtin.toml index 62e05bd51..65f9fc2d9 100644 --- a/modules/toolchain-model/data/builtin.toml +++ b/modules/toolchain-model/data/builtin.toml @@ -173,6 +173,16 @@ tier = "verified" note = "PE" standard = true +# The 32-bit x86 Microsoft ABI. The msvc probe answers it as it answers x86_64 +# (`Host*/x86`), and Windows CI builds and runs it (e2e 892, 1144). clang 23 does +# not predefine `__cpp_impl_coroutine` here, so C++23 `import std` stops at +# `` under llvm and mcpp says why (mcpp.toolchain.msvc_coroutines). +[[platform.define]] +triple = "i686-windows-msvc" +tier = "preview" +note = "PE" +standard = true + # ── Apple, Linux continued ─────────────────────────────────────────────────── [[platform.define]] @@ -602,7 +612,7 @@ runner = { cmd = ["wine", "{}"], host = "same-arch", hosts = ["linux-x86_64"] [[platform.provider]] name = "msvc" -serves = ["x86_64-windows-msvc"] +serves = ["x86_64-windows-msvc", "i686-windows-msvc"] priority = 100 hosts = ["windows-*"] probe = "msvc" @@ -750,12 +760,17 @@ command-scripts = [".bat", ".cmd"] # # Only a relation a CI has measured is stated. An x86_64 Linux kernel runs i386 # programs (IA-32 emulation), which the i686 rows' CI runs on GitHub's x86_64 -# Linux machines (openkal-platform 0.28.0; mcpp e2e `i686`). Windows' WOW64 is -# not stated until a CI measures an i686 runner there. +# Linux machines (openkal-platform 0.28.0; mcpp e2e `i686`). x86_64 Windows runs +# them by WOW64, which e2e 892 and 1144 run on GitHub's x86_64 Windows machines +# (`mcpp run --target i686-windows-msvc` prints the 4-byte pointer it measures). [[platform.executes]] host = "linux-x86_64" arches = ["i686"] +[[platform.executes]] +host = "windows-x86_64" +arches = ["i686"] + # ── Toolchain payloads ─────────────────────────────────────────────────────── # # A toolchain named by its family (`gcc@16.1.0`, `llvm@23.1.3`) is a package of diff --git a/modules/toolchain-model/mcpp.toml b/modules/toolchain-model/mcpp.toml index fdc6a7ac1..c322fc519 100644 --- a/modules/toolchain-model/mcpp.toml +++ b/modules/toolchain-model/mcpp.toml @@ -29,7 +29,7 @@ mcpplibs.os = "0.4.7" # state its contract in isolation; the root `tests/unit/` states the facts two # layers must agree on. [dev-dependencies] -mcpplibs.mtest = "0.11.2" +mcpplibs.mtest = "0.11.3" # build.mcpp compiles data/builtin.toml (the built-in target rows and providers) # into a module of static tables, with mcpp's own TOML parser. diff --git a/modules/unit-cache/mcpp.toml b/modules/unit-cache/mcpp.toml index d2eb600c6..e553a9655 100644 --- a/modules/unit-cache/mcpp.toml +++ b/modules/unit-cache/mcpp.toml @@ -18,4 +18,4 @@ license = "Apache-2.0" mcpp.toolchain-model = { path = "../toolchain-model" } [dev-dependencies] -mcpplibs.mtest = "0.11.2" +mcpplibs.mtest = "0.11.3" diff --git a/modules/versioning/mcpp.toml b/modules/versioning/mcpp.toml index 75828aa1b..d6fbe5e4a 100644 --- a/modules/versioning/mcpp.toml +++ b/modules/versioning/mcpp.toml @@ -25,4 +25,4 @@ license = "Apache-2.0" # state its contract in isolation; the root `tests/unit/` states the same facts # as the engine consumes them, and the pair is the cross-check. [dev-dependencies] -mcpplibs.mtest = "0.11.2" +mcpplibs.mtest = "0.11.3" diff --git a/modules/versioning/src/version.cppm b/modules/versioning/src/version.cppm index fb3449589..8dbd49580 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.21.1"; +inline constexpr std::string_view MCPP_VERSION = "2026.11.22.1"; } // namespace mcpp diff --git a/src/build/prepare/platform.cpp b/src/build/prepare/platform.cpp index 1f24cd1b2..6fee97a8d 100644 --- a/src/build/prepare/platform.cpp +++ b/src/build/prepare/platform.cpp @@ -292,6 +292,7 @@ void define_early_platform(PrepareState& state) { // The explicit choice for this request, by the words that need no parse: the // flag, the environment and the tables whose selector is the request itself. std::optional chosen; + bool noneChosen = false; std::string chosenText = !state.overrides.platform_choice.empty() ? state.overrides.platform_choice : mcpp::invocation::get("MCPP_PLATFORM").value_or(""); if (chosenText.empty() && !raw.empty()) { @@ -328,10 +329,13 @@ void define_early_platform(PrepareState& state) { const mp::Override* most = nullptr; for (auto const* o : mcpp::platform::matching(*tables, words)) if (o->platformSet) most = o; - if (most) { - if (!most->platformNone) chosen = most->platform; - break; - } + if (!most) continue; + // `platform = "none"` in a table is a choice as `--platform none` + // is: no platform, so the index's column is not asked (mcpp#996). + // Before, only the flag's `none` ended the lookup. + if (most->platformNone) noneChosen = true; + else chosen = most->platform; + break; } } fs::path root = state.overrides.platform_root; @@ -347,13 +351,13 @@ void define_early_platform(PrepareState& state) { // §6.2). // A request that parses but names a row nothing defines (`x86_64-toyos`) // is answered so only by the column. - if (raw.empty()) return; + if (raw.empty() || noneChosen) return; if (const auto parsed = mcpp::toolchain::triple::parse(raw); parsed && (chosen || !chosenText.empty() || parsed->defined() || mcpp::toolchain::triple::find_known_target(*parsed))) return; if (!chosen && chosenText.empty()) - if (auto column = index_platform_for(state, raw, true); !column.empty()) + if (auto column = index_platform_for(state, raw, refused_without_platform(state, raw)); !column.empty()) if (auto ref = mp::parse_ref_text(column)) chosen = *ref; if (!chosen) return; std::vector seg; @@ -521,7 +525,8 @@ std::string index_platform_for(const PrepareState& state, std::string_view tripl // taken was refused as unknown until `mcpp index update`. Decided once per // row per process; what was decided is what the refusal says. A caller for // which a miss is not a refusal (a row the table holds and serves without a - // platform) asks without it. + // platform) asks without it; `refused_without_platform` is that question, + // asked of the facts the refusal gates read. if (it == claims->end() || it->second.empty()) { if (!refreshOnMiss) return {}; { @@ -572,12 +577,18 @@ std::string platform_short_name(std::string_view ref) { return r ? known_short_name(*r) : std::string{}; } -// A row the built-in table holds as `planned`: nothing of the engine serves it, -// so a miss of the index's column for it ends in a refusal, and refreshes -// (mcpp#967). -static bool planned_row(const mcpp::toolchain::triple::Triple& t) { - const auto* known = mcpp::toolchain::triple::find_known_target(t); - return known && known->tier == "planned"; +// A miss of the index's column refreshes the index only for a request the +// build refuses without a platform (mcpp#967). Through 2026.11.21.1 every row the +// engine does not know refreshed, and every `planned` row: a custom triple a +// `[target.]` section defines, and a `planned` row built with a named +// toolchain, are built without one, so each such build more than the debounce +// apart synced the index again (mcpp#996, 12 to 19 s a build). +bool refused_without_platform(const PrepareState& state, std::string_view request) { + const auto parsed = mcpp::toolchain::triple::parse(request); + const auto* section = find_request_entry(*state.m, request, parsed); + const auto* known = parsed ? mcpp::toolchain::triple::find_known_target(*parsed) : nullptr; + if (!known) return !section && !(parsed && parsed->defined()); + return known->tier == "planned" && !toolchain_named(state, section); } // WHETHER THE BUILT-IN TABLE ANSWERS THE PLATFORM COLUMN FOR A ROW (design @@ -627,7 +638,7 @@ std::string named_provider(const PrepareState& state, const mcpp::toolchain::tri // a choice of the project would. A row nothing defines is answered by // `define_early_platform`. if (!mcpp::toolchain::triple::find_known_target(t) || table_answers(state, t)) return {}; - const auto column = index_platform_for(state, t.str(), planned_row(t)); + const auto column = index_platform_for(state, t.str(), refused_without_platform(state, t.str())); if (column.empty()) return {}; const auto ref = mp::parse_ref_text(column); if (!ref) return {}; @@ -703,7 +714,7 @@ std::expected step1_select_platform(PrepareState& state) { { const bool tableAnswers = table_answers(state, t); if (!tableAnswers) - if (auto indexed = index_platform_for(state, t.str(), planned_row(t)); !indexed.empty()) { + if (auto indexed = index_platform_for(state, t.str(), refused_without_platform(state, t.str())); !indexed.empty()) { column = std::move(indexed); fromIndex = true; } diff --git a/src/build/prepare/state.cppm b/src/build/prepare/state.cppm index fc799c2bb..49b08495f 100644 --- a/src/build/prepare/state.cppm +++ b/src/build/prepare/state.cppm @@ -1456,6 +1456,18 @@ std::string index_platform_for(const PrepareState& state, std::string_view tripl // What a refusal of `triple` adds about the index after a miss of its column: // whether the index was refreshed, and why not. Empty when nothing missed. std::string index_platform_miss_note(std::string_view triple); +// A TOOLCHAIN NAMED FOR THE BUILD: by the request's `[target.]` section +// (`section`, or null), by `--toolchain` (MCPP_TOOLCHAIN), or by the consumer +// of a sub-build. A `planned` row with one is not refused. +inline bool toolchain_named(const PrepareState& state, const mcpp::manifest::TargetEntry* section) { + return (section && !section->toolchain.empty()) || state.tcFromCommandLine || state.tcFromConsumer; +} +// WHETHER THE REQUEST IS REFUSED WITHOUT A PLATFORM (SPEC-013 §14 item 6): a row +// the engine does not know, that no `[target.]` section and no platform +// defines; or a `planned` row no toolchain is named for. Only a miss of the +// index's platform column for such a request refreshes the index (mcpp#996). +// It reads what the refusal gates read (`find_request_entry`, `toolchain_named`). +bool refused_without_platform(const PrepareState& state, std::string_view request); void step4b_seed_platform(PrepareState& state); std::expected step4b_apply_platform(PrepareState& state); diff --git a/src/build/prepare/toolchain.cpp b/src/build/prepare/toolchain.cpp index b5ce3fca3..1bbb8fea4 100644 --- a/src/build/prepare/toolchain.cpp +++ b/src/build/prepare/toolchain.cpp @@ -708,18 +708,9 @@ step1_resolve_target_triple_request(PrepareState& state, TargetOverrideCtx& ctx) // [target.X] lookup is spelling-independent: a section keyed // `x86_64-w64-mingw32` matches `--target x86_64-windows-gnu` and // vice versa. Unparseable keys/inputs compare exactly (escape hatch). - auto it = state.m->targetOverrides.find(state.overrides.target_triple); - if (it == state.m->targetOverrides.end() && ctx.parsed) { - for (auto o = state.m->targetOverrides.begin(); - o != state.m->targetOverrides.end(); ++o) { - if (auto k = triple::parse(o->first); - k && k->str() == ctx.parsed->str()) { it = o; break; } - } - } - ctx.hasExplicitSection = it != state.m->targetOverrides.end(); - ctx.sectionEntry = ctx.hasExplicitSection ? &it->second : nullptr; - ctx.hasToolchainOverride = ctx.hasExplicitSection - && !it->second.toolchain.empty(); + ctx.sectionEntry = find_request_entry(*state.m, state.overrides.target_triple, ctx.parsed); + ctx.hasExplicitSection = ctx.sectionEntry != nullptr; + ctx.hasToolchainOverride = ctx.hasExplicitSection && !ctx.sectionEntry->toolchain.empty(); ctx.known = ctx.parsed ? triple::find_known_target(*ctx.parsed) : nullptr; // The row with the facts of the provider that serves it here, rather than @@ -817,7 +808,7 @@ step1_validate_target_tier(PrepareState& state, TargetOverrideCtx& ctx) { // sub-build given its consumer's. Before 2026.11.13.1 only the section did, // and a platform's conformance run that names its toolchain on the command // line was refused. - const bool toolchainNamed = ctx.hasToolchainOverride || state.tcFromCommandLine || state.tcFromConsumer; + const bool toolchainNamed = toolchain_named(state, ctx.sectionEntry); // AND SO IS ONE A PLATFORM CHOSEN FOR THE REQUEST NAMES FOR THE ROW // (2026.11.14.1). A platform that lists the row among its targets with its // toolchain serves it; the row's `planned` says only that the engine's own diff --git a/src/build/prepare/xlings.cpp b/src/build/prepare/xlings.cpp index 4e0d24387..a0bf5efa1 100644 --- a/src/build/prepare/xlings.cpp +++ b/src/build/prepare/xlings.cpp @@ -568,6 +568,10 @@ std::expected phase3_xlings_before_graph(PrepareState& state) ? state.workRoot : state.runtimeSelection.ownerRoot; const auto indices = state.overrides.project_index_root.empty() ? state.m->indices : decltype(state.m->indices){}; + if (auto twice = mcpp::config::index_location_named_twice(state.workRoot, indices); !twice.empty()) { + refusal::record(refusal::Code::IndexLocationNamedTwice); + return std::unexpected(twice); + } if (runtimeRoot == state.workRoot) { mcpp::config::ensure_project_index_dir( **cfg2, state.workRoot, indices, penv); diff --git a/src/build/prepare_inputs.cppm b/src/build/prepare_inputs.cppm index 1e474eb75..d743331fe 100644 --- a/src/build/prepare_inputs.cppm +++ b/src/build/prepare_inputs.cppm @@ -554,6 +554,19 @@ find_target_entry(const mcpp::manifest::Manifest& m, return nullptr; } +// The section a `--target` request matches: the key written as the request, +// else the section of the row the request parses to (`parsed`, which the +// selection may have completed). One lookup for the refusal of an unknown or +// `planned` row and for the refresh of the platform column (mcpp#996), so +// the two cannot disagree about whether a section answers the request. +inline const mcpp::manifest::TargetEntry* +find_request_entry(const mcpp::manifest::Manifest& m, std::string_view request, + const std::optional& parsed) { + if (auto it = m.targetOverrides.find(std::string(request)); it != m.targetOverrides.end()) + return &it->second; + return parsed ? find_target_entry(m, *parsed) : nullptr; +} + std::filesystem::path target_dir(const mcpp::toolchain::Toolchain& tc, const mcpp::toolchain::Fingerprint& fp, const std::filesystem::path& root) diff --git a/src/build/refusal.cppm b/src/build/refusal.cppm index f254000e3..bae0fb2e7 100644 --- a/src/build/refusal.cppm +++ b/src/build/refusal.cppm @@ -227,6 +227,11 @@ enum class Code { // mcpp.lock: the lock records versions its index snapshots and archives // do not hold. BundleOlderThanLock, + // Two entries of the effective `[indices]` name one location (a directory, + // or a repository at one pin), so each of its packages would be two + // candidates of one name. Distinct from a dependency the index lacks: here + // the index has it twice (design 2026-11-22 §6.2). + IndexLocationNamedTwice, Other, // a refusal that has not been given a code yet }; @@ -295,6 +300,8 @@ constexpr std::string_view name(Code c) { case Code::ArtifactUnavailableOffline: return "artifact-unavailable-offline"; case Code::BundleOlderThanLock: return "bundle-older-than-lock"; + case Code::IndexLocationNamedTwice: + return "index-location-named-twice"; case Code::Other: return "other"; } return "other"; diff --git a/src/build/test_protocol.cppm b/src/build/test_protocol.cppm index ae53b206e..a5bf00a5a 100644 --- a/src/build/test_protocol.cppm +++ b/src/build/test_protocol.cppm @@ -19,7 +19,7 @@ inline constexpr int kVersion = 1; // The framework mcpp scaffolds tests with and suggests where a package has // none (docs/01, docs/08): mtest, by this release, from its repository. -inline constexpr std::string_view kMtestRelease = "0.11.2"; +inline constexpr std::string_view kMtestRelease = "0.11.3"; inline constexpr std::string_view kMtestRepo = "https://github.com/mcpp-community/mtest"; // The protocol's variables, removed from the environment a program inherits diff --git a/src/config.cppm b/src/config.cppm index 5d86963b4..fe3b85309 100644 --- a/src/config.cppm +++ b/src/config.cppm @@ -261,6 +261,54 @@ resolve_project_index_path(const std::filesystem::path& projectDir, return source.lexically_normal(); } +// ONE LOCATION IS ONE INDEX (design 2026-11-22 §6.2). Two entries of the +// effective `[indices]` -- one manifest's, or a member's beside its +// workspace's -- that name one directory, or one repository at one pin, +// register its packages twice, and each package of it is then two candidates +// of one qualified name: the install stopped at the provider with +// "package ':@' is ambiguous", naming neither entry. Measured on +// mcpp-index, whose members name the checkout as `mcpplibs` beside the +// workspace's `compat`. Empty when every location has one name; otherwise the +// refusal, naming both entries, the location and the remedy. +std::string index_location_named_twice(const std::filesystem::path& projectDir, + const std::map& indices) +{ + std::map dirs; + std::map repos; + for (auto const& [name, spec] : indices) { + if (spec.is_builtin()) continue; + std::string first, where; + if (spec.is_local()) { + const auto written = resolve_project_index_path(projectDir, spec); + std::error_code ec; + auto dir = std::filesystem::weakly_canonical(written, ec); + if (ec) dir = written; + // `/..` normalises to `/`, and a directory not yet + // present keeps that spelling through weakly_canonical. + if (!dir.has_filename() && dir.has_relative_path()) dir = dir.parent_path(); + auto [it, fresh] = dirs.try_emplace(dir, name); + if (fresh) continue; + const auto text = dir.generic_u8string(); + first = it->second; + where = std::format("the directory {}", std::string(text.begin(), text.end())); + } else { + const auto pin = !spec.rev.empty() ? "rev " + spec.rev : !spec.tag.empty() ? "tag " + spec.tag + : !spec.branch.empty() ? "branch " + spec.branch : std::string("its default branch"); + auto [it, fresh] = repos.try_emplace(spec.url + "\n" + pin, name); + if (fresh) continue; + first = it->second; + where = std::format("the repository {} at {}", spec.url, pin); + } + return std::format( + "[indices] `{}` and `{}` name one index, {}: each of its packages would be two candidates of " + "one name, and installing one is refused as ambiguous [index-location-named-twice]\n" + " Keep one name for the location: drop one entry, or, when one of them is a " + "[workspace.indices] entry, state the index in the members that use it instead.", + first, name, where); + } + return {}; +} + bool project_index_data_initialized(const std::filesystem::path& projectDir) { for (auto const& data : project_xlings_data_roots(projectDir)) diff --git a/src/pm/index_management.cppm b/src/pm/index_management.cppm index 4a9a86019..422e4fc49 100644 --- a/src/pm/index_management.cppm +++ b/src/pm/index_management.cppm @@ -276,6 +276,10 @@ export int index_update(const std::string& filterName) { if (auto effective = mcpp::project::load_effective_manifest(*root)) m = std::move(effective->manifest); if (m && !m->indices.empty()) { + if (auto twice = mcpp::config::index_location_named_twice(*root, m->indices); !twice.empty()) { + mcpp::ui::error(twice); + return 1; + } // filterName: optional single-index filter (parameter). for (auto& [idxName, spec] : m->indices) { if (!filterName.empty() && idxName != filterName) continue; diff --git a/src/provider/xlings/xlings.cpp b/src/provider/xlings/xlings.cpp index 999323818..643162138 100644 --- a/src/provider/xlings/xlings.cpp +++ b/src/provider/xlings/xlings.cpp @@ -701,24 +701,35 @@ payload_versions(const std::filesystem::path& xpkgs, std::string_view packageNam } // What the payload `compilerBin` belongs to declares for `packageName` on this -// host: the requirement of its descriptor's runtime dependency -// (`xim:binutils@2.42.1` gives `2.42.1`), none when it declares none. -std::optional -declared_requirement(const std::filesystem::path& xpkgs, const std::filesystem::path& compilerBin, - std::string_view packageName) { - if (compilerBin.empty()) return std::nullopt; +// host, one entry per descriptor that names the package: the requirement of its +// runtime dependency (`xim:binutils@2.42.1` gives `2.42.1`, an unversioned one +// gives ""). First the descriptor the payload was installed with +// (`/.xpkg.lua`), then the index's. +// +// TWO RECORDS, AND EITHER CAN BE THE ONE THIS STORE FOLLOWED. A home that +// installed the payload installed the companions its own descriptor named; the +// index's is the one the NEXT install reads. On 2026-11-21 xim's gcc recipe +// moved its binutils from 2.42.1 to 2.47: a gcc@16.1.0 installed before then, +// with binutils 2.42.1 beside it, was given no binutils after `mcpp index +// update` (mcpp 2026.11.21.1, "cannot execute 'as'", a home restored from a +// cache). A home whose `[xlings] upstream` holds the payload links it, with the +// upstream's descriptor in it, and installs its companions by the index: there +// the store holds 2.47 and not the 2.42.1 the linked descriptor names. +std::vector +declared_requirements(const std::filesystem::path& xpkgs, const std::filesystem::path& compilerBin, + std::string_view packageName) { + std::vector out; + if (compilerBin.empty()) return out; const auto rel = compilerBin.lexically_relative(xpkgs); - if (rel.empty() || *rel.begin() == "..") return std::nullopt; + if (rel.empty() || *rel.begin() == "..") return out; const auto dirName = rel.begin()->string(); const auto dash = dirName.find("-x-"); - if (dash == std::string::npos) return std::nullopt; + if (dash == std::string::npos) return out; const auto owner = dirName.substr(dash + 3); - for (const auto& file : descriptor_candidates(xpkgs.parent_path(), owner)) { - std::ifstream in(file); - if (!in) continue; - const std::string body((std::istreambuf_iterator(in)), {}); - for (const auto& dep : mcpp::manifest::xpkg_runtime_deps( - body, mcpp::toolchain::platform::HostPlatform::current())) { + const auto host = mcpp::toolchain::platform::HostPlatform::current(); + // The requirement one descriptor states; nullopt when it states none. + auto requirement = [&](const std::string& body) -> std::optional { + for (const auto& dep : mcpp::manifest::xpkg_runtime_deps(body, host)) { std::string_view d = dep; if (auto colon = d.find(':'); colon != std::string_view::npos) d.remove_prefix(colon + 1); const auto at = d.find('@'); @@ -726,60 +737,82 @@ declared_requirement(const std::filesystem::path& xpkgs, const std::filesystem:: return at == std::string_view::npos ? std::string{} : std::string(d.substr(at + 1)); } return std::nullopt; - } - return std::nullopt; + }; + auto read = [](const std::filesystem::path& file) -> std::optional { + std::ifstream in(file); + if (!in) return std::nullopt; + return std::string((std::istreambuf_iterator(in)), {}); + }; + auto add = [&](std::optional r) { + if (r && std::ranges::find(out, *r) == out.end()) out.push_back(std::move(*r)); + }; + if (auto version = std::next(rel.begin()); version != rel.end()) + if (auto body = read(xpkgs / *rel.begin() / *version / ".xpkg.lua")) add(requirement(*body)); + for (const auto& file : descriptor_candidates(xpkgs.parent_path(), owner)) + if (auto body = read(file)) { add(requirement(*body)); break; } + return out; +} + +// The payload's own declaration: the first of `declared_requirements`. +std::optional +declared_requirement(const std::filesystem::path& xpkgs, const std::filesystem::path& compilerBin, + std::string_view packageName) { + auto all = declared_requirements(xpkgs, compilerBin, packageName); + if (all.empty()) return std::nullopt; + return all.front(); } // THE ONE CHOICE AMONG A STORE'S VERSIONS OF A COMPANION (design 2026-11-21, -// offline and toolchain defaults §3.5). The version the compiler's payload -// declares: its exact key, or the newest that satisfies a requirement -// (`>=2.39`). Without a declaration (no compiler, or a payload that names no -// such dependency), the newest. Every picker of this file took the first -// directory the walk returned: with binutils 2.42 and 2.42.1 in one store the -// build took 2.42, which GCC's recipe does not declare and whose `ld` does not -// see the subos's libraries, or 2.42.1, by the filesystem's order. A declared -// version the store does not hold is reported: the build would otherwise take -// another and say nothing. +// offline and toolchain defaults §3.5). The first declaration of the compiler's +// payload the store holds (`declared_requirements`): its exact key, or the +// newest that satisfies a requirement (`>=2.39`). Without a declaration (no +// compiler, or a payload that names no such dependency), the newest. Every +// picker of this file took the first directory the walk returned: with binutils +// 2.42 and 2.42.1 in one store the build took 2.42, which GCC's recipe does not +// declare and whose `ld` does not see the subos's libraries, or 2.42.1, by the +// filesystem's order. Declarations the store holds none of are reported: the +// build would otherwise take another and say nothing. std::optional companion_dir(const std::filesystem::path& xpkgs, const std::filesystem::path& compilerBin, std::string_view packageName, std::string_view requiredRelPath, bool anyPrefix) { namespace vr = mcpp::version_req; const auto dirs = payload_versions(xpkgs, packageName, requiredRelPath, anyPrefix); - const auto declared = declared_requirement(xpkgs, compilerBin, packageName); - std::optional req; - if (declared && !declared->empty()) { - for (const auto& d : dirs) - if (d.filename() == *declared) return d; - if (vr::is_constraint(*declared)) - if (auto r = vr::parse_req(*declared)) req = *r; - if (!req) { - mcpp::diag::degraded("toolchain/companion", std::format( - "the toolchain at {} declares {}@{}, which this store does not hold", - compilerBin.string(), packageName, *declared), - std::format("{} is not used: the build may assemble, link or include with another or with none", - packageName), - "install the toolchain again (`mcpp toolchain install`), which installs what it declares"); - return std::nullopt; + // The newest of `dirs` a requirement admits (every one when there is none). + auto newest = [&](const std::optional& req) -> std::optional { + std::optional best; + std::optional bestVersion; + for (const auto& d : dirs) { + auto v = vr::parse_version(d.filename().string()); + if (!v || (req && !vr::matches(*req, *v))) continue; + if (!bestVersion || *bestVersion < *v) { best = d; bestVersion = *v; } } + return best; + }; + const auto declared = declared_requirements(xpkgs, compilerBin, packageName); + std::vector versioned; + for (const auto& declaration : declared) { + if (declaration.empty()) break; // an unversioned declaration admits the newest, below + versioned.push_back(declaration); + for (const auto& d : dirs) + if (d.filename() == declaration) return d; + if (!vr::is_constraint(declaration)) continue; + if (auto r = vr::parse_req(declaration)) + if (auto hit = newest(*r)) return hit; } - std::optional best; - std::optional bestVersion; - for (const auto& d : dirs) { - auto v = vr::parse_version(d.filename().string()); - if (!v || (req && !vr::matches(*req, *v))) continue; - if (!bestVersion || *bestVersion < *v) { best = d; bestVersion = *v; } - } - if (req && !best) { + if (versioned.size() == declared.size() && !versioned.empty()) { + std::string named; + for (const auto& v : versioned) named += std::format("{}{}@{}", named.empty() ? "" : " or ", packageName, v); mcpp::diag::degraded("toolchain/companion", std::format( - "the toolchain at {} declares {}@{}, and no version this store holds satisfies it", - compilerBin.string(), packageName, *declared), + "the toolchain at {} declares {}, and this store holds no version that satisfies it", + compilerBin.string(), named), std::format("{} is not used: the build may assemble, link or include with another or with none", packageName), "install the toolchain again (`mcpp toolchain install`), which installs what it declares"); return std::nullopt; } - if (best) return best; + if (auto best = newest(std::nullopt)) return best; // No key parses as a version: the newest by name, still not the walk's order. + std::optional best; for (const auto& d : dirs) if (!best || best->filename() < d.filename()) best = d; return best; diff --git a/tests/canary/cxx/mcpp.toml b/tests/canary/cxx/mcpp.toml index 773bc7eb4..34338d94f 100644 --- a/tests/canary/cxx/mcpp.toml +++ b/tests/canary/cxx/mcpp.toml @@ -9,4 +9,4 @@ kind = "bin" main = "src/main.cpp" [dev-dependencies] -mcpplibs.mtest = "0.11.2" +mcpplibs.mtest = "0.11.3" diff --git a/tests/canary/matrix.tsv b/tests/canary/matrix.tsv index 058a41866..d110493dc 100644 --- a/tests/canary/matrix.tsv +++ b/tests/canary/matrix.tsv @@ -99,6 +99,11 @@ c x86_64-windows-msvc windows-x86_64 static n/a a POSIX program; the Windows C l c x86_64-windows-msvc windows-x86_64 run n/a a POSIX program; the Windows C library presents no sigsetjmp c x86_64-windows-msvc windows-x86_64 test n/a a POSIX program; the Windows C library presents no sigsetjmp c x86_64-windows-msvc windows-x86_64 pack n/a a POSIX program; the Windows C library presents no sigsetjmp +c i686-windows-msvc windows-x86_64 build n/a a POSIX program; the Windows C library presents no sigsetjmp +c i686-windows-msvc windows-x86_64 static n/a a POSIX program; the Windows C library presents no sigsetjmp +c i686-windows-msvc windows-x86_64 run n/a a POSIX program; the Windows C library presents no sigsetjmp +c i686-windows-msvc windows-x86_64 test n/a a POSIX program; the Windows C library presents no sigsetjmp +c i686-windows-msvc windows-x86_64 pack n/a a POSIX program; the Windows C library presents no sigsetjmp c x86_64-windows-gnu windows-x86_64 build n/a a POSIX program; the Windows C library presents no sigsetjmp c x86_64-windows-gnu windows-x86_64 static n/a a POSIX program; the Windows C library presents no sigsetjmp c x86_64-windows-gnu windows-x86_64 run n/a a POSIX program; the Windows C library presents no sigsetjmp @@ -134,6 +139,11 @@ cxx x86_64-windows-msvc windows-x86_64 static ok cxx x86_64-windows-msvc windows-x86_64 run ok cxx x86_64-windows-msvc windows-x86_64 test ok cxx x86_64-windows-msvc windows-x86_64 pack ok +cxx i686-windows-msvc windows-x86_64 build fails clang 23 predefines no __cpp_impl_coroutine for i686-pc-windows-msvc, and the MSVC STL's std module at C++23 includes ; the precompile stops (mcpp explains it) +cxx i686-windows-msvc windows-x86_64 static fails clang 23 predefines no __cpp_impl_coroutine for i686-pc-windows-msvc, and the MSVC STL's std module at C++23 includes ; the precompile stops (mcpp explains it) +cxx i686-windows-msvc windows-x86_64 run fails clang 23 predefines no __cpp_impl_coroutine for i686-pc-windows-msvc, and the MSVC STL's std module at C++23 includes ; the precompile stops (mcpp explains it) +cxx i686-windows-msvc windows-x86_64 test fails clang 23 predefines no __cpp_impl_coroutine for i686-pc-windows-msvc, and the MSVC STL's std module at C++23 includes ; the precompile stops (mcpp explains it) +cxx i686-windows-msvc windows-x86_64 pack fails clang 23 predefines no __cpp_impl_coroutine for i686-pc-windows-msvc, and the MSVC STL's std module at C++23 includes ; the precompile stops (mcpp explains it) cxx x86_64-windows-gnu windows-x86_64 build ok cxx x86_64-windows-gnu windows-x86_64 static ok cxx x86_64-windows-gnu windows-x86_64 run ok diff --git a/tests/e2e/deps/lock.cpp b/tests/e2e/deps/lock.cpp index b23272812..2c076b5b5 100644 --- a/tests/e2e/deps/lock.cpp +++ b/tests/e2e/deps/lock.cpp @@ -168,15 +168,16 @@ E2E lock{"lock", s::home_fixture, [] { auto descriptor = [](std::string_view ns, std::string_view desc) { return std::format("package = {{\n spec = \"1\",\n namespace = \"{0}\",\n name = \"lua\",\n description = \"{1}\",\n licenses = {{\"MIT\"}},\n type = \"package\",\n xpm = {{ linux = {{ [\"1.0.0\"] = {{\n url = \"https://example.invalid/{0}-lua.tar.gz\",\n sha256 = \"0000000000000000000000000000000000000000000000000000000000000000\",\n }} }} }},\n mcpp = {{\n language = \"c++23\",\n import_std = false,\n sources = {{ \"src/lua.cppm\" }},\n targets = {{ [\"lua\"] = {{ kind = \"lib\" }} }},\n deps = {{}},\n }},\n}}\n", ns, desc); }; - s::project index{tmp / "index", {{"pkgs/c/capi.lua.lua", descriptor("capi", "new exact identity")}, - {"pkgs/m/mcpplibs.capi.lua.lua", descriptor("mcpplibs.capi", "old prefixed identity")}}}; + // One directory per index name: a location under two names is refused (SPEC-004 §9). + s::project defaults{tmp / "index-default", {{"pkgs/m/mcpplibs.capi.lua.lua", descriptor("mcpplibs.capi", "old prefixed identity")}}}; + s::project capi{tmp / "index-capi", {{"pkgs/c/capi.lua.lua", descriptor("capi", "new exact identity")}}}; s::project app{tmp / "app", {{".mcpp/.xlings/data/xpkgs/mcpplibs.capi-x-lua/1.0.0/src/lua.cppm", "export module selected.lua;\nexport int selected_value() { return 41; }\n"}, {".mcpp/.xlings/data/xpkgs/capi-x-lua/1.0.0/src/lua.cppm", "export module selected.lua;\nexport int selected_value() { return 42; }\n"}, {".mcpp/.xlings/data/xpkgs/mcpplibs.capi-x-lua/1.0.0/.mcpp_ok", "ok\n"}, {".mcpp/.xlings/data/xpkgs/capi-x-lua/1.0.0/.mcpp_ok", "ok\n"}, {"src/main.cpp", "import selected.lua;\nint main() { return selected_value() == 41 ? 0 : 1; }\n"}, {"mcpp.lock", "# Existing pre-exact-selector resolution anchor.\nversion = 2\n\n[package.\"capi.lua\"]\nnamespace = \"mcpplibs.capi\"\nversion = \"1.0.0\"\nsource = \"index+mcpplibs.capi@1.0.0\"\nhash = \"fnv1a:migration-fixture\"\n"}}}; - app.write("mcpp.toml", std::format("[package]\nname = \"app\"\nversion = \"0.1.0\"\n\n[indices]\ndefault = {{ path = \"{0}\" }}\ncapi = {{ path = \"{0}\" }}\n\n[dependencies]\ncapi.lua = \"1.0.0\"\n", index.dir().generic_string())); + app.write("mcpp.toml", std::format("[package]\nname = \"app\"\nversion = \"0.1.0\"\n\n[indices]\ndefault = {{ path = \"{0}\" }}\ncapi = {{ path = \"{1}\" }}\n\n[dependencies]\ncapi.lua = \"1.0.0\"\n", defaults.dir().generic_string(), capi.dir().generic_string())); auto b = app.mcpp({"build"}, inherited); expect(fatal(e2e::succeeded(b))) << "build failed"; expect(e2e::contains(s::text(b), "keeping the locked identity")) << "expected selector migration warning"; diff --git a/tests/e2e/deps/names.cpp b/tests/e2e/deps/names.cpp index ea667d9ae..24189638c 100644 --- a/tests/e2e/deps/names.cpp +++ b/tests/e2e/deps/names.cpp @@ -81,11 +81,12 @@ E2E names{"names", s::home_fixture, [] { // INV-RESOLVE (#278): a bare name resolves in exactly one place (mcpplibs; compat during // the migration window, with a warning naming the exact replacement); every other // namespace is written out; a refused add writes nothing and names what exists. - s::project p{{"idx/pkgs/a/acme.widget.lua", descriptor("acme", "acme.widget", "1.0.0")}, - {"idx/pkgs/c/compat.gadget.lua", descriptor("compat", "gadget", "2.0.0")}, + // One directory per index name: a location under two names is refused (SPEC-004 §9). + s::project p{{"idx-acme/pkgs/a/acme.widget.lua", descriptor("acme", "acme.widget", "1.0.0")}, + {"idx-compat/pkgs/c/compat.gadget.lua", descriptor("compat", "gadget", "2.0.0")}, {"app/src/main.cpp", "int main() { return 0; }\n"}}; auto write_manifest = [&](std::string_view deps) { - p.write("app/mcpp.toml", std::format("[package]\nname = \"app\"\nversion = \"0.1.0\"\n\n[indices]\nacme = {{ path = \"../idx\" }}\ncompat = {{ path = \"../idx\" }}\n{}\n", deps)); + p.write("app/mcpp.toml", std::format("[package]\nname = \"app\"\nversion = \"0.1.0\"\n\n[indices]\nacme = {{ path = \"../idx-acme\" }}\ncompat = {{ path = \"../idx-compat\" }}\n{}\n", deps)); }; auto build = [&] { return p.mcpp_in("app", {"build"}); }; write_manifest("[dependencies]\nwidget = \"1.0.0\""); diff --git a/tests/e2e/golden/surface.txt b/tests/e2e/golden/surface.txt index 587143fe8..0ba3f313f 100644 --- a/tests/e2e/golden/surface.txt +++ b/tests/e2e/golden/surface.txt @@ -415,6 +415,7 @@ reason exclusive-capability reason host-cannot-serve reason host-module-missing reason host-tool-toolchain +reason index-location-named-twice reason interface-not-provided reason layer-cycle reason layer-ordering diff --git a/tests/e2e/index/refresh.cpp b/tests/e2e/index/refresh.cpp index a2f608495..4c325d94b 100644 --- a/tests/e2e/index/refresh.cpp +++ b/tests/e2e/index/refresh.cpp @@ -472,6 +472,47 @@ exit 0 s::project(home, {{"config.toml", s::read_file(home / "config.toml") + "\n[index]\nauto_refresh = false\n"}}); refused(R"(\[index\] auto_refresh = false)", o); }; + + "1145 a column miss that refuses nothing does not refresh"_test[s::fresh_sandbox] = [] { + // mcpp#996: only a request refused without a platform refreshes the index on a miss of its + // column (SPEC-013 §14 item 6). A custom triple a `[target.]` section defines, a + // `planned` row built with a named toolchain, and a request a table answers with + // `platform = "none"` are not refused for want of a platform, so the refresh policy is not + // asked: outside the debounce window and offline, no decision for the column is logged. + // Before, each of them was decided (and, online, synced) on every build more than the + // debounce apart -- 12 to 19 s a build for `i686-windows-msvc` with a section. + const auto home = s::case_home(s::home::inherited); + const auto index = home / "indices/mcpplibs"; + s::project(index, {{".xlings-index-version", "abc1234\n"}, {"pkgs/.keep", ""}, {".mcpp-index-updated", ""}}); + age(index / ".mcpp-index-updated", std::chrono::hours{24 * 30}); + const auto app_with = [](std::string_view name, std::string_view tables) { + return s::project(s::case_dir() / name, { + {"mcpp.toml", std::format("[package]\nname = \"app\"\nversion = \"0.1.0\"\n\n[targets.app]\nkind = \"bin\"\n" + "main = \"src/main.cpp\"\n{}", tables)}, + {"src/main.cpp", "int main() { return 0; }\n"}}); + }; + s::options o = inherited; + o.env.emplace_back("MCPP_VERBOSE", "1"); + o.env.emplace_back("MCPP_OFFLINE", "1"); + const auto undecided = [&](std::string_view why, const s::project& app, std::vector args, std::string_view row) { + auto r = app.mcpp(args, o); + const auto out = s::text(r); + expect(fatal(r.started)) << why << ": " << out; + expect(fatal(s::no_line(out, std::format("refresh for the platform column for {}", row)))) + << why << ": the column's miss reached the refresh policy: " << out; + return out; + }; + undecided("a section", app_with("section", "\n[target.x86_64-toyos]\ntoolchain = \"gcc@16.1.0\"\n"), + {"build", "--target", "x86_64-toyos"}, "x86_64-toyos"); + undecided("a planned row with --toolchain", app_with("planned", ""), + {"build", "--target", "i686-linux-gnu", "--toolchain", "gcc@16.1.0"}, "i686-linux-gnu"); + const auto none = undecided("platform = \"none\"", app_with("none", "\n[target.'cfg(os = \"toyos\")']\nplatform = \"none\"\n"), + {"build", "--target", "x86_64-toyos"}, "x86_64-toyos"); + // Still refused as unknown -- no section defines it -- and the refusal adds nothing about + // an index that was not consulted. + expect(fatal(s::has_line(none, "unknown target 'x86_64-toyos'"))) << "none: not refused as unknown: " << none; + expect(fatal(s::no_line(none, "lists no platform for it"))) << "none: the refusal speaks of the column: " << none; + }; }}; } // namespace diff --git a/tests/e2e/index/routes.cpp b/tests/e2e/index/routes.cpp index 1e099d52b..7134b2477 100644 --- a/tests/e2e/index/routes.cpp +++ b/tests/e2e/index/routes.cpp @@ -304,6 +304,36 @@ E2E routes{"routes", s::home_fixture, [] { expect(fatal(e2e::contains(s::text(r), route))) << "the inherited index was anchored somewhere unreadable: " << s::text(r); expect(fatal(s::lacks(s::text(r), tmp.string()) && s::lacks(s::text(r), tmp.generic_string()))) << "the route diagnostic leaked a filesystem path: " << s::text(r); }; + + "1146 one location under two index names is refused"_test[s::fresh_sandbox] = [] { + // One location is one index (design 2026-11-22 §6.2, SPEC-004 §9): two entries of the + // effective [indices] that name one directory register it twice, and each of its packages + // is then two candidates of one name -- the install stopped at the provider as ambiguous, + // naming neither entry (measured on mcpp-index). A: two names in one manifest; B: a + // member's name beside its workspace's for the same directory; C: the same name for it is + // one index and is not refused. + const auto tmp = s::case_dir(); + s::project(tmp / "idx", {{"pkgs/.keep", ""}}); + const auto refused = [](std::string_view why, const e2e::outcome& r, std::string_view first, std::string_view second) { + const auto out = s::text(r); + expect(fatal(r.started && r.status != 0)) << why << ": built: " << out; + expect(fatal(s::has_line(out, std::format(R"(\[indices\] `{}` and `{}` name one index, the directory .*\[index-location-named-twice\])", first, second)))) + << why << ": the refusal does not name both entries and the token: " << out; + expect(fatal(s::has_line(out, "Keep one name for the location"))) << why << ": no remedy: " << out; + }; + s::project one(tmp / "one", {{"mcpp.toml", "[package]\nname = \"one\"\nversion = \"0.1.0\"\n\n[indices]\na = { path = \"../idx\" }\nb = { path = \"../idx/./\" }\n"}, + {"src/main.cpp", "int main() { return 0; }\n"}}); + refused("A", one.mcpp({"build"}, inherited), "a", "b"); + const auto ws = [&](std::string_view dir, std::string_view memberName) { + return s::project(tmp / dir, { + {"mcpp.toml", "[workspace]\nmembers = [\"m\"]\n\n[workspace.indices]\nshared = { path = \"../idx\" }\n"}, + {"m/mcpp.toml", std::format("[package]\nname = \"m\"\nversion = \"0.1.0\"\n\n[indices]\n{} = {{ path = \"../../idx\" }}\n", memberName)}, + {"m/src/main.cpp", "int main() { return 0; }\n"}}); + }; + refused("B", ws("ws-two", "mine").mcpp({"build", "-p", "m"}, inherited), "mine", "shared"); + auto r = ws("ws-one", "shared").mcpp({"build", "-p", "m"}, inherited); + expect(fatal(s::no_line(s::text(r), "index-location-named-twice"))) << "C: one name for one location was refused: " << s::text(r); + }; }}; } // namespace diff --git a/tests/e2e/windows/msvc.cpp b/tests/e2e/windows/msvc.cpp index d79b69526..ca797fe7b 100644 --- a/tests/e2e/windows/msvc.cpp +++ b/tests/e2e/windows/msvc.cpp @@ -430,6 +430,24 @@ int main() { f(); } expect(fatal(e2e::contains(out, "toolchain = \"llvm@22.1.8\""))) << "C: llvm 22.1.8 was not offered: " << out; }; + "1144 i686-windows-msvc is a row: built and run with no section"_test[s::msvc] = [] { + // The 32-bit x86 Microsoft ABI is a row of the target table, served by the msvc provider + // like x86_64-windows-msvc (mcpp#996): a project that writes no [target.i686-windows-msvc] + // builds it with the machine's toolchain and runs it on x86_64 Windows (WOW64), with no + // platform looked up. Before, it was a custom triple, and without the section it was + // refused as an unknown target. + const s::options o{.where = s::home::registry}; + s::project app{{"mcpp.toml", "[package]\nname = \"x86app\"\nversion = \"0.1.0\"\nstandard = \"c++20\"\n"}, + {"src/main.cpp", "import std;\nint main() { std::cout << \"x86 row \" << sizeof(void*) << \"\\n\"; }\n"}}; + auto r = app.mcpp({"run", "--target", "i686-windows-msvc", "--verbose"}, o); + const auto out = s::text(r); + expect(fatal(e2e::succeeded(r))) << "the row did not build and run: " << out; + expect(fatal(e2e::contains(out, "x86 row 4"))) << "the program is not a 32-bit one: " << out; + expect(fatal(!e2e::contains(out, "the platform column for i686-windows-msvc"))) << "a platform was looked up for a row the table serves: " << out; + r = app.mcpp({"toolchain", "list"}, o); + expect(fatal(e2e::succeeded(r) && e2e::contains(s::text(r), "i686-windows-msvc"))) << "the row is not listed: " << s::text(r); + }; + "1017 a system msvc builds the build program of a cross target"_test[s::windows][s::msvc] = [] { // With msvc@system the machine's default, a build program of a riscv64-none-elf build is // compiled by the located Visual Studio, not looked up as a package, and its directive diff --git a/tests/fixtures/target-rows.snapshot b/tests/fixtures/target-rows.snapshot index 385b720de..0c85f0378 100644 --- a/tests/fixtures/target-rows.snapshot +++ b/tests/fixtures/target-rows.snapshot @@ -150,6 +150,25 @@ row x86_64-windows-msvc platform-name windows descriptor-keys windows sysroot +row i686-windows-msvc + table tier=preview note=PE pin= sysroot= static=0 platform= + str i686-windows-msvc + llvm i686-pc-windows-msvc + llvm@15.0 i686-pc-windows-msvc + format PE + family windows + pe/macho/wasm 100 + apple/ios/sim/android 0000 + freestanding/openkal/own-sysroot/capability 0000 + musl/msvc/windows-gnu/x86_32 0101 + msvc-arch x86 + nasm win32 + naming exe=.exe lib= static=.lib shared=.dll import=1 sharedPrefix=- + application exe + android-abi i686 + platform-name windows + descriptor-keys windows + sysroot row aarch64-macos table tier=verified note= pin= sysroot= static=0 platform= str aarch64-macos @@ -876,9 +895,9 @@ request x86_64-windows on windows-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 request i686-windows parsed i686-windows-gnu envExplicit=0 - on linux-x86_64 -> - - fallback=0 | - on macos-aarch64 -> - - fallback=0 | - on windows-x86_64 -> - - fallback=0 | + on linux-x86_64 -> i686-windows-msvc msvc fallback=0 | i686-windows-msvc/msvc/100/x + on macos-aarch64 -> i686-windows-msvc msvc fallback=0 | i686-windows-msvc/msvc/100/x + on windows-x86_64 -> i686-windows-msvc msvc fallback=0 | i686-windows-msvc/msvc/100/x request aarch64-windows parsed aarch64-windows-gnu envExplicit=0 on linux-x86_64 -> aarch64-windows-gnu mingw-llvm fallback=0 | aarch64-windows-gnu/mingw-llvm/5 @@ -946,9 +965,9 @@ request wasm32-unknown-emscripten on windows-x86_64 -> wasm32-emscripten emsdk fallback=0 | wasm32-emscripten/emsdk/100 request x86-windows-msvc parsed i686-windows-msvc envExplicit=1 - on linux-x86_64 -> - - fallback=0 | - on macos-aarch64 -> - - fallback=0 | - on windows-x86_64 -> - - fallback=0 | + on linux-x86_64 -> i686-windows-msvc msvc fallback=0 | i686-windows-msvc/msvc/100/x + on macos-aarch64 -> i686-windows-msvc msvc fallback=0 | i686-windows-msvc/msvc/100/x + on windows-x86_64 -> i686-windows-msvc msvc fallback=0 | i686-windows-msvc/msvc/100/x request i686-none-elf parsed i686-none-elf envExplicit=1 on linux-x86_64 -> i686-none-elf bare-metal fallback=0 | i686-none-elf/bare-metal/100 @@ -969,7 +988,7 @@ 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 windows -> x86_64-windows-gnu aarch64-windows-gnu | -set windows-msvc -> x86_64-windows-msvc | +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 none-elf -> riscv64-none-elf riscv32-none-elf aarch64-none-elf x86_64-none-elf i686-none-elf | diff --git a/tests/matrix/expected.tsv b/tests/matrix/expected.tsv index da42d1306..a93e6c4e9 100644 --- a/tests/matrix/expected.tsv +++ b/tests/matrix/expected.tsv @@ -235,6 +235,8 @@ graph windows-x86_64 x86_64-windows-gnu llvm@23.1.3 x86_64-w64-windows-gnu none graph windows-x86_64 x86_64-windows-gnu msvc@system - - - - - unsupported host-tool-toolchain graph windows-x86_64 x86_64-windows-msvc llvm@23.1.3 - - - - - unsupported std-module-precompile graph windows-x86_64 x86_64-windows-msvc msvc@system - - - - - unsupported host-tool-toolchain +graph windows-x86_64 i686-windows-msvc llvm@23.1.3 - - - - - unsupported std-module-precompile +graph windows-x86_64 i686-windows-msvc msvc@system - - - - - unsupported host-tool-toolchain graph windows-x86_64 x86_64-windows-musl llvm@23.1.3 - - - - - unsupported platform-version-group graph windows-x86_64 x86_64-windows-musl msvc@system - - - - - unsupported capability-pin payload linux-aarch64 aarch64-freebsd-musl gcc@16.1.0 - - - - - unsupported capability-pin @@ -469,5 +471,7 @@ payload windows-x86_64 x86_64-windows-gnu llvm@23.1.3 x86_64-w64-windows-gnu non payload windows-x86_64 x86_64-windows-gnu msvc@system - - - - - unsupported convention-unreplaced payload windows-x86_64 x86_64-windows-msvc llvm@23.1.3 x86_64-pc-windows-msvc none msvc(payload) msvc-stl(payload) - ok none payload windows-x86_64 x86_64-windows-msvc msvc@system x86_64-pc-windows-msvc none msvc(payload) (payload) - ok none +payload windows-x86_64 i686-windows-msvc llvm@23.1.3 i686-pc-windows-msvc none msvc(payload) msvc-stl(payload) - ok none +payload windows-x86_64 i686-windows-msvc msvc@system i686-pc-windows-msvc none msvc(payload) (payload) - ok none payload windows-x86_64 x86_64-windows-musl llvm@23.1.3 x86_64-w64-windows-gnu none musl(platform) libc++(platform) openkal-llvm-runtime@0.20.3 ok none payload windows-x86_64 x86_64-windows-musl msvc@system - - - - - unsupported capability-pin diff --git a/tests/support/mcpp.toml b/tests/support/mcpp.toml index 30014f31b..7f3db8e62 100644 --- a/tests/support/mcpp.toml +++ b/tests/support/mcpp.toml @@ -13,5 +13,5 @@ license = "Apache-2.0" kind = "lib" [dependencies] -mcpplibs.mtest = "0.11.2" +mcpplibs.mtest = "0.11.3" nlohmann.json = "3.12.0" diff --git a/tests/unit/test_config.cpp b/tests/unit/test_config.cpp index f6e99d2e5..784ea1fdc 100644 --- a/tests/unit/test_config.cpp +++ b/tests/unit/test_config.cpp @@ -55,6 +55,26 @@ UTest resolve_project_index_path_uses_project_root_for_relative_local_index{"Con expect(eq(mcpp::config::resolve_project_index_path(project, spec), (project / "mcpp").lexically_normal())); }}; +UTest one_location_is_one_index{"Config/OneLocationIsOneIndex", [] { + // Two entries naming one directory, by any spelling of it, or one repository at one pin, + // are refused, naming both; another pin or another directory is not (design 2026-11-22 §6.2). + const auto project = std::filesystem::path{"/tmp/mcpp-project/member"}; + const auto local = [](std::string name, std::filesystem::path p) { + mcpp::pm::IndexSpec s; s.name = name; s.path = std::move(p); return std::pair{name, s}; + }; + const auto git = [](std::string name, std::string url, std::string tag) { + mcpp::pm::IndexSpec s; s.name = name; s.url = std::move(url); s.tag = std::move(tag); return std::pair{name, s}; + }; + using Map = std::map; + const auto twice = [&](const Map& m) { return mcpp::config::index_location_named_twice(project, m); }; + const auto refusal = twice(Map{local("compat", "/tmp/mcpp-project"), local("mcpplibs", "..")}); + expect(refusal.contains("`compat` and `mcpplibs` name one index")) << refusal; + expect(refusal.contains("[index-location-named-twice]")) << refusal; + expect(!twice(Map{git("a", "https://example.invalid/i.git", "v1"), git("b", "https://example.invalid/i.git", "v1")}).empty()); + expect(twice(Map{git("a", "https://example.invalid/i.git", "v1"), git("b", "https://example.invalid/i.git", "v2")}).empty()); + expect(twice(Map{local("a", "../one"), local("b", "../two")}).empty()); +}}; + UTest project_index_json_escapes_local_index_path{"Config/ProjectIndexJsonEscapesLocalIndexPath", [] { auto project = make_tempdir("mcpp-config-json-escape"); auto index = project / "local" / "index"; diff --git a/tests/unit/test_process_run_exec.cpp b/tests/unit/test_process_run_exec.cpp index 03cc99c10..0610660fb 100644 --- a/tests/unit/test_process_run_exec.cpp +++ b/tests/unit/test_process_run_exec.cpp @@ -44,41 +44,71 @@ UTest output_producer{"RunExec/OutputProducer", [] { std::_Exit(7); }}; +// THE BOUNDS ARE THOSE OF THE PROPERTY, NOT OF THE PRODUCER'S START. The handler +// sleeps longer than the idle bound while the producer writes its 48 lines +// (1.44 s), so the lines are queued when it returns, and the idle bound is +// renewed by them or the run is ended. Through 2026.11.21.1 the idle bound was +// 500 ms and the handler slept 750 ms: the producer is this program started +// again, and on a loaded macOS runner it wrote no line inside those bounds +// (exit 137, timed out, 0 lines, an empty error output; the loop reads both +// streams before it classifies silence, so 0 lines is the producer's time). +constexpr auto kProducerIdle = std::chrono::milliseconds(2000); +constexpr auto kHandlerSleep = kProducerIdle + std::chrono::milliseconds(250); +constexpr auto kProducerTotal = std::chrono::seconds(10); + +// What a failure says: when the ready line arrived, and how much was read. +static std::string producer_timing(std::chrono::steady_clock::time_point start, + std::optional ready, std::size_t lines) { + const auto ms = [&](auto t) { return std::chrono::duration_cast(t - start).count(); }; + return std::format("ready line after {}, {} line(s) read", + ready ? std::format("{} ms", ms(*ready)) : std::string("none"), lines); +} + UTest queued_output_renews_idle_after_a_line_handler{"RunExec/QueuedOutputRenewsIdleAfterALineHandler", [] { std::vector ticks; + const auto start = std::chrono::steady_clock::now(); + std::optional ready; const auto result = process::execute({mcpp::invocation::self_exe_path().string(), "RunExec/OutputProducer"}, { .env = {{"MTEST_PROTOCOL", ""}, {"MCPP_TEST_OUTPUT_PRODUCER", "1"}, {"MCPP_TEST_OUTPUT_STREAM", "stdout"}, {"MCPP_TEST_OUTPUT_TICKS", "48"}}, .streams = process::Streams::merged, - .total = std::chrono::seconds(3), .idle = std::chrono::milliseconds(500), + .total = kProducerTotal, .idle = kProducerIdle, .on_line = [&](std::string_view line) { - if (line == "mcpp-stderr-ready") - std::this_thread::sleep_for(std::chrono::milliseconds(750)); + if (line == "mcpp-stderr-ready") { + ready = std::chrono::steady_clock::now(); + std::this_thread::sleep_for(kHandlerSleep); + } long long tick; if (std::from_chars(line.data(), line.data() + line.size(), tick).ec == std::errc{}) ticks.push_back(tick); }}); - expect(eq(result.exit_code, 7)); - expect(!result.timed_out); - expect(eq(ticks.size(), 48u)); + const auto timing = producer_timing(start, ready, ticks.size()); + expect(eq(result.exit_code, 7)) << timing; + expect(!result.timed_out) << timing; + expect(eq(ticks.size(), 48u)) << timing; }}; UTest queued_error_output_renews_idle_after_a_line_handler{"RunExec/QueuedErrorOutputRenewsIdleAfterALineHandler", [] { + const auto start = std::chrono::steady_clock::now(); + std::optional ready; const auto result = process::execute({mcpp::invocation::self_exe_path().string(), "RunExec/OutputProducer"}, { .env = {{"MTEST_PROTOCOL", ""}, {"MCPP_TEST_OUTPUT_PRODUCER", "1"}, {"MCPP_TEST_OUTPUT_TICKS", "48"}}, .streams = process::Streams::output_error_kept, - .total = std::chrono::seconds(3), .idle = std::chrono::milliseconds(500), - .on_line = [](std::string_view line) { - if (line == "mcpp-stderr-ready") - std::this_thread::sleep_for(std::chrono::milliseconds(750)); + .total = kProducerTotal, .idle = kProducerIdle, + .on_line = [&](std::string_view line) { + if (line == "mcpp-stderr-ready") { + ready = std::chrono::steady_clock::now(); + std::this_thread::sleep_for(kHandlerSleep); + } }}); - expect(eq(result.exit_code, 7)) << result.error_output; - expect(!result.timed_out); std::istringstream input(result.error_output); - int ticks = 0; + std::size_t ticks = 0; for (long long tick; input >> tick;) ++ticks; - expect(eq(ticks, 48)); + const auto timing = producer_timing(start, ready, ticks); + expect(eq(result.exit_code, 7)) << timing << "; " << result.error_output; + expect(!result.timed_out) << timing; + expect(eq(ticks, 48u)) << timing; }}; UTest stream_completion_and_child_wait_keep_their_bounds{"RunExec/StreamCompletionAndChildWaitKeepTheirBounds", [] { diff --git a/tests/unit/test_xlings.cpp b/tests/unit/test_xlings.cpp index 94dcdf332..1b7884c2b 100644 --- a/tests/unit/test_xlings.cpp +++ b/tests/unit/test_xlings.cpp @@ -429,6 +429,34 @@ package = {{ descriptor("xim:binutils@2.39"); expect(!xp::find_sibling_binary(gccBin, "binutils", "bin/as").has_value()) << "a declared version the store does not hold was replaced by another"; + // The descriptor the payload was installed with decides, not the index's: the index moved + // gcc's binutils to a version this store does not hold (2.48 here, 2.47 on 2026-11-21), and + // the payload still runs with the 2.42.1 it was installed beside. + descriptor("xim:binutils@2.48"); + touch(xpkgs / "xim-x-gcc" / "16.1.0" / ".xpkg.lua", R"( +package = { + name = "gcc", + xpm = { + linux = { deps = { runtime = { "xim:glibc@>=2.39", "xim:binutils@2.42.1" } }, ["16.1.0"] = {} }, + macosx = { deps = { "xim:binutils@2.42.1" }, ["16.1.0"] = {} }, + windows = { deps = { "xim:binutils@2.42.1" }, ["16.1.0"] = {} }, + }, +} +)"); + expect(eq(xp::find_sibling_binary(gccBin, "binutils", "bin/as").value_or(""), + xpkgs / "xim-x-binutils" / "2.42.1" / "bin" / "as")) << "the index's newer declaration replaced the installed one"; + expect(eq(xp::declared_dependency(gccBin, "binutils").value_or(""), std::string("2.42.1"))); + // A home that links the payload from an upstream holds the companions the index names, beside + // the upstream's descriptor: the index's declaration is the one this store followed. + std::filesystem::remove_all(xpkgs / "xim-x-binutils" / "2.42.1"); + touch(xpkgs / "xim-x-binutils" / "2.48" / "bin" / "as"); + expect(eq(xp::find_sibling_binary(gccBin, "binutils", "bin/as").value_or(""), + xpkgs / "xim-x-binutils" / "2.48" / "bin" / "as")) << "the index's declaration the store holds was not taken"; + expect(eq(xp::declared_dependency(gccBin, "binutils").value_or(""), std::string("2.42.1"))) + << "the payload's own declaration is its installed descriptor's"; + std::filesystem::remove_all(xpkgs / "xim-x-binutils" / "2.48"); + expect(!xp::find_sibling_binary(gccBin, "binutils", "bin/as").has_value()) + << "declarations the store holds none of were replaced by another version"; std::filesystem::remove_all(tmp); }};