Skip to content

Commit dd9b880

Browse files
committed
docs(plan): record R2/R5 implementation findings
R5's builtin template was the wrong shape — mcpp's builtin registry is frozen at `bin` by design and templates ship with the package that provides them, so the template lives in riscv-virt-rt and mcpp needs no change at all. R2 hit a real gap: a dependency's `[xlings] deps` is materialized for the ROOT project only, so a consumer of the board package would get neither libc nor emulator. The fix is xim's own install-time dependency edge in the descriptor, verified by removing picolibc from the store and watching `mcpp add` put it back — not by observing an already-provisioned machine.
1 parent c99bd26 commit dd9b880

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

.agents/docs/2026-08-19-baremetal-phase3-usable-plan.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,55 @@ error: test result: FAILED. 2 passed; 1 failed
361361
**把位置参数改名 `bin`**(在 `--help` 里本来就更准),`--target` 就自由了。
362362
`--target-triple` 作为 2026.8.19.1 已发布的拼写保留为别名。
363363
**一致性是判据之一,它排在「不能坏」后面 —— 但排在后面不等于要放弃。**
364+
365+
### 11.2 R2/R5 的实施结论:两条计划主张又被推翻
366+
367+
#### ⭐ R5:`mcpp new --template baremetal-riscv` 不该由 mcpp 提供
368+
369+
§6 写的是给 mcpp 加一个内建模板。**读代码发现这条路是被刻意关掉的**:
370+
371+
```cpp
372+
// src/cli/cmd_new.cppm
373+
// builtin registry (frozen: bin; gui = transitional alias), else a
374+
// package template: [ns.]pkg | [ns.]pkg:tmpl | [ns.]pkg@ver:tmpl.
375+
```
376+
377+
**模板随提供它的包走**(封闭语法 / 开放词汇),而且 `mcpp new` 会把自依赖按
378+
**它解析到的版本**写进生成的 manifest —— 模板因此**不可能与库脱节**
379+
380+
落地形态因此变成:`riscv-virt-rt` 里加 `templates/blinky/`,用户敲
381+
382+
```bash
383+
mcpp new blinky --template riscv-virt-rt
384+
```
385+
386+
**mcpp 侧零改动**。这比原计划好在:模板与板级包同一版本、同一仓库、同一次发布。
387+
388+
#### ⚠️ R2:包的 `[xlings] deps` **不会**到达消费者 —— 少了这条边包是废的
389+
390+
`mcpp` 只为**根工程**(或 workspace)物化 `[xlings]`(`prepare.cppm`
391+
`runtimeOwnerManifest`)。BSP 自己声明的 `xim:picolibc-riscv` / `xim:qemu-riscv`
392+
在被当依赖用时**一个都不装** —— 用户 `mcpp add` 之后拿到的是一个没有 libc 也没有
393+
模拟器的板级包,直到 `build.mcpp` 才报出来。
394+
395+
解法**不在 mcpp 里**:xim 的描述符本来就有安装期依赖边,写在 `xpm.<平台>.deps`
396+
(`libpng.lua` 早就这么用)。⇒ 描述符里加
397+
398+
```lua
399+
deps = { "xim:picolibc-riscv@1.8.12", "xim:qemu-riscv@9.2.4-1" },
400+
```
401+
402+
**实测判据(必须是「拿走再装回来」,不能只看装好的机器)**:把 store 里的
403+
`xim-x-picolibc-riscv` 改名藏起来 → `mcpp add` + `mcpp build` **把它装了回来并链接成功**;
404+
不加这条边则停在 `build.mcpp` 说「declared in [xlings].deps but is not installed」。
405+
406+
#### ⚠️ Form A vs Form B:选错的话包会「解析成功、编译成功、链接到空气」
407+
408+
`riscv-virt-rt``build.mcpp`,而 mcpp 在**包根**找它。Form B(内联 `mcpp = {...}`)
409+
把包根留在解包目录,tarball 的 `riscv-virt-rt-<v>/` 包裹层由每条 glob 的 `*/` 吸收
410+
**`build.mcpp` 落在下一层,找不到**。Form A(`mcpp = "*/mcpp.toml"`)把包根移进包裹层。
411+
**凡是带 `build.mcpp` 的包必须用 Form A。**
412+
413+
#### 兼容性:类型化 API 没有语言内的特性探测(见 §3.2 的补记)
414+
415+
包侧无解 ⇒ 补在引擎侧的编译失败诊断上,对**以后每一次**类型化 API 新增都生效。

0 commit comments

Comments
 (0)