Add __chkstk on i686-pc-windows-gnu.

libLLVMSupport.a(DynamicLibrary.cpp.obj) references ___chkstk, which is
an alias of __alloca in libgcc.  This crate provided __alloca, but
libgcc's implementation was also pulled in by the linker due to the
reference to ___chkstk, causing a multiple definition linker error.
Providing that symbol here prevents that.

Fixes #585
This commit is contained in:
Jeremy Drake
2024-04-07 09:32:17 -07:00
parent 45aa0926c0
commit f23a83c53c

View File

@@ -8,6 +8,19 @@ use core::intrinsics;
// NOTE These functions are never mangled as they are not tested against compiler-rt
intrinsics! {
#[naked]
#[cfg(all(
windows,
target_env = "gnu",
not(feature = "no-asm")
))]
pub unsafe extern "C" fn __chkstk() {
core::arch::asm!(
"jmp __alloca", // Jump to __alloca since fallthrough may be unreliable"
options(noreturn, att_syntax)
);
}
#[naked]
#[cfg(all(
windows,
@@ -15,7 +28,7 @@ intrinsics! {
not(feature = "no-asm")
))]
pub unsafe extern "C" fn _alloca() {
// _chkstk and _alloca are the same function
// __chkstk and _alloca are the same function
core::arch::asm!(
"push %ecx",
"cmp $0x1000,%eax",