Repository navigation
Enable Control Flow Guard for Windows binaries - #366
Merged
Merged
Conversation
Pass the "cfg" argument to vcbuild.bat so node.exe and the other Windows binaries are built with Control Flow Guard (/guard:cf) enabled. vcbuild.bat translates this to configure's --control-flow-guard, which sets the control_flow_guard GYP variable. common.gypi already applies /guard:cf to both VCCLCompilerTool and VCLinkerTool when that variable is "true", so both the compiler and linker flags are covered. Co-authored-by: Copilot <[email protected]> Copilot-Session: af43f907-f9b9-4b6a-8617-c0036ac8320c
akoeplinger
enabled auto-merge (squash)
July 27, 2026 15:41
lewing
approved these changes
Jul 27, 2026
akoeplinger
disabled auto-merge
July 27, 2026 22:03
akoeplinger
enabled auto-merge (squash)
July 27, 2026 22:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Passes the
cfgargument tovcbuild.batinnode.projsonode.exeand the other Windows binaries are built with Control Flow Guard (/guard:cf).Upstream Node already has the full plumbing for this, so no changes to upstream files are needed:
vcbuild.batmapscfg->configure --control-flow-guardconfigure.pysets thecontrol_flow_guardGYP variable from itcommon.gypiapplies/guard:cfundercontrol_flow_guard=="true"to bothVCCLCompilerToolandVCLinkerToolso the compiler and linker flags are both covered. The variable defaults to
'false'incommon.gypi, which is why it needs to be opted into explicitly.The change is inside the
ReallyBuildWindowstarget, so the Linux and macOS legs are unaffected. Applies to both the Windows x64 and arm64 legs.Verification
Not built locally -- deferring to CI, which builds all legs.
Once CI produces binaries this can be confirmed with
dumpbin /loadconfig node.exe: look for a non-zeroGuard CF function count. Note that theCF instrumentedbit alone is not sufficient evidence -- it shows up even without the flag (contributed by the CRT) with an empty function table. On the equivalent change in dotnet/cpython, a control build without the flag gaveGuard Flags 00000100with a CF function count of 0, versus10017500and thousands of entries with it.