Skip to content

Commit

Permalink
Stabilize extended_varargs_abi_support
Browse files Browse the repository at this point in the history
  • Loading branch information
Soveu committed Oct 11, 2024
1 parent f496659 commit b9451d4
Show file tree
Hide file tree
Showing 15 changed files with 12 additions and 121 deletions.
3 changes: 3 additions & 0 deletions compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ declare_features! (
(accepted, expr_fragment_specifier_2024, "CURRENT_RUSTC_VERSION", Some(123742)),
/// Allows arbitrary expressions in key-value attributes at parse time.
(accepted, extended_key_value_attributes, "1.54.0", Some(78835)),
/// Allows using `efiapi`, `aapcs`, `sysv64` and `win64` as calling
/// convention for functions with varargs.
(accepted, extended_varargs_abi_support, "CURRENT_RUSTC_VERSION", Some(100189)),
/// Allows resolving absolute paths as paths from other crates.
(accepted, extern_absolute_paths, "1.30.0", Some(44660)),
/// Allows `extern crate foo as bar;`. This puts `bar` into extern prelude.
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,6 @@ declare_features! (
(unstable, exhaustive_patterns, "1.13.0", Some(51085)),
/// Allows explicit tail calls via `become` expression.
(incomplete, explicit_tail_calls, "1.72.0", Some(112788)),
/// Allows using `efiapi`, `sysv64` and `win64` as calling convention
/// for functions with varargs.
(unstable, extended_varargs_abi_support, "1.65.0", Some(100189)),
/// Allows defining `extern type`s.
(unstable, extern_types, "1.23.0", Some(43467)),
/// Allow using 128-bit (quad precision) floating point numbers.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_analysis/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ hir_analysis_value_of_associated_struct_already_specified =
.label = re-bound here
.previous_bound_label = `{$item_name}` bound here first
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like {$conventions}
hir_analysis_variadic_function_compatible_convention = C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
.label = C-variadic function must have a compatible calling convention
hir_analysis_variances_of = {$variances}
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_hir_analysis/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -672,11 +672,10 @@ pub(crate) struct MainFunctionGenericParameters {

#[derive(Diagnostic)]
#[diag(hir_analysis_variadic_function_compatible_convention, code = E0045)]
pub(crate) struct VariadicFunctionCompatibleConvention<'a> {
pub(crate) struct VariadicFunctionCompatibleConvention {
#[primary_span]
#[label]
pub span: Span,
pub conventions: &'a str,
}

#[derive(Diagnostic)]
Expand Down
31 changes: 2 additions & 29 deletions compiler/rustc_hir_analysis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,43 +97,16 @@ use rustc_middle::middle;
use rustc_middle::mir::interpret::GlobalId;
use rustc_middle::query::Providers;
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_session::parse::feature_err;
use rustc_span::Span;
use rustc_span::symbol::sym;
use rustc_target::spec::abi::Abi;
use rustc_trait_selection::traits;

rustc_fluent_macro::fluent_messages! { "../messages.ftl" }

fn require_c_abi_if_c_variadic(tcx: TyCtxt<'_>, decl: &hir::FnDecl<'_>, abi: Abi, span: Span) {
const CONVENTIONS_UNSTABLE: &str =
"`C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`";
const CONVENTIONS_STABLE: &str = "`C` or `cdecl`";
const UNSTABLE_EXPLAIN: &str =
"using calling conventions other than `C` or `cdecl` for varargs functions is unstable";

if !decl.c_variadic || matches!(abi, Abi::C { .. } | Abi::Cdecl { .. }) {
return;
if decl.c_variadic && !abi.supports_varargs() {
tcx.dcx().emit_err(errors::VariadicFunctionCompatibleConvention { span });
}

let extended_abi_support = tcx.features().extended_varargs_abi_support;
let conventions = match (extended_abi_support, abi.supports_varargs()) {
// User enabled additional ABI support for varargs and function ABI matches those ones.
(true, true) => return,

// Using this ABI would be ok, if the feature for additional ABI support was enabled.
// Return CONVENTIONS_STABLE, because we want the other error to look the same.
(false, true) => {
feature_err(&tcx.sess, sym::extended_varargs_abi_support, span, UNSTABLE_EXPLAIN)
.emit();
CONVENTIONS_STABLE
}

(false, false) => CONVENTIONS_STABLE,
(true, false) => CONVENTIONS_UNSTABLE,
};

tcx.dcx().emit_err(errors::VariadicFunctionCompatibleConvention { span, conventions });
}

pub fn provide(providers: &mut Providers) {
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,6 @@
#![feature(doc_masked)]
#![feature(doc_notable_trait)]
#![feature(dropck_eyepatch)]
#![feature(extended_varargs_abi_support)]
#![feature(f128)]
#![feature(f16)]
#![feature(if_let_guard)]
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/llvm-project
Submodule llvm-project updated 88 files
+8 −0 .github/workflows/release-binaries.yml
+2 −3 bolt/test/perf2bolt/lit.local.cfg
+2 −5 clang/cmake/caches/Release.cmake
+0 −3 clang/include/clang/AST/DeclBase.h
+0 −6 clang/include/clang/Tooling/CompilationDatabase.h
+0 −4 clang/lib/AST/DeclBase.cpp
+11 −15 clang/lib/CodeGen/CGExprScalar.cpp
+0 −26 clang/lib/Driver/ToolChains/Clang.cpp
+0 −7 clang/lib/Format/FormatTokenLexer.cpp
+5 −0 clang/lib/Format/TokenAnnotator.cpp
+2 −24 clang/lib/Sema/SemaConcept.cpp
+1 −2 clang/lib/Sema/SemaDecl.cpp
+0 −1 clang/lib/Tooling/CMakeLists.txt
+0 −71 clang/lib/Tooling/LocateToolCompilationDatabase.cpp
+0 −31 clang/test/ClangScanDeps/implicit-target.c
+2 −1 clang/test/ClangScanDeps/modules-extern-submodule.c
+4 −2 clang/test/ClangScanDeps/modules-full-output-tu-order.c
+2 −1 clang/test/ClangScanDeps/modules-has-include-umbrella-header.c
+2 −1 clang/test/ClangScanDeps/modules-header-sharing.m
+2 −1 clang/test/ClangScanDeps/modules-implementation-module-map.c
+2 −1 clang/test/ClangScanDeps/modules-implementation-private.m
+2 −1 clang/test/ClangScanDeps/modules-priv-fw-from-pub.m
+0 −32 clang/test/ClangScanDeps/resolve-executable-path.c
+44 −44 clang/test/CodeGen/X86/x86-atomic-double.c
+52 −241 clang/test/CodeGen/X86/x86-atomic-long_double.c
+1 −16 clang/test/Driver/debug-options-as.c
+0 −12 clang/test/Modules/pr107673.cppm
+0 −14 clang/test/Modules/pr108732.cppm
+0 −23 clang/test/SemaTemplate/concepts-out-of-line-def.cpp
+0 −1 clang/tools/clang-scan-deps/CMakeLists.txt
+1 −13 clang/tools/clang-scan-deps/ClangScanDeps.cpp
+0 −6 clang/unittests/Format/FormatTest.cpp
+1 −1 cmake/Modules/LLVMVersion.cmake
+0 −12 compiler-rt/lib/sanitizer_common/sanitizer_linux.cpp
+1 −1 libcxx/include/__config
+4 −1 libcxx/test/std/time/time.zone/time.zone.timezone/time.zone.members/sys_info.zdump.pass.cpp
+0 −2 libcxx/test/tools/clang_tidy_checks/CMakeLists.txt
+1 −2 libcxx/vendor/llvm/default_assertion_handler.in
+2 −2 lld/ELF/ICF.cpp
+3 −3 lld/ELF/InputSection.cpp
+0 −4 lld/ELF/InputSection.h
+0 −3 lld/test/ELF/icf10.s
+3 −1 lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/Makefile
+3 −1 lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/Makefile
+3 −1 lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/Makefile
+0 −1 .../API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
+1 −1 llvm/include/llvm/Analysis/AliasAnalysis.h
+0 −2 llvm/lib/Analysis/AliasAnalysis.cpp
+0 −1 llvm/lib/CodeGen/InitUndef.cpp
+32 −51 llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+1 −2 llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+0 −15 llvm/lib/ExecutionEngine/Orc/Core.cpp
+3 −3 llvm/lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp
+2 −7 llvm/lib/Target/AVR/AVRISelDAGToDAG.cpp
+2 −4 llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+1 −4 llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
+0 −6 llvm/lib/Target/LoongArch/LoongArchLASXInstrInfo.td
+0 −15 llvm/lib/Target/LoongArch/LoongArchOptWInstrs.cpp
+1 −2 llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+1 −1 llvm/lib/Target/X86/X86ISelLowering.cpp
+2 −2 llvm/lib/Target/X86/X86InstrAVX512.td
+4 −16 llvm/lib/Transforms/Utils/InlineFunction.cpp
+1 −1 llvm/lib/Transforms/Utils/LoopPeel.cpp
+0 −239 llvm/test/CodeGen/AMDGPU/GlobalISel/flat-scratch.ll
+0 −444 llvm/test/CodeGen/AMDGPU/flat-scratch.ll
+0 −144 llvm/test/CodeGen/AVR/ldd-immediate-overflow.ll
+0 −137 llvm/test/CodeGen/AVR/std-immediate-overflow.ll
+0 −119 llvm/test/CodeGen/LoongArch/ir-instruction/load-store-atomic.ll
+0 −61 llvm/test/CodeGen/LoongArch/ir-instruction/sdiv-udiv-srem-urem.ll
+0 −35 llvm/test/CodeGen/LoongArch/lasx/issue107355.ll
+2 −2 llvm/test/CodeGen/PowerPC/ldexp-libcall.ll
+15 −21 llvm/test/CodeGen/PowerPC/ldexp.ll
+0 −26 llvm/test/CodeGen/PowerPC/negative-integer-fp-libcall.ll
+7 −6 llvm/test/CodeGen/RISCV/rvv/fixed-vectors-buildvec-of-binop.ll
+48 −48 llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-gather.ll
+30 −30 llvm/test/CodeGen/RISCV/rvv/shuffle-reverse.ll
+0 −24 llvm/test/CodeGen/X86/cmp-shiftX-maskX.ll
+24 −45 llvm/test/CodeGen/X86/fold-int-pow2-with-fmul-or-fdiv.ll
+0 −16 llvm/test/MC/Disassembler/X86/apx/kmov.txt
+1 −13 llvm/test/MC/X86/apx/kmov-att.s
+0 −12 llvm/test/MC/X86/apx/kmov-intel.s
+0 −21 llvm/test/Transforms/Inline/access-attributes-prop.ll
+0 −51 llvm/test/Transforms/Inline/ret_attr_align_and_noundef.ll
+0 −104 llvm/test/Transforms/LoopUnroll/pr109333.ll
+1 −11 llvm/test/tools/llvm-ml/rip_relative_addressing.asm
+1 −1 llvm/utils/gn/secondary/llvm/version.gni
+1 −1 llvm/utils/lit/lit/__init__.py
+1 −1 llvm/utils/mlgo-utils/mlgo/__init__.py
17 changes: 0 additions & 17 deletions tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion tests/ui/c-variadic/variadic-ffi-1.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
--> $DIR/variadic-ffi-1.rs:9:5
|
LL | fn printf(_: *const u8, ...);
Expand Down
1 change: 0 additions & 1 deletion tests/ui/c-variadic/variadic-ffi-2.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//@ ignore-arm stdcall isn't supported
#![feature(extended_varargs_abi_support)]

fn baz(f: extern "stdcall" fn(usize, ...)) {
//~^ ERROR: C-variadic function must have a compatible calling convention,
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/c-variadic/variadic-ffi-2.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
--> $DIR/variadic-ffi-2.rs:4:11
--> $DIR/variadic-ffi-2.rs:3:11
|
LL | fn baz(f: extern "stdcall" fn(usize, ...)) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/error-codes/E0045.stderr
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error[E0045]: C-variadic function must have a compatible calling convention, like `C` or `cdecl`
error[E0045]: C-variadic function must have a compatible calling convention, like `C`, `cdecl`, `system`, `aapcs`, `win64`, `sysv64` or `efiapi`
--> $DIR/E0045.rs:1:17
|
LL | extern "Rust" { fn foo(x: u8, ...); }
Expand Down

0 comments on commit b9451d4

Please sign in to comment.