From a5a40495740354d537e3edf4f31b8a9339d3301b Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Thu, 29 Aug 2024 20:20:08 +0000 Subject: [PATCH 1/5] deps: allow amaro to be externalizable - allow amaro to be externalized like other builtins containing WASM. More context is available in https://github.com/nodejs/node/blob/main/doc/contributing/maintaining/maintaining-dependencies.md#supporting-externalizable-dependencies-with-javascript-code Signed-off-by: Michael Dawson --- configure.py | 8 +++++++- node.gni | 1 + node.gyp | 5 ----- src/node_builtins.cc | 7 +++++++ 4 files changed, 15 insertions(+), 6 deletions(-) diff --git a/configure.py b/configure.py index 870c89a1c7e871..8b78eb006ec6c8 100755 --- a/configure.py +++ b/configure.py @@ -58,9 +58,11 @@ icu_versions = json.loads((tools_path / 'icu' / 'icu_versions.json').read_text(encoding='utf-8')) maglev_enabled_architectures = ('x64', 'arm', 'arm64') +# builtins may be removed later if they have been disabled by options shareable_builtins = {'cjs_module_lexer/lexer': 'deps/cjs-module-lexer/lexer.js', 'cjs_module_lexer/dist/lexer': 'deps/cjs-module-lexer/dist/lexer.js', - 'undici/undici': 'deps/undici/undici.js' + 'undici/undici': 'deps/undici/undici.js', + 'amaro/dist/index': 'deps/amaro/dist/index.js' } # create option groups @@ -2202,6 +2204,10 @@ def make_bin_override(): configure_inspector(output) configure_section_file(output) +# remove builtins that have been disabled +if options.without_amaro: + del shareable_builtins['amaro/dist/index'] + # configure shareable builtins output['variables']['node_builtin_shareable_builtins'] = [] for builtin, value in shareable_builtins.items(): diff --git a/node.gni b/node.gni index f7d896f0ef1c13..9dca810decebd7 100644 --- a/node.gni +++ b/node.gni @@ -20,6 +20,7 @@ declare_args() { "deps/cjs-module-lexer/lexer.js", "deps/cjs-module-lexer/dist/lexer.js", "deps/undici/undici.js", + "deps/amaro/dist/index.js", ] } diff --git a/node.gyp b/node.gyp index c69670c49b660d..bc07ba0484bdc4 100644 --- a/node.gyp +++ b/node.gyp @@ -465,11 +465,6 @@ }, { 'use_openssl_def%': 0, }], - [ 'node_use_amaro=="true"', { - 'deps_files': [ - 'deps/amaro/dist/index.js', - ] - } ] ], }, diff --git a/src/node_builtins.cc b/src/node_builtins.cc index 97dde02295c975..fa2d2761474e1b 100644 --- a/src/node_builtins.cc +++ b/src/node_builtins.cc @@ -50,6 +50,13 @@ BuiltinLoader::BuiltinLoader() AddExternalizedBuiltin("internal/deps/undici/undici", STRINGIFY(NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH)); #endif // NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH + +#if HAVE_AMARO +#ifdef NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH + AddExternalizedBuiltin("internal/deps/amaro/dist/index", + STRINGIFY(NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH)); +#endif // NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH +#endif // NODE_USE_ARARO } bool BuiltinLoader::Exists(const char* id) { From a276828c6bc424316bfe3bc38cbabbccff72afe8 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Tue, 3 Sep 2024 11:01:17 -0400 Subject: [PATCH 2/5] Update src/node_builtins.cc Co-authored-by: Luigi Pinca --- src/node_builtins.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_builtins.cc b/src/node_builtins.cc index fa2d2761474e1b..2bc7155f7c075e 100644 --- a/src/node_builtins.cc +++ b/src/node_builtins.cc @@ -56,7 +56,7 @@ BuiltinLoader::BuiltinLoader() AddExternalizedBuiltin("internal/deps/amaro/dist/index", STRINGIFY(NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH)); #endif // NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH -#endif // NODE_USE_ARARO +#endif // HAVE_AMARO } bool BuiltinLoader::Exists(const char* id) { From 70154e921780dcafd0a35fdc2b0430934caa1399 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Tue, 3 Sep 2024 15:25:14 +0000 Subject: [PATCH 3/5] squash: address review comments Signed-off-by: Michael Dawson --- src/node_metadata.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/node_metadata.cc b/src/node_metadata.cc index 4ab98d91d84b41..db30578fb3014b 100644 --- a/src/node_metadata.cc +++ b/src/node_metadata.cc @@ -127,9 +127,11 @@ Metadata::Versions::Versions() { cjs_module_lexer = CJS_MODULE_LEXER_VERSION; uvwasi = UVWASI_VERSION_STRING; +#ifndef NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH #if HAVE_AMARO amaro = AMARO_VERSION; #endif +#endif #if HAVE_OPENSSL openssl = GetOpenSSLVersion(); From 3e9f641f4885cb56cf1b0b49711ef69664f7cefa Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Tue, 3 Sep 2024 18:59:03 +0000 Subject: [PATCH 4/5] squash: address comments Signed-off-by: Michael Dawson --- src/node_metadata.h | 4 ++++ test/parallel/test-process-versions.js | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/node_metadata.h b/src/node_metadata.h index 76ec862fda187b..74814c6b9d4ac0 100644 --- a/src/node_metadata.h +++ b/src/node_metadata.h @@ -28,10 +28,14 @@ namespace node { #endif #if HAVE_AMARO +#ifndef NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH #define NODE_VERSIONS_KEY_AMARO(V) V(amaro) #else #define NODE_VERSIONS_KEY_AMARO(V) #endif +#else +#define NODE_VERSIONS_KEY_AMARO(V) +#endif #ifndef NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH #define NODE_VERSIONS_KEY_UNDICI(V) V(undici) diff --git a/test/parallel/test-process-versions.js b/test/parallel/test-process-versions.js index 7475b2759407c3..3b8af4b5b52526 100644 --- a/test/parallel/test-process-versions.js +++ b/test/parallel/test-process-versions.js @@ -27,9 +27,12 @@ const expected_keys = [ ]; const hasUndici = process.config.variables.node_builtin_shareable_builtins.includes('deps/undici/undici.js'); +const hasAmaro = process.config.variables.node_builtin_shareable_builtins.includes('deps/amaro/dist/index.js'); if (process.config.variables.node_use_amaro) { - expected_keys.push('amaro'); + if (hasAmaro) { + expected_keys.push('amaro'); + } } if (hasUndici) { expected_keys.push('undici'); From 865ac335a0727743240e133ae1696c252a3c41b6 Mon Sep 17 00:00:00 2001 From: Michael Dawson Date: Wed, 4 Sep 2024 08:57:18 -0400 Subject: [PATCH 5/5] Update src/node_metadata.h Co-authored-by: Chengzhong Wu --- src/node_metadata.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/node_metadata.h b/src/node_metadata.h index 74814c6b9d4ac0..c59e65ad1fe3fa 100644 --- a/src/node_metadata.h +++ b/src/node_metadata.h @@ -27,15 +27,11 @@ namespace node { #define NODE_HAS_RELEASE_URLS #endif -#if HAVE_AMARO -#ifndef NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH +#if HAVE_AMARO && !defined(NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH) #define NODE_VERSIONS_KEY_AMARO(V) V(amaro) #else #define NODE_VERSIONS_KEY_AMARO(V) #endif -#else -#define NODE_VERSIONS_KEY_AMARO(V) -#endif #ifndef NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH #define NODE_VERSIONS_KEY_UNDICI(V) V(undici)