Skip to content

Commit c5f9f10

Browse files
build,win: change LTCG to thin LTO
1 parent 21eb097 commit c5f9f10

2 files changed

Lines changed: 27 additions & 32 deletions

File tree

configure.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@
919919
action='store_true',
920920
dest='with_ltcg',
921921
default=None,
922-
help='Use Link Time Code Generation. This feature is only available on Windows.')
922+
help='Use Thin LTO. This feature is only available on Windows.')
923923

924924
parser.add_argument('--write-snapshot-as-array-literals',
925925
action='store_true',
@@ -1929,11 +1929,6 @@ def configure_node(o):
19291929
'--enable-pgo-generate first, profile node, and then recompile '
19301930
'with --enable-pgo-use')
19311931

1932-
if flavor == 'win' and options.with_ltcg and (options.enable_pgo_generate or options.enable_pgo_use):
1933-
raise Exception(
1934-
'The --with-ltcg option cannot be used with --enable-pgo-generate or --enable-pgo-use. '
1935-
'PGO uses /LTCG:PGInstrument or /LTCG:PGOptimize while LTCG uses /LTCG:INCREMENTAL.')
1936-
19371932
o['variables']['enable_pgo_generate'] = b(options.enable_pgo_generate)
19381933
o['variables']['enable_pgo_use'] = b(options.enable_pgo_use)
19391934

node.gyp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -730,45 +730,34 @@
730730
'Ws2_32.lib',
731731
],
732732
}],
733-
# Whole-program optimization: either LTCG or PGO
734-
['node_with_ltcg=="true" or enable_pgo_generate=="true" or enable_pgo_use=="true"', {
733+
# Thin LTO for node_main.cc and linker (scoped to node_exe)
734+
['node_with_ltcg=="true"', {
735735
'msvs_settings': {
736736
'VCCLCompilerTool': {
737-
'WholeProgramOptimization': 'true' # /GL, whole program optimization, needed for both LTCG and PGO
737+
'AdditionalOptions': ['-flto=thin'],
738+
},
739+
'VCLinkerTool': {
740+
'AdditionalOptions': ['-flto=thin'],
738741
},
742+
},
743+
}],
744+
# Whole-program optimization: either Thin LTO or PGO
745+
['node_with_ltcg=="true" or enable_pgo_generate=="true" or enable_pgo_use=="true"', {
746+
'msvs_settings': {
739747
'VCLinkerTool': {
740748
'OptimizeReferences': 2, # /OPT:REF
741749
'EnableCOMDATFolding': 2, # /OPT:ICF
742750
'LinkIncremental': 1, # disable incremental linking
743-
}
751+
},
744752
},
745-
'conditions': [
746-
# LTCG-specific settings (only when PGO not active)
747-
['node_with_ltcg=="true" and enable_pgo_generate!="true" and enable_pgo_use!="true"', {
748-
'msvs_settings': {
749-
'VCLibrarianTool': {
750-
'AdditionalOptions': [
751-
'/LTCG:INCREMENTAL', # link time code generation
752-
],
753-
},
754-
'VCLinkerTool': {
755-
'AdditionalOptions': [
756-
'/LTCG:INCREMENTAL', # incremental link-time code generation
757-
],
758-
},
759-
},
760-
}],
761-
]
762753
}, {
754+
# No whole-program optimization
763755
'msvs_settings': {
764-
'VCCLCompilerTool': {
765-
'WholeProgramOptimization': 'false'
766-
},
767756
'VCLinkerTool': {
768-
'LinkIncremental': 2 # enable incremental linking
757+
'LinkIncremental': 2, # enable incremental linking
769758
},
770759
},
771-
}],
760+
}],
772761
['node_use_node_snapshot=="true"', {
773762
'dependencies': [
774763
'node_mksnapshot',
@@ -1171,6 +1160,17 @@
11711160
[ 'debug_nghttp2==1', {
11721161
'defines': [ 'NODE_DEBUG_NGHTTP2=1' ]
11731162
}],
1163+
# Thin LTO for node sources (scoped to libnode, not global)
1164+
['node_with_ltcg=="true"', {
1165+
'msvs_settings': {
1166+
'VCCLCompilerTool': {
1167+
'AdditionalOptions': ['-flto=thin'],
1168+
},
1169+
'VCLibrarianTool': {
1170+
'AdditionalOptions': ['-flto=thin'],
1171+
},
1172+
},
1173+
}],
11741174
],
11751175
'actions': [
11761176
{

0 commit comments

Comments
 (0)