whitequark opened PR #1742 from windows-x32-abi
to master
:
As it stands the patch in this PR is as minimal as it is hair-raising, and it's really not going to be merged in the current state. However, with it and #1740 I can actually run simple programs on x32!
![Screenshot_20200521_193835](https://user-images.githubusercontent.com/54771/82598768-a98bc600-9b9a-11ea-861e-7ad54ef5c350.png)(The
-Cpanic=abort
, plus a dummy#[no_mangle] pub extern fn _Unwind_Resume() { unimplemented!() }
, are there to work around the fact that Linux distributions all build MinGW with SjLj exceptions, but Rust expects a MinGW toolchain with DWARF exceptions.)Let me explain the reasons this PR looks like it does.
First, currently target-lexicon considers Windows as always using
fastcall
. However that's not the case on x32, where C code usescdecl
by default, and Win32 APIs usestdcall
by default. This is why Windows x32 is special-cased in cranelift in this PR. To fix this, I believe thatdefault_calling_convention
for Windows x32 should returncdecl
so that it matches the behavior of the Rustc
calling convention, but that's where we get to the second issue...Second, there is actually no way to express "Windows
cdecl
" in either target-lexicon or cranelift. AFAICT this calling convention is functionally identical to the System V one; LLVM calls itccc
to avoid naming it in either a *nix-specific way ("System V") or a Windows-specific way ("cdecl
"). The way this should be handled is purely subjective though (the options being "rename SystemV to Ccc", "rename SystemV to Cdecl", "add Cdecl as an alias of SystemV for Windows alone", and "do nothing and just use SystemV on Windows x32") so I'm going to implement whatever the maintainers ask me to.
whitequark updated PR #1742 from windows-x32-abi
to master
:
As it stands the patch in this PR is as minimal as it is hair-raising, and it's really not going to be merged in the current state. However, with it and #1740 I can actually run simple programs on x32!
![Screenshot_20200521_193835](https://user-images.githubusercontent.com/54771/82598768-a98bc600-9b9a-11ea-861e-7ad54ef5c350.png)(The
-Cpanic=abort
, plus a dummy#[no_mangle] pub extern fn _Unwind_Resume() { unimplemented!() }
, are there to work around the fact that Linux distributions all build MinGW with SjLj exceptions, but Rust expects a MinGW toolchain with DWARF exceptions.)Let me explain the reasons this PR looks like it does.
First, currently target-lexicon considers Windows as always using
fastcall
. However that's not the case on x32, where C code usescdecl
by default, and Win32 APIs usestdcall
by default. This is why Windows x32 is special-cased in cranelift in this PR. To fix this, I believe thatdefault_calling_convention
for Windows x32 should returncdecl
so that it matches the behavior of the Rustc
calling convention, but that's where we get to the second issue...Second, there is actually no way to express "Windows
cdecl
" in either target-lexicon or cranelift. AFAICT this calling convention is functionally identical to the System V one; LLVM calls itccc
to avoid naming it in either a *nix-specific way ("System V") or a Windows-specific way ("cdecl
"). The way this should be handled is purely subjective though (the options being "rename SystemV to Ccc", "rename SystemV to Cdecl", "add Cdecl as an alias of SystemV for Windows alone", and "do nothing and just use SystemV on Windows x32") so I'm going to implement whatever the maintainers ask me to.
alexcrichton edited PR #1742 from windows-x32-abi
to main
:
As it stands the patch in this PR is as minimal as it is hair-raising, and it's really not going to be merged in the current state. However, with it and #1740 I can actually run simple programs on x32!
![Screenshot_20200521_193835](https://user-images.githubusercontent.com/54771/82598768-a98bc600-9b9a-11ea-861e-7ad54ef5c350.png)(The
-Cpanic=abort
, plus a dummy#[no_mangle] pub extern fn _Unwind_Resume() { unimplemented!() }
, are there to work around the fact that Linux distributions all build MinGW with SjLj exceptions, but Rust expects a MinGW toolchain with DWARF exceptions.)Let me explain the reasons this PR looks like it does.
First, currently target-lexicon considers Windows as always using
fastcall
. However that's not the case on x32, where C code usescdecl
by default, and Win32 APIs usestdcall
by default. This is why Windows x32 is special-cased in cranelift in this PR. To fix this, I believe thatdefault_calling_convention
for Windows x32 should returncdecl
so that it matches the behavior of the Rustc
calling convention, but that's where we get to the second issue...Second, there is actually no way to express "Windows
cdecl
" in either target-lexicon or cranelift. AFAICT this calling convention is functionally identical to the System V one; LLVM calls itccc
to avoid naming it in either a *nix-specific way ("System V") or a Windows-specific way ("cdecl
"). The way this should be handled is purely subjective though (the options being "rename SystemV to Ccc", "rename SystemV to Cdecl", "add Cdecl as an alias of SystemV for Windows alone", and "do nothing and just use SystemV on Windows x32") so I'm going to implement whatever the maintainers ask me to.
whitequark closed without merge PR #1742.
Last updated: Nov 22 2024 at 16:03 UTC