Skip to content

fix(build): add GCC 16 std::nullptr_t compatibility workaround#303

Open
Vikyek wants to merge 1 commit into
ilysenko:mainfrom
Vikyek:fix/gcc16-nullptr-compat
Open

fix(build): add GCC 16 std::nullptr_t compatibility workaround#303
Vikyek wants to merge 1 commit into
ilysenko:mainfrom
Vikyek:fix/gcc16-nullptr-compat

Conversation

@Vikyek
Copy link
Copy Markdown

@Vikyek Vikyek commented May 24, 2026

GCC 16.1.1 no longer exposes nullptr_t in the global namespace. Electron 42.1.0's V8 headers (v8-internal.h and others) use it unqualified, which causes compilation failures of native modules (like keytar, cpu-features, etc.) during the npm/electron-rebuild stage when building on systems with GCC 16+.

This change wraps the C++ compiler (CXX) to force-include a local header containing using std::nullptr_t; to pull nullptr_t back into the global namespace, but only if the C++ compiler actually requires this workaround. This ensures compatibility on newer toolchains without modifying Electron's headers directly.

GCC 16.1.1 no longer exposes nullptr_t in the global namespace.
Electron 42.1.0's V8 headers (v8-internal.h and others) use it unqualified,
which causes compilation failures of native modules (like keytar, cpu-features, etc.)
during the npm/electron-rebuild stage when building on systems with GCC 16+.

This change wraps the C++ compiler (CXX) to force-include a local header
containing 'using std::nullptr_t;' to pull nullptr_t back into the global
namespace, but only if the C++ compiler actually requires this workaround.
This ensures compatibility on newer toolchains without modifying Electron's
headers directly.
Copy link
Copy Markdown
Owner

@ilysenko ilysenko left a comment

Choose a reason for hiding this comment

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

Thanks for the GCC 16 compatibility fix. I found a blocker in the detection guard that should be fixed before this lands.

Finding:

  • scripts/lib/native-modules.sh:176: the probe checks nullptr_t without including <cstddef>. On the current GCC 15 toolchain this already fails (nullptr_t is defined in <cstddef>), while #include <cstddef> nullptr_t x = nullptr; passes. That means the wrapper is applied on toolchains that do not need the GCC 16 workaround, so this path always replaces CXX during native module rebuilds instead of only doing so when Electron/V8 headers need it. Please make the probe mirror the actual failure mode, e.g. include <cstddef> before checking unqualified nullptr_t, and add a smoke/regression test proving the wrapper is not installed on a compiler where the included probe succeeds.

Non-blocking follow-up: the wrapper path also assumes CXX is a single executable name/path, so it would not preserve common wrappers like CXX="ccache g++". That is existing-adjacent shell complexity, but if this code is touched it would be good to make the failure mode explicit.

Validation I ran:

  • bash -n scripts/lib/native-modules.sh tests/scripts_smoke.sh
  • git diff --check origin/main...HEAD
  • local compiler probe with and without #include <cstddef>

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants