Skip to content

Commit 14df42f

Browse files
committedApr 16, 2019
build: run mkcodecache as an action
* fix test-code-cache (for the common cases) * deprecate `configure --code-cache-path` PR-URL: #27161 Reviewed-By: Joyee Cheung <[email protected]>
1 parent 5ac0308 commit 14df42f

9 files changed

+96
-147
lines changed
 

‎Makefile

+3-11
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,17 @@ $(NODE_G_EXE): config.gypi out/Makefile
103103
$(MAKE) -C out BUILDTYPE=Debug V=$(V)
104104
if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Debug/$(NODE_EXE) $@; fi
105105

106-
CODE_CACHE_DIR ?= out/$(BUILDTYPE)/obj/gen
107-
CODE_CACHE_FILE ?= $(CODE_CACHE_DIR)/node_code_cache.cc
108-
109106
ifeq ($(BUILDTYPE),Debug)
110107
CONFIG_FLAGS += --debug
111108
endif
109+
112110
.PHONY: with-code-cache
113111
with-code-cache:
114-
@echo $(CONFIG_FLAGS)
115-
$(PYTHON) ./configure $(CONFIG_FLAGS)
116-
$(MAKE)
117-
mkdir -p $(CODE_CACHE_DIR)
118-
out/$(BUILDTYPE)/mkcodecache $(CODE_CACHE_FILE)
119-
$(PYTHON) ./configure --code-cache-path $(CODE_CACHE_FILE) $(CONFIG_FLAGS)
120-
$(MAKE)
112+
echo "'with-code-cache' target is a noop"
121113

122114
.PHONY: test-code-cache
123115
test-code-cache: with-code-cache
124-
$(PYTHON) tools/test.py $(PARALLEL_ARGS) --mode=$(BUILDTYPE_LOWER) code-cache
116+
echo "'test-code-cache' target is a noop"
125117

126118
out/Makefile: config.gypi common.gypi node.gyp \
127119
deps/uv/uv.gyp deps/http_parser/http_parser.gyp deps/zlib/zlib.gyp \

‎configure.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,9 @@
485485
parser.add_option('--code-cache-path',
486486
action='store',
487487
dest='code_cache_path',
488-
help='Use a file generated by tools/generate_code_cache.js to compile the'
489-
' code cache for builtin modules into the binary')
488+
help='optparse.SUPPRESS_HELP')
489+
490+
# End dummy list.
490491

