]> git.lizzy.rs Git - rust.git/commit
rustc: Implement custom panic runtimes
authorAlex Crichton <alex@alexcrichton.com>
Fri, 8 Apr 2016 23:18:40 +0000 (16:18 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Mon, 9 May 2016 15:22:36 +0000 (08:22 -0700)
commit0ec321f7b541fcbfbf20286beb497e6d9d3352b2
tree30abd6498f7e3ae65fa94057e2bd46f6c769fcf2
parent32683ce1930ef1390f20e4ab72650e6804fd1c1b
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).
82 files changed:
mk/crates.mk
mk/tests.mk
src/bootstrap/rustc.rs
src/liballoc_system/lib.rs
src/libpanic_abort/Cargo.toml [new file with mode: 0644]
src/libpanic_abort/lib.rs [new file with mode: 0644]
src/libpanic_unwind/Cargo.lock [new file with mode: 0644]
src/libpanic_unwind/Cargo.toml [new file with mode: 0644]
src/libpanic_unwind/dwarf/eh.rs [new file with mode: 0644]
src/libpanic_unwind/dwarf/mod.rs [new file with mode: 0644]
src/libpanic_unwind/gcc.rs [new file with mode: 0644]
src/libpanic_unwind/lib.rs [new file with mode: 0644]
src/libpanic_unwind/seh.rs [new file with mode: 0644]
src/libpanic_unwind/seh64_gnu.rs [new file with mode: 0644]
src/libpanic_unwind/windows.rs [new file with mode: 0644]
src/librustc/middle/cstore.rs
src/librustc/middle/dependency_format.rs
src/librustc/middle/weak_lang_items.rs
src/librustc/session/config.rs
src/librustc/session/mod.rs
src/librustc_metadata/common.rs
src/librustc_metadata/creader.rs
src/librustc_metadata/csearch.rs
src/librustc_metadata/cstore.rs
src/librustc_metadata/decoder.rs
src/librustc_metadata/encoder.rs
src/librustc_trans/base.rs
src/libstd/Cargo.toml
src/libstd/build.rs
src/libstd/lib.rs
src/libstd/macros.rs
src/libstd/panic.rs
src/libstd/panicking.rs
src/libstd/rt.rs
src/libstd/sys/common/dwarf/eh.rs [deleted file]
src/libstd/sys/common/dwarf/mod.rs [deleted file]
src/libstd/sys/common/libunwind.rs [deleted file]
src/libstd/sys/common/mod.rs
src/libstd/sys/common/unwind/gcc.rs [deleted file]
src/libstd/sys/common/unwind/mod.rs [deleted file]
src/libstd/sys/common/unwind/seh.rs [deleted file]
src/libstd/sys/common/unwind/seh64_gnu.rs [deleted file]
src/libstd/sys/unix/backtrace/tracing/gcc_s.rs
src/libstd/sys/windows/c.rs
src/libstd/thread/mod.rs
src/libsyntax/ext/build.rs
src/libsyntax/feature_gate.rs
src/libtest/lib.rs
src/libunwind/Cargo.toml [new file with mode: 0644]
src/libunwind/build.rs [new file with mode: 0644]
src/libunwind/lib.rs [new file with mode: 0644]
src/libunwind/libunwind.rs [new file with mode: 0644]
src/rustc/std_shim/Cargo.lock
src/test/codegen/lto-removes-invokes.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/abort-link-to-unwind-dylib.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/auxiliary/needs-panic-runtime.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-abort.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-lang-items.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-unwind.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/auxiliary/panic-runtime-unwind2.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/auxiliary/runtime-depending-on-panic-runtime.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/auxiliary/wants-panic-runtime-abort.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/auxiliary/wants-panic-runtime-unwind.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/bad-panic-flag1.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/bad-panic-flag2.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/libtest-unwinds.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/needs-gate.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/runtime-depend-on-needs-runtime.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/transitive-link-a-bunch.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/two-panic-runtimes.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/want-abort-got-unwind.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/want-abort-got-unwind2.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/want-unwind-got-abort.rs [new file with mode: 0644]
src/test/compile-fail/panic-runtime/want-unwind-got-abort2.rs [new file with mode: 0644]
src/test/run-pass/panic-runtime/abort-link-to-unwinding-crates.rs [new file with mode: 0644]
src/test/run-pass/panic-runtime/abort.rs [new file with mode: 0644]
src/test/run-pass/panic-runtime/auxiliary/exit-success-if-unwind.rs [new file with mode: 0644]
src/test/run-pass/panic-runtime/link-to-abort.rs [new file with mode: 0644]
src/test/run-pass/panic-runtime/link-to-unwind.rs [new file with mode: 0644]
src/test/run-pass/panic-runtime/lto-abort.rs [new file with mode: 0644]
src/test/run-pass/panic-runtime/lto-unwind.rs [new file with mode: 0644]
src/tools/tidy/src/cargo.rs