Title: sea: generate single executable directly with Node.js binary by joyeecheung · Pull Request #61167 · nodejs/node · GitHub
Open Graph Title: sea: generate single executable directly with Node.js binary by joyeecheung · Pull Request #61167 · nodejs/node
X Title: sea: generate single executable directly with Node.js binary by joyeecheung · Pull Request #61167 · nodejs/node
Description: For reviewers: the bulk of the core changes are in the commit sea: add --build-sea to generate SEA directly with Node.js binary; The dependency updating tools and license updates are in deps: add tools and scripts to pull LIEF as a dependency. The rest are mostly refactoring and pulling LIEF using the script added in the previous commit. Instead of relying on a WASM build of postject to perform the injection, add LIEF as dependency and generate the SEA directly from core via a new CLI option --build-sea which takes the SEA config. Thi simplifies SEA generation for users and makes it easier to debug/maintain the SEA building process. For the time being, backward compatibility with the postject-based SEA building process will be maintained, until there's motivation to break it (e.g. for optimizations) The new process is simplified to as follows - no more knowledge about the blob location in the binary needed: $ echo 'console.log("Hello")' > hello.js $ echo '{ "main": "hello.js", "output": "sea" }' > sea-config.json $ node --build-sea sea-config.json $ ./sea Hello This idea was discussed a while back (brought up by @marco-ippolito) at the collaboration summit to improve the UX of SEA building process, which currently requires users to use an external tool (i.e. postject) to perform the injection, and know about the layout of the target binary. For most users, the details are probably not very useful. Moving the injection process into core simplifies the process. Bringing it into core may also make it easier to implement some of the ideas brought up back in 2022 that would require close coordination with core to implement (e.g. trimming ICU data post-build to reduce binary size). I've been helping out with the SEA feature from time to time and as I see it, apart from UX improvement, I found the current WASM-based tool somewhat difficult to debug when I was trying to fix #61483. Also, the WASM build is significantly slower than a native build, which adds friction to the debugging process. $ time out/Release/node test/sea/test-single-executable-application.js Copied /Users/joyee/projects/node/out/Release/node to /Users/joyee/projects/node/test/.tmp.0/sea Injected /Users/joyee/projects/node/test/.tmp.0/sea-prep.blob into /Users/joyee/projects/node/test/.tmp.0/sea Signed /Users/joyee/projects/node/test/.tmp.0/sea User time: 5.12s System time: 0.38s CPU time: 90% Total time: 6.06s $ time out/Release/node test/sea/test-build-sea.js Signed /Users/joyee/projects/node/test/.tmp.0/sea User time: 1.79s System time: 0.34s CPU time: 74% Total time: 2.85s At the summit @RaisinTen mentioned one concern about the potential binary size increase. With this POC the binary size is only increased by 5-6 MB on macOS/Linux, and ~3MB on Windows, which seems acceptable (as a reference, this is smaller than the decrease we recently got from compiling V8 with default hidden visibility #56290 (comment)) # Linux $ ls -lah ./node_without_lief ./out/Release/node -rwxr-xr-x 1 developer developer 122M Dec 24 16:50 ./node_without_lief -rwxr-xr-x 1 developer developer 128M Dec 24 16:51 ./out/Release/node # macOS $ ls -lah ./node_without_lief ./out/Release/node -rwxr-xr-x@ 1 joyee staff 125M Dec 24 17:48 ./node_without_lief -rwxr-xr-x@ 1 joyee staff 130M Dec 24 17:48 ./out/Release/node # Windows $ ls -lah out\Release\node.exe .\node_main.exe -rwxr-xr-x 1 joyee 197121 87M Jan 1 19:29 '.\node_main.exe' -rwxr-xr-x 1 joyee 197121 90M Jan 1 19:42 'out\Release\node.exe' In addition, I think the LIEF library may also be useful for other purposes e.g. demangling the names in the V8 prof profiles, which is a current bottleneck when trying to analyze logs via --prof-process by calling out to nm and c++filt. Commits test: use fixture directories for sea tests Instead of copying and writing files on the fly for SEA tests, put the fixtures into a directory and copy them into tmpdir for testing. This allows easier reproduction and debugging when they do fail - we can just copy the entire fixture directory and test directly from there. deps: add tools and scripts to pull LIEF as a dependency deps: add LIEF as a dependency sea: split sea binary manipulation code Split the sea binary manipulation code to a seperate file so that adding more low-level binary manipulation code doesn't clobber the higher-level code. sea: add --build-sea to generate SEA directly with Node.js binary Instead of relying on a WASM build of postject to perform the injection, add LIEF as dependency and generate the SEA directly from core via a new CLI option --build-sea which takes the SEA config. This simplifies SEA generation for users and makes it easier to debug/maintain the SEA building process. test: migrate to --build-sea in existing SEA tests Only leave a smoking test for the postject-based workflow in test-single-executable-application.js
Open Graph Description: For reviewers: the bulk of the core changes are in the commit sea: add --build-sea to generate SEA directly with Node.js binary; The dependency updating tools and license updates are in deps: add t...
X Description: For reviewers: the bulk of the core changes are in the commit sea: add --build-sea to generate SEA directly with Node.js binary; The dependency updating tools and license updates are in deps: add t...
Opengraph URL: https://github.com/nodejs/node/pull/61167
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:ed8f18ed-fd4e-ffcb-dfc8-3ab6c12b180c |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | 8B14:2C345B:1B7084:244846:6A4C245A |
| html-safe-nonce | 9c18a5a7300a65fd82a1cbd3f2b0fa6ebcb3cb493e644a7479bc077b3e808b06 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjE0OjJDMzQ1QjoxQjcwODQ6MjQ0ODQ2OjZBNEMyNDVBIiwidmlzaXRvcl9pZCI6IjY4MzA2NTA2MjQyMzQ0OTcxMTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 0a6a12c62f92477af689b35bf176ff75b5a824437aec7ebc1b1a00d61a2c8e6f |
| hovercard-subject-tag | pull_request:3128991624 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/nodejs/node/pull/61167/files |
| twitter:image | https://avatars.githubusercontent.com/u/4299420?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/4299420?s=400&v=4 |
| og:image:alt | For reviewers: the bulk of the core changes are in the commit sea: add --build-sea to generate SEA directly with Node.js binary; The dependency updating tools and license updates are in deps: add t... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1b6b16d04026f131a36d57e3b01d0f4d26a51800edf48bf5ed0256e0ac905511 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/nodejs/node git https://github.com/nodejs/node.git |
| octolytics-dimension-user_id | 9950313 |
| octolytics-dimension-user_login | nodejs |
| octolytics-dimension-repository_id | 27193779 |
| octolytics-dimension-repository_nwo | nodejs/node |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 27193779 |
| octolytics-dimension-repository_network_root_nwo | nodejs/node |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9ee13484b32cf23e15fde191da4c9aa47d41201c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width