Skip to content

Commit 40c6867

Browse files
danakjAravind Vasudevan
authored andcommitted
Start building with rustc on the Mac and Windows bots
We roll Rust from 6e0115778b0aedc90b59e035476c38e1b8c5c29b-2 to ac4379fea9e83465d814bb05005689f49bd2141e-1 And get Rust starting to build on Mac and Windows trybots. It doesn't fully succeed but we can address more things in followup CLs. Change-Id: Ia9822c8b24a5973e1ccef942944c3465075b119f Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4310857 Reviewed-by: Collin Baker <[email protected]> Commit-Queue: danakj <[email protected]> Cr-Commit-Position: refs/heads/main@{#1116627} NOKEYCHECK=True GitOrigin-RevId: 712cb486c1b2c53992fd329484c62e433df3945d
1 parent 77c18f3 commit 40c6867

File tree

3 files changed

+44
-32
lines changed

3 files changed

+44
-32
lines changed

build_rust.py

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import json
4040
import platform
4141
import os
42-
import pipes
4342
import shutil
4443
import string
4544
import subprocess
@@ -66,20 +65,21 @@
6665

6766
EXCLUDED_TESTS = [
6867
# Temporarily disabled due to https://github.com/rust-lang/rust/issues/94322
69-
'tests/ui/numeric/numeric-cast.rs',
68+
os.path.join('tests', 'ui', 'numeric', 'numeric-cast.rs'),
7069
# Temporarily disabled due to https://github.com/rust-lang/rust/issues/96497
71-
'tests/codegen/issue-96497-slice-size-nowrap.rs',
70+
os.path.join('tests', 'codegen', 'issue-96497-slice-size-nowrap.rs'),
7271
# TODO(crbug.com/1347563): Re-enable when fixed.
73-
'tests/codegen/sanitizer-cfi-emit-type-checks.rs',
74-
'tests/codegen/sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs',
72+
os.path.join('tests', 'codegen', 'sanitizer-cfi-emit-type-checks.rs'),
73+
os.path.join('tests', 'codegen',
74+
'sanitizer-cfi-emit-type-metadata-itanium-cxx-abi.rs'),
7575
# Temporarily disabled due to https://github.com/rust-lang/rust/issues/45222
7676
# which appears to have regressed as of a recent LLVM update. This test is
7777
# purely performance related, not correctness.
78-
'tests/codegen/issue-45222.rs'
78+
os.path.join('tests', 'codegen', 'issue-45222.rs')
7979
]
8080
EXCLUDED_TESTS_WINDOWS = [
8181
# https://github.com/rust-lang/rust/issues/96464
82-
'tests/codegen/vec-shrink-panik.rs'
82+
os.path.join('tests', 'codegen', 'vec-shrink-panik.rs'),
8383
]
8484

