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.
338338
339339 // Make sure musl-root is valid.
340340 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- }
347341 match build. musl_libdir ( * target) {
348342 Some ( libdir) => {
349343 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 {
13291329 }
13301330 }
13311331
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.
13331336 fn musl_root ( & self , target : TargetSelection ) -> Option < & Path > {
1334- self . config
1337+ let configured_root = self
1338+ . config
13351339 . target_config
13361340 . get ( & target)
13371341 . and_then ( |t| t. musl_root . as_ref ( ) )
13381342 . 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+ return Some ( Path :: new ( "/usr" ) ) ;
1347+ } else {
1348+ configured_root
1349+ }
13401350 }
13411351
13421352 /// Returns the "musl libdir" for this `target`.
13431353 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" ) ) )
13491359 }
13501360
13511361 /// Returns the `lib` directory for the WASI target specified, if
You can’t perform that action at this time.
0 commit comments