Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bootstrap: unify snapshot builder and embedder entry points #48242

Closed
wants to merge 2 commits into from

Conversation

joyeecheung
Copy link
Member

  • Run the embedder entry point directly through runEmbedderEntryPoint(), instead of going through another JS -> C++ trip through the function returned by getEmbedderEntryFunction()
  • For --build-snapshot, read the snapshot script code directly in C++ and pass it to SnapshotBuilder::Generate(), this makes the entry point more explicit instead of hiding it in JS land, and also makes it possible to invoke SnapshotBuilder::Generate() internally to create a custom snapshot.
  • Previously we used process.execPath for the embedder to create __filename and __dirname in the snapshot builder script while using process.argv[1] for --build-snapshot (where it's always set) which results in inconsistencies. We now require the embedder to also set args[1] when creating the Environment if they intend to run snapshot scripts with a context that contains __filename and __dirname, which would be derived from args[1]. If they prefer not to include build-time paths in the snapshot, we now provide node::GetAnonymousMainPath() as an alternative.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/startup

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels May 29, 2023
- Run the embedder entry point directly through runEmbedderEntryPoint(),
  instead of going through another JS -> C++ trip through the
  function returned by getEmbedderEntryFunction()
- For --build-snapshot, read the snapshot script code directly in C++
  and pass it to SnapshotBuilder::Generate(), this makes the entry point
  more explicit instead of hiding it in JS land, and also makes it
  possible to invoke SnapshotBuilder::Generate() internally to create
  a custom snapshot.
- Previously we used process.execPath for the embedder to create
  __filename and __dirname in the snapshot builder script while using
  process.argv[1] for --build-snapshot (where it's always set) which
  results in inconsistencies. We now require the embedder to also set
  args[1] when creating the Environment if they intend to run snapshot
  scripts with a context that contains __filename and __dirname, which
  would be derived from args[1]. If they prefer not to include build-time
  paths in the snapshot, we now provide node::GetAnonymousMainPath()
  as an alternative.
@nodejs-github-bot
Copy link
Collaborator

src/node_snapshotable.cc Outdated Show resolved Hide resolved
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@joyeecheung joyeecheung added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Jun 8, 2023
@nodejs-github-bot nodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Jun 8, 2023
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/48242
✔  Done loading data for nodejs/node/pull/48242
----------------------------------- PR info ------------------------------------
Title      bootstrap: unify snapshot builder and embedder entry points (#48242)
Author     Joyee Cheung  (@joyeecheung)
Branch     joyeecheung:unify-snapshot-entry -> nodejs:main
Labels     c++, lib / src, needs-ci, commit-queue-squash
Commits    2
 - bootstrap: unify snapshot builder and embedder entry points
 - fixup! bootstrap: unify snapshot builder and embedder entry points
Committers 1
 - Joyee Cheung 
PR-URL: https:/nodejs/node/pull/48242
Reviewed-By: Anna Henningsen 
Reviewed-By: James M Snell 
------------------------------ Generated metadata ------------------------------
PR-URL: https:/nodejs/node/pull/48242
Reviewed-By: Anna Henningsen 
Reviewed-By: James M Snell 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Mon, 29 May 2023 14:25:58 GMT
   ✔  Approvals: 2
   ✔  - Anna Henningsen (@addaleax): https:/nodejs/node/pull/48242#pullrequestreview-1450806984
   ✔  - James M Snell (@jasnell) (TSC): https:/nodejs/node/pull/48242#pullrequestreview-1459753722
   ✘  Last GitHub CI failed
   ℹ  Last Full PR CI on 2023-06-07T13:38:18Z: https://ci.nodejs.org/job/node-test-pull-request/52142/
- Querying data for job/node-test-pull-request/52142/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https:/nodejs/node/actions/runs/5209251625

joyeecheung added a commit that referenced this pull request Jun 10, 2023
- Run the embedder entry point directly through
  runEmbedderEntryPoint(), instead of going through another
  JS -> C++ trip through the function returned by
  getEmbedderEntryFunction()
- For --build-snapshot, read the snapshot script code directly in C++
  and pass it to SnapshotBuilder::Generate(), this makes the entry point
  more explicit instead of hiding it in JS land, and also makes it
  possible to invoke SnapshotBuilder::Generate() internally to create
  a custom snapshot.
- Previously we used process.execPath for the embedder to create
  __filename and __dirname in the snapshot builder script while using
  process.argv[1] for --build-snapshot (where it's always set) which
  results in inconsistencies. We now require the embedder to also set
  args[1] when creating the Environment if they intend to run snapshot
  scripts with a context that contains __filename and __dirname, which
  would be derived from args[1]. If they prefer not to include
  build-time paths in the snapshot, we now provide
  node::GetAnonymousMainPath() as an alternative.

PR-URL: #48242
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@joyeecheung
Copy link
Member Author

Landed in 718f62b with commit messages fixed to <= 72

RafaelGSS pushed a commit that referenced this pull request Jul 3, 2023
- Run the embedder entry point directly through
  runEmbedderEntryPoint(), instead of going through another
  JS -> C++ trip through the function returned by
  getEmbedderEntryFunction()
- For --build-snapshot, read the snapshot script code directly in C++
  and pass it to SnapshotBuilder::Generate(), this makes the entry point
  more explicit instead of hiding it in JS land, and also makes it
  possible to invoke SnapshotBuilder::Generate() internally to create
  a custom snapshot.
- Previously we used process.execPath for the embedder to create
  __filename and __dirname in the snapshot builder script while using
  process.argv[1] for --build-snapshot (where it's always set) which
  results in inconsistencies. We now require the embedder to also set
  args[1] when creating the Environment if they intend to run snapshot
  scripts with a context that contains __filename and __dirname, which
  would be derived from args[1]. If they prefer not to include
  build-time paths in the snapshot, we now provide
  node::GetAnonymousMainPath() as an alternative.

PR-URL: #48242
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@RafaelGSS RafaelGSS mentioned this pull request Jul 3, 2023
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
- Run the embedder entry point directly through
  runEmbedderEntryPoint(), instead of going through another
  JS -> C++ trip through the function returned by
  getEmbedderEntryFunction()
- For --build-snapshot, read the snapshot script code directly in C++
  and pass it to SnapshotBuilder::Generate(), this makes the entry point
  more explicit instead of hiding it in JS land, and also makes it
  possible to invoke SnapshotBuilder::Generate() internally to create
  a custom snapshot.
- Previously we used process.execPath for the embedder to create
  __filename and __dirname in the snapshot builder script while using
  process.argv[1] for --build-snapshot (where it's always set) which
  results in inconsistencies. We now require the embedder to also set
  args[1] when creating the Environment if they intend to run snapshot
  scripts with a context that contains __filename and __dirname, which
  would be derived from args[1]. If they prefer not to include
  build-time paths in the snapshot, we now provide
  node::GetAnonymousMainPath() as an alternative.

PR-URL: nodejs#48242
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
- Run the embedder entry point directly through
  runEmbedderEntryPoint(), instead of going through another
  JS -> C++ trip through the function returned by
  getEmbedderEntryFunction()
- For --build-snapshot, read the snapshot script code directly in C++
  and pass it to SnapshotBuilder::Generate(), this makes the entry point
  more explicit instead of hiding it in JS land, and also makes it
  possible to invoke SnapshotBuilder::Generate() internally to create
  a custom snapshot.
- Previously we used process.execPath for the embedder to create
  __filename and __dirname in the snapshot builder script while using
  process.argv[1] for --build-snapshot (where it's always set) which
  results in inconsistencies. We now require the embedder to also set
  args[1] when creating the Environment if they intend to run snapshot
  scripts with a context that contains __filename and __dirname, which
  would be derived from args[1]. If they prefer not to include
  build-time paths in the snapshot, we now provide
  node::GetAnonymousMainPath() as an alternative.

PR-URL: nodejs#48242
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: James M Snell <[email protected]>
@ruyadorno
Copy link
Member

hi @joyeecheung this commit is not landing cleanly on v18.x-staging and will need manual backport in case we want to land this in v18.

@ruyadorno ruyadorno added the backport-requested-v18.x PRs awaiting manual backport to the v18.x-staging branch. label Aug 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-requested-v18.x PRs awaiting manual backport to the v18.x-staging branch. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-failed An error occurred while landing this pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants