@@ -70,6 +70,7 @@ fn show_usage() {
7070
7171 --features [arg] : Add a new feature [arg]
7272 --use-system-gcc : Use system installed libgccjit
73+ --use-llvm-sysroot : Use LLVM sysroot instead of the one compiled with `cg_gcc`
7374 --build-only : Only build rustc_codegen_gcc then exits
7475 --nb-parts : Used to split rustc_tests (for CI needs)
7576 --current-part : Used with `--nb-parts`, allows you to specify which parts to test"#
@@ -132,6 +133,9 @@ impl TestArg {
132133 "--keep-lto-tests" => {
133134 test_arg. keep_lto_tests = true ;
134135 }
136+ "--use-llvm-sysroot" => {
137+ test_arg. config_info . use_llvm_sysroot = true ;
138+ }
135139 "--sysroot-features" => match args. next ( ) {
136140 Some ( feature) if !feature. is_empty ( ) => {
137141 test_arg. sysroot_features . push ( feature) ;
@@ -283,6 +287,9 @@ fn mini_tests(env: &Env, args: &TestArg) -> Result<(), String> {
283287fn build_sysroot ( env : & Env , args : & TestArg ) -> Result < ( ) , String > {
284288 // FIXME: create a function "display_if_not_quiet" or something along the line.
285289 println ! ( "[BUILD] sysroot" ) ;
290+ if !args. config_info . use_llvm_sysroot {
291+ println ! ( "`--use-llvm-sysroot` option was used, skipping sysroot build" ) ;
292+ }
286293 let mut config = args. config_info . clone ( ) ;
287294 config. features . extend ( args. sysroot_features . iter ( ) . cloned ( ) ) ;
288295 build:: build_sysroot ( env, & config) ?;
@@ -630,8 +637,12 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
630637 if args. is_using_gcc_master_branch ( ) { "" } else { " -Csymbol-mangling-version=v0" } ;
631638
632639 let rustc_args = format ! (
633- "-Zpanic-abort-tests -Zcodegen-backend={codegen_backend_path} --sysroot {} -Cpanic=abort{extra}" ,
634- args. config_info. sysroot_path
640+ "-Zpanic-abort-tests -Zcodegen-backend={codegen_backend_path}{} -Cpanic=abort{extra}" ,
641+ if args. config_info. use_llvm_sysroot {
642+ String :: new( )
643+ } else {
644+ format!( " --sysroot {}" , args. config_info. sysroot_path)
645+ } ,
635646 ) ;
636647
637648 run_command_with_env (
@@ -1124,10 +1135,14 @@ where
11241135 if args. is_using_gcc_master_branch ( ) { "" } else { " -Csymbol-mangling-version=v0" } ;
11251136
11261137 let rustc_args = format ! (
1127- "{test_flags} -Zcodegen-backend={backend} --sysroot {sysroot}{extra}" ,
1138+ "{test_flags} -Zcodegen-backend={backend}{sysroot}{extra}" ,
11281139 test_flags = env. get( "TEST_FLAGS" ) . unwrap_or( & String :: new( ) ) ,
11291140 backend = args. config_info. cg_backend_path,
1130- sysroot = args. config_info. sysroot_path,
1141+ sysroot = if args. config_info. use_llvm_sysroot {
1142+ String :: new( )
1143+ } else {
1144+ format!( " --sysroot {}" , args. config_info. sysroot_path)
1145+ } ,
11311146 extra = extra,
11321147 ) ;
11331148
0 commit comments