Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 76ef7ac

Browse filesBrowse files
bzoztargos
authored andcommitted
build, win: make LTCG optional
Disables Link Time Code Generation by default. Adds ‘ltcg’ vcbuild option to enable it. LTCG will be used by default by release and CI builds. PR-URL: #21186 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 206e5bf commit 76ef7ac
Copy full SHA for 76ef7ac

File tree

Expand file treeCollapse file tree

3 files changed

+47
-18
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+47
-18
lines changed
Open diff view settings
Collapse file

‎common.gypi‎

Copy file name to clipboardExpand all lines: common.gypi
+32-16Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
'node_use_v8_platform%': 'true',
1717
'node_use_bundled_v8%': 'true',
1818
'node_module_version%': '',
19+
'node_with_ltcg%': '',
1920

2021
'node_tag%': '',
2122
'uv_library%': 'static_library',
@@ -192,36 +193,51 @@
192193
'RuntimeLibrary': 0 # MultiThreaded (/MT)
193194
}
194195
}
196+
}],
197+
['node_with_ltcg=="true"', {
198+
'msvs_settings': {
199+
'VCCLCompilerTool': {
200+
'WholeProgramOptimization': 'true' # /GL, whole program optimization, needed for LTCG
201+
},
202+
'VCLibrarianTool': {
203+
'AdditionalOptions': [
204+
'/LTCG:INCREMENTAL', # link time code generation
205+
]
206+
},
207+
'VCLinkerTool': {
208+
'OptimizeReferences': 2, # /OPT:REF
209+
'EnableCOMDATFolding': 2, # /OPT:ICF
210+
'LinkIncremental': 1, # disable incremental linking
211+
'AdditionalOptions': [
212+
'/LTCG:INCREMENTAL', # incremental link-time code generation
213+
]
214+
}
215+
}
216+
}, {
217+
'msvs_settings': {
218+
'VCCLCompilerTool': {
219+
'WholeProgramOptimization': 'false'
220+
},
221+
'VCLinkerTool': {
222+
'LinkIncremental': 2 # enable incremental linking
223+
}
224+
}
195225
}]
196226
],
197227
'msvs_settings': {
198228
'VCCLCompilerTool': {
199229
'Optimization': 3, # /Ox, full optimization
200230
'FavorSizeOrSpeed': 1, # /Ot, favor speed over size
201231
'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible
202-
'WholeProgramOptimization': 'true', # /GL, whole program optimization, needed for LTCG
203232
'OmitFramePointers': 'true',
204233
'EnableFunctionLevelLinking': 'true',
205234
'EnableIntrinsicFunctions': 'true',
206235
'RuntimeTypeInfo': 'false',
207236
'AdditionalOptions': [
208237
'/MP', # compile across multiple CPUs
209238
],
210-
},
211-
'VCLibrarianTool': {
212-
'AdditionalOptions': [
213-
'/LTCG', # link time code generation
214-
],
215-
},
216-
'VCLinkerTool': {
217-
'OptimizeReferences': 2, # /OPT:REF
218-
'EnableCOMDATFolding': 2, # /OPT:ICF
219-
'LinkIncremental': 1, # disable incremental linking
220-
'AdditionalOptions': [
221-
'/LTCG:INCREMENTAL', # incremental link-time code generation
222-
],
223-
},
224-
},
239+
}
240+
}
225241
}
226242
},
227243
# Forcibly disable -Werror. We support a wide range of compilers, it's
Collapse file

‎configure‎

Copy file name to clipboardExpand all lines: configure
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,11 @@ intl_optgroup.add_option('--with-icu-source',
425425
dest='with_icu_source',
426426
help='Intl mode: optional local path to icu/ dir, or path/URL of icu source archive.')
427427

