Skip to content

Commit 9df5d42

Browse files
chbaker0Aravind Vasudevan
authored andcommitted
Use rust_src CIPD package for Rust toolchain build
Instead of checking out the Rust git repository and fetching all dependencies, use the rust_src package added in crrev.com/c/3863563 which already has all dependencies. Bug: 1245714 Change-Id: I371db4d0dfcaa774d3c08d7a4367c5f6609068ed Cq-Include-Trybots: luci.chromium.try:android-rust-arm-dbg,android-rust-arm-rel,linux-rust-x64-dbg,linux-rust-x64-rel Change-Id: I371db4d0dfcaa774d3c08d7a4367c5f6609068ed Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3867195 Reviewed-by: Hans Wennborg <hans@chromium.org> Commit-Queue: Collin Baker <collinbaker@chromium.org> Cr-Commit-Position: refs/heads/main@{#1047772} NOKEYCHECK=True GitOrigin-RevId: 1a5fb4a08915b40307a465771d7711277d10a69c
1 parent fc25986 commit 9df5d42

File tree

3 files changed

+3
-65
lines changed

3 files changed

+3
-65
lines changed

build_rust.py

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
RUST_GIT_URL = 'https://github.com/rust-lang/rust/'
6363

64-
RUST_SRC_DIR = os.path.join(THIRD_PARTY_DIR, 'rust-src')
64+
RUST_SRC_DIR = os.path.join(THIRD_PARTY_DIR, 'rust_src', 'src')
6565
STAGE0_JSON_PATH = os.path.join(RUST_SRC_DIR, 'src', 'stage0.json')
6666
# Download crates.io dependencies to rust-src subdir (rather than $HOME/.cargo)
6767
CARGO_HOME_DIR = os.path.join(RUST_SRC_DIR, 'cargo-home')
@@ -110,49 +110,6 @@ def RunCommand(command, env=None, fail_hard=True):
110110
return False
111111

112112

113-
def CheckoutRust(commit, dir):
114-
# Submodules we must update early since bootstrap wants them before it
115-
# starts managing them.
116-
force_update_submodules = [
117-
'src/tools/rust-analyzer', 'compiler/rustc_codegen_cranelift'
118-
]
119-
120-
# Shared between first checkout and subsequent updates.
121-
def UpdateSubmodules():
122-
return RunCommand(
123-
['git', 'submodule', 'update', '--init', '--recursive'] +
124-
force_update_submodules,
125-
fail_hard=False)
126-
127-
# Try updating the current repo if it exists and has no local diff.
128-
if os.path.isdir(dir):
129-
os.chdir(dir)
130-
# git diff-index --quiet returns success when there is no diff.
131-
# Also check that the first commit is reachable.
132-
if (RunCommand(['git', 'diff-index', '--quiet', 'HEAD'],
133-
fail_hard=False)
134-
and RunCommand(['git', 'fetch'], fail_hard=False)
135-
and RunCommand(['git', 'checkout', commit], fail_hard=False)
136-
and UpdateSubmodules()):
137-
return
138-
139-
# If we can't use the current repo, delete it.
140-
os.chdir(CHROMIUM_DIR) # Can't remove dir if we're in it.
141-
print('Removing %s.' % dir)
142-
RmTree(dir)
143-
144-
clone_cmd = ['git', 'clone', RUST_GIT_URL, dir]
145-
146-
if RunCommand(clone_cmd, fail_hard=False):
147-
os.chdir(dir)
148-
if (RunCommand(['git', 'checkout', commit], fail_hard=False)
149-
and UpdateSubmodules()):
150-
return
151-
152-
print('CheckoutRust failed.')
153-
sys.exit(1)
154-
155-
156113
def VerifyStage0JsonHash():
157114
hasher = hashlib.sha256()
158115
with open(STAGE0_JSON_PATH, 'rb') as input:
@@ -243,10 +200,6 @@ def main():
243200
help=
244201
'checkout Rust, verify the stage0 hash, then quit without building. '
245202
'Will print the actual hash if different than expected.')
246-
parser.add_argument(
247-
'--skip-checkout',
248-
action='store_true',
249-
help='skip Rust git checkout. Useful for trying local changes')
250203
parser.add_argument('--skip-clean',
251204
action='store_true',
252205
help='skip x.py clean step')
@@ -284,9 +237,6 @@ def main():
284237
else:
285238
llvm_libs_root = build.LLVM_BOOTSTRAP_DIR
286239

287-
if not args.skip_checkout:
288-
CheckoutRust(RUST_REVISION, RUST_SRC_DIR)
289-
290240
VerifyStage0JsonHash()
291241
if args.verify_stage0_hash:
292242
# The above function exits and prints the actual hash if verification
@@ -313,16 +263,6 @@ def main():
313263
else:
314264
assert not rest
315265

316-
# Delete vendored sources and .cargo subdir. Otherwise when updating an
317-
# existing checkout, vendored sources will not be re-fetched leaving deps
318-
# out of date.
319-
if not args.skip_checkout:
320-
for dir in [
321-
os.path.join(RUST_SRC_DIR, d) for d in ['vendor', '.cargo']
322-
]:
323-
if os.path.exists(dir):
324-
shutil.rmtree(dir)
325-
326266
if not args.skip_clean:
327267
print('Cleaning build artifacts...')
328268
RunXPy('clean', [], args.gcc_toolchain, args.verbose)

config.toml.template

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ description = "$PACKAGE_VERSION chromium"
2727
# it fails to run under sudo even if the sudo user is not root, unless sources
2828
# are vendored in tree.
2929
locked-deps = true
30-
31-
# TODO(crbug.com/1342708): fix vendoring and re-enable.
32-
vendor = false
30+
vendor = true
3331

3432
target = ["x86_64-unknown-linux-gnu"]
3533

update_rust.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'clang',
2828
'scripts'))
2929

30-
RUST_REVISION = 'abd4d2ef'
30+
RUST_REVISION = '20220914'
3131
RUST_SUB_REVISION = 1
3232

3333
# Trunk on 2022-08-26.

0 commit comments

Comments
 (0)