Skip to content

aarch64-pc-windows-msvc target needs to treat extern "stdcall" like extern "C" #54569

Closed
@froydnj

Description

@froydnj

Compiling code like:

https://github.com/jcjones/u2f-hid-rs/blob/ea7244febb010bb8e02c5e01dd6f2b9a0082884a/src/windows/winapi.rs#L22-L49

results in:

LLVM ERROR: Unsupported calling convention

presumably because rustc attempts to translate it into an x86-specific ABI, which the AArch64 backend rightly rejects.

clang already ignores __stdcall for non-x86 targets:

https://reviews.llvm.org/D36105

I'm not completely sure what the right answer for Rust is. I think Target::adjust_abi is the rough equivalent of the above clang bit and needs to take a few more cases into account for non-x86 Windows:

/// Given a function ABI, turn "System" into the correct ABI for this target.
pub fn adjust_abi(&self, abi: Abi) -> Abi {
match abi {
Abi::System => {
if self.options.is_like_windows && self.arch == "x86" {
Abi::Stdcall
} else {
Abi::C
}
},
abi => abi
}
}

@alexcrichton does that sound right? If so, I'll code up a patch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions