about summary refs log tree commit diff
path: root/src/test/compile-fail/unwind-tables-panic-required.rs
diff options
context:
space:
mode:
authorSam Elliott <selliott@lowrisc.org>2020-05-04 12:08:35 +0100
committerSam Elliott <selliott@lowrisc.org>2020-05-04 12:08:35 +0100
commitcda994633ee109639b9c4c12c20e2aacb6a879cd (patch)
tree29f36af9ce8b3325f8cd92818e5ef74fe3780adc /src/test/compile-fail/unwind-tables-panic-required.rs
parentd626e4dadc37d7027d65f087da0ad1ddb460959f (diff)
downloadrust-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/test/compile-fail/unwind-tables-panic-required.rs')
-rw-r--r--src/test/compile-fail/unwind-tables-panic-required.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/test/compile-fail/unwind-tables-panic-required.rs b/src/test/compile-fail/unwind-tables-panic-required.rs
new file mode 100644
index 00000000000..314d9e778d5
--- /dev/null
+++ b/src/test/compile-fail/unwind-tables-panic-required.rs
@@ -0,0 +1,10 @@
+// Tests that the compiler errors if the user tries to turn off unwind tables
+// when they are required.
+//
+// compile-flags: -C panic=unwind -C force-unwind-tables=no
+// ignore-tidy-linelength
+//
+// error-pattern: panic=unwind requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`.
+
+pub fn main() {
+}