Skip to content

Commit 0243152

Browse files
committed
1 parent 2baa9f3 commit 0243152

File tree

1 file changed

+81
-8
lines changed

1 file changed

+81
-8
lines changed

build/plugins/llvm-mingw/patches/rust-1-fixes.patch

Lines changed: 81 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Contains ad hoc patches for cross building.
55
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
66
From: Kleis Auke Wolthuizen <[email protected]>
77
Date: Tue, 15 Sep 2020 11:50:00 +0200
8-
Subject: [PATCH 1/4] Add `armv7-pc-windows-gnullvm` triple
8+
Subject: [PATCH 1/5] Add `armv7-pc-windows-gnullvm` triple
99

1010
Upstream-Status: Pending
1111

@@ -48,11 +48,7 @@ index 1111111..2222222 100644
4848
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
4949
From: Kleis Auke Wolthuizen <[email protected]>
5050
Date: Tue, 22 Sep 2020 10:00:00 +0200
51-
Subject: [PATCH 2/4] Ensure that std/unwind can be successfully built on
52-
llvm-mingw
53-
54-
Fixes undefined symbol errors while linking these crates on llvm-mingw
55-
(targeting ARMv7).
51+
Subject: [PATCH 2/5] std/unwind: Fix linker errors on `armv7-pc-windows-gnullvm`
5652

5753
Details:
5854
ld.lld: error: undefined symbol: __gnu_unwind_frame
@@ -105,7 +101,7 @@ index 1111111..2222222 100644
105101
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
106102
From: Kleis Auke Wolthuizen <[email protected]>
107103
Date: Tue, 30 Aug 2022 23:20:27 +0200
108-
Subject: [PATCH 3/4] windows-gnullvm: avoid linking to libunwind statically
104+
Subject: [PATCH 3/5] windows-gnullvm: Avoid linking to libunwind statically
109105

110106
Avoid linking against the static variant of libunwind, which is not
111107
always available. Instead, prefer to use the unwind library from the
@@ -161,7 +157,7 @@ index 1111111..2222222 100644
161157
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
162158
From: Kleis Auke Wolthuizen <[email protected]>
163159
Date: Mon, 17 Oct 2022 11:50:00 +0200
164-
Subject: [PATCH 4/4] Use GCC-style unwinding on MinGW targets other than i686
160+
Subject: [PATCH 4/5] Use GCC-style unwinding on MinGW targets other than i686
165161

166162
See: https://github.com/msys2/MINGW-packages/pull/13278
167163

@@ -206,3 +202,80 @@ index 1111111..2222222 100644
206202
// We declare these as opaque types. This is fine since you just need to
207203
// pass them to _GCC_specific_handler and forget about them.
208204
pub enum EXCEPTION_RECORD {}
205+
206+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
207+
From: Kleis Auke Wolthuizen <[email protected]>
208+
Date: Sat, 4 Nov 2023 12:01:36 +0100
209+
Subject: [PATCH 5/5] backtrace-rs: Fix build errors on `armv7-pc-windows-gnullvm`
210+
211+
Resolves: https://github.com/rust-lang/backtrace-rs/issues/572
212+
213+
Upstream-Status: Submitted [https://github.com/rust-lang/backtrace-rs/pull/573]
214+
215+
diff --git a/library/backtrace/src/backtrace/dbghelp.rs b/library/backtrace/src/backtrace/dbghelp.rs
216+
index 1111111..2222222 100644
217+
--- a/library/backtrace/src/backtrace/dbghelp.rs
218+
+++ b/library/backtrace/src/backtrace/dbghelp.rs
219+
@@ -167,11 +167,21 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
220+
Some(StackWalkEx) => {
221+
let mut stack_frame_ex: STACKFRAME_EX = mem::zeroed();
222+
stack_frame_ex.StackFrameSize = mem::size_of::<STACKFRAME_EX>() as DWORD;
223+
- stack_frame_ex.AddrPC.Offset = context.0.Eip as u64;
224+
+
225+
+ cfg_if::cfg_if! {
226+
+ if #[cfg(target_arch = "x86")] {
227+
+ stack_frame_ex.AddrPC.Offset = context.0.Eip as u64;
228+
+ stack_frame_ex.AddrStack.Offset = context.0.Esp as u64;
229+
+ stack_frame_ex.AddrFrame.Offset = context.0.Ebp as u64;
230+
+ } else {
231+
+ stack_frame_ex.AddrPC.Offset = context.0.Pc as u64;
232+
+ stack_frame_ex.AddrStack.Offset = context.0.Sp as u64;
233+
+ stack_frame_ex.AddrFrame.Offset = context.0.R11 as u64;
234+
+ }
235+
+ }
236+
+
237+
stack_frame_ex.AddrPC.Mode = AddrModeFlat;
238+
- stack_frame_ex.AddrStack.Offset = context.0.Esp as u64;
239+
stack_frame_ex.AddrStack.Mode = AddrModeFlat;
240+
- stack_frame_ex.AddrFrame.Offset = context.0.Ebp as u64;
241+
stack_frame_ex.AddrFrame.Mode = AddrModeFlat;
242+
243+
while StackWalkEx(
244+
@@ -205,11 +215,21 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
245+
}
246+
None => {
247+
let mut stack_frame64: STACKFRAME64 = mem::zeroed();
248+
- stack_frame64.AddrPC.Offset = context.0.Eip as u64;
249+
+
250+
+ cfg_if::cfg_if! {
251+
+ if #[cfg(target_arch = "x86")] {
252+
+ stack_frame64.AddrPC.Offset = context.0.Eip as u64;
253+
+ stack_frame64.AddrStack.Offset = context.0.Esp as u64;
254+
+ stack_frame64.AddrFrame.Offset = context.0.Ebp as u64;
255+
+ } else {
256+
+ stack_frame64.AddrPC.Offset = context.0.Pc as u64;
257+
+ stack_frame64.AddrStack.Offset = context.0.Sp as u64;
258+
+ stack_frame64.AddrFrame.Offset = context.0.R11 as u64;
259+
+ }
260+
+ }
261+
+
262+
stack_frame64.AddrPC.Mode = AddrModeFlat;
263+
- stack_frame64.AddrStack.Offset = context.0.Esp as u64;
264+
stack_frame64.AddrStack.Mode = AddrModeFlat;
265+
- stack_frame64.AddrFrame.Offset = context.0.Ebp as u64;
266+
stack_frame64.AddrFrame.Mode = AddrModeFlat;
267+
268+
while dbghelp.StackWalk64()(
269+
diff --git a/library/backtrace/src/lib.rs b/library/backtrace/src/lib.rs
270+
index 1111111..2222222 100644
271+
--- a/library/backtrace/src/lib.rs
272+
+++ b/library/backtrace/src/lib.rs
273+
@@ -194,7 +194,7 @@ mod lock {
274+
275+
#[cfg(all(
276+
windows,
277+
- any(target_env = "msvc", all(target_env = "gnu", target_arch = "x86")),
278+
+ any(target_env = "msvc", all(target_env = "gnu", any(target_arch = "x86", target_arch = "arm"))),
279+
not(target_vendor = "uwp")
280+
))]
281+
mod dbghelp;

0 commit comments

Comments
 (0)