Skip to content

Commit 560fc2e

Browse files
committed
Disable mangling for msvc stack intrinsics
This prevents linker errors in test builds due to the `jmp` instruction in __alloca
1 parent c9bff74 commit 560fc2e

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/x86_64.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,13 @@ use core::intrinsics;
22

33
// NOTE These functions are implemented using assembly because they using a custom
44
// calling convention which can't be implemented using a normal Rust function
5+
6+
// NOTE These functions are never mangled as they are not tested against compiler-rt
7+
// and mangling ___chkstk would break the `jmp ___chkstk` instruction in __alloca
8+
59
#[cfg(windows)]
610
#[naked]
7-
#[cfg_attr(not(test), no_mangle)]
11+
#[no_mangle]
812
pub unsafe fn ___chkstk_ms() {
913
asm!("push %rcx
1014
push %rax
@@ -28,7 +32,7 @@ pub unsafe fn ___chkstk_ms() {
2832

2933
#[cfg(windows)]
3034
#[naked]
31-
#[cfg_attr(not(test), no_mangle)]
35+
#[no_mangle]
3236
pub unsafe fn __alloca() {
3337
asm!("mov %rcx,%rax // x64 _alloca is a normal function with parameter in rcx
3438
jmp ___chkstk // Jump to ___chkstk since fallthrough may be unreliable");
@@ -37,7 +41,7 @@ pub unsafe fn __alloca() {
3741

3842
#[cfg(windows)]
3943
#[naked]
40-
#[cfg_attr(not(test), no_mangle)]
44+
#[no_mangle]
4145
pub unsafe fn ___chkstk() {
4246
asm!("push %rcx
4347
cmp $$0x1000,%rax

0 commit comments

Comments
 (0)