Skip to content

Commit dd20a31

Browse files
committed
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.
1 parent 25443db commit dd20a31

File tree

1 file changed

+49
-20
lines changed

1 file changed

+49
-20
lines changed

configure.py

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,6 +1156,11 @@
11561156
default=None,
11571157
help='Enable the built-in snapshot compression in V8.')
11581158

1159+
parser.add_argument('--v8-disable-temporal-support',
1160+
action='store_true',
1161+
dest='v8_disable_temporal_support',
1162+
default=None,
1163+
help='Disable Temporal support in V8.')
11591164

11601165
parser.add_argument('--v8-enable-temporal-support',
11611166
action='store_true',
@@ -1450,11 +1455,7 @@ def get_cargo_version(cargo):
14501455
stdin=subprocess.PIPE, stderr=subprocess.PIPE,
14511456
stdout=subprocess.PIPE)
14521457
except OSError:
1453-
error('''No acceptable cargo found!
1454-
1455-
Please make sure you have cargo installed on your system and/or
1456-
consider adjusting the CARGO environment variable if you have installed
1457-
it in a non-standard prefix.''')
1458+
return '0.0'
14581459

14591460
with proc:
14601461
cargo_ret = to_utf8(proc.communicate()[0])
@@ -1473,11 +1474,7 @@ def get_rustc_version(rustc):
14731474
stdin=subprocess.PIPE, stderr=subprocess.PIPE,
14741475
stdout=subprocess.PIPE)
14751476
except OSError:
1476-
error('''No acceptable rustc compiler found!
1477-
1478-
Please make sure you have a rust compiler installed on your system and/or
1479-
consider adjusting the RUSTC environment variable if you have installed
1480-
it in a non-standard prefix.''')
1477+
return '0.0'
14811478

14821479
with proc:
14831480
rustc_ret = to_utf8(proc.communicate()[0])
@@ -1538,23 +1535,51 @@ def check_compiler(o):
15381535
o['variables']['llvm_version'] = get_llvm_version(CC) if is_clang else '0.0'
15391536

15401537
# cargo and rustc are needed for Temporal.
1541-
if options.v8_enable_temporal_support and not options.shared_temporal_capi:
1538+
if not options.v8_disable_temporal_support or not options.shared_temporal_capi:
15421539
# Minimum cargo and rustc versions should match values in BUILDING.md.
15431540
min_cargo_ver_tuple = (1, 82)
15441541
min_rustc_ver_tuple = (1, 82)
15451542
cargo = os.environ.get('CARGO', 'cargo')
15461543
cargo_ver = get_cargo_version(cargo)
15471544
print_verbose(f'Detected cargo (CARGO={cargo}): {cargo_ver}')
1548-
cargo_ver_tuple = tuple(map(int, cargo_ver.split('.')))
1549-
if cargo_ver_tuple < min_cargo_ver_tuple:
1550-
warn(f'cargo {cargo_ver} too old, need cargo {".".join(map(str, min_cargo_ver_tuple))}')
1545+
if cargo_ver == '0.0':
1546+
# Error if --v8-enable-temporal-support is explicitly set,
1547+
# otherwise disable support for Temporal.
1548+
if options.v8_enable_temporal_support:
1549+
error('''No acceptable cargo found!
1550+
1551+
Enabling Temporal support requires cargo.
1552+
Please make sure you have cargo installed on your system and/or
1553+
consider adjusting the CARGO environment variable if you have installed
1554+
it in a non-standard prefix.''')
1555+
else:
1556+
warn('cargo not found! Support for Temporal will be disabled.')
1557+
options.v8_disable_temporal_support = True
1558+
else:
1559+
cargo_ver_tuple = tuple(map(int, cargo_ver.split('.')))
1560+
if cargo_ver_tuple < min_cargo_ver_tuple:
1561+
warn(f'cargo {cargo_ver} too old, need cargo {".".join(map(str, min_cargo_ver_tuple))}')
15511562
# cargo supports RUSTC environment variable to override "rustc".
15521563
rustc = os.environ.get('RUSTC', 'rustc')
15531564
rustc_ver = get_rustc_version(rustc)
1554-
print_verbose(f'Detected rustc (RUSTC={rustc}): {rustc_ver}')
1555-
rust_ver_tuple = tuple(map(int, rustc_ver.split('.')))
1556-
if rust_ver_tuple < min_rustc_ver_tuple:
1557-
warn(f'rustc {rustc_ver} too old, need rustc {".".join(map(str, min_rustc_ver_tuple))}')
1565+
if rustc_ver == '0.0':
1566+
# Error if --v8-enable-temporal-support is explicitly set,
1567+
# otherwise disable support for Temporal.
1568+
if options.v8_enable_temporal_support:
1569+
error('''No acceptable rustc compiler found!
1570+
1571+
Enabling Temporal support requires a Rust toolchain.
1572+
Please make sure you have a Rust compiler installed on your system and/or
1573+
consider adjusting the RUSTC environment variable if you have installed
1574+
it in a non-standard prefix.''')
1575+
else:
1576+
warn(f'{rustc} not found! Support for Temporal will be disabled.')
1577+
options.v8_disable_temporal_support = True
1578+
else:
1579+
print_verbose(f'Detected rustc (RUSTC={rustc}): {rustc_ver}')
1580+
rust_ver_tuple = tuple(map(int, rustc_ver.split('.')))
1581+
if rust_ver_tuple < min_rustc_ver_tuple:
1582+
warn(f'rustc {rustc_ver} too old, need rustc {".".join(map(str, min_rustc_ver_tuple))}')
15581583

