@@ -5,7 +5,7 @@ Contains ad hoc patches for cross building.
55From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
66From: Kleis Auke Wolthuizen <github@kleisauke.nl>
77Date: Tue, 15 Sep 2020 11:50:00 +0200
8- Subject: [PATCH 1/2 ] Add llvm-mingw i686/ARMv7 targets
8+ Subject: [PATCH 1/3 ] Add llvm-mingw i686/ARMv7 targets
99
1010Upstream-Status: Pending
1111
@@ -62,7 +62,7 @@ diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/s
6262index 1111111..2222222 100644
6363--- a/compiler/rustc_target/src/spec/mod.rs
6464+++ b/compiler/rustc_target/src/spec/mod.rs
65- @@ -1006 ,7 +1006 ,9 @@ supported_targets! {
65+ @@ -1045 ,7 +1045 ,9 @@ supported_targets! {
6666 ("x86_64-uwp-windows-gnu", x86_64_uwp_windows_gnu),
6767
6868 ("aarch64-pc-windows-gnullvm", aarch64_pc_windows_gnullvm),
@@ -76,7 +76,7 @@ index 1111111..2222222 100644
7676From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
7777From: Kleis Auke Wolthuizen <github@kleisauke.nl>
7878Date: Tue, 22 Sep 2020 10:00:00 +0200
79- Subject: [PATCH 2/2 ] Ensure that panic_unwind/unwind can be successfully built on
79+ Subject: [PATCH 2/3 ] Ensure that panic_unwind/unwind can be successfully built on
8080 llvm-mingw
8181
8282Fixes undefined symbol errors while linking these crates on llvm-mingw
@@ -129,3 +129,47 @@ index 1111111..2222222 100644
129129 link(name = "unwind", kind = "static", modifiers = "-bundle")
130130 )]
131131 extern "C" {
132+
133+ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
134+ From: Kleis Auke Wolthuizen <github@kleisauke.nl>
135+ Date: Tue, 30 Aug 2022 23:20:27 +0200
136+ Subject: [PATCH 3/3] windows-gnullvm: avoid linking to libunwind statically
137+
138+ Avoid linking against the static variant of libunwind, which is not
139+ always available. Instead, prefer to use the unwind library from the
140+ toolchain, which the linker will automatically include, depending
141+ on what's available, and depending on the -static flag.
142+
143+ diff --git a/compiler/rustc_target/src/spec/windows_gnullvm_base.rs b/compiler/rustc_target/src/spec/windows_gnullvm_base.rs
144+ index 1111111..2222222 100644
145+ --- a/compiler/rustc_target/src/spec/windows_gnullvm_base.rs
146+ +++ b/compiler/rustc_target/src/spec/windows_gnullvm_base.rs
147+ @@ -6,7 +6,7 @@ pub fn opts() -> TargetOptions {
148+ // There were attempts to make it behave like libgcc (so one can just use -l<name>)
149+ // but LLVM maintainers rejected it: https://reviews.llvm.org/D51440
150+ let pre_link_args =
151+ - TargetOptions::link_args(LinkerFlavor::Gcc, &["-nolibc", "--unwindlib=none"]);
152+ + TargetOptions::link_args(LinkerFlavor::Gcc, &["-nolibc"]);
153+ // Order of `late_link_args*` does not matter with LLD.
154+ let late_link_args = TargetOptions::link_args(
155+ LinkerFlavor::Gcc,
156+ diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs
157+ index 1111111..2222222 100644
158+ --- a/library/unwind/src/lib.rs
159+ +++ b/library/unwind/src/lib.rs
160+ @@ -3,7 +3,6 @@
161+ #![feature(link_cfg)]
162+ #![feature(staged_api)]
163+ #![feature(c_unwind)]
164+ - #![feature(cfg_target_abi)]
165+ #![cfg_attr(not(target_env = "msvc"), feature(libc))]
166+
167+ cfg_if::cfg_if! {
168+ @@ -104,7 +103,3 @@ extern "C" {}
169+ #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))]
170+ #[link(name = "unwind", kind = "static", modifiers = "-bundle")]
171+ extern "C" {}
172+ -
173+ - #[cfg(all(target_os = "windows", target_env = "gnu", target_abi = "llvm"))]
174+ - #[link(name = "unwind", kind = "static", modifiers = "-bundle")]
175+ - extern "C" {}
0 commit comments