8585
RUST_GIT_URL = ('https://chromium.googlesource.com/external/' +
@@ -313,28 +313,30 @@ def __init__(self, llvm_bins_path, zlib_path, libxml2_dirs, build_mac_arm,
313313
self._env['AR'] = os.path.join(llvm_bins_path, 'llvm-lib.exe')
314314
self._env['CC'] = os.path.join(llvm_bins_path, 'clang-cl.exe')
315315
self._env['CXX'] = os.path.join(llvm_bins_path, 'clang-cl.exe')
316+
self._env['LD'] = os.path.join(llvm_bins_path, 'lld-link.exe')
316317
else:
317318
self._env['AR'] = os.path.join(llvm_bins_path, 'llvm-ar')
318319
self._env['CC'] = os.path.join(llvm_bins_path, 'clang')
319320
self._env['CXX'] = os.path.join(llvm_bins_path, 'clang++')
321+
self._env['LD'] = os.path.join(llvm_bins_path, 'clang')
320322

321323
if sys.platform == 'darwin':
322324
# The system/xcode compiler would find system SDK correctly, but
323325
# the Clang we've built does not. See
324326
# https://github.com/llvm/llvm-project/issues/45225
325327
sdk_path = subprocess.check_output(['xcrun', '--show-sdk-path'],
326328
text=True).rstrip()
327-
RUSTENV['CFLAGS'] += f' -isysroot {sdk_path}'
328-
RUSTENV['CXXFLAGS'] += f' -isysroot {sdk_path}'
329-
RUSTENV['LDFLAGS'] += f' -isysroot {sdk_path}'
330-
RUSTENV['RUSTFLAGS_BOOTSTRAP'] += (
329+
self._env['CFLAGS'] += f' -isysroot {sdk_path}'
330+
self._env['CXXFLAGS'] += f' -isysroot {sdk_path}'
331+
self._env['LDFLAGS'] += f' -isysroot {sdk_path}'
332+
self._env['RUSTFLAGS_BOOTSTRAP'] += (
331333
f' -Clink-arg=-isysroot -Clink-arg={sdk_path}')
332-
RUSTENV['RUSTFLAGS_NOT_BOOTSTRAP'] += (
334+
self._env['RUSTFLAGS_NOT_BOOTSTRAP'] += (
333335
f' -Clink-arg=-isysroot -Clink-arg={sdk_path}')
334336
# Rust compiletests don't get any of the RUSTFLAGS that we set here
335337
# and then the clang linker can't find `-lSystem`, unless we set the
336338
# `SDKROOT`.
337-
RUSTENV['SDKROOT'] = sdk_path
339+
self._env['SDKROOT'] = sdk_path
338340

339341
if zlib_path:
340342
self._env['CFLAGS'] += f' -I{zlib_path}'
@@ -361,29 +363,39 @@ def __init__(self, llvm_bins_path, zlib_path, libxml2_dirs, build_mac_arm,
361363
self._env['CXXFLAGS'] += f' {gcc_toolchain_flag}'
362364
self._env['LDFLAGS'] += f' {gcc_toolchain_flag}'
363365
# A `-Clink-arg=<foo>` arg passes `foo`` to the linker invovation.
364-
self._env[
365-
'RUSTFLAGS_BOOTSTRAP'] += f' -Clink-arg={gcc_toolchain_flag}'
366-
self._env[
367-
'RUSTFLAGS_NOT_BOOTSTRAP'] += f' -Clink-arg={gcc_toolchain_flag}'
366+
self._env['RUSTFLAGS_BOOTSTRAP'] += (
367+
f' -Clink-arg={gcc_toolchain_flag}')
368+
self._env['RUSTFLAGS_NOT_BOOTSTRAP'] += (
369+
f' -Clink-arg={gcc_toolchain_flag}')
368370
self._env['RUSTFLAGS_BOOTSTRAP'] += (
369371
f' -L native={gcc_toolchain_path}/lib64')
370372
self._env['RUSTFLAGS_NOT_BOOTSTRAP'] += (
371373
f' -L native={gcc_toolchain_path}/lib64')
372374

373-
# Direct rustc to use Chromium's lld instead of the system linker. This
374-
# is critical for stage 1 onward since we need to link libs with LLVM
375-
# bitcode. It is also good for a hermetic build in general.
376-
#
375+
# TODO(danakj): On windows we point the to lld-link in config.toml so
376+
# we don't (and can't) specify -fuse-ld=lld, as lld-link doesn't know
377+
# that argument, and it's already using lld. Should we do the same for
378+
# other platforms and remove this link argument?
379+
if sys.platform != 'win32':
380+
# Direct rustc to use Chromium's lld instead of the system linker.
381+
# This is critical for stage 1 onward since we need to link libs
382+
# with LLVM bitcode. It is also good for a hermetic build in
383+
# general.
384+
self._env['RUSTFLAGS_BOOTSTRAP'] += ' -Clink-arg=-fuse-ld=lld'
385+
self._env['RUSTFLAGS_NOT_BOOTSTRAP'] += ' -Clink-arg=-fuse-ld=lld'
386+
377387
# The `--undefined-version` flag is needed due to a bug in libtest:
378-
# https://github.com/rust-lang/rust/issues/105967
379-
self._env[
380-
'RUSTFLAGS_BOOTSTRAP'] += ' -Clink-arg=-fuse-ld=lld -Clink-arg=-Wl,--undefined-version'
381-
self._env[
382-
'RUSTFLAGS_NOT_BOOTSTRAP'] += ' -Clink-arg=-fuse-ld=lld -Clink-arg=-Wl,--undefined-version'
388+
# https://github.com/rust-lang/rust/issues/105967. The flag does
389+
# not exist on Mac or Windows.
390+
if sys.platform.startswith('linux'):
391+
self._env['RUSTFLAGS_BOOTSTRAP'] += (
392+
' -Clink-arg=-Wl,--undefined-version')
393+
self._env['RUSTFLAGS_NOT_BOOTSTRAP'] += (
394+
' -Clink-arg=-Wl,--undefined-version')
383395

384396
# Rustdoc should use our clang linker as well, as we pass flags that
385397
# the system linker may not understand.
386-
self._env['RUSTDOCFLAGS'] += f' -Clinker={self._env["CC"]}'
398+
self._env['RUSTDOCFLAGS'] += f' -Clinker={self._env["LD"]}'
387399

388400
# Cargo normally stores files in $HOME. Override this.
389401
self._env['CARGO_HOME'] = CARGO_HOME_DIR

config.toml.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ ranlib = "$LLVM_BIN/llvm-ranlib"
4242
ar = "$LLVM_BIN/llvm-lib"
4343
cc = "$LLVM_BIN/clang-cl"
4444
cxx = "$LLVM_BIN/clang-cl"
45-
# linker will be the system link.exe.
45+
linker = "$LLVM_BIN/lld-link"
4646

4747
[target.arm64-apple-darwin]
4848
llvm-config = "$LLVM_LIB_ROOT/bin/llvm-config"
@@ -52,7 +52,7 @@ cc = "$LLVM_BIN/clang"
5252
cxx = "$LLVM_BIN/clang++"
5353
linker = "$LLVM_BIN/clang"
5454

55-
[target.amd64-apple-darwin]
55+
[target.x86_64-apple-darwin]
5656
llvm-config = "$LLVM_LIB_ROOT/bin/llvm-config"
5757
ranlib = "$LLVM_BIN/llvm-ranlib"
5858
ar = "$LLVM_BIN/llvm-ar"

update_rust.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929

3030
# These fields are written by //tools/clang/scripts/upload_revision.py, and
3131
# should not be changed manually.
32-
RUST_REVISION = '6e0115778b0aedc90b59e035476c38e1b8c5c29b'
33-
RUST_SUB_REVISION = 2
32+
RUST_REVISION = 'ac4379fea9e83465d814bb05005689f49bd2141e'
33+
RUST_SUB_REVISION = 1
3434

3535
# Trunk on 2022-10-15.
3636
#
@@ -62,7 +62,7 @@
6262
# TODO(lukasza): Include CRUBIT_REVISION and CRUBIT_SUB_REVISION once we
6363
# include Crubit binaries in the generated package. See also a TODO comment
6464
# in BuildCrubit in package_rust.py.
65-
FALLBACK_REVISION = '6e0115778b0aedc90b59e035476c38e1b8c5c29b-2-llvmorg-17-init-2387-g68e81d7e-1'
65+
FALLBACK_REVISION = 'ac4379fea9e83465d814bb05005689f49bd2141e-1-llvmorg-17-init-3874-g93a2fecc-1'
6666

6767
# Hash of src/stage0.json, which itself contains the stage0 toolchain hashes.
6868
# We trust the Rust build system checks, but to ensure it is not tampered with

0 commit comments

Comments
 (0)