Skip to content

Commit

Permalink
Partial stabilisation of c_unwind
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed Apr 29, 2023
1 parent f229949 commit 723aee2
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 43 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ declare_features! (
(active, async_closure, "1.37.0", Some(62290), None),
/// Allows async functions to be declared, implemented, and used in traits.
(incomplete, async_fn_in_trait, "1.66.0", Some(91611), None),
/// Allows `extern "C-unwind" fn` to enable unwinding across ABI boundaries.
/// Treat `extern "C"` function as nounwind.
(active, c_unwind, "1.52.0", Some(74990), None),
/// Allows using C-variadics.
(active, c_variadic, "1.34.0", Some(44930), None),
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4014,7 +4014,6 @@ declare_lint! {
/// ### Example
///
/// ```rust
/// #![feature(c_unwind)]
/// #![warn(ffi_unwind_calls)]
///
/// extern "C-unwind" {
Expand All @@ -4037,8 +4036,7 @@ declare_lint! {
/// that desire this ability it is therefore necessary to avoid such calls.
pub FFI_UNWIND_CALLS,
Allow,
"call to foreign functions or function pointers with FFI-unwind ABI",
@feature_gate = sym::c_unwind;
"call to foreign functions or function pointers with FFI-unwind ABI"
}

declare_lint! {
Expand Down
40 changes: 5 additions & 35 deletions compiler/rustc_target/src/spec/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
match name {
// Stable
"Rust" | "C" | "cdecl" | "stdcall" | "fastcall" | "aapcs" | "win64" | "sysv64"
| "system" | "efiapi" => Ok(()),
| "system" | "efiapi" | "C-unwind" | "cdecl-unwind" | "stdcall-unwind"
| "fastcall-unwind" | "aapcs-unwind" | "win64-unwind" | "sysv64-unwind"
| "system-unwind" => Ok(()),
"rust-intrinsic" => Err(AbiDisabled::Unstable {
feature: sym::intrinsics,
explain: "intrinsics are subject to change",
Expand Down Expand Up @@ -202,46 +204,14 @@ pub fn is_stable(name: &str) -> Result<(), AbiDisabled> {
feature: sym::abi_c_cmse_nonsecure_call,
explain: "C-cmse-nonsecure-call ABI is experimental and subject to change",
}),
"C-unwind" => Err(AbiDisabled::Unstable {
feature: sym::c_unwind,
explain: "C-unwind ABI is experimental and subject to change",
}),
"stdcall-unwind" => Err(AbiDisabled::Unstable {
feature: sym::c_unwind,
explain: "stdcall-unwind ABI is experimental and subject to change",
}),
"system-unwind" => Err(AbiDisabled::Unstable {
feature: sym::c_unwind,
explain: "system-unwind ABI is experimental and subject to change",
}),
"thiscall-unwind" => Err(AbiDisabled::Unstable {
feature: sym::c_unwind,
feature: sym::abi_thiscall,
explain: "thiscall-unwind ABI is experimental and subject to change",
}),
"cdecl-unwind" => Err(AbiDisabled::Unstable {
feature: sym::c_unwind,
explain: "cdecl-unwind ABI is experimental and subject to change",
}),
"fastcall-unwind" => Err(AbiDisabled::Unstable {
feature: sym::c_unwind,
explain: "fastcall-unwind ABI is experimental and subject to change",
}),
"vectorcall-unwind" => Err(AbiDisabled::Unstable {
feature: sym::c_unwind,
feature: sym::abi_vectorcall,
explain: "vectorcall-unwind ABI is experimental and subject to change",
}),
"aapcs-unwind" => Err(AbiDisabled::Unstable {
feature: sym::c_unwind,
explain: "aapcs-unwind ABI is experimental and subject to change",
}),
"win64-unwind" => Err(AbiDisabled::Unstable {
feature: sym::c_unwind,
explain: "win64-unwind ABI is experimental and subject to change",
}),
"sysv64-unwind" => Err(AbiDisabled::Unstable {
feature: sym::c_unwind,
explain: "sysv64-unwind ABI is experimental and subject to change",
}),
"wasm" => Err(AbiDisabled::Unstable {
feature: sym::wasm_abi,
explain: "wasm ABI is experimental and subject to change",
Expand Down
2 changes: 1 addition & 1 deletion library/panic_unwind/src/emcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ static EXCEPTION_TYPE_INFO: TypeInfo = TypeInfo {
name: b"rust_panic\0".as_ptr(),
};

// NOTE(nbdd0121): The `canary` field will be part of stable ABI after `c_unwind` stabilization.
// NOTE(nbdd0121): The `canary` field is part of stable ABI.
#[repr(C)]
struct Exception {
// See `gcc.rs` on why this is present. We already have a static here so just use it.
Expand Down
4 changes: 2 additions & 2 deletions library/panic_unwind/src/gcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ use unwind as uw;
static CANARY: u8 = 0;

// NOTE(nbdd0121)
// Once `c_unwind` feature is stabilized, there will be ABI stability requirement
// on this struct. The first two field must be `_Unwind_Exception` and `canary`,
// There is an ABI stability requirement on this struct.
// The first two field must be `_Unwind_Exception` and `canary`,
// as it may be accessed by a different version of the std with a different compiler.
#[repr(C)]
struct Exception {
Expand Down
2 changes: 1 addition & 1 deletion library/panic_unwind/src/seh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use core::mem::{self, ManuallyDrop};
use core::ptr;
use libc::{c_int, c_uint, c_void};

// NOTE(nbdd0121): The `canary` field will be part of stable ABI after `c_unwind` stabilization.
// NOTE(nbdd0121): The `canary` field is part of stable ABI.
#[repr(C)]
struct Exception {
// See `gcc.rs` on why this is present. We already have a static here so just use it.
Expand Down

0 comments on commit 723aee2

Please sign in to comment.