Skip to content

Commit 20a917c

Browse files
committedFeb 14, 2019
build: move optimizing link directives to node.exe target
* ASCIIbetize directives * Merge duplicate directives from 'conditions' PR-URL: #25931 Reviewed-By: João Reis <[email protected]>
1 parent 582c0d5 commit 20a917c

File tree

2 files changed

+74
-92
lines changed

2 files changed

+74
-92
lines changed
 

‎common.gypi

+34-90
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,17 @@
137137
'Debug': {
138138
'variables': {
139139
'v8_enable_handle_zapping': 1,
140+
'conditions': [
141+
['node_shared != "true"', {
142+
'MSVC_runtimeType': 1, # MultiThreadedDebug (/MTd)
143+
}, {
144+
'MSVC_runtimeType': 3, # MultiThreadedDebugDLL (/MDd)
145+
}],
146+
],
140147
},
141148
'defines': [ 'DEBUG', '_DEBUG', 'V8_ENABLE_CHECKS' ],
142149
'cflags': [ '-g', '-O0' ],
143150
'conditions': [
144-
['target_arch=="x64"', {
145-
'msvs_configuration_platform': 'x64',
146-
}],
147151
['OS=="aix"', {
148152
'cflags': [ '-gxcoff' ],
149153
'ldflags': [ '-Wl,-bbigtoc' ],
@@ -152,31 +156,14 @@
152156
'cflags': [ '-fPIE' ],
153157
'ldflags': [ '-fPIE', '-pie' ]
154158
}],
155-
['node_shared=="true"', {
156-
'msvs_settings': {
157-
'VCCLCompilerTool': {
158-
'RuntimeLibrary': 3, # MultiThreadedDebugDLL (/MDd)
159-
}
160-
}
161-
}],
162-
['node_shared=="false"', {
163-
'msvs_settings': {
164-
'VCCLCompilerTool': {
165-
'RuntimeLibrary': 1 # MultiThreadedDebug (/MTd)
166-
}
167-
}
168-
}]
169159
],
170160
'msvs_settings': {
171161
'VCCLCompilerTool': {
172-
'Optimization': 0, # /Od, no optimization
162+
'BasicRuntimeChecks': 3, # /RTC1
173163
'MinimalRebuild': 'false',
174164
'OmitFramePointers': 'false',
175-
'BasicRuntimeChecks': 3, # /RTC1
176-
'MultiProcessorCompilation': 'true',
177-
'AdditionalOptions': [
178-
'/bigobj', # prevent error C1128 in VS2015
179-
],
165+
'Optimization': 0, # /Od, no optimization
166+
'RuntimeLibrary': '<(MSVC_runtimeType)',
180167
},
181168
'VCLinkerTool': {
182169
'LinkIncremental': 2, # enable incremental linking
@@ -189,12 +176,19 @@
189176
'Release': {
190177
'variables': {
191178
'v8_enable_handle_zapping': 0,
179+
'pgo_generate': ' -fprofile-generate ',
180+
'pgo_use': ' -fprofile-use -fprofile-correction ',
181+
'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ',
182+
'conditions': [
183+
['node_shared != "true"', {
184+
'MSVC_runtimeType': 0 # MultiThreaded (/MT)
185+
}, {
186+
'MSVC_runtimeType': 2 # MultiThreadedDLL (/MD)
187+
}],
188+
],
192189
},
193190
'cflags': [ '-O3' ],
194191
'conditions': [
195-
['target_arch=="x64"', {
196-
'msvs_configuration_platform': 'x64',
197-
}],
198192
['OS=="solaris"', {
199193
# pull in V8's postmortem metadata
200194
'ldflags': [ '-Wl,-z,allextract' ]
@@ -203,11 +197,6 @@
203197
'cflags': [ '-fno-omit-frame-pointer' ],
204198
}],
205199
['OS=="linux"', {
206-
'variables': {
207-
'pgo_generate': ' -fprofile-generate ',
208-
'pgo_use': ' -fprofile-use -fprofile-correction ',
209-
'lto': ' -flto=4 -fuse-linker-plugin -ffat-lto-objects ',
210-
},
211200
'conditions': [
212201
['enable_pgo_generate=="true"', {
213202
'cflags': ['<(pgo_generate)'],
@@ -227,62 +216,17 @@
227216
'cflags': [ '-fPIE' ],
228217
'ldflags': [ '-fPIE', '-pie' ]
229218
}],
230-
['node_shared=="true"', {
231-
'msvs_settings': {
232-
'VCCLCompilerTool': {
233-
'RuntimeLibrary': 2 # MultiThreadedDLL (/MD)
234-
}
235-
}
236-
}],
237-
['node_shared=="false"', {
238-
'msvs_settings': {
239-
'VCCLCompilerTool': {
240-
'RuntimeLibrary': 0 # MultiThreaded (/MT)
241-
}
242-
}
243-
}],
244-
['node_with_ltcg=="true"', {
245-
'msvs_settings': {
246-
'VCCLCompilerTool': {
247-
'WholeProgramOptimization': 'true' # /GL, whole program optimization, needed for LTCG
248-
},
249-
'VCLibrarianTool': {
250-
'AdditionalOptions': [
251-
'/LTCG:INCREMENTAL', # link time code generation
252-
]
253-
},
254-
'VCLinkerTool': {
255-
'OptimizeReferences': 2, # /OPT:REF
256-
'EnableCOMDATFolding': 2, # /OPT:ICF
257-
'LinkIncremental': 1, # disable incremental linking
258-
'AdditionalOptions': [
259-
'/LTCG:INCREMENTAL', # incremental link-time code generation
260-
]
261-
}
262-
}
263-
}, {
264-
'msvs_settings': {
265-
'VCCLCompilerTool': {
266-
'WholeProgramOptimization': 'false'
267-
},
268-
'VCLinkerTool': {
269-
'LinkIncremental': 2 # enable incremental linking
270-
}
271-
}
272-
}]
273219
],
274220
'msvs_settings': {
275221
'VCCLCompilerTool': {
276-
'Optimization': 3, # /Ox, full optimization
277-
'FavorSizeOrSpeed': 1, # /Ot, favor speed over size
278-
'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible
279-
'OmitFramePointers': 'true',
280222
'EnableFunctionLevelLinking': 'true',
281223
'EnableIntrinsicFunctions': 'true',
224+
'FavorSizeOrSpeed': 1, # /Ot, favor speed over size
225+
'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible
226+
'OmitFramePointers': 'true',
227+
'Optimization': 3, # /Ox, full optimization
228+
'RuntimeLibrary': '<(MSVC_runtimeType)',
282229
'RuntimeTypeInfo': 'false',
283-
'MultiProcessorCompilation': 'true',
284-
'AdditionalOptions': [
285-
],
286230
}
287231
}
288232
}
@@ -301,13 +245,14 @@
301245
'cflags!': ['-Werror'],
302246
'msvs_settings': {
303247
'VCCLCompilerTool': {
304-
'StringPooling': 'true', # pool string literals
305-
'DebugInformationFormat': 1, # /Z7 embed info in .obj files
306-
'WarningLevel': 3,
307248
'BufferSecurityCheck': 'true',
249+
'DebugInformationFormat': 1, # /Z7 embed info in .obj files
308250
'ExceptionHandling': 0, # /EHsc
251+
'MultiProcessorCompilation': 'true',
252+
'StringPooling': 'true', # pool string literals
309253
'SuppressStartupBanner': 'true',
310254
'WarnAsError': 'false',
255+
'WarningLevel': 3, # /W3
311256
},
312257
'VCLinkerTool': {
313258
'conditions': [
@@ -329,11 +274,6 @@
329274
}],
330275
],
331276
'GenerateDebugInformation': 'true',
332-
'GenerateMapFile': 'true', # /MAP
333-
'MapExports': 'true', # /MAPINFO:EXPORTS
334-
'RandomizedBaseAddress': 2, # enable ASLR
335-
'DataExecutionPrevention': 2, # enable DEP
336-
'AllowIsolation': 'true',
337277
'SuppressStartupBanner': 'true',
338278
},
339279
},
@@ -351,7 +291,12 @@
351291
# - "C4244: conversion from 'type1' to 'type2', possible loss of data"
352292
# Ususaly safe. Disable for `dep`, enable for `src`
353293
'msvs_disabled_warnings': [4351, 4355, 4800, 4251, 4275, 4244, 4267],
294+
'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin
295+
354296
'conditions': [
297+
[ 'target_arch=="x64"', {
298+
'msvs_configuration_platform': 'x64',
299+
}],
355300
['asan == 1 and OS != "mac"', {
356301
'cflags+': [
357302
'-fno-omit-frame-pointer',
@@ -380,7 +325,6 @@
380325
],
381326
}],
382327
['OS == "win"', {
383-
'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin
384328
'defines': [
385329
'WIN32',
386330
# we don't really want VC++ warning us about

‎node.gyp

+40-2
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,16 @@
266266
],
267267
'dependencies': [ 'deps/histogram/histogram.gyp:histogram' ],
268268

269+
'msvs_settings': {
270+
'VCLinkerTool': {
271+
'GenerateMapFile': 'true', # /MAP
272+
'MapExports': 'true', # /MAPINFO:EXPORTS
273+
'RandomizedBaseAddress': 2, # enable ASLR
274+
'DataExecutionPrevention': 2, # enable DEP
275+
'AllowIsolation': 'true',
276+
},
277+
},
278+
269279
# - "C4244: conversion from 'type1' to 'type2', possible loss of data"
270280
# Ususaly safe. Disable for `dep`, enable for `src`
271281
'msvs_disabled_warnings!': [4244],
@@ -281,8 +291,7 @@
281291
}, {
282292
'dependencies': [ '<(node_lib_target_name)' ],
283293
}],
284-
[ 'node_intermediate_lib_type=="static_library" and '
285-
'node_shared=="false"', {
294+
[ 'node_intermediate_lib_type=="static_library" and node_shared=="false"', {
286295
'xcode_settings': {
287296
'OTHER_LDFLAGS': [
288297
'-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)'
@@ -348,6 +357,35 @@
348357
}],
349358
],
350359
}],
360+
['node_with_ltcg=="true"', {
361+
'msvs_settings': {
362+
'VCCLCompilerTool': {
363+
'WholeProgramOptimization': 'true' # /GL, whole program optimization, needed for LTCG
364+
},
365+
'VCLibrarianTool': {
366+
'AdditionalOptions': [
367+
'/LTCG:INCREMENTAL', # link time code generation
368+
],
369+
},
370+
'VCLinkerTool': {
371+
'OptimizeReferences': 2, # /OPT:REF
372+
'EnableCOMDATFolding': 2, # /OPT:ICF
373+
'LinkIncremental': 1, # disable incremental linking
374+
'AdditionalOptions': [
375+
'/LTCG:INCREMENTAL', # incremental link-time code generation
376+
],
377+
}
378+
}
379+
}, {
380+
'msvs_settings': {
381+
'VCCLCompilerTool': {
382+
'WholeProgramOptimization': 'false'
383+
},
384+
'VCLinkerTool': {
385+
'LinkIncremental': 2 # enable incremental linking
386+
},
387+
},
388+
}]
351389
],
352390
}, # node_core_target_name
353391
{

0 commit comments

Comments
 (0)
Please sign in to comment.