491492
parser.add_option('--without-ssl',
492493
action='store_true',
@@ -1050,8 +1051,7 @@ def configure_node(o):
10501051
o['variables']['debug_nghttp2'] = 'false'
10511052

10521053
o['variables']['node_no_browser_globals'] = b(options.no_browser_globals)
1053-
if options.code_cache_path:
1054-
o['variables']['node_code_cache_path'] = options.code_cache_path
1054+
o['variables']['node_code_cache_path'] = 'yes'
10551055
o['variables']['node_shared'] = b(options.shared)
10561056
node_module_version = getmoduleversion.get_version()
10571057

‎node.gyp

+52-18
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
'node_use_dtrace%': 'false',
77
'node_use_etw%': 'false',
88
'node_no_browser_globals%': 'false',
9-
'node_code_cache_path%': '',
109
'node_use_v8_platform%': 'true',
1110
'node_use_bundled_v8%': 'true',
1211
'node_shared%': 'false',
@@ -224,6 +223,7 @@
224223
'deps/acorn/acorn/dist/acorn.js',
225224
'deps/acorn/acorn-walk/dist/walk.js',
226225
],
226+
'mkcodecache_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)mkcodecache<(EXECUTABLE_SUFFIX)',
227227
'conditions': [
228228
[ 'node_shared=="true"', {
229229
'node_target_type%': 'shared_library',
@@ -280,16 +280,24 @@
280280
{
281281
'target_name': '<(node_core_target_name)',
282282
'type': 'executable',
283-
'sources': [
284-
'src/node_main.cc'
283+
284+
'defines': [
285+
'NODE_WANT_INTERNALS=1',
285286
],
287+
286288
'includes': [
287289
'node.gypi'
288290
],
291+
289292
'include_dirs': [
290293
'src',
291294
'deps/v8/include'
292295
],
296+
297+
'sources': [
298+
'src/node_main.cc'
299+
],
300+
293301
'dependencies': [ 'deps/histogram/histogram.gyp:histogram' ],
294302

295303
'msvs_settings': {
@@ -402,7 +410,32 @@
402410
'LinkIncremental': 2 # enable incremental linking
403411
},
404412
},
405-
}]
413+
}],
414+
['want_separate_host_toolset==0', {
415+
'dependencies': [
416+
'mkcodecache',
417+
],
418+
'actions': [
419+
{
420+
'action_name': 'run_mkcodecache',
421+
'process_outputs_as_sources': 1,
422+
'inputs': [
423+
'<(mkcodecache_exec)',
424+
],
425+
'outputs': [
426+
'<(SHARED_INTERMEDIATE_DIR)/node_code_cache.cc',
427+
],
428+
'action': [
429+
'<@(_inputs)',
430+
'<@(_outputs)',
431+
],
432+
},
433+
],
434+
}, {
435+
'sources': [
436+
'src/node_code_cache_stub.cc'
437+
],
438+
}],
406439
],
407440
}, # node_core_target_name
408441
{
@@ -615,11 +648,6 @@
615648
'msvs_disabled_warnings!': [4244],
616649

617650
'conditions': [
618-
[ 'node_code_cache_path!=""', {
619-
'sources': [ '<(node_code_cache_path)' ]
620-
}, {
621-
'sources': [ 'src/node_code_cache_stub.cc' ]
622-
}],
623651
[ 'node_shared=="true" and node_module_version!="" and OS!="win"', {
624652
'product_extension': '<(shlib_suffix)',
625653
'xcode_settings': {
@@ -1047,6 +1075,7 @@
10471075
'defines': [ 'NODE_WANT_INTERNALS=1' ],
10481076

10491077
'sources': [
1078+
'src/node_code_cache_stub.cc',
10501079
'test/cctest/node_test_fixture.cc',
10511080
'test/cctest/test_aliased_buffer.cc',
10521081
'test/cctest/test_base64.cc',
@@ -1075,7 +1104,9 @@
10751104
'HAVE_INSPECTOR=1',
10761105
],
10771106
}, {
1078-
'defines': [ 'HAVE_INSPECTOR=0' ]
1107+
'defines': [
1108+
'HAVE_INSPECTOR=0',
1109+
]
10791110
}],
10801111
['OS=="solaris"', {
10811112
'ldflags': [ '-I<(SHARED_INTERMEDIATE_DIR)' ]
@@ -1130,11 +1161,14 @@
11301161
'deps/uv/include',
11311162
],
11321163

1133-
'defines': [ 'NODE_WANT_INTERNALS=1' ],
1134-
1164+
'defines': [
1165+
'NODE_WANT_INTERNALS=1'
1166+
],
11351167
'sources': [
1168+
'src/node_code_cache_stub.cc',
11361169
'tools/code_cache/mkcodecache.cc',
1137-
'tools/code_cache/cache_builder.cc'
1170+
'tools/code_cache/cache_builder.cc',
1171+
'tools/code_cache/cache_builder.h',
11381172
],
11391173

11401174
'conditions': [
@@ -1155,22 +1189,22 @@
11551189
],
11561190
}],
11571191
],
1158-
}, # cache_builder
1159-
], # end targets
1192+
}, # mkcodecache
1193+
], # end targets
11601194

11611195
'conditions': [
1162-
[ 'OS=="aix" and node_shared=="true"', {
1196+
['OS=="aix" and node_shared=="true"', {
11631197
'targets': [
11641198
{
11651199
'target_name': 'node_aix_shared',
11661200
'type': 'shared_library',
11671201
'product_name': '<(node_core_target_name)',
1168-
'ldflags': [ '--shared' ],
1202+
'ldflags': ['--shared'],
11691203
'product_extension': '<(shlib_suffix)',
11701204
'includes': [
11711205
'node.gypi'
11721206
],
1173-
'dependencies': [ '<(node_lib_target_name)' ],
1207+
'dependencies': ['<(node_lib_target_name)'],
11741208
'include_dirs': [
11751209
'src',
11761210
'deps/v8/include',

‎node.gypi

+16-10
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@
143143
'conditions': [
144144
['OS!="aix" and node_shared=="false"', {
145145
'ldflags': [
146-
'-Wl,--whole-archive,<(obj_dir)/deps/zlib/<(STATIC_LIB_PREFIX)'
147-
'zlib<(STATIC_LIB_SUFFIX)',
146+
'-Wl,--whole-archive,'
147+
'<(obj_dir)/deps/zlib/<(STATIC_LIB_PREFIX)zlib<(STATIC_LIB_SUFFIX)',
148148
'-Wl,--no-whole-archive',
149149
],
150150
}],
@@ -184,8 +184,8 @@
184184
'conditions': [
185185
['OS!="aix" and node_shared=="false"', {
186186
'ldflags': [
187-
'-Wl,--whole-archive,<(obj_dir)/deps/uv/<(STATIC_LIB_PREFIX)'
188-
'uv<(STATIC_LIB_SUFFIX)',
187+
'-Wl,--whole-archive,'
188+
'<(obj_dir)/deps/uv/<(STATIC_LIB_PREFIX)uv<(STATIC_LIB_SUFFIX)',
189189
'-Wl,--no-whole-archive',
190190
],
191191
}],
@@ -223,27 +223,33 @@
223223
[ 'OS=="aix"', {
224224
'defines': [
225225
'_LINUX_SOURCE_COMPAT',
226-
'__STDC_FORMAT_MACROS'
226+
'__STDC_FORMAT_MACROS',
227227
],
228228
'conditions': [
229229
[ 'force_load=="true"', {
230-
230+
'variables': {
231+
'exp_filename': '<(PRODUCT_DIR)/<(_target_name).exp',
232+
},
231233
'actions': [
232234
{
233235
'action_name': 'expfile',
234236
'inputs': [
235-
'<(obj_dir)'
237+
'<(obj_dir)',
236238
],
237239
'outputs': [
238-
'<(PRODUCT_DIR)/node.exp'
240+
'<(exp_filename)',
239241
],
240242
'action': [
241243
'sh', 'tools/create_expfile.sh',
242-
'<@(_inputs)', '<@(_outputs)'
244+
'<@(_inputs)',
245+
'<@(_outputs)',
243246
],
244247
}
245248
],
246-
'ldflags': ['-Wl,-bE:<(PRODUCT_DIR)/node.exp', '-Wl,-brtl'],
249+
'ldflags': [
250+
'-Wl,-bE:<(exp_filename)',
251+
'-Wl,-brtl',
252+
],
247253
}],
248254
],
249255
}],

‎test/code-cache/code-cache.status

-21
This file was deleted.

‎test/code-cache/test-code-cache-generator.js

-64
This file was deleted.

‎test/code-cache/testcfg.py

-6
This file was deleted.

‎test/code-cache/test-code-cache.js ‎test/parallel/test-code-cache.js

+20-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
// Flags: --expose-internals
12
'use strict';
23

3-
// Flags: --expose-internals
44
// This test verifies that if the binary is compiled with code cache,
55
// and the cache is used when built in modules are compiled.
66
// Otherwise, verifies that no cache is used when compiling builtins.
@@ -29,9 +29,9 @@ const loadedModules = process.moduleLoadList
2929
.filter((m) => m.startsWith('NativeModule'))
3030
.map((m) => m.replace('NativeModule ', ''));
3131

32-
// The binary is not configured with code cache, verifies that the builtins
32+
// Cross-compiled binaries do not have code cache, verifies that the builtins
3333
// are all compiled without cache and we are doing the bookkeeping right.
34-
if (process.config.variables.node_code_cache_path === undefined) {
34+
if (process.config.variables.want_separate_host_toolset === 1) {
3535
console.log('The binary is not configured with code cache');
3636
if (isMainThread) {
3737
assert.deepStrictEqual(compiledWithCache, new Set());
@@ -45,20 +45,27 @@ if (process.config.variables.node_code_cache_path === undefined) {
4545
// cache are hit
4646
assert.notDeepStrictEqual(compiledWithCache, new Set());
4747
}
48-
} else {
49-
console.log('The binary is configured with code cache');
48+
} else { // Native compiled
5049
assert.strictEqual(
51-
typeof process.config.variables.node_code_cache_path,
52-
'string'
50+
process.config.variables.node_code_cache_path,
51+
'yes'
5352
);
5453

54+
if (!isMainThread) {
55+
for (const key of [ 'internal/bootstrap/pre_execution' ]) {
56+
canBeRequired.add(key);
57+
cannotBeRequired.delete(key);
58+
}
59+
}
60+
61+
const wrong = [];
5562
for (const key of loadedModules) {
56-
if (cannotBeRequired.has(key)) {
57-
assert(compiledWithoutCache.has(key),
58-
`"${key}" should've been compiled without code cache`);
59-
} else {
60-
assert(compiledWithCache.has(key),
61-
`"${key}" should've been compiled with code cache`);
63+
if (cannotBeRequired.has(key) && !compiledWithoutCache.has(key)) {
64+
wrong.push(`"${key}" should've been compiled **without** code cache`);
65+
}
66+
if (canBeRequired.has(key) && !compiledWithCache.has(key)) {
67+
wrong.push(`"${key}" should've been compiled **with** code cache`);
6268
}
6369
}
70+
assert.strictEqual(wrong.length, 0, wrong.join('\n'));
6471
}

‎vcbuild.bat

+1
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ if defined config_flags set configure_flags=%configure_flags% %config_flags%
190190
if defined target_arch set configure_flags=%configure_flags% --dest-cpu=%target_arch%
191191
if defined openssl_no_asm set configure_flags=%configure_flags% --openssl-no-asm
192192
if defined DEBUG_HELPER set configure_flags=%configure_flags% --verbose
193+
if "%target_arch%"=="x86" if "%PROCESSOR_ARCHITECTURE%"=="AMD64" set configure_flags=%configure_flags% --no-cross-compiling
193194

194195
if not exist "%~dp0deps\icu" goto no-depsicu
195196
if "%target%"=="Clean" echo deleting %~dp0deps\icu

0 commit comments

Comments
 (0)
Please sign in to comment.