Skip to content

Commit 51ef2b3

Browse files
committed
rustbuild: Fix bug preventing per-target musl-root
In #36292, support was added to target musl libc for ARM targets using rustbuild. Specifically, that change allowed the addition of per-target "musl-root" options in the rustbuild config.toml so that multiple targets depending on musl could be built. However, that implementation contained a couple of omissions: the musl-root option was added to the config, but was never added to the TOML parsing, and therefore was not actually being loaded from config.toml. This commit rectifies that and allows successful building of musl-based ARM targets.
1 parent ff71346 commit 51ef2b3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/bootstrap/compile.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,16 @@ pub fn std_link(build: &Build,
9090
add_to_sysroot(&out_dir, &libdir);
9191

9292
if target.contains("musl") && !target.contains("mips") {
93-
copy_musl_third_party_objects(build, &libdir);
93+
copy_musl_third_party_objects(build, target, &libdir);
9494
}
9595
}
9696

9797
/// Copies the crt(1,i,n).o startup objects
9898
///
9999
/// Only required for musl targets that statically link to libc
100-
fn copy_musl_third_party_objects(build: &Build, into: &Path) {
100+
fn copy_musl_third_party_objects(build: &Build, target: &str, into: &Path) {
101101
for &obj in &["crt1.o", "crti.o", "crtn.o"] {
102-
copy(&build.config.musl_root.as_ref().unwrap().join("lib").join(obj), &into.join(obj));
102+
copy(&build.musl_root(target).unwrap().join("lib").join(obj), &into.join(obj));
103103
}
104104
}
105105

src/bootstrap/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ struct TomlTarget {
158158
cc: Option<String>,
159159
cxx: Option<String>,
160160
android_ndk: Option<String>,
161+
musl_root: Option<String>,
161162
}
162163

163164
impl Config {
@@ -268,6 +269,7 @@ impl Config {
268269
}
269270
target.cxx = cfg.cxx.clone().map(PathBuf::from);
270271
target.cc = cfg.cc.clone().map(PathBuf::from);
272+
target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
271273

272274
config.target_config.insert(triple.clone(), target);
273275
}

0 commit comments

Comments
 (0)