# build native code.
#android-ndk = "/path/to/ndk"
+# Force static or dynamic linkage of the standard library for this target. If
+# this target is a host for rustc, this will also affect the linkage of the
+# compiler itself. This is useful for building rustc on targets that normally
+# only use static libraries. If unset, the target's default linkage is used.
+#crt-static = false
+
# 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
cmd.arg("-C").arg("target-feature=+crt-static");
}
+ if let Ok(s) = env::var("RUSTC_CRT_STATIC") {
+ if s == "true" {
+ cmd.arg("-C").arg("target-feature=+crt-static");
+ }
+ if s == "false" {
+ cmd.arg("-C").arg("target-feature=-crt-static");
+ }
+ }
+
// Force all crates compiled by this compiler to (a) be unstable and (b)
// allow the `rustc_private` feature to link to other unstable crates
// also in the sysroot.
cargo.env("RUSTC_METADATA_SUFFIX", "rustc");
}
+ if let Some(x) = self.crt_static(target) {
+ cargo.env("RUSTC_CRT_STATIC", x.to_string());
+ }
+
// Enable usage of unstable features
cargo.env("RUSTC_BOOTSTRAP", "1");
self.add_rust_test_threads(&mut cargo);
pub cc: Option<PathBuf>,
pub cxx: Option<PathBuf>,
pub ndk: Option<PathBuf>,
+ pub crt_static: Option<bool>,
pub musl_root: Option<PathBuf>,
pub qemu_rootfs: Option<PathBuf>,
}
cc: Option<String>,
cxx: Option<String>,
android_ndk: Option<String>,
+ crt_static: Option<bool>,
musl_root: Option<String>,
qemu_rootfs: Option<String>,
}
}
target.cxx = cfg.cxx.clone().map(PathBuf::from);
target.cc = cfg.cc.clone().map(PathBuf::from);
+ target.crt_static = cfg.crt_static.clone();
target.musl_root = cfg.musl_root.clone().map(PathBuf::from);
target.qemu_rootfs = cfg.qemu_rootfs.clone().map(PathBuf::from);
base
}
+ /// Returns if this target should statically link the C runtime, if specified
+ fn crt_static(&self, target: Interned<String>) -> Option<bool> {
+ self.config.target_config.get(&target)
+ .and_then(|t| t.crt_static)
+ }
+
/// Returns the "musl root" for this `target`, if defined
fn musl_root(&self, target: Interned<String>) -> Option<&Path> {
self.config.target_config.get(&target)