Skip to content

Commit f4f91f0

Browse files
committed
Remove eh_unwind_resume lang item
1 parent d73813a commit f4f91f0

File tree

24 files changed

+34
-140
lines changed

24 files changed

+34
-140
lines changed

Cargo.lock

-1
Original file line numberDiff line numberDiff line change
@@ -2308,7 +2308,6 @@ dependencies = [
23082308
name = "panic_abort"
23092309
version = "0.0.0"
23102310
dependencies = [
2311-
"cfg-if",
23122311
"compiler_builtins",
23132312
"core",
23142313
"libc",

src/doc/unstable-book/src/language-features/lang-items.md

+3-19
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ fn main(_argc: isize, _argv: *const *const u8) -> isize {
5252
5353
#[lang = "eh_personality"] extern fn rust_eh_personality() {}
5454
#[lang = "panic_impl"] extern fn rust_begin_panic(info: &PanicInfo) -> ! { unsafe { intrinsics::abort() } }
55-
#[lang = "eh_unwind_resume"] extern fn rust_eh_unwind_resume() {}
5655
#[no_mangle] pub extern fn rust_eh_register_frames () {}
5756
#[no_mangle] pub extern fn rust_eh_unregister_frames () {}
5857
```
@@ -67,7 +66,7 @@ Other features provided by lang items include:
6766
marked with lang items; those specific four are `eq`, `ord`,
6867
`deref`, and `add` respectively.
6968
- stack unwinding and general failure; the `eh_personality`,
70-
`eh_unwind_resume`, `fail` and `fail_bounds_checks` lang items.
69+
`panic` and `panic_bounds_checks` lang items.
7170
- the traits in `std::marker` used to indicate types of
7271
various kinds; lang items `send`, `sync` and `copy`.
7372
- the marker types and variance indicators found in
@@ -130,12 +129,6 @@ fn start(_argc: isize, _argv: *const *const u8) -> isize {
130129
pub extern fn rust_eh_personality() {
131130
}
132131
133-
// This function may be needed based on the compilation target.
134-
#[lang = "eh_unwind_resume"]
135-
#[no_mangle]
136-
pub extern fn rust_eh_unwind_resume() {
137-
}
138-
139132
#[lang = "panic_impl"]
140133
#[no_mangle]
141134
pub extern fn rust_begin_panic(info: &PanicInfo) -> ! {
@@ -173,12 +166,6 @@ pub extern fn main(_argc: i32, _argv: *const *const u8) -> i32 {
173166
pub extern fn rust_eh_personality() {
174167
}
175168
176-
// This function may be needed based on the compilation target.
177-
#[lang = "eh_unwind_resume"]
178-
#[no_mangle]
179-
pub extern fn rust_eh_unwind_resume() {
180-
}
181-
182169
#[lang = "panic_impl"]
183170
#[no_mangle]
184171
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
211198
the screen. While the language item's name is `panic_impl`, the symbol name is
212199
`rust_begin_panic`.
213200

214-
A third function, `rust_eh_unwind_resume`, is also needed if the `custom_unwind_resume`
215-
flag is set in the options of the compilation target. It allows customizing the
216-
process of resuming unwind at the end of the landing pads. The language item's name
217-
is `eh_unwind_resume`.
201+
Finally, a `eh_catch_typeinfo` static is needed for certain targets which
202+
implement Rust panics on top of C++ exceptions.
218203

219204
## List of all language items
220205

@@ -247,7 +232,6 @@ the source code.
247232
- `eh_personality`: `libpanic_unwind/emcc.rs` (EMCC)
248233
- `eh_personality`: `libpanic_unwind/gcc.rs` (GNU)
249234
- `eh_personality`: `libpanic_unwind/seh.rs` (SEH)
250-
- `eh_unwind_resume`: `libpanic_unwind/gcc.rs` (GCC)
251235
- `eh_catch_typeinfo`: `libpanic_unwind/emcc.rs` (EMCC)
252236
- `panic`: `libcore/panicking.rs`
253237
- `panic_bounds_check`: `libcore/panicking.rs`

src/libpanic_abort/Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ doc = false
1414
core = { path = "../libcore" }
1515
libc = { version = "0.2", default-features = false }
1616
compiler_builtins = "0.1.0"
17-
cfg-if = "0.1.8"

src/libpanic_abort/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub mod personalities {
115115
// Note that we don't execute landing pads, so this is never called, so it's
116116
// body is empty.
117117
#[no_mangle]
118-
#[cfg(all(target_os = "windows", target_env = "gnu"))]
118+
#[cfg(all(bootstrap, target_os = "windows", target_env = "gnu"))]
119119
pub extern "C" fn rust_eh_unwind_resume() {}
120120

121121
// These two are called by our startup objects on i686-pc-windows-gnu, but

src/libpanic_unwind/gcc.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,6 @@
3535
//!
3636
//! Once stack has been unwound down to the handler frame level, unwinding stops
3737
//! and the last personality routine transfers control to the catch block.
38-
//!
39-
//! ## `eh_personality` and `eh_unwind_resume`
40-
//!
41-
//! These language items are used by the compiler when generating unwind info.
42-
//! The first one is the personality routine described above. The second one
43-
//! allows compilation target to customize the process of resuming unwind at the
44-
//! end of the landing pads. `eh_unwind_resume` is used only if
45-
//! `custom_unwind_resume` flag in the target options is set.
4638
4739
#![allow(private_no_mangle_fns)]
4840

@@ -324,8 +316,8 @@ unsafe fn find_eh_action(
324316
eh::find_eh_action(lsda, &eh_context, foreign_exception)
325317
}
326318

327-
// See docs in the `unwind` module.
328319
#[cfg(all(
320+
bootstrap,
329321
target_os = "windows",
330322
any(target_arch = "x86", target_arch = "x86_64"),
331323
target_env = "gnu"

src/librustc/middle/lang_items.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ pub fn whitelisted(tcx: TyCtxt<'_>, lang_item: LangItem) -> bool {
5757
// symbols. Other panic runtimes ensure that the relevant symbols are
5858
// available to link things together, but they're never exercised.
5959
if tcx.sess.panic_strategy() != PanicStrategy::Unwind {
60-
return lang_item == LangItem::EhPersonalityLangItem
61-
|| lang_item == LangItem::EhUnwindResumeLangItem;
60+
return lang_item == LangItem::EhPersonalityLangItem;
6261
}
6362

6463
false

src/librustc_codegen_llvm/context.rs

+1-46
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use crate::abi::FnAbi;
21
use crate::attributes;
32
use crate::debuginfo;
43
use crate::llvm;
@@ -15,23 +14,20 @@ use rustc::mir::mono::CodegenUnit;
1514
use rustc::session::config::{self, CFGuard, DebugInfo};
1615
use rustc::session::Session;
1716
use rustc::ty::layout::{
18-
FnAbiExt, HasParamEnv, LayoutError, LayoutOf, PointeeInfo, Size, TyLayout, VariantIdx,
17+
HasParamEnv, LayoutError, LayoutOf, PointeeInfo, Size, TyLayout, VariantIdx,
1918
};
2019
use rustc::ty::{self, Instance, Ty, TyCtxt};
2120
use rustc_codegen_ssa::base::wants_msvc_seh;
2221
use rustc_data_structures::base_n;
2322
use rustc_data_structures::const_cstr;
2423
use rustc_data_structures::fx::FxHashMap;
2524
use rustc_data_structures::small_c_str::SmallCStr;
26-
use rustc_hir::Unsafety;
2725
use rustc_target::spec::{HasTargetSpec, Target};
2826

29-
use crate::abi::Abi;
3027
use rustc_span::source_map::{Span, DUMMY_SP};
3128
use rustc_span::symbol::Symbol;
3229
use std::cell::{Cell, RefCell};
3330
use std::ffi::CStr;
34-
use std::iter;
3531
use std::str;
3632
use std::sync::Arc;
3733

@@ -87,7 +83,6 @@ pub struct CodegenCx<'ll, 'tcx> {
8783
pub dbg_cx: Option<debuginfo::CrateDebugContext<'ll, 'tcx>>,
8884

8985
eh_personality: Cell<Option<&'ll Value>>,
90-
eh_unwind_resume: Cell<Option<&'ll Value>>,
9186
pub rust_try_fn: Cell<Option<&'ll Value>>,
9287

9388
intrinsics: RefCell<FxHashMap<&'static str, &'ll Value>>,
@@ -328,7 +323,6 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
328323
isize_ty,
329324
dbg_cx,
330325
eh_personality: Cell::new(None),
331-
eh_unwind_resume: Cell::new(None),
332326
rust_try_fn: Cell::new(None),
333327
intrinsics: Default::default(),
334328
local_gen_sym_counter: Cell::new(0),
@@ -406,45 +400,6 @@ impl MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
406400
llfn
407401
}
408402

409-
// Returns a Value of the "eh_unwind_resume" lang item if one is defined,
410-
// otherwise declares it as an external function.
411-
fn eh_unwind_resume(&self) -> &'ll Value {
412-
let unwresume = &self.eh_unwind_resume;
413-
if let Some(llfn) = unwresume.get() {
414-
return llfn;
415-
}
416-
417-
let tcx = self.tcx;
418-
assert!(self.sess().target.target.options.custom_unwind_resume);
419-
if let Some(def_id) = tcx.lang_items().eh_unwind_resume() {
420-
let llfn = self.get_fn_addr(
421-
ty::Instance::resolve(
422-
tcx,
423-
ty::ParamEnv::reveal_all(),
424-
def_id,
425-
tcx.intern_substs(&[]),
426-
)
427-
.unwrap(),
428-
);
429-
unwresume.set(Some(llfn));
430-
return llfn;
431-
}
432-
433-
let sig = ty::Binder::bind(tcx.mk_fn_sig(
434-
iter::once(tcx.mk_mut_ptr(tcx.types.u8)),
435-
tcx.types.never,
436-
false,
437-
Unsafety::Unsafe,
438-
Abi::C,
439-
));
440-
441-
let fn_abi = FnAbi::of_fn_ptr(self, sig, &[]);
442-
let llfn = self.declare_fn("rust_eh_unwind_resume", &fn_abi);
443-
attributes::apply_target_cpu_attr(self, llfn);
444-
unwresume.set(Some(llfn));
445-
llfn
446-
}
447-
448403
fn sess(&self) -> &Session {
449404
&self.tcx.sess
450405
}

src/librustc_codegen_ssa/mir/block.rs

+4-9
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,10 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
178178
let lp1 = bx.load_operand(lp1).immediate();
179179
slot.storage_dead(&mut bx);
180180

181-
if !bx.sess().target.target.options.custom_unwind_resume {
182-
let mut lp = bx.const_undef(self.landing_pad_type());
183-
lp = bx.insert_value(lp, lp0, 0);
184-
lp = bx.insert_value(lp, lp1, 1);
185-
bx.resume(lp);
186-
} else {
187-
bx.call(bx.eh_unwind_resume(), &[lp0], helper.funclet(self));
188-
bx.unreachable();
189-
}
181+
let mut lp = bx.const_undef(self.landing_pad_type());
182+
lp = bx.insert_value(lp, lp0, 0);
183+
lp = bx.insert_value(lp, lp1, 1);
184+
bx.resume(lp);
190185
}
191186
}
192187

src/librustc_codegen_ssa/traits/misc.rs

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ pub trait MiscMethods<'tcx>: BackendTypes {
1414
fn get_fn(&self, instance: Instance<'tcx>) -> Self::Function;
1515
fn get_fn_addr(&self, instance: Instance<'tcx>) -> Self::Value;
1616
fn eh_personality(&self) -> Self::Value;
17-
fn eh_unwind_resume(&self) -> Self::Value;
1817
fn sess(&self) -> &Session;
1918
fn codegen_unit(&self) -> &Arc<CodegenUnit<'tcx>>;
2019
fn used_statics(&self) -> &RefCell<Vec<Self::Value>>;

src/librustc_hir/lang_items.rs

-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ language_item_table! {
240240
StartFnLangItem, "start", start_fn, Target::Fn;
241241

242242
EhPersonalityLangItem, "eh_personality", eh_personality, Target::Fn;
243-
EhUnwindResumeLangItem, "eh_unwind_resume", eh_unwind_resume, Target::Fn;
244243
EhCatchTypeinfoLangItem, "eh_catch_typeinfo", eh_catch_typeinfo, Target::Static;
245244

246245
OwnedBoxLangItem, "owned_box", owned_box, Target::Struct;

src/librustc_hir/weak_lang_items.rs

-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,5 @@ impl LanguageItems {
4343
weak_lang_items! {
4444
panic_impl, PanicImplLangItem, rust_begin_unwind;
4545
eh_personality, EhPersonalityLangItem, rust_eh_personality;
46-
eh_unwind_resume, EhUnwindResumeLangItem, rust_eh_unwind_resume;
4746
oom, OomLangItem, rust_oom;
4847
}

src/librustc_passes/weak_lang_items.rs

-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ pub fn check_crate<'tcx>(tcx: TyCtxt<'tcx>, items: &mut lang_items::LanguageItem
2828
if items.eh_personality().is_none() {
2929
items.missing.push(lang_items::EhPersonalityLangItem);
3030
}
31-
if tcx.sess.target.target.options.custom_unwind_resume & items.eh_unwind_resume().is_none() {
32-
items.missing.push(lang_items::EhUnwindResumeLangItem);
33-
}
3431

3532
{
3633
let mut cx = Context { tcx, items };

src/librustc_span/symbol.rs

-2
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ symbols! {
287287
dylib,
288288
dyn_trait,
289289
eh_personality,
290-
eh_unwind_resume,
291290
enable,
292291
Encodable,
293292
env,
@@ -663,7 +662,6 @@ symbols! {
663662
rustc_variance,
664663
rustfmt,
665664
rust_eh_personality,
666-
rust_eh_unwind_resume,
667665
rust_oom,
668666
rvalue_static_promotion,
669667
sanitize,

src/librustc_target/spec/mod.rs

-8
Original file line numberDiff line numberDiff line change
@@ -692,11 +692,6 @@ pub struct TargetOptions {
692692
pub archive_format: String,
693693
/// Is asm!() allowed? Defaults to true.
694694
pub allow_asm: bool,
695-
/// Whether the target uses a custom unwind resumption routine.
696-
/// By default LLVM lowers `resume` instructions into calls to `_Unwind_Resume`
697-
/// defined in libgcc. If this option is enabled, the target must provide
698-
/// `eh_unwind_resume` lang item.
699-
pub custom_unwind_resume: bool,
700695
/// Whether the runtime startup code requires the `main` function be passed
701696
/// `argc` and `argv` values.
702697
pub main_needs_argc_argv: bool,
@@ -866,7 +861,6 @@ impl Default for TargetOptions {
866861
link_env: Vec::new(),
867862
link_env_remove: Vec::new(),
868863
archive_format: "gnu".to_string(),
869-
custom_unwind_resume: false,
870864
main_needs_argc_argv: true,
871865
allow_asm: true,
872866
has_elf_tls: false,
@@ -1182,7 +1176,6 @@ impl Target {
11821176
key!(relro_level, RelroLevel)?;
11831177
key!(archive_format);
11841178
key!(allow_asm, bool);
1185-
key!(custom_unwind_resume, bool);
11861179
key!(main_needs_argc_argv, bool);
11871180
key!(has_elf_tls, bool);
11881181
key!(obj_is_bitcode, bool);
@@ -1410,7 +1403,6 @@ impl ToJson for Target {
14101403
target_option_val!(relro_level);
14111404
target_option_val!(archive_format);
14121405
target_option_val!(allow_asm);
1413-
target_option_val!(custom_unwind_resume);
14141406
target_option_val!(main_needs_argc_argv);
14151407
target_option_val!(has_elf_tls);
14161408
target_option_val!(obj_is_bitcode);

src/librustc_target/spec/windows_uwp_base.rs

-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ pub fn opts() -> TargetOptions {
5454
pre_link_objects_dll: vec!["rsbegin.o".to_string()],
5555
late_link_args,
5656
post_link_objects: vec!["rsend.o".to_string()],
57-
custom_unwind_resume: true,
5857
abi_return_struct_as_int: true,
5958
emit_debug_gdb_scripts: false,
6059
requires_uwtable: true,

src/test/compile-fail/auxiliary/panic-runtime-lang-items.rs

-2
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ use core::panic::PanicInfo;
1111
fn panic_impl(info: &PanicInfo) -> ! { loop {} }
1212
#[lang = "eh_personality"]
1313
fn eh_personality() {}
14-
#[lang = "eh_unwind_resume"]
15-
fn eh_unwind_resume() {}

src/test/ui/consts/const-eval/const_panic_libcore_main.rs

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ const X: () = unimplemented!();
1717

1818
#[lang = "eh_personality"]
1919
fn eh() {}
20-
#[lang = "eh_unwind_resume"]
21-
fn eh_unwind_resume() {}
2220

2321
#[panic_handler]
2422
fn panic(_info: &PanicInfo) -> ! {

src/test/ui/macros/macro-comma-behavior.core.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
error: 1 positional argument in format string, but no arguments were given
2-
--> $DIR/macro-comma-behavior.rs:21:23
2+
--> $DIR/macro-comma-behavior.rs:20:23
33
|
44
LL | assert_eq!(1, 1, "{}",);
55
| ^^
66

77
error: 1 positional argument in format string, but no arguments were given
8-
--> $DIR/macro-comma-behavior.rs:24:23
8+
--> $DIR/macro-comma-behavior.rs:23:23
99
|
1010
LL | assert_ne!(1, 2, "{}",);
1111
| ^^
1212

1313
error: 1 positional argument in format string, but no arguments were given
14-
--> $DIR/macro-comma-behavior.rs:30:29
14+
--> $DIR/macro-comma-behavior.rs:29:29
1515
|
1616
LL | debug_assert_eq!(1, 1, "{}",);
1717
| ^^
1818

1919
error: 1 positional argument in format string, but no arguments were given
20-
--> $DIR/macro-comma-behavior.rs:33:29
20+
--> $DIR/macro-comma-behavior.rs:32:29
2121
|
2222
LL | debug_assert_ne!(1, 2, "{}",);
2323
| ^^
2424

2525
error: 1 positional argument in format string, but no arguments were given
26-
--> $DIR/macro-comma-behavior.rs:54:19
26+
--> $DIR/macro-comma-behavior.rs:53:19
2727
|
2828
LL | format_args!("{}",);
2929
| ^^
3030

3131
error: 1 positional argument in format string, but no arguments were given
32-
--> $DIR/macro-comma-behavior.rs:72:21
32+
--> $DIR/macro-comma-behavior.rs:71:21
3333
|
3434
LL | unimplemented!("{}",);
3535
| ^^
3636

3737
error: 1 positional argument in format string, but no arguments were given
38-
--> $DIR/macro-comma-behavior.rs:81:24
38+
--> $DIR/macro-comma-behavior.rs:80:24
3939
|
4040
LL | write!(f, "{}",)?;
4141
| ^^

src/test/ui/macros/macro-comma-behavior.rs

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#[cfg(std)] use std::fmt;
1010
#[cfg(core)] use core::fmt;
1111
#[cfg(core)] #[lang = "eh_personality"] fn eh_personality() {}
12-
#[cfg(core)] #[lang = "eh_unwind_resume"] fn eh_unwind_resume() {}
1312
#[cfg(core)] #[lang = "panic_impl"] fn panic_impl(panic: &core::panic::PanicInfo) -> ! { loop {} }
1413

1514
// (see documentation of the similarly-named test in run-pass)

0 commit comments

Comments
 (0)