Skip to content

Commit

Permalink
rustbuild: Fix bug preventing per-target musl-root
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nastevens committed Oct 5, 2016
1 parent ff71346 commit 51ef2b3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/bootstrap/compile.rs
Expand Up @@ -90,16 +90,16 @@ pub fn std_link(build: &Build,
add_to_sysroot(&out_dir, &libdir);

if target.contains("musl") && !target.contains("mips") {
copy_musl_third_party_objects(build, &libdir);
copy_musl_third_party_objects(build, target, &libdir);
}
}

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

Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/config.rs
Expand Up @@ -158,6 +158,7 @@ struct TomlTarget {
cc: Option<String>,
cxx: Option<String>,
android_ndk: Option<String>,
musl_root: Option<String>,
}

impl Config {
Expand Down Expand Up @@ -268,6 +269,7 @@ impl Config {
}
target.cxx = cfg.cxx.clone().map(PathBuf::from);
target.cc = cfg.cc.clone().map(PathBuf::from);
target.musl_root = cfg.musl_root.clone().map(PathBuf::from);

config.target_config.insert(triple.clone(), target);
}
Expand Down

0 comments on commit 51ef2b3

Please sign in to comment.