Skip to content

Commit 8cfc69e

Browse files
author
Jorge Aparicio
committed
add utility musl_root method, update config.toml.example
1 parent 8df4a76 commit 8cfc69e

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

src/bootstrap/compile.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ pub fn std<'a>(build: &'a Build, target: &str, compiler: &Compiler<'a>) {
6060
}
6161
}
6262
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()) {
63+
if let Some(p) = build.musl_root(target) {
6564
cargo.env("MUSL_ROOT", p);
6665
}
6766
}

src/bootstrap/config.toml.example

+6-4
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@
115115
# nightly features
116116
#channel = "dev"
117117

118-
# The root location of the MUSL installation directory. The library directory
119-
# will also need to contain libunwind.a for an unwinding implementation.
120-
#musl-root = "..."
121-
122118
# By default the `rustc` executable is built with `-Wl,-rpath` flags on Unix
123119
# platforms to ensure that the compiler is usable by default from the build
124120
# directory (as it links to a number of dynamic libraries). This may not be
@@ -160,3 +156,9 @@
160156
# the NDK for the target lives. This is used to find the C compiler to link and
161157
# build native code.
162158
#android-ndk = "/path/to/ndk"
159+
160+
# The root location of the MUSL installation directory. The library directory
161+
# will also need to contain libunwind.a for an unwinding implementation. Note
162+
# that this option only makes sense for MUSL targets that produce statically
163+
# linked binaries
164+
#musl-root = "..."

src/bootstrap/lib.rs

+7
Original file line numberDiff line numberDiff line change
@@ -977,6 +977,13 @@ impl Build {
977977
}
978978
return base
979979
}
980+
981+
/// Returns the "musl root" for this `target`, if defined
982+
fn musl_root(&self, target: &str) -> Option<&Path> {
983+
self.config.target_config[target].musl_root.as_ref()
984+
.or(self.config.musl_root.as_ref())
985+
.map(|p| &**p)
986+
}
980987
}
981988

982989
impl<'a> Compiler<'a> {

src/bootstrap/sanity.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ 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.target_config[target].musl_root.as_ref()
115-
.or(build.config.musl_root.as_ref()) {
114+
match build.musl_root(target) {
116115
Some(root) => {
117116
if fs::metadata(root.join("lib/libc.a")).is_err() {
118117
panic!("couldn't find libc.a in musl dir: {}",

0 commit comments

Comments
 (0)