Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ab568bf

Browse files
committedMay 5, 2016
Auto merge of #32900 - alexcrichton:panic2abort, r=nikomatsakis
rustc: Implement custom panic runtimes This commit is an implementation of [RFC 1513] which allows applications to alter the behavior of panics at compile time. A new compiler flag, `-C panic`, is added and accepts the values `unwind` or `panic`, with the default being `unwind`. This model affects how code is generated for the local crate, skipping generation of landing pads with `-C panic=abort`. [RFC 1513]: https://github.com/rust-lang/rfcs/blob/master/text/1513-less-unwinding.md Panic implementations are then provided by crates tagged with `#![panic_runtime]` and lazily required by crates with `#![needs_panic_runtime]`. The panic strategy (`-C panic` value) of the panic runtime must match the final product, and if the panic strategy is not `abort` then the entire DAG must have the same panic strategy. With the `-C panic=abort` strategy, users can expect a stable method to disable generation of landing pads, improving optimization in niche scenarios, decreasing compile time, and decreasing output binary size. With the `-C panic=unwind` strategy users can expect the existing ability to isolate failure in Rust code from the outside world. Organizationally, this commit dismantles the `sys_common::unwind` module in favor of some bits moving part of it to `libpanic_unwind` and the rest into the `panicking` module in libstd. The custom panic runtime support is pretty similar to the custom allocator support with the only major difference being how the panic runtime is injected (takes the `-C panic` flag into account). Closes #32837
2 parents 7a0ccc4 + 9320ee3 commit ab568bf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2256
-931
lines changed
 

‎mk/crates.mk

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ TARGET_CRATES := libc std term \
5353
getopts collections test rand \
5454
core alloc \
5555
rustc_unicode rustc_bitflags \
56-
alloc_system alloc_jemalloc
56+
alloc_system alloc_jemalloc \
57+
panic_abort panic_unwind unwind
5758
RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_driver \
5859
rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \
5960
rustc_data_structures rustc_platform_intrinsics \
@@ -72,10 +73,18 @@ DEPS_libc := core
7273
DEPS_rand := core
7374
DEPS_rustc_bitflags := core
7475
DEPS_rustc_unicode := core
76+
DEPS_panic_abort := libc alloc
77+
DEPS_panic_unwind := libc alloc unwind
78+
DEPS_unwind := libc
79+
80+
# FIXME(stage0): change this to just `RUSTFLAGS_panic_abort := ...`
81+
RUSTFLAGS1_panic_abort := -C panic=abort
82+
RUSTFLAGS2_panic_abort := -C panic=abort
83+
RUSTFLAGS3_panic_abort := -C panic=abort
7584

7685
DEPS_std := core libc rand alloc collections rustc_unicode \
7786
native:backtrace \
78-
alloc_system
87+
alloc_system panic_abort panic_unwind unwind
7988
DEPS_arena := std
8089
DEPS_glob := std
8190
DEPS_flate := std native:miniz
@@ -148,6 +157,9 @@ ONLY_RLIB_rustc_unicode := 1
148157
ONLY_RLIB_rustc_bitflags := 1
149158
ONLY_RLIB_alloc_system := 1
150159
ONLY_RLIB_alloc_jemalloc := 1
160+
ONLY_RLIB_panic_unwind := 1
161+
ONLY_RLIB_panic_abort := 1
162+
ONLY_RLIB_unwind := 1
151163

152164
TARGET_SPECIFIC_alloc_jemalloc := 1
153165

‎mk/tests.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ DEPS_collectionstest :=
2323
$(eval $(call RUST_CRATE,collectionstest))
2424

2525
TEST_TARGET_CRATES = $(filter-out core rustc_unicode alloc_system libc \
26-
alloc_jemalloc,$(TARGET_CRATES)) \
26+
alloc_jemalloc panic_unwind \
27+
panic_abort,$(TARGET_CRATES)) \
2728
collectionstest coretest
2829
TEST_DOC_CRATES = $(DOC_CRATES) arena flate fmt_macros getopts graphviz \
2930
log rand rbml serialize syntax term test

0 commit comments

Comments
 (0)
Please sign in to comment.