diff options
| author | Sam Elliott <selliott@lowrisc.org> | 2020-05-04 12:08:35 +0100 |
|---|---|---|
| committer | Sam Elliott <selliott@lowrisc.org> | 2020-05-04 12:08:35 +0100 |
| commit | cda994633ee109639b9c4c12c20e2aacb6a879cd (patch) | |
| tree | 29f36af9ce8b3325f8cd92818e5ef74fe3780adc /src/librustc_codegen_llvm/attributes.rs | |
| parent | d626e4dadc37d7027d65f087da0ad1ddb460959f (diff) | |
| download | rust-cda994633ee109639b9c4c12c20e2aacb6a879cd.tar.gz rust-cda994633ee109639b9c4c12c20e2aacb6a879cd.zip | |
Add Option to Force Unwind Tables
When panic != unwind, `nounwind` is added to all functions for a target. This can cause issues when a panic happens with RUST_BACKTRACE=1, as there needs to be a way to reconstruct the backtrace. There are three possible sources of this information: forcing frame pointers (for which an option exists already), debug info (for which an option exists), or unwind tables. Especially for embedded devices, forcing frame pointers can have code size overheads (RISC-V sees ~10% overheads, ARM sees ~2-3% overheads). In code, it can be the case that debug info is not kept, so it is useful to provide this third option, unwind tables, that users can use to reconstruct the call stack. Reconstructing this stack is harder than with frame pointers, but it is still possible. This commit adds a compiler option which allows a user to force the addition of unwind tables. Unwind tables cannot be disabled on targets that require them for correctness, or when using `-C panic=unwind`.
Diffstat (limited to 'src/librustc_codegen_llvm/attributes.rs')
| -rw-r--r-- | src/librustc_codegen_llvm/attributes.rs | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/librustc_codegen_llvm/attributes.rs b/src/librustc_codegen_llvm/attributes.rs index fc357ebb05d..64412843f6d 100644 --- a/src/librustc_codegen_llvm/attributes.rs +++ b/src/librustc_codegen_llvm/attributes.rs @@ -13,7 +13,6 @@ use rustc_middle::ty::query::Providers; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::config::{OptLevel, Sanitizer}; use rustc_session::Session; -use rustc_target::spec::PanicStrategy; use crate::attributes; use crate::llvm::AttributePlace::Function; @@ -271,9 +270,7 @@ pub fn from_fn_attrs(cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value, instance: ty:: // // You can also find more info on why Windows is whitelisted here in: // https://bugzilla.mozilla.org/show_bug.cgi?id=1302078 - if cx.sess().panic_strategy() == PanicStrategy::Unwind - || cx.sess().target.target.options.requires_uwtable - { + if cx.sess().must_emit_unwind_tables() { attributes::emit_uwtable(llfn, true); } |
