@@ -2967,3 +2967,129 @@ impl Step for TestHelpers {
2967
2967
. compile ( "rust_test_helpers" ) ;
2968
2968
}
2969
2969
}
2970
+
2971
+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
2972
+ pub struct CodegenCranelift {
2973
+ compiler : Compiler ,
2974
+ target : TargetSelection ,
2975
+ }
2976
+
2977
+ impl Step for CodegenCranelift {
2978
+ type Output = ( ) ;
2979
+ const DEFAULT : bool = true ;
2980
+ const ONLY_HOSTS : bool = true ;
2981
+
2982
+ fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
2983
+ run. paths ( & [ "compiler/rustc_codegen_cranelift" ] )
2984
+ }
2985
+
2986
+ fn make_run ( run : RunConfig < ' _ > ) {
2987
+ let builder = run. builder ;
2988
+ let host = run. build_triple ( ) ;
2989
+ let compiler = run. builder . compiler_for ( run. builder . top_stage , host, host) ;
2990
+
2991
+ if builder. doc_tests == DocTests :: Only {
2992
+ return ;
2993
+ }
2994
+
2995
+ let triple = run. target . triple ;
2996
+ let target_supported = if triple. contains ( "linux" ) {
2997
+ triple. contains ( "x86_64" ) || triple. contains ( "aarch64" ) || triple. contains ( "s390x" )
2998
+ } else if triple. contains ( "darwin" ) || triple. contains ( "windows" ) {
2999
+ triple. contains ( "x86_64" )
3000
+ } else {
3001
+ false
3002
+ } ;
3003
+ if !target_supported {
3004
+ builder. info ( "target not supported by rustc_codegen_cranelift. skipping" ) ;
3005
+ return ;
3006
+ }
3007
+
3008
+ if builder. remote_tested ( run. target ) {
3009
+ builder. info ( "remote testing is not supported by rustc_codegen_cranelift. skipping" ) ;
3010
+ return ;
3011
+ }
3012
+
3013
+ if !builder. config . rust_codegen_backends . contains ( & INTERNER . intern_str ( "cranelift" ) ) {
3014
+ builder. info ( "cranelift not in rust.codegen-backends. skipping" ) ;
3015
+ return ;
3016
+ }
3017
+
3018
+ builder. ensure ( CodegenCranelift { compiler, target : run. target } ) ;
3019
+ }
3020
+
3021
+ fn run ( self , builder : & Builder < ' _ > ) {
3022
+ let compiler = self . compiler ;
3023
+ let target = self . target ;
3024
+
3025
+ builder. ensure ( compile:: Std :: new ( compiler, target) ) ;
3026
+
3027
+ // If we're not doing a full bootstrap but we're testing a stage2
3028
+ // version of libstd, then what we're actually testing is the libstd
3029
+ // produced in stage1. Reflect that here by updating the compiler that
3030
+ // we're working with automatically.
3031
+ let compiler = builder. compiler_for ( compiler. stage , compiler. host , target) ;
3032
+
3033
+ let build_cargo = || {
3034
+ let mut cargo = builder. cargo (
3035
+ compiler,
3036
+ Mode :: Codegen , // Must be codegen to ensure dlopen on compiled dylibs works
3037
+ SourceType :: InTree ,
3038
+ target,
3039
+ "run" ,
3040
+ ) ;
3041
+ cargo. current_dir ( & builder. src . join ( "compiler/rustc_codegen_cranelift" ) ) ;
3042
+ cargo
3043
+ . arg ( "--manifest-path" )
3044
+ . arg ( builder. src . join ( "compiler/rustc_codegen_cranelift/build_system/Cargo.toml" ) ) ;
3045
+ compile:: rustc_cargo_env ( builder, & mut cargo, target, compiler. stage ) ;
3046
+
3047
+ // Avoid incremental cache issues when changing rustc
3048
+ cargo. env ( "CARGO_BUILD_INCREMENTAL" , "false" ) ;
3049
+
3050
+ cargo
3051
+ } ;
3052
+
3053
+ builder. info ( & format ! (
3054
+ "{} cranelift stage{} ({} -> {})" ,
3055
+ Kind :: Test . description( ) ,
3056
+ compiler. stage,
3057
+ & compiler. host,
3058
+ target
3059
+ ) ) ;
3060
+ let _time = util:: timeit ( & builder) ;
3061
+
3062
+ // FIXME handle vendoring for source tarballs before removing the --skip-test below
3063
+ let download_dir = builder. out . join ( "cg_clif_download" ) ;
3064
+
3065
+ /*
3066
+ let mut prepare_cargo = build_cargo();
3067
+ prepare_cargo.arg("--").arg("prepare").arg("--download-dir").arg(&download_dir);
3068
+ #[allow(deprecated)]
3069
+ builder.config.try_run(&mut prepare_cargo.into()).unwrap();
3070
+ */
3071
+
3072
+ let mut cargo = build_cargo ( ) ;
3073
+ cargo
3074
+ . arg ( "--" )
3075
+ . arg ( "test" )
3076
+ . arg ( "--download-dir" )
3077
+ . arg ( & download_dir)
3078
+ . arg ( "--out-dir" )
3079
+ . arg ( builder. stage_out ( compiler, Mode :: ToolRustc ) . join ( "cg_clif" ) )
3080
+ . arg ( "--no-unstable-features" )
3081
+ . arg ( "--use-backend" )
3082
+ . arg ( "cranelift" )
3083
+ // Avoid having to vendor the standard library dependencies
3084
+ . arg ( "--sysroot" )
3085
+ . arg ( "llvm" )
3086
+ // These tests depend on crates that are not yet vendored
3087
+ // FIXME remove once vendoring is handled
3088
+ . arg ( "--skip-test" )
3089
+ . arg ( "testsuite.extended_sysroot" ) ;
3090
+ cargo. args ( builder. config . test_args ( ) ) ;
3091
+
3092
+ #[ allow( deprecated) ]
3093
+ builder. config . try_run ( & mut cargo. into ( ) ) . unwrap ( ) ;
3094
+ }
3095
+ }
0 commit comments