@@ -3094,3 +3094,130 @@ impl Step for CodegenCranelift {
30943094 builder. run_cmd ( BootstrapCommand :: from ( & mut cmd) . fail_fast ( ) ) ;
30953095 }
30963096}
3097+
3098+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
3099+ pub struct CodegenGCC {
3100+ compiler : Compiler ,
3101+ target : TargetSelection ,
3102+ }
3103+
3104+ impl Step for CodegenGCC {
3105+ type Output = ( ) ;
3106+ const DEFAULT : bool = true ;
3107+ const ONLY_HOSTS : bool = true ;
3108+
3109+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
3110+ run. paths ( & [ "compiler/rustc_codegen_gcc" ] )
3111+ }
3112+
3113+ fn make_run ( run : RunConfig < ' _ > ) {
3114+ let builder = run. builder ;
3115+ let host = run. build_triple ( ) ;
3116+ let compiler = run. builder . compiler_for ( run. builder . top_stage , host, host) ;
3117+
3118+ if builder. doc_tests == DocTests :: Only {
3119+ return ;
3120+ }
3121+
3122+ let triple = run. target . triple ;
3123+ let target_supported = if triple. contains ( "linux" ) {
3124+ triple. contains ( "x86_64" )
3125+ || triple. contains ( "aarch64" )
3126+ || triple. contains ( "s390x" )
3127+ || triple. contains ( "riscv64gc" )
3128+ } else if triple. contains ( "darwin" ) || triple. contains ( "windows" ) {
3129+ triple. contains ( "x86_64" )
3130+ } else {
3131+ false
3132+ } ;
3133+ if !target_supported {
3134+ builder. info ( "target not supported by rustc_codegen_gcc. skipping" ) ;
3135+ return ;
3136+ }
3137+
3138+ if builder. remote_tested ( run. target ) {
3139+ builder. info ( "remote testing is not supported by rustc_codegen_gcc. skipping" ) ;
3140+ return ;
3141+ }
3142+
3143+ if !builder. config . rust_codegen_backends . contains ( & INTERNER . intern_str ( "gcc" ) ) {
3144+ builder. info ( "gcc not in rust.codegen-backends. skipping" ) ;
3145+ return ;
3146+ }
3147+
3148+ builder. ensure ( CodegenGCC { compiler, target : run. target } ) ;
3149+ }
3150+
3151+ fn run ( self , builder : & Builder < ' _ > ) {
3152+ let compiler = self . compiler ;
3153+ let target = self . target ;
3154+
3155+ builder. ensure ( compile:: Std :: new_with_extra_rust_args (
3156+ compiler,
3157+ target,
3158+ & [ "-Csymbol-mangling-version=v0" , "-Cpanic=abort" ] ,
3159+ ) ) ;
3160+
3161+ // If we're not doing a full bootstrap but we're testing a stage2
3162+ // version of libstd, then what we're actually testing is the libstd
3163+ // produced in stage1. Reflect that here by updating the compiler that
3164+ // we're working with automatically.
3165+ let compiler = builder. compiler_for ( compiler. stage , compiler. host , target) ;
3166+
3167+ let build_cargo = || {
3168+ let mut cargo = builder. cargo (
3169+ compiler,
3170+ Mode :: Codegen , // Must be codegen to ensure dlopen on compiled dylibs works
3171+ SourceType :: InTree ,
3172+ target,
3173+ "run" ,
3174+ ) ;
3175+ cargo. current_dir ( & builder. src . join ( "compiler/rustc_codegen_gcc" ) ) ;
3176+ cargo
3177+ . arg ( "--manifest-path" )
3178+ . arg ( builder. src . join ( "compiler/rustc_codegen_gcc/build_system/Cargo.toml" ) ) ;
3179+ compile:: rustc_cargo_env ( builder, & mut cargo, target, compiler. stage ) ;
3180+
3181+ // Avoid incremental cache issues when changing rustc
3182+ cargo. env ( "CARGO_BUILD_INCREMENTAL" , "false" ) ;
3183+ cargo. rustflag ( "-Cpanic=abort" ) ;
3184+
3185+ cargo
3186+ } ;
3187+
3188+ builder. info ( & format ! (
3189+ "{} GCC stage{} ({} -> {})" ,
3190+ Kind :: Test . description( ) ,
3191+ compiler. stage,
3192+ & compiler. host,
3193+ target
3194+ ) ) ;
3195+ let _time = helpers:: timeit ( & builder) ;
3196+
3197+ /*
3198+ let mut prepare_cargo = build_cargo();
3199+ prepare_cargo.arg("--").arg("prepare");
3200+ #[allow(deprecated)]
3201+ builder.config.try_run(&mut prepare_cargo.into()).unwrap();
3202+ */
3203+
3204+ let mut cargo = build_cargo ( ) ;
3205+
3206+ cargo
3207+ . arg ( "--" )
3208+ . arg ( "test" )
3209+ . arg ( "--use-system-gcc" )
3210+ . arg ( "--use-backend" )
3211+ . arg ( "gcc" )
3212+ . arg ( "--out-dir" )
3213+ . arg ( builder. stage_out ( compiler, Mode :: ToolRustc ) . join ( "cg_gcc" ) )
3214+ . arg ( "--release" )
3215+ . arg ( "--no-default-features" )
3216+ . arg ( "--mini-tests" )
3217+ . arg ( "--std-tests" ) ;
3218+ cargo. args ( builder. config . test_args ( ) ) ;
3219+
3220+ let mut cmd: Command = cargo. into ( ) ;
3221+ builder. run_cmd ( BootstrapCommand :: from ( & mut cmd) . fail_fast ( ) ) ;
3222+ }
3223+ }
0 commit comments