1
Fork 0

Rollup merge of #119587 - beepster4096:system_varargs, r=petrochenkov

Varargs support for system ABI

This PR allows functions with the `system` ABI to be variadic (under the `extended_varargs_abi_support` feature tracked in #100189). On x86 windows, the `system` ABI is equivalent to `C` for variadic functions. On other platforms, `system` is already equivalent to `C`.

Fixes #110505
This commit is contained in:
Matthias Krüger 2024-01-13 15:10:28 +01:00 committed by GitHub
commit 7b507db24b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 34 additions and 13 deletions

View file

@ -228,9 +228,9 @@ fn fn_sig_for_fn_abi<'tcx>(
}
#[inline]
fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi) -> Conv {
fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: SpecAbi, c_variadic: bool) -> Conv {
use rustc_target::spec::abi::Abi::*;
match tcx.sess.target.adjust_abi(abi) {
match tcx.sess.target.adjust_abi(abi, c_variadic) {
RustIntrinsic | PlatformIntrinsic | Rust | RustCall => Conv::Rust,
// This is intentionally not using `Conv::Cold`, as that has to preserve
@ -488,7 +488,7 @@ fn fn_abi_new_uncached<'tcx>(
) -> Result<&'tcx FnAbi<'tcx, Ty<'tcx>>, &'tcx FnAbiError<'tcx>> {
let sig = cx.tcx.normalize_erasing_late_bound_regions(cx.param_env, sig);
let conv = conv_from_spec_abi(cx.tcx(), sig.abi);
let conv = conv_from_spec_abi(cx.tcx(), sig.abi, sig.c_variadic);
let mut inputs = sig.inputs();
let extra_args = if sig.abi == RustCall {