@@ -129,7 +129,8 @@ fn build_sysroot_for_triple(
129
129
sysroot_kind : SysrootKind ,
130
130
) -> SysrootTarget {
131
131
match sysroot_kind {
132
- SysrootKind :: None => SysrootTarget { triple : compiler. triple , libs : vec ! [ ] } ,
132
+ SysrootKind :: None => build_rtstartup ( dirs, & compiler)
133
+ . unwrap_or ( SysrootTarget { triple : compiler. triple , libs : vec ! [ ] } ) ,
133
134
SysrootKind :: Llvm => build_llvm_sysroot_for_triple ( compiler) ,
134
135
SysrootKind :: Clif => {
135
136
build_clif_sysroot_for_triple ( dirs, channel, compiler, & cg_clif_dylib_path)
@@ -198,31 +199,10 @@ fn build_clif_sysroot_for_triple(
198
199
199
200
let mut target_libs = SysrootTarget { triple : compiler. triple . clone ( ) , libs : vec ! [ ] } ;
200
201
201
- if compiler. triple . ends_with ( "windows-gnu" ) {
202
- eprintln ! ( "[BUILD] rtstartup for {}" , compiler. triple) ;
203
-
204
- RTSTARTUP_SYSROOT . ensure_fresh ( dirs) ;
205
-
206
- let rtstartup_src = SYSROOT_SRC . to_path ( dirs) . join ( "library" ) . join ( "rtstartup" ) ;
207
- let mut rtstartup_target_libs =
208
- SysrootTarget { triple : compiler. triple . clone ( ) , libs : vec ! [ ] } ;
209
-
210
- for file in [ "rsbegin" , "rsend" ] {
211
- let obj = RTSTARTUP_SYSROOT . to_path ( dirs) . join ( format ! ( "{file}.o" ) ) ;
212
- let mut build_rtstartup_cmd = Command :: new ( & compiler. rustc ) ;
213
- build_rtstartup_cmd
214
- . arg ( "--target" )
215
- . arg ( & compiler. triple )
216
- . arg ( "--emit=obj" )
217
- . arg ( "-o" )
218
- . arg ( & obj)
219
- . arg ( rtstartup_src. join ( format ! ( "{file}.rs" ) ) ) ;
220
- spawn_and_wait ( build_rtstartup_cmd) ;
221
- rtstartup_target_libs. libs . push ( obj. clone ( ) ) ;
222
- target_libs. libs . push ( obj) ;
223
- }
224
-
202
+ if let Some ( rtstartup_target_libs) = build_rtstartup ( dirs, & compiler) {
225
203
rtstartup_target_libs. install_into_sysroot ( & RTSTARTUP_SYSROOT . to_path ( dirs) ) ;
204
+
205
+ target_libs. libs . extend ( rtstartup_target_libs. libs ) ;
226
206
}
227
207
228
208
let build_dir = STANDARD_LIBRARY . target_dir ( dirs) . join ( & compiler. triple ) . join ( channel) ;
@@ -266,3 +246,30 @@ fn build_clif_sysroot_for_triple(
266
246
267
247
target_libs
268
248
}
249
+
250
+ fn build_rtstartup ( dirs : & Dirs , compiler : & Compiler ) -> Option < SysrootTarget > {
251
+ if !compiler. triple . ends_with ( "windows-gnu" ) {
252
+ return None ;
253
+ }
254
+
255
+ RTSTARTUP_SYSROOT . ensure_fresh ( dirs) ;
256
+
257
+ let rtstartup_src = SYSROOT_SRC . to_path ( dirs) . join ( "library" ) . join ( "rtstartup" ) ;
258
+ let mut target_libs = SysrootTarget { triple : compiler. triple . clone ( ) , libs : vec ! [ ] } ;
259
+
260
+ for file in [ "rsbegin" , "rsend" ] {
261
+ let obj = RTSTARTUP_SYSROOT . to_path ( dirs) . join ( format ! ( "{file}.o" ) ) ;
262
+ let mut build_rtstartup_cmd = Command :: new ( & compiler. rustc ) ;
263
+ build_rtstartup_cmd
264
+ . arg ( "--target" )
265
+ . arg ( & compiler. triple )
266
+ . arg ( "--emit=obj" )
267
+ . arg ( "-o" )
268
+ . arg ( & obj)
269
+ . arg ( rtstartup_src. join ( format ! ( "{file}.rs" ) ) ) ;
270
+ spawn_and_wait ( build_rtstartup_cmd) ;
271
+ target_libs. libs . push ( obj. clone ( ) ) ;
272
+ }
273
+
274
+ Some ( target_libs)
275
+ }
0 commit comments