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