Skip to content

build: keep PGO settings out of addon builds - #67638

Open
vmoroz wants to merge 1 commit into
nodejs:mainfrom
vmoroz:PR/fix-addon-pgo
Open

vmoroz wants to merge 1 commit into
nodejs:mainfrom
vmoroz:PR/fix-addon-pgo

Conversation

@vmoroz

@vmoroz vmoroz commented Nov 20, 2026

Copy link
Copy Markdown
Member

Node.js 26.13 Windows releases are built with PGO (profile-guided optimization). common.gypi adds the PGO compiler and linker flags to every target. node-gyp builds addons with the same common.gypi and the same settings that Node.js was built with, so on Windows every addon gets these flags too, even though they are meant only for building Node.js itself.

We hit this in the node-addon-api CI on Windows. MSVC does not know -fprofile-use, so every addon build prints warnings. Worse, the flag points to $(SolutionDir)node.profdata without quotes. When the addon path has a space, the flag is split in two and the build fails:

error C1083: Cannot open source file: 'addon\build\node.profdata'

node-addon-api worked around this by turning PGO off in its CI (nodejs/node-addon-api#1763), but other addons in such paths still fail to build.

This change:

  • adds the PGO flags only when building Node.js itself (when configuring_node is set), the same way the Linux PIE flags work;
  • leaves the PGO flags for Node.js builds unchanged.

Because node-gyp takes common.gypi from the Node.js headers, the fix works with any node-gyp version once it is in a release.

Tested on Windows with Node.js 26.13.1: an addon in a folder with a space fails to build with the current common.gypi, and builds and loads with this change. Also compared the generated build settings for Linux, macOS, and Windows: Node.js builds get the same flags as before, and addons get no PGO flags. The full test suite was not run.

AI-assisted work. All changes reviewed by a human.

Refs: nodejs/node-addon-api#1763

Gate PGO generation and use flags on configuring_node so native addons
do not inherit Node.js-specific profiling settings from process.config.
The inherited Windows profile-use option is unquoted and breaks addon
builds when their paths contain spaces.

Preserve Node.js PGO flags and the Windows host-toolset exclusion.
Expand configuring_node early for the Windows target condition.

Refs: nodejs/node-addon-api#1763
Signed-off-by: Vladimir Morozov <vmorozov@microsoft.com>
Assisted-by: AI coding assistant
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/gyp

@nodejs-github-bot nodejs-github-bot added build Issues and PRs related to Node.js builds or CI infrastructure. needs-ci PRs that need a full CI run. labels Nov 20, 2026
@legendecas legendecas added the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 20, 2026
@github-actions github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. Only starts once the PR has an approving review. label Nov 20, 2026
@nodejs-github-bot

nodejs-github-bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

@legendecas legendecas added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label Nov 21, 2026

@gurgunday gurgunday left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jasnell jasnell added the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 22, 2026
@nodejs-github-bot nodejs-github-bot added commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. and removed commit-queue PRs queued for automated landing through the Commit Queue. labels Nov 22, 2026
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Commit Queue failed

   ✖  1 GitHub CI job(s) cancelled:
   ✖    - aarch64-darwin: with shared libraries / build: CANCELLED (https://github.com/nodejs/node/actions/runs/44688155601/job/136329546425)

The pull request was removed from the Commit Queue and labeled commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. . After resolving the failure, remove that label and add commit-queue PRs queued for automated landing through the Commit Queue. to retry.

Full Commit Queue output
�[36m⠋�[39m Loading data for nodejs/node/pull/67638
�[36m⠋�[39m Loading data for nodejs/node/pull/67638
�[36m⠋�[39m Getting collaborator contacts from README of nodejs/node
�[36m⠋�[39m Getting PR from nodejs/node/pull/67638
�[36m⠋�[39m Getting reviews from nodejs/node/pull/67638
�[36m⠋�[39m Getting comments from nodejs/node/pull/67638
�[36m⠋�[39m Getting commits from nodejs/node/pull/67638
✔  Done loading data for nodejs/node/pull/67638
----------------------------------- PR info ------------------------------------
Title      build: keep PGO settings out of addon builds (#67638)
Author     Vladimir Morozov <vmorozov@microsoft.com> (@vmoroz)
Branch     vmoroz:PR/fix-addon-pgo -> nodejs:main
Labels     build, author ready, needs-ci, commit-queue
Commits    1
 - build: keep PGO settings out of addon builds
Committers 1
 - Vladimir Morozov <vmorozov@microsoft.com>
PR-URL: https://github.com/nodejs/node/pull/67638
Refs: https://github.com/nodejs/node-addon-api/pull/1763
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/67638
Refs: https://github.com/nodejs/node-addon-api/pull/1763
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
--------------------------------------------------------------------------------
   ℹ  This PR was created on Fri, 20 Nov 2026 06:29:24 GMT
   ✔  Approvals: 3
   ✔  - Chengzhong Wu (@legendecas) (TSC): https://github.com/nodejs/node/pull/67638#pullrequestreview-5993765402
   ✔  - Luigi Pinca (@lpinca): https://github.com/nodejs/node/pull/67638#pullrequestreview-6007773967
   ✔  - Gürgün Dayıoğlu (@gurgunday): https://github.com/nodejs/node/pull/67638#pullrequestreview-6008051224
   ✖  1 GitHub CI job(s) cancelled:
   ✖    - aarch64-darwin: with shared libraries / build: CANCELLED (https://github.com/nodejs/node/actions/runs/44688155601/job/136329546425)
   ℹ  Last Full PR CI on 2026-11-20T14:08:12Z: https://ci.nodejs.org/job/node-test-pull-request/79353/
�[36m⠙�[39m Querying data for job/node-test-pull-request/79353/
�[36m⠙�[39m Querying data for job/node-test-pull-request/79353/
�[36m⠙�[39m Querying API for job/node-test-pull-request/79353/
✔  Build data downloaded
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu

View workflow run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. build Issues and PRs related to Node.js builds or CI infrastructure. commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants