void-packages/srcpkgs/rust/patches/native-sysroot.patch
q66 ce3b8aef99 rust: update to 1.57.0
- separate bootstrap into packages (cleans up template mess)
- sync patches from chimera linux (only relevant ones)
- drop bootstrap for BE ppc musl targets i don't do anymore
- some minor patch updates from ericonr

Closes https://github.com/void-linux/void-packages/pull/32555
2022-01-04 16:51:10 +01:00

67 lines
2.5 KiB
Diff

commit 57ed964d186212739fa436f103bd923a2309f341
Author: Daniel Kolesa <daniel@octaforge.org>
Date: Tue Dec 21 02:46:30 2021 +0100
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/builder.rs b/src/bootstrap/builder.rs
index de771280e..5faaf9439 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -1166,6 +1166,10 @@ impl<'a> Builder<'a> {
}
}
+ 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 06b7a8c55..d8e9275ad 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -292,6 +292,7 @@ pub struct Target {
pub ar: Option<PathBuf>,
pub ranlib: Option<PathBuf>,
pub linker: Option<PathBuf>,
+ pub sysroot: Option<PathBuf>,
pub ndk: Option<PathBuf>,
pub sanitizers: Option<bool>,
pub profiler: Option<bool>,
@@ -525,6 +526,7 @@ struct TomlTarget {
ar: Option<String>,
ranlib: Option<String>,
linker: Option<String>,
+ sysroot: Option<String>,
llvm_config: Option<String>,
llvm_filecheck: Option<String>,
android_ndk: Option<String>,
@@ -909,6 +911,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.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 b930f3cd7..06e782520 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -1056,6 +1056,10 @@ impl Build {
}
}
+ 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)