Skip to content

Commit 5a2f0c6

Browse files
chbaker0Aravind Vasudevan
authored andcommitted
Update Rust revision, include src, and disable bad test
Rolls a new Rust toolchain with the following changes in addition to updating the revision: With rust-lang/rust#96493, disables test src/test/ui/numeric/numeric-cast.rs (which fails on our CI due to bug rust-lang/rust#94322) and re-enables the rest of the src/test/ui suite. Includes Rust std sources and vendored dependencies in the package at third_party/rust-toolchain/lib/rustlib/src/rust/ Fixed: 1320459 Change-Id: I6b25be163214c4408123f3abb7e0135e94ec642e Cq-Include-Trybots: luci.chromium.try:linux-rust-x64-rel,linux-rust-x64-dbg Change-Id: I6b25be163214c4408123f3abb7e0135e94ec642e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3635438 Commit-Queue: Collin Baker <[email protected]> Reviewed-by: Adrian Taylor <[email protected]> Cr-Commit-Position: refs/heads/main@{#1003924} NOKEYCHECK=True GitOrigin-RevId: a6e76db0e266a58447df055c9d77950a78d16380
1 parent a6707ed commit 5a2f0c6

File tree

2 files changed

+49
-20
lines changed

2 files changed

+49
-20
lines changed

build_rust.py

Lines changed: 39 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,31 @@
6666
CARGO_HOME_DIR = os.path.join(RUST_SRC_DIR, 'cargo-home')
6767
RUST_SRC_VERSION_FILE_PATH = os.path.join(RUST_SRC_DIR, 'src', 'version')
6868
RUST_TOOLCHAIN_LIB_DIR = os.path.join(RUST_TOOLCHAIN_OUT_DIR, 'lib')
69+
RUST_TOOLCHAIN_SRC_DIST_DIR = os.path.join(RUST_TOOLCHAIN_LIB_DIR, 'rustlib',
70+
'src', 'rust')
71+
RUST_TOOLCHAIN_SRC_DIST_VENDOR_DIR = os.path.join(RUST_TOOLCHAIN_SRC_DIST_DIR,
72+
'vendor')
6973
VERSION_STAMP_PATH = os.path.join(RUST_TOOLCHAIN_OUT_DIR, 'VERSION')
7074
RUST_CONFIG_TEMPLATE_PATH = os.path.join(
7175
os.path.dirname(os.path.abspath(__file__)), 'config.toml.template')
76+
RUST_SRC_VENDOR_DIR = os.path.join(RUST_SRC_DIR, 'vendor')
7277

7378
# Desired tools and libraries in our Rust toolchain.
7479
DISTRIBUTION_ARTIFACTS = [
7580
'cargo', 'clippy', 'compiler/rustc', 'library/std', 'rust-analyzer',
76-
'rustfmt'
81+
'rustfmt', 'src'
7782
]
7883

7984
# Which test suites to run. Any failure will fail the build.
8085
TEST_SUITES = [
8186
'library/std',
8287
'src/test/codegen',
88+
'src/test/ui',
89+
]
8390

91+
EXCLUDED_TESTS = [
8492
# Temporarily disabled due to https://github.com/rust-lang/rust/issues/94322
85-
# 'src/test/ui',
93+
'src/test/ui/numeric/numeric-cast.rs',
8694
]
8795

8896

@@ -206,6 +214,15 @@ def RunXPy(sub, args, gcc_toolchain_path, verbose):
206214
RunCommand(cmd + args, env=RUSTENV)
207215

208216

217+
# Get arguments to run desired test suites, minus disabled tests.
218+
def GetTestArgs():
219+
args = TEST_SUITES
220+
for excluded in EXCLUDED_TESTS:
221+
args.append('--skip')
222+
args.append(excluded)
223+
return args
224+
225+
209226
def main():
210227
parser = argparse.ArgumentParser(
211228
description='Build and package Rust toolchain')
@@ -302,7 +319,7 @@ def main():
302319
if not args.skip_test:
303320
print('Running stage 2 tests...')
304321
# Run a subset of tests. Tell x.py to keep the rustc we already built.
305-
RunXPy('test', TEST_SUITES, args.gcc_toolchain, args.verbose)
322+
RunXPy('test', GetTestArgs(), args.gcc_toolchain, args.verbose)
306323

