39
39
import json
40
40
import platform
41
41
import os
42
- import pipes
43
42
import shutil
44
43
import string
45
44
import subprocess
66
65
67
66
EXCLUDED_TESTS = [
68
67
# 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') ,
70
69
# 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') ,
72
71
# 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' ),
75
75
# Temporarily disabled due to https://github.com/rust-lang/rust/issues/45222
76
76
# which appears to have regressed as of a recent LLVM update. This test is
77
77
# purely performance related, not correctness.
78
- 'tests/ codegen/ issue-45222.rs'
78
+ os . path . join ( 'tests' , ' codegen' , ' issue-45222.rs')
79
79
]
80
80
EXCLUDED_TESTS_WINDOWS = [
81
81
# 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'),
83
83
]
84
84
85
85
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,
313
313
self ._env ['AR' ] = os .path .join (llvm_bins_path , 'llvm-lib.exe' )
314
314
self ._env ['CC' ] = os .path .join (llvm_bins_path , 'clang-cl.exe' )
315
315
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' )
316
317
else :
317
318
self ._env ['AR' ] = os .path .join (llvm_bins_path , 'llvm-ar' )
318
319
self ._env ['CC' ] = os .path .join (llvm_bins_path , 'clang' )
319
320
self ._env ['CXX' ] = os .path .join (llvm_bins_path , 'clang++' )
321
+ self ._env ['LD' ] = os .path .join (llvm_bins_path , 'clang' )
320
322
321
323
if sys .platform == 'darwin' :
322
324
# The system/xcode compiler would find system SDK correctly, but
323
325
# the Clang we've built does not. See
324
326
# https://github.com/llvm/llvm-project/issues/45225
325
327
sdk_path = subprocess .check_output (['xcrun' , '--show-sdk-path' ],
326
328
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' ] += (
331
333
f' -Clink-arg=-isysroot -Clink-arg={ sdk_path } ' )
332
- RUSTENV ['RUSTFLAGS_NOT_BOOTSTRAP' ] += (
334
+ self . _env ['RUSTFLAGS_NOT_BOOTSTRAP' ] += (
333
335
f' -Clink-arg=-isysroot -Clink-arg={ sdk_path } ' )
334
336
# Rust compiletests don't get any of the RUSTFLAGS that we set here
335
337
# and then the clang linker can't find `-lSystem`, unless we set the
336
338
# `SDKROOT`.
337
- RUSTENV ['SDKROOT' ] = sdk_path
339
+ self . _env ['SDKROOT' ] = sdk_path
338
340
339
341
if zlib_path :
340
342
self ._env ['CFLAGS' ] += f' -I{ zlib_path } '
@@ -361,29 +363,39 @@ def __init__(self, llvm_bins_path, zlib_path, libxml2_dirs, build_mac_arm,
361
363
self ._env ['CXXFLAGS' ] += f' { gcc_toolchain_flag } '
362
364
self ._env ['LDFLAGS' ] += f' { gcc_toolchain_flag } '
363
365
# 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 } ' )
368
370
self ._env ['RUSTFLAGS_BOOTSTRAP' ] += (
369
371
f' -L native={ gcc_toolchain_path } /lib64' )
370
372
self ._env ['RUSTFLAGS_NOT_BOOTSTRAP' ] += (
371
373
f' -L native={ gcc_toolchain_path } /lib64' )
372
374
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
+
377
387
# 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' )
383
395
384
396
# Rustdoc should use our clang linker as well, as we pass flags that
385
397
# the system linker may not understand.
386
- self ._env ['RUSTDOCFLAGS' ] += f' -Clinker={ self ._env ["CC " ]} '
398
+ self ._env ['RUSTDOCFLAGS' ] += f' -Clinker={ self ._env ["LD " ]} '
387
399
388
400
# Cargo normally stores files in $HOME. Override this.
389
401
self ._env ['CARGO_HOME' ] = CARGO_HOME_DIR
0 commit comments