recipes: devel/rust: Downgraded to version 1.64.0
[dragora.git] / patches / rust / void / 0013-allow-specifying-native-sysroot-to-use-for-linkage.patch
blob2414d72380b6a8c8652e4ce749d010e86eb6ad56
1 From 236c0272667d69380d03984cfa8bad44b033fd69 Mon Sep 17 00:00:00 2001
2 From: Daniel Kolesa <daniel@octaforge.org>
3 Date: Tue, 21 Dec 2021 02:46:30 +0100
4 Subject: [PATCH 13/15] allow specifying native sysroot to use for linkage
6 This allows us to get around the linker attempting to use
7 incompatible libs.
8 ---
9 src/bootstrap/builder.rs | 4 ++++
10 src/bootstrap/config.rs | 3 +++
11 src/bootstrap/lib.rs | 4 ++++
12 3 files changed, 11 insertions(+)
14 diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
15 index 6a02a225c..483aa8818 100644
16 --- a/src/bootstrap/builder.rs
17 +++ b/src/bootstrap/builder.rs
18 @@ -1708,6 +1708,10 @@ impl<'a> Builder<'a> {
22 + if let Some(sysroot) = self.native_sysroot(target) {
23 + rustflags.arg(&format!("-Clink-args=--sysroot={}", sysroot.display()));
24 + }
26 if let Some(host_linker) = self.linker(compiler.host) {
27 cargo.env("RUSTC_HOST_LINKER", host_linker);
29 diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
30 index 18a764689..f8b9bbd96 100644
31 --- a/src/bootstrap/config.rs
32 +++ b/src/bootstrap/config.rs
33 @@ -395,6 +395,7 @@ pub struct Target {
34 pub ranlib: Option<PathBuf>,
35 pub default_linker: Option<PathBuf>,
36 pub linker: Option<PathBuf>,
37 + pub sysroot: Option<PathBuf>,
38 pub ndk: Option<PathBuf>,
39 pub sanitizers: Option<bool>,
40 pub profiler: Option<bool>,
41 @@ -723,6 +724,7 @@ define_config! {
42 ranlib: Option<String> = "ranlib",
43 default_linker: Option<PathBuf> = "default-linker",
44 linker: Option<String> = "linker",
45 + sysroot: Option<String> = "sysroot",
46 llvm_config: Option<String> = "llvm-config",
47 llvm_filecheck: Option<String> = "llvm-filecheck",
48 llvm_libunwind: Option<String> = "llvm-libunwind",
49 @@ -1156,6 +1158,7 @@ impl Config {
50 target.ar = cfg.ar.map(PathBuf::from);
51 target.ranlib = cfg.ranlib.map(PathBuf::from);
52 target.linker = cfg.linker.map(PathBuf::from);
53 + target.sysroot = cfg.sysroot.map(PathBuf::from);
54 target.crt_static = cfg.crt_static;
55 target.wasi_root = cfg.wasi_root.map(PathBuf::from);
56 target.qemu_rootfs = cfg.qemu_rootfs.map(PathBuf::from);
57 diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
58 index 0a7012dbd..cded50d20 100644
59 --- a/src/bootstrap/lib.rs
60 +++ b/src/bootstrap/lib.rs
61 @@ -1152,6 +1152,10 @@ impl Build {
62 self.config.target_config.get(&target).and_then(|t| t.crt_static)
66 + fn native_sysroot(&self, target: TargetSelection) -> Option<&Path> {
67 + self.config.target_config.get(&target).and_then(|c| c.sysroot.as_ref()).map(|p| &**p)
68 + }
70 /// Returns the sysroot for the wasi target, if defined
71 fn wasi_root(&self, target: TargetSelection) -> Option<&Path> {
72 --
73 2.37.2