stabilize c-style varargs for system, sysv64, win64, efiapi, aapcs #144066
+166
−190
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This stabilizes extern block declarations of variadic functions with the system, sysv64, win64, efiapi, aapcs ABIs. This corresponds to the extended_varargs_abi_support and extern_system_varargs feature gates.
The feature gates were split up since it seemed like there might be further discussion needed for what exactly "system" ABI variadic functions should do, but a consensus has meanwhile been reached: they shall behave like "C" functions. IOW, the ABI of a "system" function is (bold part is new in this PR):
This had been previously stabilized without FCP in #116161, which got reverted in #136897. There was also a "fun" race condition involved with the system ABI being added to the list of variadic-supporting ABIs between the creation and merge of #116161.
There was a question raised here whether t-lang even needs to be involved for a change like this. Not sure if that has meanwhile been clarified? The behavior of the "system" ABI (a Rust-specific ABI) definitely feels like t-lang territory to me.
Fixes #100189, #136946
Cc @rust-lang/lang
Stabilization report
AFAIK there is no RFC. The tracking issues are
extended_varargs_abi_support
#100189extern_system_varargs
#136946The only controversial point is whether "system" ABI functions should support variadics.
extern "system"
as much as possible microsoft/windows-rs#3626.Note that "system" is already a magic ABI we introduced to "do the right thing". This just makes it do the right thing in more cases.
Actually defining variadic functions in Rust remains unstable, under the c_variadic feature gate.
There was no call for testing.
A search brings up https://github.com/rust-osdev/uefi-rs/blob/main/uefi-raw/src/table/boot.rs using this for "efiapi". THis doesn't seem widely used, but it is an "obvious" gap in our support for c-variadics.
All rustc does here is forward the ABI to LLVM so there's lot a lot to say here...
The check for allowed variadic ABIs is here.
The special handling of "system" is here.
This PR adds a codegen test ensuring we emit the correct LLVM IR:
tests/codegen/cffi/c-variadic-ffi.rs
.There is an existing test ensuring that we keep rejecting variadics for ABIs where that is not supported (
tests/ui/c-variadic/variadic-ffi-1.rs
).The test ensuring that we do not stabilize defining c-variadic functions is
tests/ui/feature-gates/feature-gate-c_variadic.rs
.None that I am aware of.
None that I am aware of.
@Soveu added sysv64, win64, efiapi, aapcs to the list of ABIs that allow variadics, @beepster4096 added system. @workingjubilee recently refactored the ABI handling in the compiler, also affecting this feature.
Maybe RA needs to be taught about the new allowed ABIs? No idea how precisely they mirror what exactly rustc accepts and rejects here.
Nothing new here, this just expands the existing support for calling variadic functions to more ABIs.
Nothing new here, this just expands the existing support for calling variadic functions to more ABIs.
Nothing new here, this just expands the existing support for calling variadic functions to more ABIs.
No.
None.