Skip to content

Commit 07f6da1

Browse files
win,build: add option to enable Control Flow Guard
1 parent f4fcf0e commit 07f6da1

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

common.gypi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
'clang%': 0,
2929
'error_on_warn%': 'false',
30+
'cfg%': 'false',
3031

3132
'openssl_product': '<(STATIC_LIB_PREFIX)openssl<(STATIC_LIB_SUFFIX)',
3233
'openssl_no_asm%': 0,
@@ -309,6 +310,11 @@
309310
'/Zm2000',
310311
],
311312
}],
313+
['cfg=="true"', {
314+
'AdditionalOptions': [
315+
'/guard:cf', # Control Flow Guard
316+
],
317+
}],
312318
],
313319
'BufferSecurityCheck': 'true',
314320
'DebugInformationFormat': 1, # /Z7 embed info in .obj files
@@ -335,6 +341,11 @@
335341
['target_arch=="arm64"', {
336342
'TargetMachine' : 0, # NotSet. MACHINE:ARM64 is inferred from the input files.
337343
}],
344+
['cfg=="true"', {
345+
'AdditionalOptions': [
346+
'/guard:cf', # Control Flow Guard
347+
],
348+
}],
338349
],
339350
'GenerateDebugInformation': 'true',
340351
'SuppressStartupBanner': 'true',

configure.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,12 @@
791791
default=None,
792792
help='do not install the bundled Corepack')
793793

794+
parser.add_argument('--cfg',
795+
action='store_true',
796+
dest='enable_cfg',
797+
default=None,
798+
help='enable Control Flow Guard (CFG)')
799+
794800
# Dummy option for backwards compatibility
795801
parser.add_argument('--without-report',
796802
action='store_true',
@@ -1394,6 +1400,7 @@ def configure_node(o):
13941400
o['variables']['node_prefix'] = options.prefix
13951401
o['variables']['node_install_npm'] = b(not options.without_npm)
13961402
o['variables']['node_install_corepack'] = b(not options.without_corepack)
1403+
o['variables']['cfg'] = b(options.enable_cfg)
13971404
o['variables']['node_use_amaro'] = b(not options.without_amaro)
13981405
o['variables']['debug_node'] = b(options.debug_node)
13991406
o['default_configuration'] = 'Debug' if options.debug else 'Release'

vcbuild.bat

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ set no_shared_roheap=
7171
set doc=
7272
set extra_msbuild_args=
7373
set compile_commands=
74+
set cfg=
7475
set exit_code=0
7576

7677
:next-arg
@@ -148,6 +149,7 @@ if /i "%1"=="no-shared-roheap" set no_shared_roheap=1&goto arg-ok
148149
if /i "%1"=="doc" set doc=1&goto arg-ok
149150
if /i "%1"=="binlog" set extra_msbuild_args=/binaryLogger:out\%config%\node.binlog&goto arg-ok
150151
if /i "%1"=="compile-commands" set compile_commands=1&goto arg-ok
152+
if /i "%1"=="cfg" set cfg=1&goto arg-ok
151153

152154
echo Error: invalid command line option `%1`.
153155
exit /b 1
@@ -207,6 +209,7 @@ if defined openssl_no_asm set configure_flags=%configure_flags% --openssl-no-a
207209
if defined no_shared_roheap set configure_flags=%configure_flags% --disable-shared-readonly-heap
208210
if defined DEBUG_HELPER set configure_flags=%configure_flags% --verbose
209211
if defined compile_commands set configure_flags=%configure_flags% -C
212+
if defined cfg set configure_flags=%configure_flags% --cfg
210213

211214
if "%target_arch%"=="x86" (
212215
echo "32-bit Windows builds are not supported anymore."

0 commit comments

Comments
 (0)