File tree Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Expand file tree Collapse file tree 2 files changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -338,12 +338,6 @@ than building it.
338
338
339
339
// Make sure musl-root is valid.
340
340
if target. contains ( "musl" ) && !target. contains ( "unikraft" ) {
341
- // If this is a native target (host is also musl) and no musl-root is given,
342
- // fall back to the system toolchain in /usr before giving up
343
- if build. musl_root ( * target) . is_none ( ) && build. config . is_host_target ( * target) {
344
- let target = build. config . target_config . entry ( * target) . or_default ( ) ;
345
- target. musl_root = Some ( "/usr" . into ( ) ) ;
346
- }
347
341
match build. musl_libdir ( * target) {
348
342
Some ( libdir) => {
349
343
if fs:: metadata ( libdir. join ( "libc.a" ) ) . is_err ( ) {
Original file line number Diff line number Diff line change @@ -1329,23 +1329,33 @@ impl Build {
1329
1329
}
1330
1330
}
1331
1331
1332
- /// Returns the "musl root" for this `target`, if defined
1332
+ /// Returns the "musl root" for this `target`, if defined.
1333
+ ///
1334
+ /// If this is a native target (host is also musl) and no musl-root is given,
1335
+ /// it falls back to the system toolchain in /usr.
1333
1336
fn musl_root ( & self , target : TargetSelection ) -> Option < & Path > {
1334
- self . config
1337
+ let configured_root = self
1338
+ . config
1335
1339
. target_config
1336
1340
. get ( & target)
1337
1341
. and_then ( |t| t. musl_root . as_ref ( ) )
1338
1342
. or ( self . config . musl_root . as_ref ( ) )
1339
- . map ( |p| & * * p)
1343
+ . map ( |p| & * * p) ;
1344
+
1345
+ if self . config . is_host_target ( target) && configured_root. is_none ( ) {
1346
+ Some ( Path :: new ( "/usr" ) )
1347
+ } else {
1348
+ configured_root
1349
+ }
1340
1350
}
1341
1351
1342
1352
/// Returns the "musl libdir" for this `target`.
1343
1353
fn musl_libdir ( & self , target : TargetSelection ) -> Option < PathBuf > {
1344
- let t = self . config . target_config . get ( & target ) ? ;
1345
- if let libdir @ Some ( _ ) = & t . musl_libdir {
1346
- return libdir . clone ( ) ;
1347
- }
1348
- self . musl_root ( target) . map ( |root| root. join ( "lib" ) )
1354
+ self . config
1355
+ . target_config
1356
+ . get ( & target )
1357
+ . and_then ( |t| t . musl_libdir . clone ( ) )
1358
+ . or_else ( || self . musl_root ( target) . map ( |root| root. join ( "lib" ) ) )
1349
1359
}
1350
1360
1351
1361
/// Returns the `lib` directory for the WASI target specified, if
You can’t perform that action at this time.
0 commit comments