Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rustbuild: per target musl-root #36292

Merged
merged 2 commits into from
Sep 8, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
cargo.env("JEMALLOC_OVERRIDE", jemalloc);
}
}
if let Some(ref p) = build.config.musl_root {
if target.contains("musl") {
if target.contains("musl") {
if let Some(p) = build.config.target_config[target].musl_root.as_ref()
.or(build.config.musl_root.as_ref()) {
cargo.env("MUSL_ROOT", p);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub struct Config {

// misc
pub channel: String,
// Fallback musl-root for all targets
pub musl_root: Option<PathBuf>,
pub prefix: Option<String>,
pub codegen_tests: bool,
Expand All @@ -89,6 +90,7 @@ pub struct Target {
pub cc: Option<PathBuf>,
pub cxx: Option<PathBuf>,
pub ndk: Option<PathBuf>,
pub musl_root: Option<PathBuf>,
}

/// Structure of the `config.toml` file that configuration is read from.
Expand Down
10 changes: 6 additions & 4 deletions src/bootstrap/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,9 @@ pub fn check(build: &mut Build) {

// Make sure musl-root is valid if specified
if target.contains("musl") && !target.contains("mips") {
match build.config.musl_root {
Some(ref root) => {
match build.config.target_config[target].musl_root.as_ref()
.or(build.config.musl_root.as_ref()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this logic with .or could be a helper method on Build?

Some(root) => {
if fs::metadata(root.join("lib/libc.a")).is_err() {
panic!("couldn't find libc.a in musl dir: {}",
root.join("lib").display());
Expand All @@ -123,8 +124,9 @@ pub fn check(build: &mut Build) {
}
}
None => {
panic!("when targeting MUSL the build.musl-root option \
must be specified in config.toml")
panic!("when targeting MUSL either the build.musl-root \
option or the target.$TARGET.musl-root one must \
be specified in config.toml")
}
}
}
Expand Down