mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
build: enable Temporal by default
Enabling Temporal support requires `cargo` and `rustc`, which are new build toolchain requirements. Add a `--v8-disable-temporal-support` option to `configure.py` to explicitly opt-out of Temporal support (i.e. no need for Rust). If the existing `--v8-enable-temporal-support` option is not explicitly passed to `configure.py`: - Attempt to detect `cargo` and `rustc`. - If neither `cargo` and `rustc` are detected, print a warning and disable Temporal support. - If both `cargo` and `rustc` are detected, enable Temporal support. If `--v8-enable-temporal-support` is passed to `configure.py`, then the build will error and stop if `cargo` and/or `rustc` are not detected. To avoid ambiguity, `configure.py` will error and stop if both `--v8-disable-temporal-support` and `--v8-enable-temporal-support` are used. Signed-off-by: Richard Lau <richard.lau@ibm.com> PR-URL: https://github.com/nodejs/node/pull/61806 Fixes: https://github.com/nodejs/node/issues/57127 Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
1 file changed
+61
-20
+61
-20
@@ -1156,6 +1156,11 @@ parser.add_argument('--v8-enable-snapshot-compression',
|
||||
default=None,
|
||||
help='Enable the built-in snapshot compression in V8.')
|
||||
|
||||
parser.add_argument('--v8-disable-temporal-support',
|
||||
action='store_true',
|
||||
dest='v8_disable_temporal_support',
|
||||
default=None,
|
||||
help='Disable Temporal support in V8.')
|
||||
|
||||
parser.add_argument('--v8-enable-temporal-support',
|
||||
action='store_true',
|
||||
@@ -1450,11 +1455,7 @@ def get_cargo_version(cargo):
|
||||
stdin=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE)
|
||||
except OSError:
|
||||
error('''No acceptable cargo found!
|
||||
|
||||
Please make sure you have cargo installed on your system and/or
|
||||
consider adjusting the CARGO environment variable if you have installed
|
||||
it in a non-standard prefix.''')
|
||||
return '0.0'
|
||||
|
||||
with proc:
|
||||
cargo_ret = to_utf8(proc.communicate()[0])
|
||||
@@ -1473,11 +1474,7 @@ def get_rustc_version(rustc):
|
||||
stdin=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE)
|
||||
except OSError:
|
||||
error('''No acceptable rustc compiler found!
|
||||
|
||||
Please make sure you have a rust compiler installed on your system and/or
|
||||
consider adjusting the RUSTC environment variable if you have installed
|
||||
it in a non-standard prefix.''')
|
||||
return '0.0'
|
||||
|
||||
with proc:
|
||||
rustc_ret = to_utf8(proc.communicate()[0])
|
||||
@@ -1538,23 +1535,51 @@ def check_compiler(o):
|
||||
o['variables']['llvm_version'] = get_llvm_version(CC) if is_clang else '0.0'
|
||||
|
||||
# cargo and rustc are needed for Temporal.
|
||||
if options.v8_enable_temporal_support and not options.shared_temporal_capi:
|
||||
if not options.v8_disable_temporal_support or not options.shared_temporal_capi:
|
||||
# Minimum cargo and rustc versions should match values in BUILDING.md.
|
||||
min_cargo_ver_tuple = (1, 82)
|
||||
min_rustc_ver_tuple = (1, 82)
|
||||
cargo = os.environ.get('CARGO', 'cargo')
|
||||
cargo_ver = get_cargo_version(cargo)
|
||||
print_verbose(f'Detected cargo (CARGO={cargo}): {cargo_ver}')
|
||||
cargo_ver_tuple = tuple(map(int, cargo_ver.split('.')))
|
||||
if cargo_ver_tuple < min_cargo_ver_tuple:
|
||||
warn(f'cargo {cargo_ver} too old, need cargo {".".join(map(str, min_cargo_ver_tuple))}')
|
||||
if cargo_ver == '0.0':
|
||||
# Error if --v8-enable-temporal-support is explicitly set,
|
||||
# otherwise disable support for Temporal.
|
||||
if options.v8_enable_temporal_support:
|
||||
error('''No acceptable cargo found!
|
||||
|
||||
Enabling Temporal support requires cargo.
|
||||
Please make sure you have cargo installed on your system and/or
|
||||
consider adjusting the CARGO environment variable if you have installed
|
||||
it in a non-standard prefix.''')
|
||||
else:
|
||||
warn('cargo not found! Support for Temporal will be disabled.')
|
||||
options.v8_disable_temporal_support = True
|
||||
else:
|
||||
cargo_ver_tuple = tuple(map(int, cargo_ver.split('.')))
|
||||
if cargo_ver_tuple < min_cargo_ver_tuple:
|
||||
warn(f'cargo {cargo_ver} too old, need cargo {".".join(map(str, min_cargo_ver_tuple))}')
|
||||
# cargo supports RUSTC environment variable to override "rustc".
|
||||
rustc = os.environ.get('RUSTC', 'rustc')
|
||||
rustc_ver = get_rustc_version(rustc)
|
||||
print_verbose(f'Detected rustc (RUSTC={rustc}): {rustc_ver}')
|
||||
rust_ver_tuple = tuple(map(int, rustc_ver.split('.')))
|
||||
if rust_ver_tuple < min_rustc_ver_tuple:
|
||||
warn(f'rustc {rustc_ver} too old, need rustc {".".join(map(str, min_rustc_ver_tuple))}')
|
||||
if rustc_ver == '0.0':
|
||||
# Error if --v8-enable-temporal-support is explicitly set,
|
||||
# otherwise disable support for Temporal.
|
||||
if options.v8_enable_temporal_support:
|
||||
error('''No acceptable rustc compiler found!
|
||||
|
||||
Enabling Temporal support requires a Rust toolchain.
|
||||
Please make sure you have a Rust compiler installed on your system and/or
|
||||
consider adjusting the RUSTC environment variable if you have installed
|
||||
it in a non-standard prefix.''')
|
||||
else:
|
||||
warn(f'{rustc} not found! Support for Temporal will be disabled.')
|
||||
options.v8_disable_temporal_support = True
|
||||
else:
|
||||
print_verbose(f'Detected rustc (RUSTC={rustc}): {rustc_ver}')
|
||||
rust_ver_tuple = tuple(map(int, rustc_ver.split('.')))
|
||||
if rust_ver_tuple < min_rustc_ver_tuple:
|
||||
warn(f'rustc {rustc_ver} too old, need rustc {".".join(map(str, min_rustc_ver_tuple))}')
|
||||
|
||||
# Need xcode_version or gas_version when openssl asm files are compiled.
|
||||
if options.without_ssl or options.openssl_no_asm or options.shared_openssl:
|
||||
@@ -2065,7 +2090,19 @@ def configure_v8(o, configs):
|
||||
o['variables']['v8_enable_external_code_space'] = 1 if options.enable_pointer_compression else 0
|
||||
o['variables']['v8_enable_31bit_smis_on_64bit_arch'] = 1 if options.enable_pointer_compression else 0
|
||||
o['variables']['v8_enable_extensible_ro_snapshot'] = 0
|
||||
o['variables']['v8_enable_temporal_support'] = 1 if options.v8_enable_temporal_support else 0
|
||||
# TODO(richardlau): Temporal objects in V8 currently reference a private
|
||||
# ICU header file and fail to compile with shared ICU or no ICU. For now,
|
||||
# if auto-detecting, warn and disable Temporal in those cases.
|
||||
# Refs: https://github.com/nodejs/node/issues/62676
|
||||
if (not options.v8_disable_temporal_support and not options.v8_enable_temporal_support):
|
||||
match options.with_intl:
|
||||
case 'none':
|
||||
warn('Temporal support disabled when compiling without ICU')
|
||||
options.v8_disable_temporal_support = True
|
||||
case 'system-icu':
|
||||
warn('Temporal support disabled when compiling with a shared ICU library')
|
||||
options.v8_disable_temporal_support = True
|
||||
o['variables']['v8_enable_temporal_support'] = 0 if options.v8_disable_temporal_support else 1
|
||||
o['variables']['v8_trace_maps'] = 1 if options.trace_maps else 0
|
||||
o['variables']['node_use_v8_platform'] = b(not options.without_v8_platform)
|
||||
o['variables']['node_use_bundled_v8'] = b(not options.without_bundled_v8)
|
||||
@@ -2097,6 +2134,10 @@ def configure_v8(o, configs):
|
||||
raise Exception(
|
||||
'Only one of the --v8-enable-object-print or --v8-disable-object-print options '
|
||||
'can be specified at a time.')
|
||||
if all(opt in sys.argv for opt in ['--v8-enable-temporal-support', '--v8-disable-temporal-support']):
|
||||
raise Exception(
|
||||
'Only one of the --v8-enable-temporal-support or --v8-disable-temporal-support options '
|
||||
'can be specified at a time.')
|
||||
if sys.platform != 'darwin':
|
||||
if o['variables']['v8_enable_webassembly'] and o['variables']['target_arch'] == 'x64':
|
||||
o['variables']['v8_enable_wasm_simd256_revec'] = 1
|
||||
@@ -2762,7 +2803,7 @@ if flavor == 'win' and python.lower().endswith('.exe'):
|
||||
# will fail to run python scripts.
|
||||
gyp_args += ['-Dpython=' + python]
|
||||
|
||||
if options.v8_enable_temporal_support and not options.shared_temporal_capi:
|
||||
if not options.v8_disable_temporal_support or not options.shared_temporal_capi:
|
||||
cargo = os.environ.get('CARGO')
|
||||
if cargo:
|
||||
gyp_args += ['-Dcargo=' + cargo]
|
||||
|
||||
Reference in new issue
Block a user