307324
targets = [
308325
'library/proc_macro', 'library/std', 'src/tools/cargo',
@@ -314,22 +331,28 @@ def main():
314331
print('Building stage 2 artifacts...')
315332
RunXPy('build', ['--stage', '2'] + targets, args.gcc_toolchain, args.verbose)
316333

317-
if not args.skip_install:
318-
print(f'Installing to {RUST_TOOLCHAIN_OUT_DIR} ...')
319-
# Clean output directory.
320-
if os.path.exists(RUST_TOOLCHAIN_OUT_DIR):
321-
shutil.rmtree(RUST_TOOLCHAIN_OUT_DIR)
334+
if args.skip_install:
335+
# Rust is fully built. We can quit.
336+
return 0
337+
338+
print(f'Installing to {RUST_TOOLCHAIN_OUT_DIR} ...')
339+
# Clean output directory.
340+
if os.path.exists(RUST_TOOLCHAIN_OUT_DIR):
341+
shutil.rmtree(RUST_TOOLCHAIN_OUT_DIR)
322342

323-
RunXPy('install', DISTRIBUTION_ARTIFACTS, args.gcc_toolchain, args.verbose)
343+
RunXPy('install', DISTRIBUTION_ARTIFACTS, args.gcc_toolchain, args.verbose)
324344

325-
# Write expected `rustc --version` string to our toolchain directory.
326-
with open(RUST_SRC_VERSION_FILE_PATH) as version_file:
327-
rust_version = version_file.readline().rstrip()
328-
with open(VERSION_STAMP_PATH, 'w') as stamp:
329-
stamp.write('rustc %s-dev (%s chromium)\n' %
330-
(rust_version, GetPackageVersion()))
345+
# Write expected `rustc --version` string to our toolchain directory.
346+
with open(RUST_SRC_VERSION_FILE_PATH) as version_file:
347+
rust_version = version_file.readline().rstrip()
348+
with open(VERSION_STAMP_PATH, 'w') as stamp:
349+
stamp.write('rustc %s-dev (%s chromium)\n' %
350+
(rust_version, GetPackageVersion()))
331351

332-
return 0
352+
# x.py installed library sources to our toolchain directory. We also need to
353+
# copy the vendor directory so Chromium checkouts have all the deps needed to
354+
# build std.
355+
shutil.copytree(RUST_SRC_VENDOR_DIR, RUST_TOOLCHAIN_SRC_DIST_VENDOR_DIR)
333356

334357

335358
if __name__ == '__main__':

update_rust.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import argparse
1515
import os
16+
import shutil
1617
import sys
1718
import tempfile
1819
import urllib
@@ -25,8 +26,8 @@
2526
os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'clang',
2627
'scripts'))
2728

28-
RUST_REVISION = '1f631e8e'
29-
RUST_SUB_REVISION = 2
29+
RUST_REVISION = 'f001f930'
30+
RUST_SUB_REVISION = 1
3031

3132
# Hash of src/stage0.json, which itself contains the stage0 toolchain hashes.
3233
# We trust the Rust build system checks, but to ensure it is not tampered with
@@ -69,10 +70,15 @@ def main():
6970
from update import (DownloadAndUnpack, GetDefaultHostOs, GetPlatformUrlPrefix)
7071

7172
try:
72-
with tempfile.TemporaryFile() as f:
73+
with tempfile.TemporaryDirectory() as tdir:
7374
url = '%srust-toolchain-%s.tgz' % (GetPlatformUrlPrefix(
7475
GetDefaultHostOs()), GetPackageVersion())
75-
DownloadAndUnpack(url, THIRD_PARTY_DIR)
76+
DownloadAndUnpack(url, tdir)
77+
78+
# If download was successful, swap out existing rust-toolchain dir with
79+
# newly extracted one.
80+
shutil.rmtree(RUST_TOOLCHAIN_OUT_DIR)
81+
shutil.move(os.path.join(tdir, 'rust-toolchain'), RUST_TOOLCHAIN_OUT_DIR)
7682
except urllib.error.HTTPError as e:
7783
# Fail softly for now. This can happen if a Rust package was not produced,
7884
# e.g. if the Rust build failed upon a Clang update, or if a Rust roll and

0 commit comments

Comments
 (0)