Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 159ae48

Browse filesBrowse files
authored
build: add cargo and rustc checks for Temporal
If opting into building Node.js with statically linked Temporal (`configure --v8-enable-temporal-support`), check for the presence of `cargo` and `rustc` and compare the detected versions against the documented toolchain versions in `BUILDING.md`. PR-URL: #61467 Refs: #60942 Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 1ad04e2 commit 159ae48
Copy full SHA for 159ae48

1 file changed

+62Lines changed: 62 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎configure.py‎

Copy file name to clipboardExpand all lines: configure.py
+62Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,50 @@ def get_openssl_version(o):
13971397
warn(f'Failed to determine OpenSSL version from header: {e}')
13981398
return 0
13991399

1400+
def get_cargo_version(cargo):
1401+
try:
1402+
proc = subprocess.Popen(shlex.split(cargo) + ['--version'],
1403+
stdin=subprocess.PIPE, stderr=subprocess.PIPE,
1404+
stdout=subprocess.PIPE)
1405+
except OSError:
1406+
error('''No acceptable cargo found!
1407+
1408+
Please make sure you have cargo installed on your system.''')
1409+
1410+
with proc:
1411+
cargo_ret = to_utf8(proc.communicate()[0])
1412+
1413+
match = re.match(r"cargo ([0-9]+\.[0-9]+\.[0-9]+)", cargo_ret)
1414+
1415+
if match:
1416+
return match.group(1)
1417+
1418+
warn(f'Could not recognize `cargo`: {cargo_ret}')
1419+
return '0.0'
1420+
1421+
def get_rustc_version(rustc):
1422+
try:
1423+
proc = subprocess.Popen(shlex.split(rustc) + ['--version'],
1424+
stdin=subprocess.PIPE, stderr=subprocess.PIPE,
1425+
stdout=subprocess.PIPE)
1426+
except OSError:
1427+
error('''No acceptable rustc compiler found!
1428+
1429+
Please make sure you have a rust compiler installed on your system and/or
1430+
consider adjusting the RUSTC environment variable if you have installed
1431+
it in a non-standard prefix.''')
1432+
1433+
with proc:
1434+
rustc_ret = to_utf8(proc.communicate()[0])
1435+
1436+
match = re.match(r"rustc ([0-9]+\.[0-9]+\.[0-9]+)", rustc_ret)
1437+
1438+
if match:
1439+
return match.group(1)
1440+
1441+
warn(f'Could not recognize `rustc`: {rustc_ret}')
1442+
return '0.0'
1443+
14001444
# Note: Apple clang self-reports as clang 4.2.0 and gcc 4.2.1. It passes
14011445
# the version check more by accident than anything else but a more rigorous
14021446
# check involves checking the build number against an allowlist. I'm not
@@ -1444,6 +1488,24 @@ def check_compiler(o):
14441488

14451489
o['variables']['llvm_version'] = get_llvm_version(CC) if is_clang else '0.0'
14461490

1491+
# cargo and rustc are needed for Temporal.
1492+
if options.v8_enable_temporal_support and not options.shared_temporal_capi:
1493+
# Minimum cargo and rustc versions should match values in BUILDING.md.
1494+
min_cargo_ver_tuple = (1, 82)
1495+
min_rustc_ver_tuple = (1, 82)
1496+
cargo_ver = get_cargo_version('cargo')
1497+
print_verbose(f'Detected cargo: {cargo_ver}')
1498+
cargo_ver_tuple = tuple(map(int, cargo_ver.split('.')))
1499+
if cargo_ver_tuple < min_cargo_ver_tuple:
1500+
warn(f'cargo {cargo_ver} too old, need cargo {".".join(map(str, min_cargo_ver_tuple))}')
1501+
# cargo supports RUSTC environment variable to override "rustc".
1502+
rustc = os.environ.get('RUSTC', 'rustc')
1503+
rustc_ver = get_rustc_version(rustc)
1504+
print_verbose(f'Detected rustc (RUSTC={rustc}): {rustc_ver}')
1505+
rust_ver_tuple = tuple(map(int, rustc_ver.split('.')))
1506+
if rust_ver_tuple < min_rustc_ver_tuple:
1507+
warn(f'rustc {rustc_ver} too old, need rustc {".".join(map(str, min_rustc_ver_tuple))}')
1508+
14471509
# Need xcode_version or gas_version when openssl asm files are compiled.
14481510
if options.without_ssl or options.openssl_no_asm or options.shared_openssl:
14491511
return

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.