about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJorge Aparicio <japaricious@gmail.com>2016-09-06 21:49:02 -0500
committerJorge Aparicio <japaricious@gmail.com>2016-09-06 21:49:02 -0500
commit8cfc69ecea9874ad28253ecc47d50099f9e7001e (patch)
tree9f7a4a5a0b08ebed9ec5290adb03e320edb6442e
parent8df4a768a7e98a594bd7a2d70a7bdcec14bc0518 (diff)
downloadrust-8cfc69ecea9874ad28253ecc47d50099f9e7001e.tar.gz
rust-8cfc69ecea9874ad28253ecc47d50099f9e7001e.zip
add utility musl_root method, update config.toml.example
-rw-r--r--src/bootstrap/compile.rs3
-rw-r--r--src/bootstrap/config.toml.example10
-rw-r--r--src/bootstrap/lib.rs7
-rw-r--r--src/bootstrap/sanity.rs3
4 files changed, 15 insertions, 8 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index e14317b23b4..dbb356c82e6 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -60,8 +60,7 @@ pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
         }
     }
     if target.contains("musl") {
-        if let Some(p) = build.config.target_config[target].musl_root.as_ref()
-            .or(build.config.musl_root.as_ref()) {
+        if let Some(p) = build.musl_root(target) {
             cargo.env("MUSL_ROOT", p);
         }
     }
diff --git a/src/bootstrap/config.toml.example b/src/bootstrap/config.toml.example
index 2894adafef6..1b453baa298 100644
--- a/src/bootstrap/config.toml.example
+++ b/src/bootstrap/config.toml.example
@@ -115,10 +115,6 @@
 # nightly features
 #channel = "dev"
 
-# The root location of the MUSL installation directory. The library directory
-# will also need to contain libunwind.a for an unwinding implementation.
-#musl-root = "..."
-
 # By default the `rustc` executable is built with `-Wl,-rpath` flags on Unix
 # platforms to ensure that the compiler is usable by default from the build
 # directory (as it links to a number of dynamic libraries). This may not be
@@ -160,3 +156,9 @@
 # the NDK for the target lives. This is used to find the C compiler to link and
 # build native code.
 #android-ndk = "/path/to/ndk"
+
+# The root location of the MUSL installation directory. The library directory
+# will also need to contain libunwind.a for an unwinding implementation. Note
+# that this option only makes sense for MUSL targets that produce statically
+# linked binaries
+#musl-root = "..."
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index dbf29cda492..94c14f7ea25 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -977,6 +977,13 @@ impl Build {
         }
         return base
     }
+
+    /// Returns the "musl root" for this `target`, if defined
+    fn musl_root(&self, target: &str) -> Option<&Path> {
+        self.config.target_config[target].musl_root.as_ref()
+            .or(self.config.musl_root.as_ref())
+            .map(|p| &**p)
+    }
 }
 
 impl<'a> Compiler<'a> {
diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs
index f1d7f869a96..c69f9489c30 100644
--- a/src/bootstrap/sanity.rs
+++ b/src/bootstrap/sanity.rs
@@ -111,8 +111,7 @@ pub fn check(build: &mut Build) {
 
         // Make sure musl-root is valid if specified
         if target.contains("musl") && !target.contains("mips") {
-            match build.config.target_config[target].musl_root.as_ref()
-                .or(build.config.musl_root.as_ref()) {
+            match build.musl_root(target) {
                 Some(root) => {
                     if fs::metadata(root.join("lib/libc.a")).is_err() {
                         panic!("couldn't find libc.a in musl dir: {}",