Remove eh_unwind_resume lang item

This commit is contained in:
Amanieu d'Antras 2020-01-27 06:10:10 +00:00
parent d73813ae62
commit f4f91f0b2f
24 changed files with 34 additions and 140 deletions

View File

@ -2308,7 +2308,6 @@ dependencies = [
name = "panic_abort"
version = "0.0.0"
dependencies = [
"cfg-if",
"compiler_builtins",
"core",
"libc",

View File

@ -52,7 +52,6 @@ fn main(_argc: isize, _argv: *const *const u8) -> isize {
#[lang = "eh_personality"] extern fn rust_eh_personality() {}
#[lang = "panic_impl"] extern fn rust_begin_panic(info: &PanicInfo) -> ! { unsafe { intrinsics::abort() } }
#[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
#[no_mangle] pub extern fn rust_eh_register_frames () {}
#[no_mangle] pub extern fn rust_eh_unregister_frames () {}
```
@ -67,7 +66,7 @@ Other features provided by lang items include:
marked with lang items; those specific four are `eq`, `ord`,
`deref`, and `add` respectively.
- stack unwinding and general failure; the `eh_personality`,
`eh_unwind_resume`, `fail` and `fail_bounds_checks` lang items.
`panic` and `panic_bounds_checks` lang items.
- the traits in `std::marker` used to indicate types of
various kinds; lang items `send`, `sync` and `copy`.
- the marker types and variance indicators found in
@ -130,12 +129,6 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
pub extern fn rust_eh_personality() {
}
// This function may be needed based on the compilation target.
#[lang = "eh_unwind_resume"]
#[no_mangle]
pub extern fn rust_eh_unwind_resume() {
}
#[lang = "panic_impl"]
#[no_mangle]
pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
@ -173,12 +166,6 @@ pub extern fn main(_argc: i32, _argv: *const *const u8) -> i32 {
pub extern fn rust_eh_personality() {
}
// This function may be needed based on the compilation target.
#[lang = "eh_unwind_resume"]
#[no_mangle]
pub extern fn rust_eh_unwind_resume() {
}
#[lang = "panic_impl"]
#[no_mangle]
pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
@ -211,10 +198,8 @@ compiler. When a panic happens, this controls the message that's displayed on
the screen. While the language item's name is `panic_impl`, the symbol name is
`rust_begin_panic`.
A third function, `rust_eh_unwind_resume`, is also needed if the `custom_unwind_resume`
flag is set in the options of the compilation target. It allows customizing the
process of resuming unwind at the end of the landing pads. The language item's name
is `eh_unwind_resume`.
Finally, a `eh_catch_typeinfo` static is needed for certain targets which
implement Rust panics on top of C++ exceptions.
## List of all language items
@ -247,7 +232,6 @@ the source code.
- `eh_personality`: `libpanic_unwind/emcc.rs` (EMCC)
- `eh_personality`: `libpanic_unwind/gcc.rs` (GNU)
- `eh_personality`: `libpanic_unwind/seh.rs` (SEH)
- `eh_unwind_resume`: `libpanic_unwind/gcc.rs` (GCC)
- `eh_catch_typeinfo`: `libpanic_unwind/emcc.rs` (EMCC)
- `panic`: `libcore/panicking.rs`
- `panic_bounds_check`: `libcore/panicking.rs`

View File

@ -14,4 +14,3 @@ doc = false
core = { path = "../libcore" }
libc = { version = "0.2", default-features = false }
compiler_builtins = "0.1.0"
cfg-if = "0.1.8"

View File

@ -115,7 +115,7 @@ pub mod personalities {
// Note that we don't execute landing pads, so this is never called, so it's
// body is empty.
#[no_mangle]
#[cfg(all(target_os = "windows", target_env = "gnu"))]
#[cfg(all(bootstrap, target_os = "windows", target_env = "gnu"))]
pub extern "C" fn rust_eh_unwind_resume() {}
// These two are called by our startup objects on i686-pc-windows-gnu, but

View File

@ -35,14 +35,6 @@
//!
//! Once stack has been unwound down to the handler frame level, unwinding stops
//! and the last personality routine transfers control to the catch block.
//!
//! ## `eh_personality` and `eh_unwind_resume`
//!
//! These language items are used by the compiler when generating unwind info.
//! The first one is the personality routine described above. The second one
//! allows compilation target to customize the process of resuming unwind at the
//! end of the landing pads. `eh_unwind_resume` is used only if
//! `custom_unwind_resume` flag in the target options is set.
#![allow(private_no_mangle_fns)]
@ -324,8 +316,8 @@ unsafe fn find_eh_action(
eh::find_eh_action(lsda, &eh_context, foreign_exception)
}
// See docs in the `unwind` module.
#[cfg(all(
bootstrap,
target_os = "windows",
any(target_arch = "x86", target_arch = "x86_64"),
target_env = "gnu"

View File

@ -57,8 +57,7 @@ pub fn whitelisted(tcx: TyCtxt<'_>, lang_item: LangItem) -> bool {
// symbols. Other panic runtimes ensure that the relevant symbols are
// available to link things together, but they're never exercised.
if tcx.sess.panic_strategy() != PanicStrategy::Unwind {
return lang_item == LangItem::EhPersonalityLangItem
|| lang_item == LangItem::EhUnwindResumeLangItem;
return lang_item == LangItem::EhPersonalityLangItem;
}
false

View File

@ -1,4 +1,3 @@
use crate::abi::FnAbi;
use crate::attributes;
use crate::debuginfo;
use crate::llvm;
@ -15,7 +14,7 @@ use rustc::mir::mono::CodegenUnit;
use rustc::session::config::{self, CFGuard, DebugInfo};
use rustc::session::Session;
use rustc::ty::layout::{
FnAbiExt, HasParamEnv, LayoutError, LayoutOf, PointeeInfo, Size, TyLayout, VariantIdx,
HasParamEnv, LayoutError, LayoutOf, PointeeInfo, Size, TyLayout, VariantIdx,
};
use rustc::ty::{self, Instance, Ty, TyCtxt};
use rustc_codegen_ssa::base::wants_msvc_seh;
@ -23,15 +22,12 @@ use rustc_data_structures::base_n;
use rustc_data_structures::const_cstr;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_hir::Unsafety;
use rustc_target::spec::{HasTargetSpec, Target};
use crate::abi::Abi;
use rustc_span::source_map::{Span, DUMMY_SP};
use rustc_span::symbol::Symbol;
use std::cell::{Cell, RefCell};
use std::ffi::CStr;
use std::iter;
use std::str;
use std::sync::Arc;
@ -87,7 +83,6 @@ pub struct CodegenCx<'ll, 'tcx> {
pub dbg_cx: Option<debuginfo::CrateDebugContext<'ll, 'tcx>>,
eh_personality: Cell<Option<&'ll Value>>,
eh_unwind_resume: Cell<Option<&'ll Value>>,
pub rust_try_fn: Cell<Option<&'ll Value>>,
intrinsics: RefCell<FxHashMap<&'static str, &'ll Value>>,
@ -328,7 +323,6 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
isize_ty,
dbg_cx,
eh_personality: Cell::new(None),
eh_unwind_resume: Cell::new(None),
rust_try_fn: Cell::new(None),
intrinsics: Default::default(),
local_gen_sym_counter: Cell::new(0),
@ -406,45 +400,6 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
llfn
}
// Returns a Value of the "eh_unwind_resume" lang item if one is defined,
// otherwise declares it as an external function.
fn eh_unwind_resume(&self) -> &'ll Value {
let unwresume = &self.eh_unwind_resume;
if let Some(llfn) = unwresume.get() {
return llfn;
}
let tcx = self.tcx;
assert!(self.sess().target.target.options.custom_unwind_resume);
if let Some(def_id) = tcx.lang_items().eh_unwind_resume() {
let llfn = self.get_fn_addr(
ty::Instance::resolve(
tcx,
ty::ParamEnv::reveal_all(),
def_id,
tcx.intern_substs(&[]),
)
.unwrap(),
);
unwresume.set(Some(llfn));
return llfn;
}
let sig = ty::Binder::bind(tcx.mk_fn_sig(
iter::once(tcx.mk_mut_ptr(tcx.types.u8)),
tcx.types.never,
false,
Unsafety::Unsafe,
Abi::C,
));
let fn_abi = FnAbi::of_fn_ptr(self, sig, &[]);
let llfn = self.declare_fn("rust_eh_unwind_resume", &fn_abi);
attributes::apply_target_cpu_attr(self, llfn);
unwresume.set(Some(llfn));
llfn
}
fn sess(&self) -> &Session {
&self.tcx.sess
}

View File

@ -178,15 +178,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let lp1 = bx.load_operand(lp1).immediate();
slot.storage_dead(&mut bx);
if !bx.sess().target.target.options.custom_unwind_resume {
let mut lp = bx.const_undef(self.landing_pad_type());
lp = bx.insert_value(lp, lp0, 0);
lp = bx.insert_value(lp, lp1, 1);
bx.resume(lp);
} else {
bx.call(bx.eh_unwind_resume(), &[lp0], helper.funclet(self));
bx.unreachable();
}
}
}

View File

@ -14,7 +14,6 @@ pub trait MiscMethods<'tcx>: BackendTypes {
fn get_fn(&self, instance: Instance<'tcx>) -> Self::Function;
fn get_fn_addr(&self, instance: Instance<'tcx>) -> Self::Value;
fn eh_personality(&self) -> Self::Value;
fn eh_unwind_resume(&self) -> Self::Value;
fn sess(&self) -> &Session;
fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>>;
fn used_statics(&self) -> &RefCell<Vec<Self::Value>>;

View File

@ -240,7 +240,6 @@ language_item_table! {
StartFnLangItem, "start", start_fn, Target::Fn;
EhPersonalityLangItem, "eh_personality", eh_personality, Target::Fn;
EhUnwindResumeLangItem, "eh_unwind_resume", eh_unwind_resume, Target::Fn;
EhCatchTypeinfoLangItem, "eh_catch_typeinfo", eh_catch_typeinfo, Target::Static;
OwnedBoxLangItem, "owned_box", owned_box, Target::Struct;

View File

@ -43,6 +43,5 @@ impl LanguageItems {
weak_lang_items! {
panic_impl, PanicImplLangItem, rust_begin_unwind;
eh_personality, EhPersonalityLangItem, rust_eh_personality;
eh_unwind_resume, EhUnwindResumeLangItem, rust_eh_unwind_resume;
oom, OomLangItem, rust_oom;
}

View File

@ -28,9 +28,6 @@ pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>, items: &mut lang_items::LanguageItem
if items.eh_personality().is_none() {
items.missing.push(lang_items::EhPersonalityLangItem);
}
if tcx.sess.target.target.options.custom_unwind_resume & items.eh_unwind_resume().is_none() {
items.missing.push(lang_items::EhUnwindResumeLangItem);
}
{
let mut cx = Context { tcx, items };

View File

@ -287,7 +287,6 @@ symbols! {
dylib,
dyn_trait,
eh_personality,
eh_unwind_resume,
enable,
Encodable,
env,
@ -663,7 +662,6 @@ symbols! {
rustc_variance,
rustfmt,
rust_eh_personality,
rust_eh_unwind_resume,
rust_oom,
rvalue_static_promotion,
sanitize,

View File

@ -692,11 +692,6 @@ pub struct TargetOptions {
pub archive_format: String,
/// Is asm!() allowed? Defaults to true.
pub allow_asm: bool,
/// Whether the target uses a custom unwind resumption routine.
/// By default LLVM lowers `resume` instructions into calls to `_Unwind_Resume`
/// defined in libgcc. If this option is enabled, the target must provide
/// `eh_unwind_resume` lang item.
pub custom_unwind_resume: bool,
/// Whether the runtime startup code requires the `main` function be passed
/// `argc` and `argv` values.
pub main_needs_argc_argv: bool,
@ -866,7 +861,6 @@ impl Default for TargetOptions {
link_env: Vec::new(),
link_env_remove: Vec::new(),
archive_format: "gnu".to_string(),
custom_unwind_resume: false,
main_needs_argc_argv: true,
allow_asm: true,
has_elf_tls: false,
@ -1182,7 +1176,6 @@ impl Target {
key!(relro_level, RelroLevel)?;
key!(archive_format);
key!(allow_asm, bool);
key!(custom_unwind_resume, bool);
key!(main_needs_argc_argv, bool);
key!(has_elf_tls, bool);
key!(obj_is_bitcode, bool);
@ -1410,7 +1403,6 @@ impl ToJson for Target {
target_option_val!(relro_level);
target_option_val!(archive_format);
target_option_val!(allow_asm);
target_option_val!(custom_unwind_resume);
target_option_val!(main_needs_argc_argv);
target_option_val!(has_elf_tls);
target_option_val!(obj_is_bitcode);

View File

@ -54,7 +54,6 @@ pub fn opts() -> TargetOptions {
pre_link_objects_dll: vec!["rsbegin.o".to_string()],
late_link_args,
post_link_objects: vec!["rsend.o".to_string()],
custom_unwind_resume: true,
abi_return_struct_as_int: true,
emit_debug_gdb_scripts: false,
requires_uwtable: true,

View File

@ -11,5 +11,3 @@ use core::panic::PanicInfo;
fn panic_impl(info: &PanicInfo) -> ! { loop {} }
#[lang = "eh_personality"]
fn eh_personality() {}
#[lang = "eh_unwind_resume"]
fn eh_unwind_resume() {}

View File

@ -17,8 +17,6 @@ const X: () = unimplemented!();
#[lang = "eh_personality"]
fn eh() {}
#[lang = "eh_unwind_resume"]
fn eh_unwind_resume() {}
#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {

View File

@ -1,41 +1,41 @@
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:21:23
--> $DIR/macro-comma-behavior.rs:20:23
|
LL | assert_eq!(1, 1, "{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:24:23
--> $DIR/macro-comma-behavior.rs:23:23
|
LL | assert_ne!(1, 2, "{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:30:29
--> $DIR/macro-comma-behavior.rs:29:29
|
LL | debug_assert_eq!(1, 1, "{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:33:29
--> $DIR/macro-comma-behavior.rs:32:29
|
LL | debug_assert_ne!(1, 2, "{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:54:19
--> $DIR/macro-comma-behavior.rs:53:19
|
LL | format_args!("{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:72:21
--> $DIR/macro-comma-behavior.rs:71:21
|
LL | unimplemented!("{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:81:24
--> $DIR/macro-comma-behavior.rs:80:24
|
LL | write!(f, "{}",)?;
| ^^

View File

@ -9,7 +9,6 @@
#[cfg(std)] use std::fmt;
#[cfg(core)] use core::fmt;
#[cfg(core)] #[lang = "eh_personality"] fn eh_personality() {}
#[cfg(core)] #[lang = "eh_unwind_resume"] fn eh_unwind_resume() {}
#[cfg(core)] #[lang = "panic_impl"] fn panic_impl(panic: &core::panic::PanicInfo) -> ! { loop {} }
// (see documentation of the similarly-named test in run-pass)

View File

@ -1,59 +1,59 @@
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:21:23
--> $DIR/macro-comma-behavior.rs:20:23
|
LL | assert_eq!(1, 1, "{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:24:23
--> $DIR/macro-comma-behavior.rs:23:23
|
LL | assert_ne!(1, 2, "{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:30:29
--> $DIR/macro-comma-behavior.rs:29:29
|
LL | debug_assert_eq!(1, 1, "{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:33:29
--> $DIR/macro-comma-behavior.rs:32:29
|
LL | debug_assert_ne!(1, 2, "{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:38:18
--> $DIR/macro-comma-behavior.rs:37:18
|
LL | eprint!("{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:50:18
--> $DIR/macro-comma-behavior.rs:49:18
|
LL | format!("{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:54:19
--> $DIR/macro-comma-behavior.rs:53:19
|
LL | format_args!("{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:61:17
--> $DIR/macro-comma-behavior.rs:60:17
|
LL | print!("{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:72:21
--> $DIR/macro-comma-behavior.rs:71:21
|
LL | unimplemented!("{}",);
| ^^
error: 1 positional argument in format string, but no arguments were given
--> $DIR/macro-comma-behavior.rs:81:24
--> $DIR/macro-comma-behavior.rs:80:24
|
LL | write!(f, "{}",)?;
| ^^

View File

@ -12,5 +12,4 @@ fn main() {
}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "eh_unwind_resume"] extern fn eh_unwind_resume() {}
#[lang = "panic_impl"] fn panic_impl(panic: &PanicInfo) -> ! { loop {} }

View File

@ -11,5 +11,3 @@ use core::panic::PanicInfo;
fn panic_impl(info: &PanicInfo) -> ! { loop {} }
#[lang = "eh_personality"]
fn eh_personality() {}
#[lang = "eh_unwind_resume"]
fn eh_unwind_resume() {}

View File

@ -15,10 +15,6 @@ use core::ops::RangeBounds;
#[lang = "eh_personality"]
extern fn eh_personality() {}
#[cfg(target_os = "windows")]
#[lang = "eh_unwind_resume"]
extern fn eh_unwind_resume() {}
// take a reference to any built-in range
fn take_range(_r: &impl RangeBounds<i8>) {}

View File

@ -1,7 +1,7 @@
error: `#[panic_handler]` function required, but not found
error[E0308]: mismatched types
--> $DIR/issue-54505-no-std.rs:28:16
--> $DIR/issue-54505-no-std.rs:24:16
|
LL | take_range(0..1);
| ^^^^
@ -13,7 +13,7 @@ LL | take_range(0..1);
found struct `core::ops::Range<{integer}>`
error[E0308]: mismatched types
--> $DIR/issue-54505-no-std.rs:33:16
--> $DIR/issue-54505-no-std.rs:29:16
|
LL | take_range(1..);
| ^^^
@ -25,7 +25,7 @@ LL | take_range(1..);
found struct `core::ops::RangeFrom<{integer}>`
error[E0308]: mismatched types
--> $DIR/issue-54505-no-std.rs:38:16
--> $DIR/issue-54505-no-std.rs:34:16
|
LL | take_range(..);
| ^^
@ -37,7 +37,7 @@ LL | take_range(..);
found struct `core::ops::RangeFull`
error[E0308]: mismatched types
--> $DIR/issue-54505-no-std.rs:43:16
--> $DIR/issue-54505-no-std.rs:39:16
|
LL | take_range(0..=1);
| ^^^^^
@ -49,7 +49,7 @@ LL | take_range(0..=1);
found struct `core::ops::RangeInclusive<{integer}>`
error[E0308]: mismatched types
--> $DIR/issue-54505-no-std.rs:48:16
--> $DIR/issue-54505-no-std.rs:44:16
|
LL | take_range(..5);
| ^^^
@ -61,7 +61,7 @@ LL | take_range(..5);
found struct `core::ops::RangeTo<{integer}>`
error[E0308]: mismatched types
--> $DIR/issue-54505-no-std.rs:53:16
--> $DIR/issue-54505-no-std.rs:49:16
|
LL | take_range(..=42);
| ^^^^^