Commit 37eaf6f
committed
fix(build): stage BMIs through mcpp instead of an in-place shell copy (#311)
Windows-only symptom, three overlapping defects.
1. `rule cp_bmi` overwrote the destination IN PLACE
(`powershell Copy-Item -Force` / `cp -f`). mcpp writes the staged std BMI
path into compile_commands.json so clangd can resolve `import std;`, clangd
memory-maps that very file, and Windows refuses to replace a file with an
open user-mapped section — error 1224, reported as a bare "build failed".
Staging now runs through `mcpp stage` (new internal subcommand, same shape
as `mcpp dyndep`): skip when the destination is already equivalent, else
temp-file + rename, else in-place, with retries, and a failure message that
names the file and the likely holder. Never downgraded to a warning — a
stale BMI turns into a confusing "module 'std' not found" or a silently
mismatched link.
The rule is shared with Windows runtime-DLL deployment, which had the same
hazard against a program still running from a previous `mcpp run`.
2. `default_cache_root()` was a private copy of the home resolution, unchanged
since v0.0.1: no %USERPROFILE% branch, no self-contained detection. On
Windows PowerShell (no $HOME) the std BMI cache landed in the *current
working directory* as `.mcpp-bmi/` while dep BMIs went to
%USERPROFILE%\.mcpp\bmi — two roots for one cache, the second cwd-dependent,
which is what made a re-stage a routine event. New leaf module `mcpp.home`
is now the single resolver (config, stdmod, prepare's git cache and two more
copies in doctor all route through it).
3. The staging rule carried no `restat`, so any re-stage recompiled everything
that imports std even when the bytes were identical. Adding `restat = 1` on
top of the no-write path fixes that — measured: touching the cache-side BMI
now runs the stage edge alone, and the next build is "no work to do".
Note for the record: aligning the destination's mtime with the source
defeats restat and re-triggers the cascade, so a skipped stage touches no
timestamps at all.
Also: `FAILED: <target>` survives the ninja output filter (normalized to
`failed: <target>`) — dropping it is why the report couldn't tell a staging
failure from a compile error; `mcpp new` ignores `.mcpp/`; `mcpp doctor` points
at a leftover `.mcpp-bmi/`.
Design + plan: .agents/docs/2026-07-30-issue311-*.md
Tests: unit test_home (4), test_build_stage (10), test_ninja_backend (+4),
e2e 170 (no-cascade + cache root), e2e 171 (held destination, PowerShell
MemoryMappedFile on Windows — reproduces #311 without needing clangd).1 parent c765e83 commit 37eaf6f
18 files changed
Lines changed: 1575 additions & 109 deletions
File tree
- .agents/docs
- src
- build
- cli
- scaffold
- toolchain
- tests
- e2e
- unit
Lines changed: 361 additions & 0 deletions
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 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 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 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 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
190 | 190 | | |
191 | 191 | | |
192 | 192 | | |
193 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
194 | 198 | | |
195 | 199 | | |
196 | 200 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
288 | 288 | | |
289 | 289 | | |
290 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
291 | 295 | | |
292 | 296 | | |
293 | 297 | | |
| |||
331 | 335 | | |
332 | 336 | | |
333 | 337 | | |
334 | | - | |
335 | 338 | | |
336 | 339 | | |
337 | 340 | | |
338 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
339 | 358 | | |
340 | 359 | | |
341 | 360 | | |
| |||
400 | 419 | | |
401 | 420 | | |
402 | 421 | | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
403 | 425 | | |
404 | | - | |
405 | 426 | | |
406 | 427 | | |
407 | 428 | | |
408 | 429 | | |
409 | 430 | | |
410 | 431 | | |
411 | | - | |
412 | | - | |
413 | | - | |
414 | | - | |
415 | | - | |
416 | | - | |
417 | | - | |
418 | | - | |
419 | | - | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
420 | 444 | | |
421 | 445 | | |
422 | 446 | | |
| |||
790 | 814 | | |
791 | 815 | | |
792 | 816 | | |
793 | | - | |
| 817 | + | |
794 | 818 | | |
795 | | - | |
| 819 | + | |
796 | 820 | | |
797 | 821 | | |
798 | 822 | | |
| |||
804 | 828 | | |
805 | 829 | | |
806 | 830 | | |
807 | | - | |
| 831 | + | |
808 | 832 | | |
809 | 833 | | |
810 | | - | |
| 834 | + | |
811 | 835 | | |
812 | 836 | | |
813 | 837 | | |
| |||
1074 | 1098 | | |
1075 | 1099 | | |
1076 | 1100 | | |
1077 | | - | |
| 1101 | + | |
| 1102 | + | |
| 1103 | + | |
| 1104 | + | |
1078 | 1105 | | |
1079 | 1106 | | |
1080 | | - | |
| 1107 | + | |
1081 | 1108 | | |
1082 | 1109 | | |
1083 | 1110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
2823 | 2824 | | |
2824 | 2825 | | |
2825 | 2826 | | |
2826 | | - | |
2827 | | - | |
2828 | | - | |
2829 | | - | |
2830 | | - | |
2831 | | - | |
2832 | | - | |
| 2827 | + | |
2833 | 2828 | | |
2834 | 2829 | | |
2835 | 2830 | | |
| |||
0 commit comments