File tree 3 files changed +14
-2
lines changed 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -339,7 +339,7 @@ fn copy_self_contained_objects(
339
339
// to using gcc from a glibc-targeting toolchain for linking.
340
340
// To do that we have to distribute musl startup objects as a part of Rust toolchain
341
341
// and link with them manually in the self-contained mode.
342
- if target. contains ( "musl" ) && !target . contains ( "unikraft" ) {
342
+ if target. needs_crt_begin_end ( ) {
343
343
let srcdir = builder. musl_libdir ( target) . unwrap_or_else ( || {
344
344
panic ! ( "Target {:?} does not have a \" musl-libdir\" key" , target. triple)
345
345
} ) ;
Original file line number Diff line number Diff line change @@ -1295,11 +1295,19 @@ impl Step for CrtBeginEnd {
1295
1295
}
1296
1296
1297
1297
fn make_run ( run : RunConfig < ' _ > ) {
1298
- run. builder . ensure ( CrtBeginEnd { target : run. target } ) ;
1298
+ if run. target . needs_crt_begin_end ( ) {
1299
+ run. builder . ensure ( CrtBeginEnd { target : run. target } ) ;
1300
+ }
1299
1301
}
1300
1302
1301
1303
/// Build crtbegin.o/crtend.o for musl target.
1302
1304
fn run ( self , builder : & Builder < ' _ > ) -> Self :: Output {
1305
+ assert ! (
1306
+ self . target. needs_crt_begin_end( ) ,
1307
+ "tried to build crtbegin.o and crtend.o for the wrong target ({})" ,
1308
+ self . target
1309
+ ) ;
1310
+
1303
1311
builder. require_submodule (
1304
1312
"src/llvm-project" ,
1305
1313
Some ( "The LLVM sources are required for the CRT from `compiler-rt`." ) ,
Original file line number Diff line number Diff line change @@ -573,6 +573,10 @@ impl TargetSelection {
573
573
env:: var ( "OSTYPE" ) . is_ok_and ( |v| v. to_lowercase ( ) . contains ( "cygwin" ) )
574
574
}
575
575
576
+ pub fn needs_crt_begin_end ( & self ) -> bool {
577
+ self . contains ( "musl" ) && !self . contains ( "unikraft" )
578
+ }
579
+
576
580
/// Path to the file defining the custom target, if any.
577
581
pub fn filepath ( & self ) -> Option < & Path > {
578
582
self . file . as_ref ( ) . map ( Path :: new)
You can’t perform that action at this time.
0 commit comments