Commit 3c53c18
committed
fix(pack): the build machine does not travel, and packages ship stripped (#460)
A `kind = "shared"` package kept the DT_RUNPATH the link gave it — a list of
absolute paths into the BUILD MACHINE's store — so on any other machine the
consumer died with `libstdc++.so.6: cannot open shared object file`.
The issue's suggested fix does not work, and that is the whole design. Measured
on a real package with the build machine's store made unreachable:
stale absolute DT_RUNPATH consumer's DT_RPATH inherited? no rc=127
no tag at all YES ok
DT_RUNPATH = $ORIGIN no rc=127
DT_RUNPATH = "" (what --set-rpath '' writes) no rc=127
An object carrying ANY DT_RUNPATH makes the loader skip the whole inherited
DT_RPATH chain for that object's dependencies. So the criterion is "there is no
tag", and removing it is the right answer rather than a compromise: the
consumer's own DT_RPATH is the same closure — payload, package dir, SubOS farm —
resolved on the machine that will actually run it.
New `mcpp.pack.relocate` edits PT_DYNAMIC in process (delete the slot, shift the
tail, pad with DT_NULL; same file length) instead of shelling out to patchelf.
Library packs are cross-target by construction and have no host gate, so
`sandbox_patchelf` resolves to nothing on a macOS or Windows host — and the
application packer's shape for that is `if (!patchelf.empty())`, i.e. silently
do nothing. ELF32 and big-endian are covered by unit tests; no CI job produces
one and `--target` can. Mach-O LC_RPATH is read and reported, not yet rewritten.
Also refuses `mcpp pack <program>` for a Mach-O artifact. That path resolves the
dependency closure with `LD_TRACE_LOADED_OBJECTS=1 '<binary>'`, which is glibc's
variable — dyld ignores it and RUNS THE PROGRAM, then parses its stdout as a
dependency table and reports `Packed`. Keyed on the format, not the host, like
the `_WIN32` refusal beside it. Never noticed because the e2e harness grants the
`pack` capability only where elf+patchelf exist, i.e. Linux.
And the third silent one: the SONAME alias' copy fallback read `leg.artifact`
rather than the staged file. Byte-identical while nothing modified the staging
copy; with relocate and strip in place it would ship an unprocessed library
under the exact name the loader asks for, on the machines where create_symlink
fails.
Packaging now builds release and strips what it ships. Only the profile FALLBACK
changes (dev -> release); `--profile` and `[build] default-profile` still win, so
pack never produces flags `mcpp build` would not. Stripping follows dh_strip's
division, and the archive row is measured: `--strip-all` on a `.a` removes the
archive symbol index and the consumer's link fails with `archive has no index;
run ranlib to add one`, while `--strip-debug` links and runs. Shared libraries
get `--strip-unneeded` (keeps .dynsym), executables `--strip-all`, and bundled
third-party .so files nothing at all. New `--profile` / `--no-strip` /
`--debug-symbols DIR` and `[pack] strip` / `[pack] debug_symbols`;
`--debug-symbols` separates rather than discards and adds a .gnu_debuglink.
e2e 264 puts the defect BACK with patchelf and requires the consumer to FAIL
before restoring it: 251 consumed the package on the machine that built it, so
it was green throughout this bug's life. The guard reads the DYNAMIC ENTRIES,
never the file's bytes — the dead string stays in .dynstr (patchelf leaves the
identical residue; .dynstr is tail-merged and deleting it cannot be shown safe),
and a byte-pattern check would also have flipped to green for an unrelated
reason the day stripping landed.1 parent 282bc41 commit 3c53c18
28 files changed
Lines changed: 3209 additions & 132 deletions
File tree
- .agents/docs
- docs
- zh
- src
- build
- cli
- manifest
- pack
- toolchain
- tests
- e2e
- unit
Lines changed: 605 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 416 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 | + | |
| 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 | + | |
6 | 94 | | |
7 | 95 | | |
8 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
136 | 139 | | |
137 | 140 | | |
138 | 141 | | |
139 | 142 | | |
140 | 143 | | |
141 | 144 | | |
142 | 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 | + | |
143 | 187 | | |
144 | 188 | | |
145 | 189 | | |
| |||
310 | 354 | | |
311 | 355 | | |
312 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
313 | 372 | | |
314 | 373 | | |
315 | 374 | | |
316 | 375 | | |
317 | 376 | | |
318 | 377 | | |
319 | 378 | | |
320 | | - | |
321 | | - | |
322 | | - | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
323 | 384 | | |
324 | 385 | | |
325 | 386 | | |
| |||
339 | 400 | | |
340 | 401 | | |
341 | 402 | | |
342 | | - | |
343 | | - | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
344 | 409 | | |
345 | 410 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
259 | 319 | | |
260 | 320 | | |
261 | 321 | | |
262 | 322 | | |
263 | 323 | | |
264 | | - | |
| 324 | + | |
265 | 325 | | |
266 | | - | |
| 326 | + | |
267 | 327 | | |
268 | 328 | | |
| 329 | + | |
269 | 330 | | |
270 | 331 | | |
271 | 332 | | |
| |||
415 | 476 | | |
416 | 477 | | |
417 | 478 | | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
418 | 482 | | |
419 | 483 | | |
420 | 484 | | |
| |||
0 commit comments