forked from msys2/MINGW-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix issue-21763.rs test failure when vendor is enabled the issue is fixed upstream in 1.79.0 see rust-lang/rust#123652 * fix externally linking some math functions The tests\ui\issues\issue-2214.rs test fails with undefined reference to `__sinl_internal' and other math functions. Mateusz Mikuła analyzed the issue and found that the root cause is this change in mingw-w64: mingw-w64/mingw-w64@a64c1f4 The error happens because Rust pulls in lgamma from libmingwex.a, which pulls in sin from libmsvcrt.a, which in turn tries to pull in __sinl_internal from libmingwex.a and fails because of how Rust links MinGW libs. The proposed fix was to add an extra "-lmingwex" after the second "-lmsvcrt" in https://github.com/rust-lang/rust/blob/aa6a697a1c75b0aa06954136f7641706edadc2be/compiler/rustc_target/src/spec/base/windows_gnu.rs#L30. * backport fix for windows aarch64 backtrace
- Loading branch information
Showing
2 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
mingw-w64-rust/0016-backport-backtrace-fix-windows-aarch64.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- rustc-1.77.2-src/library/backtrace/src/backtrace/dbghelp.rs.orig 2024-04-19 14:12:20.763735300 -0700 | ||
+++ rustc-1.77.2-src/library/backtrace/src/backtrace/dbghelp.rs 2024-04-19 14:17:14.861312400 -0700 | ||
@@ -127,45 +127,67 @@ | ||
pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) { | ||
use core::ptr; | ||
|
||
+ // Capture the initial context to start walking from. | ||
let mut context = core::mem::zeroed::<MyContext>(); | ||
RtlCaptureContext(&mut context.0); | ||
|
||
- // Call `RtlVirtualUnwind` to find the previous stack frame, walking until we hit ip = 0. | ||
- while context.ip() != 0 { | ||
+ loop { | ||
+ let ip = context.ip(); | ||
+ | ||
let mut base = 0; | ||
|
||
- let fn_entry = RtlLookupFunctionEntry(context.ip(), &mut base, ptr::null_mut()); | ||
+ let fn_entry = RtlLookupFunctionEntry(ip, &mut base, ptr::null_mut()); | ||
if fn_entry.is_null() { | ||
+ // No function entry could be found - this may indicate a corrupt | ||
+ // stack or that a binary was unloaded (amongst other issues). Stop | ||
+ // walking and don't call the callback as we can't be confident in | ||
+ // this frame or the rest of the stack. | ||
break; | ||
} | ||
|
||
let frame = super::Frame { | ||
inner: Frame { | ||
base_address: fn_entry as *mut c_void, | ||
- ip: context.ip() as *mut c_void, | ||
+ ip: ip as *mut c_void, | ||
sp: context.sp() as *mut c_void, | ||
#[cfg(not(target_env = "gnu"))] | ||
inline_context: None, | ||
}, | ||
}; | ||
|
||
+ // We've loaded all the info about the current frame, so now call the | ||
+ // callback. | ||
if !cb(&frame) { | ||
+ // Callback told us to stop, so we're done. | ||
break; | ||
} | ||
|
||
+ // Unwind to the next frame. | ||
+ let previous_ip = ip; | ||
+ let previous_sp = context.sp(); | ||
let mut handler_data = 0usize; | ||
let mut establisher_frame = 0; | ||
|
||
RtlVirtualUnwind( | ||
0, | ||
base, | ||
- context.ip(), | ||
+ ip, | ||
fn_entry, | ||
&mut context.0, | ||
&mut handler_data as *mut usize as *mut PVOID, | ||
&mut establisher_frame, | ||
ptr::null_mut(), | ||
); | ||
+ | ||
+ // RtlVirtualUnwind indicates the end of the stack in two different ways: | ||
+ // * On x64, it sets the instruction pointer to 0. | ||
+ // * On ARM64, it leaves the context unchanged (easiest way to check is | ||
+ // to see if the instruction and stack pointers are the same). | ||
+ // If we detect either of these, then unwinding is completed. | ||
+ let ip = context.ip(); | ||
+ if ip == 0 || (ip == previous_ip && context.sp() == previous_sp) { | ||
+ break; | ||
+ } | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters