Repository navigation
[dotnet/release/10.0] Enable Control Flow Guard for Windows binaries - #367
Merged
akoeplinger merged 1 commit intoJul 27, 2026
Merged
Conversation
Backport the upstream Control Flow Guard plumbing and enable it, so node.exe
and the other Windows binaries are built with /guard:cf.
This branch is on Node 18.17, which predates upstream's CFG support, so unlike
dotnet/main the plumbing has to be added first:
* vcbuild.bat gains a "cfg" argument that maps to --control-flow-guard
* configure.py gains --control-flow-guard, setting the control_flow_guard
GYP variable
* common.gypi applies /guard:cf to both VCCLCompilerTool and VCLinkerTool
when that variable is "true", defaulting to "false"
node.proj then passes "cfg" to vcbuild.bat to turn it on.
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
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.
Ports #366 to
dotnet/release/10.0, enabling Control Flow Guard (/guard:cf) for the Windows binaries.Unlike
dotnet/main, this could not be a one-line change. This branch is on Node 18.17, which predates upstream's CFG support -- there is nocfgargument invcbuild.bat, no--control-flow-guardoption inconfigure.py, and nocontrol_flow_guardhandling incommon.gypi. So the upstream plumbing is backported first, mirroring upstream exactly:vcbuild.bat-- newcfgargument, mapped toconfigure --control-flow-guardconfigure.py-- new--control-flow-guardoption setting thecontrol_flow_guardGYP variablecommon.gypi-- applies/guard:cfto bothVCCLCompilerToolandVCLinkerToolundercontrol_flow_guard=="true", defaulting to'false'node.proj-- passescfgtovcbuild.batto opt inThe
common.gypichange is gated on the new variable which defaults to off, so it is a no-op for anyone not passing the flag. Thenode.projchange is inside theReallyBuildWindowstarget, so the Linux and macOS legs are unaffected.Verification
A full build was not run, but the entire plumbing chain was verified locally by running
configureand the GYP generation step:INFO: configure completed successfullyconfig.gypicontains'control_flow_guard': 'true'/guard:cfnodeproject the flag lands on both tools, in both the Debug and Release configurations:VCCLCompilerTool:AdditionalOptions="/Zc:__cplusplus -std:c++17 /guard:cf"VCLinkerTool:AdditionalOptions="/guard:cf /WHOLEARCHIVE:libnode.lib ..."configure.pyandcommon.gypiwere also syntax-checked (py_compile/ast.literal_eval).Compilation and linking themselves are left to CI. Once it produces binaries this can be confirmed with
dumpbin /loadconfig node.exe: look for a non-zeroGuard CF function count. Note theCF instrumentedbit alone is not sufficient evidence -- it appears even without the flag (contributed by the CRT) with an empty function table.