@@ -48,42 +48,13 @@ pub fn main() {
4848 // The target dir is expected in the default location. Guard against the user changing it.
4949 env:: set_var ( "CARGO_TARGET_DIR" , "target" ) ;
5050
51-
52- let host_triple = if let Ok ( host_triple) = std:: env:: var ( "HOST_TRIPLE" ) {
53- host_triple
54- } else if let Some ( host_triple) = config:: get_value ( "host" ) {
55- host_triple
56- } else {
57- rustc_info:: get_host_triple ( )
58- } ;
59- let target_triple = if let Ok ( target_triple) = std:: env:: var ( "TARGET_TRIPLE" ) {
60- if target_triple != "" {
61- target_triple
62- } else {
63- host_triple. clone ( ) // Empty target triple can happen on GHA
64- }
65- } else if let Some ( target_triple) = config:: get_value ( "target" ) {
66- target_triple
67- } else {
68- host_triple. clone ( )
69- } ;
70-
71- if target_triple. ends_with ( "-msvc" ) {
72- eprintln ! ( "The MSVC toolchain is not yet supported by rustc_codegen_cranelift." ) ;
73- eprintln ! ( "Switch to the MinGW toolchain for Windows support." ) ;
74- eprintln ! ( "Hint: You can use `rustup set default-host x86_64-pc-windows-gnu` to" ) ;
75- eprintln ! ( "set the global default target to MinGW" ) ;
76- process:: exit ( 1 ) ;
77- }
78-
79-
8051 let mut args = env:: args ( ) . skip ( 1 ) ;
8152 let command = match args. next ( ) . as_deref ( ) {
8253 Some ( "prepare" ) => {
8354 if args. next ( ) . is_some ( ) {
8455 arg_error ! ( "./y.rs prepare doesn't expect arguments" ) ;
8556 }
86- prepare:: prepare ( & host_triple ) ;
57+ prepare:: prepare ( ) ;
8758 process:: exit ( 0 ) ;
8859 }
8960 Some ( "build" ) => Command :: Build ,
@@ -124,6 +95,33 @@ pub fn main() {
12495 }
12596 target_dir = std:: env:: current_dir ( ) . unwrap ( ) . join ( target_dir) ;
12697
98+ let host_triple = if let Ok ( host_triple) = std:: env:: var ( "HOST_TRIPLE" ) {
99+ host_triple
100+ } else if let Some ( host_triple) = config:: get_value ( "host" ) {
101+ host_triple
102+ } else {
103+ rustc_info:: get_host_triple ( )
104+ } ;
105+ let target_triple = if let Ok ( target_triple) = std:: env:: var ( "TARGET_TRIPLE" ) {
106+ if target_triple != "" {
107+ target_triple
108+ } else {
109+ host_triple. clone ( ) // Empty target triple can happen on GHA
110+ }
111+ } else if let Some ( target_triple) = config:: get_value ( "target" ) {
112+ target_triple
113+ } else {
114+ host_triple. clone ( )
115+ } ;
116+
117+ if target_triple. ends_with ( "-msvc" ) {
118+ eprintln ! ( "The MSVC toolchain is not yet supported by rustc_codegen_cranelift." ) ;
119+ eprintln ! ( "Switch to the MinGW toolchain for Windows support." ) ;
120+ eprintln ! ( "Hint: You can use `rustup set default-host x86_64-pc-windows-gnu` to" ) ;
121+ eprintln ! ( "set the global default target to MinGW" ) ;
122+ process:: exit ( 1 ) ;
123+ }
124+
127125 let cg_clif_build_dir = build_backend:: build_backend ( channel, & host_triple, use_unstable_features) ;
128126 match command {
129127 Command :: Test => {
0 commit comments