59 lines
2.5 KiB
Diff
59 lines
2.5 KiB
Diff
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
|
|
index e816f9b4..a2668fa9 100644
|
|
--- a/src/bootstrap/builder.rs
|
|
+++ b/src/bootstrap/builder.rs
|
|
@@ -1313,6 +1313,10 @@ pub fn cargo(
|
|
}
|
|
}
|
|
|
|
+ if let Some(sysroot) = self.native_sysroot(target) {
|
|
+ rustflags.arg(&format!("-Clink-args=--sysroot={}", sysroot.display()));
|
|
+ }
|
|
+
|
|
if let Some(host_linker) = self.linker(compiler.host) {
|
|
cargo.env("RUSTC_HOST_LINKER", host_linker);
|
|
}
|
|
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
|
|
index 642a5c24..0dd4f879 100644
|
|
--- a/src/bootstrap/config.rs
|
|
+++ b/src/bootstrap/config.rs
|
|
@@ -294,6 +294,7 @@ pub struct Target {
|
|
pub ranlib: Option<PathBuf>,
|
|
pub default_linker: Option<PathBuf>,
|
|
pub linker: Option<PathBuf>,
|
|
+ pub sysroot: Option<PathBuf>,
|
|
pub ndk: Option<PathBuf>,
|
|
pub sanitizers: Option<bool>,
|
|
pub profiler: Option<bool>,
|
|
@@ -621,6 +622,7 @@ struct TomlTarget {
|
|
ranlib: Option<String> = "ranlib",
|
|
default_linker: Option<PathBuf> = "default-linker",
|
|
linker: Option<String> = "linker",
|
|
+ sysroot: Option<String> = "sysroot",
|
|
llvm_config: Option<String> = "llvm-config",
|
|
llvm_filecheck: Option<String> = "llvm-filecheck",
|
|
android_ndk: Option<String> = "android-ndk",
|
|
@@ -1051,6 +1053,7 @@ pub fn parse(args: &[String]) -> Config {
|
|
target.ar = cfg.ar.map(PathBuf::from);
|
|
target.ranlib = cfg.ranlib.map(PathBuf::from);
|
|
target.linker = cfg.linker.map(PathBuf::from);
|
|
+ target.sysroot = cfg.sysroot.map(PathBuf::from);
|
|
target.crt_static = cfg.crt_static;
|
|
target.wasi_root = cfg.wasi_root.map(PathBuf::from);
|
|
target.qemu_rootfs = cfg.qemu_rootfs.map(PathBuf::from);
|
|
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
|
|
index f3d5f308..7f8b9b27 100644
|
|
--- a/src/bootstrap/lib.rs
|
|
+++ b/src/bootstrap/lib.rs
|
|
@@ -1125,6 +1125,10 @@ fn crt_static(&self, target: TargetSelection) -> Option<bool> {
|
|
}
|
|
}
|
|
|
|
+ fn native_sysroot(&self, target: TargetSelection) -> Option<&Path> {
|
|
+ self.config.target_config.get(&target).and_then(|c| c.sysroot.as_ref()).map(|p| &**p)
|
|
+ }
|
|
+
|
|
/// Returns the sysroot for the wasi target, if defined
|
|
fn wasi_root(&self, target: TargetSelection) -> Option<&Path> {
|
|
self.config.target_config.get(&target).and_then(|t| t.wasi_root.as_ref()).map(|p| &**p)
|