Commit 9249553
0.4.0: every payload a compile reads is in the build graph (#12)
* 0.4.0: the surface becomes pure, and generation becomes an action
Every payload a compile reads is now in the build graph. Two mechanisms carry
that, and which one applies is decided by WHEN the thing is known.
DISCOVERED WHILE THE COMPILER RUNS: a shader's `#include`
--------------------------------------------------------
`a.input()` is fixed when `build.mcpp` runs, before the compiler has read a
line, so a shader or kernel that includes another file had no edge to it:
editing that file rebuilt nothing and the build stayed green over a stale
artifact. `grep depfile rules/` returned nothing across all six rules.
每一种拼法都用真实输出验过,不是照着文档写的:
glslangValidator --depfile -> out.spv: scale.comp ./common.glsl
glslc -MD -MF -> out2.spv: scale.comp common.glsl
slangc -depfile -> out.spv: <entry>.slang <included>.slang
nvcc -MMD -MF -> n.o : k.cu \ common.cuh
clang++ -MMD -MF -> c.o: k.cpp common.cuh
bisheng -MMD -MF -> k2.o: k.asc inc.h
ascendc 是唯一没有 CI 消费者的 lane,「bisheng 是 clang 血统所以应该支持」这种理由
会把未验证的旗标发进唯一没人检查的规则里。工具包在本机,于是问了它。`-MMD` 而不是
`-MD`:后者在 BiSheng 上实测拉进五十个 `/usr/include` 宿主头,让目标文件依赖共享构建
目录不该携带的绝对路径。
DISCOVERED BY NOBODY: `.incbin`
-------------------------------
汇编器在汇编期打开被内嵌的文件,而生成的 `.S` 自己的文本并不随载荷改变,于是目标文件
只被汇编一次。在已发布的 0.3.0 上、在沙箱里、对着索引解析出来的包实测:改一个 shader,
程序打印的还是上一版载荷的字节数(1480 -> 1480),而 header 存储是 1480 -> 1776。
问汇编器不行,这是实测的:编译器驱动的 `-MD` 是预处理器通道看不见 `.incbin`;GNU as 的
`--MD` 报得出来;clang 的集成汇编器根本没有依赖输出(三种拼法全被拒)。采信它会让这条
依赖在 GCC 上被跟踪、在 Clang 上静默缺失 —— 比两边都缺失更坏。
**修法不是给引擎加一条通道,而是不要在错误的时刻写那个文件。** 一条 `mcpp::action`
声明它的输入;把生成变成 action、载荷作它的声明输入,这条边就是普通的边,用的是引擎
已有的唯一图原语。原型先证后写:`BYTES=64 -> 192`,零引擎改动。
机制逐文件追踪过:载荷 mtime 前移、`.S` 不动(内容没变)、`.o` 前移 —— ninja 因 action
的声明输入变化而重跑它,无 `restat` 于是其 output 视为新的,汇编边随之重跑。去掉载荷
输入,`.o` 不动、字节停住。两个方向都量过。
这要求三件事,而每一件本身都是对的
--------------------------------
1. **`mcpp.plugins.surface` 只 import `std`。** 它原先读 `mcpp::target_os()`、
`mcpp::compiler()`、`mcpp::package_name()`;现在这些是参数。一个取输入而不读环境的
生成器,在构建程序里和在普通程序里是同一份代码 —— 而 action 的命令必须是程序。
实测:此前这个包**不能**普通构建,`mcpp: failed to read compiled module`。
2. **`mcpp-embed` 由 mcpp 从本包源码造**,走 `tools = ["mcpp-embed"]`,与规则同一条
依赖边。不单独发包:`docs/05` §2.14 写明代价 —— 「工具的版本**就是**依赖的版本,
所以 protoc 与它的 runtime 不匹配这件事不可表达」。生成器与它写下的声明是一个决定。
3. **`src/declare.cppm` 是第二个单元**,承载构建程序侧(`mcpp::action` / `dep_bin` /
按存储分派)。它需要 mcpp 2026.9.8.1:此前一个包的 host module 按**路径**排序,
`rules/` 在 `src/` 之前,import 它会失败。
两条 action 而不是一条,这是关于输入的事实而非限制:接口是条目表的函数,实现体还是
载荷的函数。合成一条会让改一个载荷去重写接口、重建每个 import 它的 BMI。
(`mcpp::action::provides` 也是 action 级的,一条 action 三个 output 一个 provides
会让扫描器报 "already provided by" —— 实测。)
只有 `object` 需要这一切。`header` 的字节经由载荷编译器已经写出的数据头(本就是 action
的 output)到达产物,`sidecar` 根本不进编译 —— 都检查过而不是假定。所以默认路径不造
任何工具,不选 object 存储的消费者一个字都不用多写。
其它
----
`options::store` 改变了形状,所以这是破坏性发布:0.3.x -> 0.4.0。
`storage::object` 要求 `item::payload_path`,现在它拒绝 —— 这条约束一直写在注释里而
没有任何东西执行它。今天只有 spirv 能走到这条路且只有它设这个字段,那是巧合不是保证。
`rules/spirv.cppm` 里 `options::module_name` 的注释说默认值取自「包目录」,而它调用的
函数开头就写着「THE PACKAGE'S NAME. NOT ITS DIRECTORY'S.」。
CI 四条步骤,判据都落在产物的字节上,不落退出码也不落日志行;第四条断言「没要工具就
用 object 存储」被拒绝且点名了要加的键 —— 消息是契约。
* CI: the all-rules denominator counts members, not internal features
这一步比较包里每一个 `[features.<x>]` 与夹具激活的那一列,好让第七个成员不能被悄悄漏出
「every rule module compiles for this host」。`[features.surface]` 让它红了,而且红得对:
那是一个夹具没点名的新 feature。
但它不是成员。它承载 surface 的构建程序那一半,每个成员都 implies 它,消费者永远不写它。
把它加进夹具是错的修法 —— 夹具那一列的含义是「消费者能激活的成员」,为了让检查变绿而往里
填东西,只会让检查的含义变少。
所以分母减去「被别的 feature implies 的」。这条规则从 manifest 推出来而不是列在这里,正是
这个检查原本就有的性质:第七个**成员**仍会被抓到,因为没有东西 implies 它。
两条腿都验过:修正后两列一致;临时加一个新成员,它出现在分母里并会让这一步失败。
* CI: the denominator fix belonged in both jobs, not the first one found
「every rule module compiles for this host」这一步在 `consumers` 与
`rules-cross-platform` 里各有一份。上一次只改了第一份 —— 而那个 job 本来就是绿的;
红的是另一个。
**做这次替换的脚本在锚点「存在」时就放行了。存在不等于唯一,而这个差别就是缺陷本身:**
它验证了自己将要改的东西在,没验证它是唯一的一处。现在按**出现次数**断言,并在写回前
再数一次两个 job 是否都拿到了修好的形状。
顺带把 `<(...)` 换成临时文件:这一步也在 windows-2022 的 Git Bash 上跑,进程替换在那里
是模拟的、不可依赖 —— 而「一个在三台宿主上行为不同的检查」正是这个 job 存在的理由所要
抓的东西,它自己不能引入一个。
---------
Co-authored-by: sunrisepeak <speakshen@163.com>1 parent 74c8e40 commit 9249553
14 files changed
Lines changed: 1008 additions & 116 deletions
File tree
- .github/workflows
- rules
- src
- tests/spirv-object-storage
- tools
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
472 | 472 | | |
473 | 473 | | |
474 | 474 | | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
475 | 626 | | |
476 | 627 | | |
477 | 628 | | |
| |||
601 | 752 | | |
602 | 753 | | |
603 | 754 | | |
604 | | - | |
605 | | - | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
606 | 774 | | |
607 | 775 | | |
608 | 776 | | |
| |||
898 | 1066 | | |
899 | 1067 | | |
900 | 1068 | | |
901 | | - | |
902 | | - | |
| 1069 | + | |
| 1070 | + | |
| 1071 | + | |
| 1072 | + | |
| 1073 | + | |
| 1074 | + | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
903 | 1086 | | |
904 | 1087 | | |
905 | 1088 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
127 | 127 | | |
128 | 128 | | |
129 | 129 | | |
130 | | - | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
131 | 146 | | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
136 | 152 | | |
137 | 153 | | |
138 | 154 | | |
| |||
224 | 240 | | |
225 | 241 | | |
226 | 242 | | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
227 | 278 | | |
228 | 279 | | |
229 | 280 | | |
| |||
0 commit comments