428+
parser.add_option('--with-ltcg',
429+
action='store_true',
430+
dest='with_ltcg',
431+
help='Use Link Time Code Generation. This feature is only available on Windows.')
432+
428433
intl_optgroup.add_option('--download',
429434
action='store',
430435
dest='download_list',
@@ -953,6 +958,10 @@ def configure_node(o):
953958
else:
954959
o['variables']['node_use_perfctr'] = 'false'
955960

961+
o['variables']['node_with_ltcg'] = b(options.with_ltcg)
962+
if flavor != 'win' and options.with_ltcg:
963+
raise Exception('Link Time Code Generation is only supported on Windows.')
964+
956965
if options.tag:
957966
o['variables']['node_tag'] = '-' + options.tag
958967
else:
Collapse file

‎vcbuild.bat‎

Copy file name to clipboardExpand all lines: vcbuild.bat
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ cd %~dp0
1515
set config=Release
1616
set target=Build
1717
set target_arch=x64
18+
set ltcg=
1819
set target_env=
1920
set noprojgen=
2021
set projgen=
@@ -61,7 +62,7 @@ set doc=
6162
:next-arg
6263
if "%1"=="" goto args-done
6364
if /i "%1"=="debug" set config=Debug&goto arg-ok
64-
if /i "%1"=="release" set config=Release&goto arg-ok
65+
if /i "%1"=="release" set config=Release&set ltcg=1&goto arg-ok
6566
if /i "%1"=="clean" set target=Clean&goto arg-ok
6667
if /i "%1"=="ia32" set target_arch=x86&goto arg-ok
6768
if /i "%1"=="x86" set target_arch=x86&goto arg-ok
@@ -75,6 +76,7 @@ if /i "%1"=="sign" set sign=1&goto arg-ok
7576
if /i "%1"=="nosnapshot" set nosnapshot=1&goto arg-ok
7677
if /i "%1"=="noetw" set noetw=1&goto arg-ok
7778
if /i "%1"=="noperfctr" set noperfctr=1&goto arg-ok
79+
if /i "%1"=="ltcg" set ltcg=1&goto arg-ok
7880
if /i "%1"=="licensertf" set licensertf=1&goto arg-ok
7981
if /i "%1"=="test" set test_args=%test_args% -J %common_test_suites%&set lint_cpp=1&set lint_js=1&set lint_md=1&goto arg-ok
8082
if /i "%1"=="test-ci" set test_args=%test_args% %test_ci_args% -p tap --logfile test.tap %common_test_suites%&set cctest_args=%cctest_args% --gtest_output=tap:cctest.tap&goto arg-ok
@@ -150,6 +152,7 @@ if defined build_release (
150152
set download_arg="--download=all"
151153
set i18n_arg=small-icu
152154
set projgen=1
155+
set ltcg=1
153156
)
154157

155158
:: assign path to node_exe
@@ -162,6 +165,7 @@ if "%config%"=="Debug" set configure_flags=%configure_flags% --debug
162165
if defined nosnapshot set configure_flags=%configure_flags% --without-snapshot
163166
if defined noetw set configure_flags=%configure_flags% --without-etw& set noetw_msi_arg=/p:NoETW=1
164167
if defined noperfctr set configure_flags=%configure_flags% --without-perfctr& set noperfctr_msi_arg=/p:NoPerfCtr=1
168+
if defined ltcg set configure_flags=%configure_flags% --with-ltcg
165169
if defined release_urlbase set configure_flags=%configure_flags% --release-urlbase=%release_urlbase%
166170
if defined download_arg set configure_flags=%configure_flags% %download_arg%
167171
if defined enable_vtune_arg set configure_flags=%configure_flags% --enable-vtune-profiling
@@ -656,7 +660,7 @@ del .used_configure_flags
656660
goto exit
657661

658662
:help
659-
echo vcbuild.bat [debug/release] [msi] [doc] [test/test-ci/test-all/test-addons/test-addons-napi/test-internet/test-pummel/test-simple/test-message/test-gc/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-async-hooks/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [noetw] [noperfctr] [licensetf] [sign] [ia32/x86/x64] [vs2017] [download-all] [enable-vtune] [lint/lint-ci/lint-js/lint-js-ci/lint-md] [lint-md-build] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [no-cctest] [openssl-no-asm]
663+
echo vcbuild.bat [debug/release] [msi] [doc] [test/test-ci/test-all/test-addons/test-addons-napi/test-internet/test-pummel/test-simple/test-message/test-gc/test-tick-processor/test-known-issues/test-node-inspect/test-check-deopts/test-npm/test-async-hooks/test-v8/test-v8-intl/test-v8-benchmarks/test-v8-all] [ignore-flaky] [static/dll] [noprojgen] [projgen] [small-icu/full-icu/without-intl] [nobuild] [nosnapshot] [noetw] [noperfctr] [ltcg] [licensetf] [sign] [ia32/x86/x64] [vs2017] [download-all] [enable-vtune] [lint/lint-ci/lint-js/lint-js-ci/lint-md] [lint-md-build] [package] [build-release] [upload] [no-NODE-OPTIONS] [link-module path-to-module] [debug-http2] [debug-nghttp2] [clean] [no-cctest] [openssl-no-asm]
660664
echo Examples:
661665
echo vcbuild.bat : builds release build
662666
echo vcbuild.bat debug : builds debug build

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.