Skip to content

Commit a285b0a

Browse files
committed
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
1 parent d8ab794 commit a285b0a

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/x86.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,27 @@ use core::intrinsics;
88
// NOTE These functions are never mangled as they are not tested against compiler-rt
99

1010
intrinsics! {
11+
#[naked]
12+
#[cfg(all(
13+
windows,
14+
target_env = "gnu",
15+
not(feature = "no-asm")
16+
))]
17+
pub unsafe extern "C" fn __chkstk() {
18+
core::arch::asm!(
19+
"jmp __alloca", // Jump to __alloca since fallthrough may be unreliable"
20+
options(noreturn, att_syntax)
21+
);
22+
}
23+
1124
#[naked]
1225
#[cfg(all(
1326
windows,
1427
target_env = "gnu",
1528
not(feature = "no-asm")
1629
))]
1730
pub unsafe extern "C" fn _alloca() {
18-
// _chkstk and _alloca are the same function
31+
// __chkstk and _alloca are the same function
1932
core::arch::asm!(
2033
"push %ecx",
2134
"cmp $0x1000,%eax",

0 commit comments

Comments
 (0)