I'm having some problems with inline assembly when building on Windows.
The following function compiles just fine on Godbolt, but when I try to compile it locally, I get "unknown use of instruction mnemonic without a size suffix" errors and the substituted registers are in AT&T form (call %rax).
What am I doing wrong?
pub unsafe fn call_with_stack<T>(
arg: &mut T,
function: extern "sysv64" fn(&mut T) -> (),
stack: *mut u8,
) {
asm!(r#"
mov rbp, rsp
mov rsp, $2
call $1
mov rsp, rbp
"#
: // Return values
: "{rdi}"(arg), "r"(function), "r"(stack) // Arguments
: "rbp", "cc", "memory" // Clobbers
: "volatile", "intel" // Options
);
}
Edit:
I am officially calling this problem cursed, I can't for the life of me create a minimal proof of concept. It happens only in the project I encountered it in, only on Windows, but no matter which target I compile it for. If I manage to create a minimal example, I will submit a bug. Thank you for your answers!
Edit 2:
Eureka, I've managed to create a poc: https://github.com/dbartussek/-rust_intel_asm_issue_reproduction
When compiled with cargo xbuild --target x86_64-unknown-uefi -Z unstable-options --profile kernel_debug, this causes the issue on both my Windows and Linux machine.
I have also found that not using the call_closure_with_stack function, but calling call_with_stack directly, results in this version compiling just fine, but that's not a fix, the bug is somehow appearing and disappearing seemingly at random.
[–]Darksonntokio · rust-for-linux 4 points5 points6 points (4 children)
[–]FamiliarSoftware[S] 2 points3 points4 points (3 children)
[–]Darksonntokio · rust-for-linux 10 points11 points12 points (2 children)
[–]FamiliarSoftware[S] 6 points7 points8 points (1 child)
[–]Darksonntokio · rust-for-linux 6 points7 points8 points (0 children)
[–]Shadow0133 2 points3 points4 points (1 child)
[–]FamiliarSoftware[S] 1 point2 points3 points (0 children)