Skip to content

Commit 8606782

Browse files
committed
Infer a default musl_root for native builds
1 parent 1757a87 commit 8606782

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/bootstrap/sanity.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,15 @@ pub fn check(build: &mut Build) {
151151
panic!("the iOS target is only supported on macOS");
152152
}
153153

154-
// Make sure musl-root is valid if specified
154+
// Make sure musl-root is valid
155155
if target.contains("musl") && !target.contains("mips") {
156+
// If this is a native target (host is also musl) and no musl-root is given,
157+
// fall back to the system toolchain in /usr before giving up
158+
if build.musl_root(*target).is_none() && build.config.build == *target {
159+
let target = build.config.target_config.entry(target.clone())
160+
.or_insert(Default::default());
161+
target.musl_root = Some("/usr".into());
162+
}
156163
match build.musl_root(*target) {
157164
Some(root) => {
158165
if fs::metadata(root.join("lib/libc.a")).is_err() {

0 commit comments

Comments
 (0)