Skip to content

Commit 8df4a76

Browse files
author
Jorge Aparicio
committed
rustbuild: per target musl-root
config.toml now accepts a target.$TARGET.musl-root key that lets you override the "build" musl-root value, which is set via the --musl-root flag or via the build.musl-root key. With this change, it's now possible to compile std for several musl targets at once. Here's are the sample commands to do such thing: ``` $ configure \ --enable-rustbuild \ --target=x86_64-unknown-linux-musl,arm-unknown-linux-musleabi \ --musl-root=/musl/x86_64-unknown-linux-musl/ $ edit config.toml && tail config.toml [target.arm-unknown-linux-musleabi] musl-root = "/x-tools/arm-unknown-linux-musleabi/arm-unknown-linux-musleabi/sysroot/usr" $ make ```
1 parent e77d86c commit 8df4a76

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

src/bootstrap/compile.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
5959
cargo.env("JEMALLOC_OVERRIDE", jemalloc);
6060
}
6161
}
62-
if let Some(ref p) = build.config.musl_root {
63-
if target.contains("musl") {
62+
if target.contains("musl") {
63+
if let Some(p) = build.config.target_config[target].musl_root.as_ref()
64+
.or(build.config.musl_root.as_ref()) {
6465
cargo.env("MUSL_ROOT", p);
6566
}
6667
}

src/bootstrap/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pub struct Config {
7676

7777
// misc
7878
pub channel: String,
79+
// Fallback musl-root for all targets
7980
pub musl_root: Option<PathBuf>,
8081
pub prefix: Option<String>,
8182
pub codegen_tests: bool,
@@ -89,6 +90,7 @@ pub struct Target {
8990
pub cc: Option<PathBuf>,
9091
pub cxx: Option<PathBuf>,
9192
pub ndk: Option<PathBuf>,
93+
pub musl_root: Option<PathBuf>,
9294
}
9395

9496
/// Structure of the `config.toml` file that configuration is read from.

src/bootstrap/sanity.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,9 @@ pub fn check(build: &mut Build) {
111111

112112
// Make sure musl-root is valid if specified
113113
if target.contains("musl") && !target.contains("mips") {
114-
match build.config.musl_root {
115-
Some(ref root) => {
114+
match build.config.target_config[target].musl_root.as_ref()
115+
.or(build.config.musl_root.as_ref()) {
116+
Some(root) => {
116117
if fs::metadata(root.join("lib/libc.a")).is_err() {
117118
panic!("couldn't find libc.a in musl dir: {}",
118119
root.join("lib").display());
@@ -123,8 +124,9 @@ pub fn check(build: &mut Build) {
123124
}
124125
}
125126
None => {
126-
panic!("when targeting MUSL the build.musl-root option \
127-
must be specified in config.toml")
127+
panic!("when targeting MUSL either the build.musl-root \
128+
option or the target.$TARGET.musl-root one must \
129+
be specified in config.toml")
128130
}
129131
}
130132
}

0 commit comments

Comments
 (0)