@@ -27,7 +27,6 @@ use crate::core::config::flags::Subcommand;
2727use crate :: core:: config:: TargetSelection ;
2828use crate :: utils;
2929use crate :: utils:: cache:: { Interned , INTERNER } ;
30- use crate :: utils:: exec:: BootstrapCommand ;
3130use crate :: utils:: helpers:: {
3231 self , add_link_lib_path, dylib_path, dylib_path_var, output, t, up_to_date,
3332} ;
@@ -630,7 +629,7 @@ impl Step for Miri {
630629 SourceType :: InTree ,
631630 & [ ] ,
632631 ) ;
633- let _guard = builder. msg_sysroot_tool ( Kind :: Test , compiler. stage , "miri" , host, target ) ;
632+ let _guard = builder. msg_sysroot_tool ( Kind :: Test , compiler. stage , "miri" , host, host ) ;
634633
635634 cargo. add_rustc_lib_path ( builder, compiler) ;
636635
@@ -809,8 +808,8 @@ impl Step for Clippy {
809808
810809 let _guard = builder. msg_sysroot_tool ( Kind :: Test , compiler. stage , "clippy" , host, host) ;
811810
812- // Clippy reports errors if it blessed the outputs
813- if builder. run_cmd ( BootstrapCommand :: from ( & mut cargo) . allow_failure ( ) ) {
811+ # [ allow ( deprecated ) ] // Clippy reports errors if it blessed the outputs
812+ if builder. config . try_run ( & mut cargo) . is_ok ( ) {
814813 // The tests succeeded; nothing to do.
815814 return ;
816815 }
@@ -1567,12 +1566,10 @@ note: if you're sure you want to do this, please open an issue as to why. In the
15671566 cmd. arg ( "--coverage-dump-path" ) . arg ( coverage_dump) ;
15681567 }
15691568
1570- if mode == "run-coverage" {
1571- // The demangler doesn't need the current compiler, so we can avoid
1572- // unnecessary rebuilds by using the bootstrap compiler instead.
1569+ if mode == "run-make" || mode == "run-coverage" {
15731570 let rust_demangler = builder
15741571 . ensure ( tool:: RustDemangler {
1575- compiler : compiler . with_stage ( 0 ) ,
1572+ compiler,
15761573 target : compiler. host ,
15771574 extra_features : Vec :: new ( ) ,
15781575 } )
@@ -3002,10 +2999,7 @@ impl Step for CodegenCranelift {
30022999
30033000 let triple = run. target . triple ;
30043001 let target_supported = if triple. contains ( "linux" ) {
3005- triple. contains ( "x86_64" )
3006- || triple. contains ( "aarch64" )
3007- || triple. contains ( "s390x" )
3008- || triple. contains ( "riscv64gc" )
3002+ triple. contains ( "x86_64" ) || triple. contains ( "aarch64" ) || triple. contains ( "s390x" )
30093003 } else if triple. contains ( "darwin" ) || triple. contains ( "windows" ) {
30103004 triple. contains ( "x86_64" )
30113005 } else {
@@ -3100,7 +3094,131 @@ impl Step for CodegenCranelift {
31003094 . arg ( "testsuite.extended_sysroot" ) ;
31013095 cargo. args ( builder. config . test_args ( ) ) ;
31023096
3103- let mut cmd: Command = cargo. into ( ) ;
3104- builder. run_cmd ( BootstrapCommand :: from ( & mut cmd) . fail_fast ( ) ) ;
3097+ #[ allow( deprecated) ]
3098+ builder. config . try_run ( & mut cargo. into ( ) ) . unwrap ( ) ;
3099+ }
3100+ }
3101+
3102+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
3103+ pub struct CodegenGCC {
3104+ compiler : Compiler ,
3105+ target : TargetSelection ,
3106+ }
3107+
3108+ impl Step for CodegenGCC {
3109+ type Output = ( ) ;
3110+ const DEFAULT : bool = true ;
3111+ const ONLY_HOSTS : bool = true ;
3112+
3113+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
3114+ run. paths ( & [ "compiler/rustc_codegen_gcc" ] )
3115+ }
3116+
3117+ fn make_run ( run : RunConfig < ' _ > ) {
3118+ let builder = run. builder ;
3119+ let host = run. build_triple ( ) ;
3120+ let compiler = run. builder . compiler_for ( run. builder . top_stage , host, host) ;
3121+
3122+ if builder. doc_tests == DocTests :: Only {
3123+ return ;
3124+ }
3125+
3126+ let triple = run. target . triple ;
3127+ let target_supported = if triple. contains ( "linux" ) {
3128+ triple. contains ( "x86_64" ) || triple. contains ( "aarch64" ) || triple. contains ( "s390x" )
3129+ } else if triple. contains ( "darwin" ) || triple. contains ( "windows" ) {
3130+ triple. contains ( "x86_64" )
3131+ } else {
3132+ false
3133+ } ;
3134+ if !target_supported {
3135+ builder. info ( "target not supported by rustc_codegen_gcc. skipping" ) ;
3136+ return ;
3137+ }
3138+
3139+ if builder. remote_tested ( run. target ) {
3140+ builder. info ( "remote testing is not supported by rustc_codegen_gcc. skipping" ) ;
3141+ return ;
3142+ }
3143+
3144+ if !builder. config . rust_codegen_backends . contains ( & INTERNER . intern_str ( "gcc" ) ) {
3145+ builder. info ( "gcc not in rust.codegen-backends. skipping" ) ;
3146+ return ;
3147+ }
3148+
3149+ builder. ensure ( CodegenGCC { compiler, target : run. target } ) ;
3150+ }
3151+
3152+ fn run ( self , builder : & Builder < ' _ > ) {
3153+ let compiler = self . compiler ;
3154+ let target = self . target ;
3155+
3156+ builder. ensure ( compile:: Std :: new_with_extra_rust_args (
3157+ compiler,
3158+ target,
3159+ & [ "-Csymbol-mangling-version=v0" , "-Cpanic=abort" , "-Zpanic-abort-tests" ] ,
3160+ ) ) ;
3161+
3162+ // If we're not doing a full bootstrap but we're testing a stage2
3163+ // version of libstd, then what we're actually testing is the libstd
3164+ // produced in stage1. Reflect that here by updating the compiler that
3165+ // we're working with automatically.
3166+ let compiler = builder. compiler_for ( compiler. stage , compiler. host , target) ;
3167+
3168+ let build_cargo = || {
3169+ let mut cargo = builder. cargo (
3170+ compiler,
3171+ Mode :: Codegen , // Must be codegen to ensure dlopen on compiled dylibs works
3172+ SourceType :: InTree ,
3173+ target,
3174+ "run" ,
3175+ ) ;
3176+ cargo. current_dir ( & builder. src . join ( "compiler/rustc_codegen_gcc" ) ) ;
3177+ cargo
3178+ . arg ( "--manifest-path" )
3179+ . arg ( builder. src . join ( "compiler/rustc_codegen_gcc/build_system/Cargo.toml" ) ) ;
3180+ compile:: rustc_cargo_env ( builder, & mut cargo, target, compiler. stage ) ;
3181+
3182+ // Avoid incremental cache issues when changing rustc
3183+ cargo. env ( "CARGO_BUILD_INCREMENTAL" , "false" ) ;
3184+ cargo. rustflag ( "-Cpanic=abort" ) ;
3185+
3186+ cargo
3187+ } ;
3188+
3189+ builder. info ( & format ! (
3190+ "{} GCC stage{} ({} -> {})" ,
3191+ Kind :: Test . description( ) ,
3192+ compiler. stage,
3193+ & compiler. host,
3194+ target
3195+ ) ) ;
3196+ let _time = helpers:: timeit ( & builder) ;
3197+
3198+ /*
3199+ let mut prepare_cargo = build_cargo();
3200+ prepare_cargo.arg("--").arg("prepare");
3201+ #[allow(deprecated)]
3202+ builder.config.try_run(&mut prepare_cargo.into()).unwrap();
3203+ */
3204+
3205+ let mut cargo = build_cargo ( ) ;
3206+
3207+ cargo
3208+ . arg ( "--" )
3209+ . arg ( "test" )
3210+ . arg ( "--use-system-gcc" )
3211+ . arg ( "--use-backend" )
3212+ . arg ( "gcc" )
3213+ . arg ( "--out-dir" )
3214+ . arg ( builder. stage_out ( compiler, Mode :: ToolRustc ) . join ( "cg_gcc" ) )
3215+ . arg ( "--release" )
3216+ . arg ( "--no-default-features" )
3217+ . arg ( "--mini-tests" )
3218+ . arg ( "--std-tests" ) ;
3219+ cargo. args ( builder. config . test_args ( ) ) ;
3220+
3221+ #[ allow( deprecated) ]
3222+ builder. config . try_run ( & mut cargo. into ( ) ) . unwrap ( ) ;
31053223 }
31063224}
0 commit comments