Commit 702c1c8
authored
* fix(cache): a package's object layout must not depend on the consumer (#344)
A dependency's objects live in the global build cache under a key that
deliberately excludes the consuming project — that exclusion is what makes an
entry shareable across projects. Their LAYOUT inside the entry did not exclude
it: the address was the consumer's build-dir path with `obj/` stripped, and
build-dir object paths are decided by #233's basename disambiguation, whose
census spans the WHOLE build directory. So `compat.zlib`'s compress.o was
obj/compress.o alone
obj/compat_zlib/zlib-1.3.2/compress.o beside compat.bzip2
under one key. Whichever project ran second asked the entry for a path the first
had never written, and ninja rejected the graph before running any command:
ninja: error: '<cache>/…/obj/compress.o', needed by 'obj/compress.o',
missing and no known rule to make it
one line after the CLI printed `Cached compat.zlib v1.3.2 (15 units)`.
32 of 47 mcpp-index workspace members across three platforms.
#233 (compile edges collided), #240 (link inputs didn't follow the rename) and
this are three products of one machine: a layout decided by a global census.
The fix is not a fourth place to keep in sync — it is to take dependencies out
of the census.
* plan.cppm now emits TWO addresses from ONE derivation: `object` (build dir)
and `packageObjectRel` (inside a cache entry, a pure function of the owning
package). Dependency objects go to `obj/<pkg-slug>/<mirrored relDir>/<name>.o`
unconditionally — cross-package collisions are structurally impossible, so
dependencies need no census at all. The root project, never cached, keeps its
flat `obj/<name>.o` and now censuses only its own sources.
* prepare.cppm's `object_cache_path` — the second derivation — is deleted,
along with its `filename()` fallback, which silently mapped distinct sources
onto one entry address.
* `is_cached(key)` validated the entry's OWN file list while the caller went on
to read addresses it computed itself; the two answers were never compared.
It is now `probe_cached(key, requested)`. Any divergence is a MISS, never a
build failure, and is reported — a systematic recurrence would otherwise show
up only as "the cache never hits", with no signal at all.
* Cacheability is judged by where the payload is on disk, not by the
`sourceKind` label. Multi-version mangling re-anchors a consumer package at
`target/.mangled/…` and rewrites its sources while keeping that label; it
stays out of the cache today only because axis F happens to differ.
Containment is judged LEXICALLY (`path_is_under_any`): stores built out of
symlinks are ordinary, and canonicalizing drops every such package out of the
cache silently.
* All-or-nothing per package: one unaddressable unit takes the whole package
out, rather than leaving it half staged.
* kCacheEpoch 1 → 2 (the artifact layout changed) and `cache verify` now
reports obj addresses that escape their entry.
Tests: unit ObjectAddress pins "a dependency's addresses are immune to the rest
of the graph"; e2e 184 runs both orderings and asserts ZERO compile edges for
the reused dependency — asserting only "it builds" would be satisfied by a
build that quietly degraded every hit to a miss. e2e 123's assertion is
generalized from "the consumer's main must be renamed" (the shape of #240's
first fix) to "every link input is produced by some edge" (the property).
* fix(build): link through a response file on every platform, not just Windows
Discovered by running the real mcpp-index workspace against the #344 branch:
`opencv-module`, `opencv-module-dnn` and `opencv-module-unifont` all died with
ninja: fatal: posix_spawn: Argument list too long
naming no edge, no file and no cause. #344 lengthened dependency object paths
(they now carry a per-package directory) and that was enough to cross a ceiling
nothing was watching.
The rule emitter said rsp was needed only where commands spawn through
CreateProcess, and that "POSIX driver-style keeps the inline form: ARG_MAX is
ample". Both halves are wrong. ninja runs `sh -c "<whole command>"` on POSIX, so
the command is a SINGLE argv entry and the limit is MAX_ARG_STRLEN — 32 pages,
128 KiB — not the 2 MiB ARG_MAX anyone would think to check. And it was never
ample: measured on opencv-module, the inline link line was already 56 840 bytes
before this branch, 43% of the ceiling. With #344's paths it reached 161 687.
So: rsp always, every platform, every dialect. clang/gcc drivers, link.exe, GNU
ar and llvm-ar all accept @rspfile, so this is one rule shape instead of two,
and the response file next to the output reads better than a 160 KB command line
anyway. A build system may not have a maximum project size that it discovers by
crashing, and "how long is this command" must not be something anyone carries in
their head when choosing an object path.
The unit test asserted the falsified premise for POSIX ("must NOT use rspfile");
it now asserts the invariant on every platform, plus that `$in` appears exactly
once per rule — as rspfile_content, never inlined into the command.
Note this was invisible to all 18 CI jobs: none of them builds an
opencv-class package. CI has no large-link coverage at all.
1 parent 5d71824 commit 702c1c8
15 files changed
Lines changed: 1540 additions & 142 deletions
File tree
- .agents/docs
- src
- bmi_cache
- build
- toolchain
- tests
- e2e
- unit
Lines changed: 448 additions & 0 deletions
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
6 | 35 | | |
7 | 36 | | |
8 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
9 | 18 | | |
10 | 19 | | |
11 | 20 | | |
| |||
75 | 84 | | |
76 | 85 | | |
77 | 86 | | |
78 | | - | |
79 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
80 | 109 | | |
81 | | - | |
82 | | - | |
| 110 | + | |
| 111 | + | |
83 | 112 | | |
84 | 113 | | |
85 | | - | |
86 | | - | |
87 | | - | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
88 | 144 | | |
89 | 145 | | |
90 | 146 | | |
| |||
137 | 193 | | |
138 | 194 | | |
139 | 195 | | |
| 196 | + | |
| 197 | + | |
140 | 198 | | |
141 | 199 | | |
142 | 200 | | |
143 | 201 | | |
144 | 202 | | |
145 | | - | |
| 203 | + | |
| 204 | + | |
146 | 205 | | |
147 | 206 | | |
148 | 207 | | |
| |||
199 | 258 | | |
200 | 259 | | |
201 | 260 | | |
202 | | - | |
| 261 | + | |
| 262 | + | |
203 | 263 | | |
204 | | - | |
205 | | - | |
206 | | - | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
207 | 267 | | |
208 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
209 | 276 | | |
210 | | - | |
211 | 277 | | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
217 | 294 | | |
218 | 295 | | |
219 | 296 | | |
| |||
250 | 327 | | |
251 | 328 | | |
252 | 329 | | |
253 | | - | |
254 | 330 | | |
255 | 331 | | |
256 | 332 | | |
| |||
263 | 339 | | |
264 | 340 | | |
265 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
266 | 347 | | |
267 | | - | |
268 | | - | |
| 348 | + | |
| 349 | + | |
269 | 350 | | |
270 | 351 | | |
271 | 352 | | |
272 | | - | |
| 353 | + | |
273 | 354 | | |
274 | | - | |
| 355 | + | |
275 | 356 | | |
276 | 357 | | |
277 | 358 | | |
| |||
289 | 370 | | |
290 | 371 | | |
291 | 372 | | |
292 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
293 | 380 | | |
294 | 381 | | |
295 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
181 | 190 | | |
182 | | - | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
183 | 198 | | |
184 | 199 | | |
185 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
68 | 74 | | |
69 | 75 | | |
70 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
749 | 749 | | |
750 | 750 | | |
751 | 751 | | |
752 | | - | |
753 | | - | |
754 | | - | |
755 | | - | |
756 | | - | |
757 | | - | |
758 | | - | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
759 | 777 | | |
760 | | - | |
| 778 | + | |
761 | 779 | | |
762 | 780 | | |
763 | 781 | | |
| |||
0 commit comments