Delete node-gyp debris and strip addons when bottling - #23645
Conversation
|
Thanks for your pull request. This has been closed because it appears to be missing the pull request template, perhaps because this was written by an AI not a human. We require humans to read and fill in these templates. Please edit this pull request to fill in the current pull request template. This workflow will reopen this pull request automatically once the template is complete. Do not open a new pull request for this. |
There was a problem hiding this comment.
Pull request overview
This pull request improves bottle relocatability for npm-installed formulae by removing node-gyp intermediate build artifacts from bottled kegs and stripping debug information from compiled .node addons so embedded build paths don鈥檛 pin bottles.
Changes:
- Add
Keg#delete_node_gyp_debris!to remove node-gyp intermediateobj.targettrees and related.o,.d, and build-tree.afiles undernode_modules. - Add
Keg#strip_node_gyp_addons!to runstrip -Son.nodeaddons undernode_modules, replacing the addon only when stripping succeeds. - Invoke both new cleanup steps during
brew bottle, and add RSpec coverage for the new Keg behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| Library/Homebrew/keg.rb | Implements node-gyp debris deletion and .node addon stripping helpers on Keg. |
| Library/Homebrew/dev-cmd/bottle.rb | Runs the new keg cleanup steps as part of the bottling flow. |
| Library/Homebrew/test/keg_spec.rb | Adds tests validating debris cleanup and conditional addon replacement on strip success/failure. |
| Library/Homebrew/plans/relocatable-bottles.md | Removes the plan item now implemented by this PR. |
馃挕 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
e2c5c20 to
7af9c95
Compare
7af9c95 to
7ce623d
Compare
9f5e46e to
48524ba
Compare
050e7b3 to
e67986e
Compare
e67986e to
ce91bf9
Compare
- node-gyp compiles native addons inside the keg at install time and leaves `obj.target` trees, `*.o` objects, `*.d` dependency files and intermediate `*.a` archives behind under `node_modules`; they embed build paths that pin about 33 npm formulae's bottles and are never needed at run time (addons load the linked `.node` files, not the objects they were linked from). - `brew bottle` now deletes them alongside `*.pyc` files, scoped to `node_modules` trees (`*.a` further to node-gyp `build` trees) so legitimate shipped objects and archives are untouched. - The linked `.node` addons themselves embed keg build paths in their `N_OSO`/`N_SO` stab strings, so `brew bottle` also runs `strip -S -o` on them, replacing each addon only when `strip` succeeds. Verified on `hsd`'s published `leveldown.node`: 76 keg paths before, 0 after, with the signature still valid because Apple `strip` re-signs ad hoc, so no separate codesign step is needed. This change is part of [`plans/relocatable-bottles.md`](https://github.com/Homebrew/brew/blob/HEAD/Library/Homebrew/plans/relocatable-bottles.md)
ce91bf9 to
5f17060
Compare
leaves
obj.targettrees,*.oobjects,*.ddependency files andintermediate
*.aarchives behind undernode_modules; they embedbuild paths that pin about 33 npm formulae's bottles and are never
needed at run time (addons load the linked
.nodefiles, not theobjects they were linked from).
brew bottlenow deletes them alongside*.pycfiles, scoped tonode_modulestrees (*.afurther to node-gypbuildtrees) solegitimate shipped objects and archives are untouched.
.nodeaddons themselves embed keg build paths in theirN_OSO/N_SOstab strings, sobrew bottlealso runsstrip -S -oon them, replacing each addon only whenstripsucceeds. Verified on
hsd's publishedleveldown.node: 76 kegpaths before, 0 after, with the signature still valid because Apple
stripre-signs ad hoc, so no separate codesign step is needed.This change is part of
plans/relocatable-bottles.mdbrew benchmarkresults.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Fable 5 with local review and testing.