@@ -68,7 +68,8 @@ fn show_usage() {
6868 --use-system-gcc : Use system installed libgccjit
6969 --build-only : Only build rustc_codegen_gcc then exits
7070 --nb-parts : Used to split rustc_tests (for CI needs)
71- --current-part : Used with `--nb-parts`, allows you to specify which parts to test"#
71+ --current-part : Used with `--nb-parts`, allows you to specify which parts to test
72+ --with-llvm-sysroot : Use the LLVM sysroot instead of the GCC one"#
7273 ) ;
7374 ConfigInfo :: show_usage ( ) ;
7475 for ( option, ( doc, _) ) in get_runners ( ) {
@@ -93,6 +94,7 @@ struct TestArg {
9394 config_info : ConfigInfo ,
9495 sysroot_features : Vec < String > ,
9596 keep_lto_tests : bool ,
97+ with_llvm_sysroot : bool ,
9698}
9799
98100impl TestArg {
@@ -136,6 +138,9 @@ impl TestArg {
136138 return Err ( format ! ( "Expected an argument after `{arg}`, found nothing" ) ) ;
137139 }
138140 } ,
141+ "--with-llvm-sysroot" => {
142+ test_arg. with_llvm_sysroot = true ;
143+ }
139144 "--help" => {
140145 show_usage ( ) ;
141146 return Ok ( None ) ;
@@ -559,9 +564,14 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
559564 let extra =
560565 if args. is_using_gcc_master_branch ( ) { "" } else { " -Csymbol-mangling-version=v0" } ;
561566
567+ let sysroot_arg = if args. with_llvm_sysroot {
568+ String :: new ( )
569+ } else {
570+ format ! ( " --sysroot {}" , args. config_info. sysroot_path)
571+ } ;
572+
562573 let rustc_args = format ! (
563- "-Zpanic-abort-tests -Zcodegen-backend={codegen_backend_path} --sysroot {} -Cpanic=abort{extra}" ,
564- args. config_info. sysroot_path
574+ "-Zpanic-abort-tests -Zcodegen-backend={codegen_backend_path}{sysroot_arg} -Cpanic=abort{extra}" ,
565575 ) ;
566576
567577 run_command_with_env (
@@ -1028,11 +1038,16 @@ where
10281038 let extra =
10291039 if args. is_using_gcc_master_branch ( ) { "" } else { " -Csymbol-mangling-version=v0" } ;
10301040
1041+ let sysroot_arg = if args. with_llvm_sysroot {
1042+ String :: new ( )
1043+ } else {
1044+ format ! ( " --sysroot {}" , args. config_info. sysroot_path)
1045+ } ;
1046+
10311047 let rustc_args = format ! (
1032- "{test_flags} -Zcodegen-backend={backend} --sysroot {sysroot }{extra}" ,
1048+ "{test_flags} -Zcodegen-backend={backend}{sysroot_arg }{extra}" ,
10331049 test_flags = env. get( "TEST_FLAGS" ) . unwrap_or( & String :: new( ) ) ,
10341050 backend = args. config_info. cg_backend_path,
1035- sysroot = args. config_info. sysroot_path,
10361051 extra = extra,
10371052 ) ;
10381053
@@ -1270,7 +1285,7 @@ pub fn run() -> Result<(), String> {
12701285 return Ok ( ( ) ) ;
12711286 }
12721287
1273- args. config_info . setup ( & mut env, args. use_system_gcc ) ?;
1288+ args. config_info . setup ( & mut env, args. use_system_gcc , args . with_llvm_sysroot ) ?;
12741289
12751290 if args. runners . is_empty ( ) {
12761291 run_all ( & env, & args) ?;
0 commit comments