67 lines
2.9 KiB
Diff
67 lines
2.9 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 e18096443..b48742ae4 100644
|
|
--- a/src/bootstrap/src/core/builder.rs
|
|
+++ b/src/bootstrap/src/core/builder.rs
|
|
@@ -1706,6 +1706,10 @@ impl<'a> Builder<'a> {
|
|
hostflags.arg(&arg);
|
|
}
|
|
|
|
+ if let Some(sysroot) = self.native_sysroot(target) {
|
|
+ rustflags.arg(&format!("-Clink-args=--sysroot={}", sysroot.display()));
|
|
+ }
|
|
+
|
|
if let Some(target_linker) = self.linker(target) {
|
|
let target = crate::envify(&target.triple);
|
|
cargo.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 f1e1b89d9..30e61161d 100644
|
|
--- a/src/bootstrap/src/core/config/config.rs
|
|
+++ b/src/bootstrap/src/core/config/config.rs
|
|
@@ -570,6 +570,7 @@ pub struct Target {
|
|
pub ranlib: Option<PathBuf>,
|
|
pub default_linker: Option<PathBuf>,
|
|
pub linker: Option<PathBuf>,
|
|
+ pub sysroot: Option<PathBuf>,
|
|
pub sanitizers: Option<bool>,
|
|
pub profiler: Option<StringOrBool>,
|
|
pub rpath: Option<bool>,
|
|
@@ -1123,6 +1124,7 @@ define_config! {
|
|
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_has_rust_patches: Option<bool> = "llvm-has-rust-patches",
|
|
llvm_filecheck: Option<String> = "llvm-filecheck",
|
|
@@ -1826,6 +1828,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 871318de5..96abbe721 100644
|
|
--- a/src/bootstrap/src/lib.rs
|
|
+++ b/src/bootstrap/src/lib.rs
|
|
@@ -1289,6 +1289,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> {
|