rust-lang / rustc_codegen_gcc

libgccjit AOT codegen for rustc
Apache License 2.0
894 stars 61 forks source link

Non-default ABIs aren't supported #451

Open sadlerap opened 4 months ago

sadlerap commented 4 months ago

The following function miscompiles:

#[no_mangle]
extern "efiapi" fn efi(x: u32, y: u32) -> u32 {
    x * y
}

LLVM emits this:

efi:
        mov     eax, ecx
        imul    eax, edx
        ret

GCC emits this (notice the incorrect registers used for parameters):

efi:
        mov     eax, edi
        imul    eax, esi
        ret

As far as I can tell, we don't preserve the declared ABI since libgccjit doesn't have a way to annotate the ABI of functions with an annotated ABI. This needs to be implemented for ui/asm/x86_64/multiple-clobber-abi.rs to pass, which requires both the sysv64 and win64 extern abi to be supported.

antoyo commented 4 months ago

Yeah, for that, we would need to support a few new function attributes. If you want to take a look, you would need to add the attributes in a few places: