From f593a94dd8750f4f2fada1597d5d1caf86da23d7 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Tue, 26 Nov 2019 13:03:22 +0800 Subject: [PATCH 1/3] build: add --without-node-code-cache configure option So that it's possible to build without code cache (in particular, without building mkcodecache) for testing. --- configure.py | 15 ++++++++++++--- node.gyp | 2 +- test/parallel/test-code-cache.js | 7 +++---- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/configure.py b/configure.py index 959c1db6518fdb..61708a4447d125 100755 --- a/configure.py +++ b/configure.py @@ -455,6 +455,11 @@ dest='without_node_snapshot', help='Turn off V8 snapshot integration. Currently experimental.') +parser.add_option('--without-node-code-cache', + action='store_true', + dest='without_node_code_cache', + help='Turn off V8 Code cache integration.') + intl_optgroup.add_option('--download', action='store', dest='download_list', @@ -980,6 +985,12 @@ def configure_node(o): else: o['variables']['node_use_node_snapshot'] = 'false' + if not options.without_node_code_cache: + # TODO(refack): fix this when implementing embedded code-cache when cross-compiling. + o['variables']['node_use_node_code_cache'] = b(not cross_compiling) + else: + o['variables']['node_use_node_code_cache'] = 'false' + if target_arch == 'arm': configure_arm(o) elif target_arch in ('mips', 'mipsel', 'mips64el'): @@ -1100,9 +1111,7 @@ def configure_node(o): o['variables']['debug_nghttp2'] = 'false' o['variables']['node_no_browser_globals'] = b(options.no_browser_globals) - # TODO(refack): fix this when implementing embedded code-cache when cross-compiling. - if o['variables']['want_separate_host_toolset'] == 0: - o['variables']['node_code_cache'] = 'yes' # For testing + o['variables']['node_shared'] = b(options.shared) node_module_version = getmoduleversion.get_version() diff --git a/node.gyp b/node.gyp index 810cea8c241359..84374da8310a73 100644 --- a/node.gyp +++ b/node.gyp @@ -432,7 +432,7 @@ }, }, }], - ['want_separate_host_toolset==0', { + ['node_use_node_code_cache=="true"', { 'dependencies': [ 'mkcodecache', ], diff --git a/test/parallel/test-code-cache.js b/test/parallel/test-code-cache.js index d01392f1ee6433..3c4488c557d524 100644 --- a/test/parallel/test-code-cache.js +++ b/test/parallel/test-code-cache.js @@ -33,6 +33,8 @@ const loadedModules = process.moduleLoadList // are all compiled without cache and we are doing the bookkeeping right. if (!process.features.cached_builtins) { console.log('The binary is not configured with code cache'); + assert(!process.config.variables.node_use_node_code_cache); + if (isMainThread) { assert.deepStrictEqual(compiledWithCache, new Set()); for (const key of loadedModules) { @@ -46,10 +48,7 @@ if (!process.features.cached_builtins) { assert.notDeepStrictEqual(compiledWithCache, new Set()); } } else { // Native compiled - assert.strictEqual( - process.config.variables.node_code_cache, - 'yes' - ); + assert(process.config.variables.node_use_node_code_cache); if (!isMainThread) { for (const key of [ 'internal/bootstrap/pre_execution' ]) { From 609fc754a2738cf8162e7475da596fcd2b1f2de9 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Tue, 26 Nov 2019 13:30:28 +0800 Subject: [PATCH 2/3] build: do not build mksnapshot and mkcodecache for --shared To build mkcodecache and mksnapshot (they are executables), we currently build libnode with unresolved symbols, then build the two exectuables with src/node_snapshot_stub.cc and src/node_code_cache_stub.cc. Each of them write a C++ file to disk when being run. We then use the generated C++ files & libnode (with unresolved symbols) to build the final Node executable. However, if libnode itself is the final product, then we should not build it with unresolved symbols. https://github.com/nodejs/node/pull/28897 added the two stubs for the libnode target when the --shared configure option is used, but it did not get rid of the actions to build and run mksnapshot and mkcodecache for --shared, so I think to get it working we also need a patch to make sure --shared imply --without-node-code-cache and --without-node-snapshot, until we actually fix the TODO so that mksnapshot and mkcodecache do not use the libnode that way. --- configure.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.py b/configure.py index 61708a4447d125..27b4e9837a52cc 100755 --- a/configure.py +++ b/configure.py @@ -981,13 +981,13 @@ def configure_node(o): o['variables']['want_separate_host_toolset'] = int(cross_compiling) if not options.without_node_snapshot: - o['variables']['node_use_node_snapshot'] = b(not cross_compiling) + o['variables']['node_use_node_snapshot'] = b(not cross_compiling and not options.shared) else: o['variables']['node_use_node_snapshot'] = 'false' if not options.without_node_code_cache: # TODO(refack): fix this when implementing embedded code-cache when cross-compiling. - o['variables']['node_use_node_code_cache'] = b(not cross_compiling) + o['variables']['node_use_node_code_cache'] = b(not cross_compiling and not options.shared) else: o['variables']['node_use_node_code_cache'] = 'false' From 3615173701d37e1deef511024d7d092bde388976 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 2 Dec 2019 21:46:32 +0800 Subject: [PATCH 3/3] fixup! build: do not build mksnapshot and mkcodecache for --shared --- configure.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/configure.py b/configure.py index 27b4e9837a52cc..48624aba92bf19 100755 --- a/configure.py +++ b/configure.py @@ -981,13 +981,15 @@ def configure_node(o): o['variables']['want_separate_host_toolset'] = int(cross_compiling) if not options.without_node_snapshot: - o['variables']['node_use_node_snapshot'] = b(not cross_compiling and not options.shared) + o['variables']['node_use_node_snapshot'] = b( + not cross_compiling and not options.shared) else: o['variables']['node_use_node_snapshot'] = 'false' if not options.without_node_code_cache: # TODO(refack): fix this when implementing embedded code-cache when cross-compiling. - o['variables']['node_use_node_code_cache'] = b(not cross_compiling and not options.shared) + o['variables']['node_use_node_code_cache'] = b( + not cross_compiling and not options.shared) else: o['variables']['node_use_node_code_cache'] = 'false'