15591584
# Need xcode_version or gas_version when openssl asm files are compiled.
15601585
if options.without_ssl or options.openssl_no_asm or options.shared_openssl:
@@ -2057,7 +2082,7 @@ def configure_v8(o, configs):
20572082
o['variables']['v8_enable_external_code_space'] = 1 if options.enable_pointer_compression else 0
20582083
o['variables']['v8_enable_31bit_smis_on_64bit_arch'] = 1 if options.enable_pointer_compression else 0
20592084
o['variables']['v8_enable_extensible_ro_snapshot'] = 0
2060-
o['variables']['v8_enable_temporal_support'] = 1 if options.v8_enable_temporal_support else 0
2085+
o['variables']['v8_enable_temporal_support'] = 0 if options.v8_disable_temporal_support else 1
20612086
o['variables']['v8_trace_maps'] = 1 if options.trace_maps else 0
20622087
o['variables']['node_use_v8_platform'] = b(not options.without_v8_platform)
20632088
o['variables']['node_use_bundled_v8'] = b(not options.without_bundled_v8)
@@ -2089,6 +2114,10 @@ def configure_v8(o, configs):
20892114
raise Exception(
20902115
'Only one of the --v8-enable-object-print or --v8-disable-object-print options '
20912116
'can be specified at a time.')
2117+
if all(opt in sys.argv for opt in ['--v8-enable-temporal-support', '--v8-disable-temporal-support']):
2118+
raise Exception(
2119+
'Only one of the --v8-enable-temporal-support or --v8-disable-temporal-support options '
2120+
'can be specified at a time.')
20922121
if sys.platform != 'darwin':
20932122
if o['variables']['v8_enable_webassembly'] and o['variables']['target_arch'] == 'x64':
20942123
o['variables']['v8_enable_wasm_simd256_revec'] = 1
@@ -2754,7 +2783,7 @@ def make_bin_override():
27542783
# will fail to run python scripts.
27552784
gyp_args += ['-Dpython=' + python]
27562785

2757-
if options.v8_enable_temporal_support and not options.shared_temporal_capi:
2786+
if not options.v8_disable_temporal_support or not options.shared_temporal_capi:
27582787
cargo = os.environ.get('CARGO')
27592788
if cargo:
27602789
gyp_args += ['-Dcargo=' + cargo]

0 commit comments

Comments
 (0)