67 lines
3.0 KiB
Diff
67 lines
3.0 KiB
Diff
From 236c0272667d69380d03984cfa8bad44b033fd69 Mon Sep 17 00:00:00 2001
|
|
From: Daniel Kolesa <daniel@octaforge.org>
|
|
Date: Tue, 21 Dec 2021 02:46:30 +0100
|
|
Subject: [PATCH 13/15] allow specifying native sysroot to use for linkage
|
|
|
|
This allows us to get around the linker attempting to use
|
|
incompatible libs.
|
|
|
|
diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs
|
|
index 7f93fdc72..f52644b57 100644
|
|
--- a/src/bootstrap/src/core/builder.rs
|
|
+++ b/src/bootstrap/src/core/builder.rs
|
|
@@ -2429,6 +2429,10 @@ impl Cargo {
|
|
self.hostflags.arg(&arg);
|
|
}
|
|
|
|
+ if let Some(sysroot) = builder.native_sysroot(target) {
|
|
+ self.rustflags.arg(&format!("-Clink-args=--sysroot={}", sysroot.display()));
|
|
+ }
|
|
+
|
|
if let Some(target_linker) = builder.linker(target) {
|
|
let target = crate::envify(&target.triple);
|
|
self.command.env(&format!("CARGO_TARGET_{target}_LINKER"), target_linker);
|
|
diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs
|
|
index 3e1bc9a9a..e0038b9ac 100644
|
|
--- a/src/bootstrap/src/core/config/config.rs
|
|
+++ b/src/bootstrap/src/core/config/config.rs
|
|
@@ -575,6 +575,7 @@ pub struct Target {
|
|
pub default_linker: Option<PathBuf>,
|
|
pub linker: Option<PathBuf>,
|
|
pub split_debuginfo: Option<SplitDebuginfo>,
|
|
+ pub sysroot: Option<PathBuf>,
|
|
pub sanitizers: Option<bool>,
|
|
pub profiler: Option<StringOrBool>,
|
|
pub rpath: Option<bool>,
|
|
@@ -1135,6 +1136,7 @@ define_config! {
|
|
default_linker: Option<PathBuf> = "default-linker",
|
|
linker: Option<String> = "linker",
|
|
split_debuginfo: Option<String> = "split-debuginfo",
|
|
+ sysroot: Option<String> = "sysroot",
|
|
llvm_config: Option<String> = "llvm-config",
|
|
llvm_has_rust_patches: Option<bool> = "llvm-has-rust-patches",
|
|
llvm_filecheck: Option<String> = "llvm-filecheck",
|
|
@@ -1875,6 +1877,7 @@ impl 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.musl_root = cfg.musl_root.map(PathBuf::from);
|
|
target.musl_libdir = cfg.musl_libdir.map(PathBuf::from);
|
|
diff --git a/src/bootstrap/src/lib.rs b/src/bootstrap/src/lib.rs
|
|
index 5ed6b357e..0d4392dd8 100644
|
|
--- a/src/bootstrap/src/lib.rs
|
|
+++ b/src/bootstrap/src/lib.rs
|
|
@@ -1318,6 +1318,10 @@ impl Build {
|
|
self.config.target_config.get(&target).and_then(|t| t.crt_static)
|
|
}
|
|
}
|
|
+
|
|
+ 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 "musl root" for this `target`, if defined
|
|
fn musl_root(&self, target: TargetSelection) -> Option<&Path> {
|