Skip to content

fix: compile Node 24+ prebuilds as C++20 - #28

Merged
erunion merged 4 commits into
masterfrom
erunion/fix-node24-prebuild-cxx20-a34f
Oct 9, 2026
Merged

erunion merged 4 commits into
masterfrom
erunion/fix-node24-prebuild-cxx20-a34f

Conversation

@erunion

@erunion erunion commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Problem

The 3.3.0 publish run failed while building the macOS Node 24 prebuild (job). Fail-fast cancelled the rest of the build matrix, so the package was never published.

prebuildify compiles each release binary with node-gyp --target=<that Node version>. For this run the Node 24 target was 24.18.0. utils/defaultCxxStandard.js treated every --target as an Electron version, and Electron versions below 32 are compiled as C++17. The Node 24 build was therefore forced onto -std=c++17.

That flag replaces the gnu++20 default that ships in Node's headers (common.gypi). Node 24.18's V8 headers require C++20, so compilation stopped in src/async_worker.cc:

v8config.h:13:2: error: "C++20 or later required."

The same override is in the Linux cflags_cc path. Those jobs were cancelled when the macOS build failed, before they reached the C++ sources. The musl jobs are a separate matrix and succeeded: their Docker build sets CXXFLAGS, which makes binding.gyp skip its own -std flag and leave Node's gnu++20 in place.

The test workflow on the same commit passed. npm install there does not pass --target, so the standard comes from the running process's Node ABI. Node 24 is ABI 137, which already selects C++20.

Fix

--target is now read as a Node version. Electron and NW.js are detected on their own, from npm_config_runtime (electron or node-webkit) or from built_with_electron in the downloaded headers.

  • Node 23 and newer, including the Node 24 and 26 prebuilds, compile as C++20.
  • Node 18 through 22 stay on C++17.
  • Electron 21 through 31 stays on C++17. Electron 32 and newer stays on C++20.

Tests

utils/defaultCxxStandard.test.js runs at the start of npm test (from test/index.js, before Mocha) and at the start of npm run mocha. CI uses npm test, so these checks run on every test job. They do not load the native addon.

Node fixtures drop an inherited npm_config_runtime. An Electron or NW.js install environment no longer makes the Node 23 and 24 checks select C++17 and stop the suite. Tests that pass npm_config_runtime explicitly still cover the Electron mapping.

Workflow names

.github/workflows/publish.yml is named Publish and .github/workflows/tests.yml is named Tests, so the Actions list no longer shows those workflows by filename. Prebuilds stay inside Publish; they are not a separate workflow that runs on every pull request.

Open in Web Open in Cursor 

prebuildify passes the Node version as --target. That path treated every
target as Electron and selected C++17 below version 32, overriding Node's
gnu++20 default. Node 24.18 headers require C++20, so the macOS publish
prebuild failed and cancelled the rest of the release matrix.

Co-authored-by: Jon Ursenbach <erunion@users.noreply.github.com>
@erunion

erunion commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

@greptileai

@erunion erunion added the bug Something isn't working label Oct 8, 2026
@greptile-apps

greptile-apps Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[High impact] This PR appears safe to merge; the workflow name additions introduce no identified failures.

Reviews (4) · Last reviewed commit: "ci: name the Publish and Tests workflows" · Reviewed by Greptile

Comment thread utils/defaultCxxStandard.test.js
CI launches Mocha through test/index.js and never called node --test, so
the new compiler-standard checks did not run. Run them before Mocha from
both npm test and npm run mocha.

Co-authored-by: Jon Ursenbach <erunion@users.noreply.github.com>
Comment thread test/index.js
npm test forwards npm_config_runtime into the new checks. An electron or
node-webkit value made the Node 23 fixture select C++17 and stopped the
suite before Mocha. Node fixtures now drop that inherited setting unless
a test sets it on purpose.

Co-authored-by: Jon Ursenbach <erunion@users.noreply.github.com>
@erunion
erunion added this pull request to stack #30 October 8, 2026 22:43
The Actions list was showing these workflows by filename. Give them the
same display names added on the closed prebuild-split branch.

Co-authored-by: Jon Ursenbach <erunion@users.noreply.github.com>
@erunion
erunion marked this pull request as ready for review October 8, 2026 23:31
@erunion
erunion merged commit 2f3986e into master Oct 9, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants