Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign uprustc: Implement custom panic runtimes #32900
Conversation
alexcrichton
referenced this pull request
Apr 12, 2016
Open
Pluggable panic implementations (tracking issue for RFC 1513) #32837
This comment has been minimized.
This comment has been minimized.
alexcrichton
assigned
nikomatsakis
Apr 12, 2016
retep998
reviewed
Apr 12, 2016
| extern "system" { | ||
| fn ExitProcess(code: u32) -> !; | ||
| } | ||
| ExitProcess(101); |
This comment has been minimized.
This comment has been minimized.
retep998
Apr 12, 2016
Member
This is a rather quiet way of exiting the process. If we want something that debuggers will notice we need a noisier way of killing the process, like say __fastfail.
This comment has been minimized.
This comment has been minimized.
alexcrichton
Apr 12, 2016
Author
Member
I'd be fine doing so, but it doesn't appear that there's a function we can call anywhere? Must we resort to assembly to actually do that?
This comment has been minimized.
This comment has been minimized.
retep998
Apr 12, 2016
Member
Unfortunately it is an intrisic so unless LLVM gets an intrinsic for it, there's not much we can do other than using assembly. Alternatively we can raise an uncatchable exception as described here.
This comment has been minimized.
This comment has been minimized.
retep998
Apr 12, 2016
Member
Or wait, never mind, there is the function RaiseFailFastException although it requires Windows 7 at a minimum.
This comment has been minimized.
This comment has been minimized.
alexcrichton
Apr 12, 2016
Author
Member
Ok, I've updated to just use intrinsics::abort for now and we can perhaps look into fastfail later
This comment has been minimized.
This comment has been minimized.
|
Sweet patch. |
Ericson2314
reviewed
Apr 12, 2016
| // | ||
| // This... is a bit of a hack how we detect this. Ideally this information | ||
| // should be encoded in the crate I guess? Would likely require an RFC | ||
| // amendment to RFC 1513, however. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
alexcrichton
Apr 12, 2016
Author
Member
No, that's meant for compiling an entire DAG with a particular panic runtime
This comment has been minimized.
This comment has been minimized.
Ericson2314
Apr 12, 2016
Contributor
Ah gotcha, because even when building panic_abort alone, there's the deps of libc, alloc, and core in the DAG too. Sorry for the noise.
alexcrichton
force-pushed the
alexcrichton:panic2abort
branch
from
d7f2e11
to
936aee5
Apr 12, 2016
arielb1
reviewed
Apr 12, 2016
| }); | ||
|
|
||
| fn get_call<F: FnMut()>(_: &mut F) -> fn(&mut F) { | ||
| call |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
alexcrichton
Apr 12, 2016
Author
Member
Hm good point! This felt a little weird... The signature of that though is:
extern "rust-call" fn(&mut F, ());Which I'm slightly hesitant to transmute to fn(*mut u8) due to the second argument...
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
force-pushed the
alexcrichton:panic2abort
branch
2 times, most recently
from
d7e2d4d
to
22b5ae0
Apr 12, 2016
nikomatsakis
reviewed
Apr 12, 2016
| //! The first one is the personality routine described above. The second one | ||
| //! allows compilation target to customize the process of resuming unwind at the | ||
| //! end of the landing pads. `eh_unwind_resume` is used only if | ||
| //! `custom_unwind_resume` flag in the target options is set. |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
reviewed
Apr 12, 2016
| }; | ||
| info!("panic runtime not found -- loading {}", name); | ||
|
|
||
| // To ensure that the `-Z allocation-crate=foo` option isn't abused, and |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Apr 12, 2016
Contributor
this comment is presumably copied-and-pasted over from the allocator code
This comment has been minimized.
This comment has been minimized.
alexcrichton
Apr 12, 2016
Author
Member
What in the world is this comment, that flag doesn't even exist.
nikomatsakis
reviewed
Apr 12, 2016
| fn inject_dependency_if(&self, | ||
| krate: ast::CrateNum, | ||
| what: &str, | ||
| needs_dep: &Fn(&cstore::crate_metadata) -> bool) { | ||
| // Before we inject any dependencies, make sure we don't inject a | ||
| // circular dependency by validating that this allocator crate doesn't | ||
| // transitively depend on any `#![needs_allocator]` crates. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
r=me once tidy errors are fixed. this is nice. |
alexcrichton
force-pushed the
alexcrichton:panic2abort
branch
from
22b5ae0
to
a9e4f62
Apr 12, 2016
This comment has been minimized.
This comment has been minimized.
alexcrichton
added
the
relnotes
label
Apr 12, 2016
alexcrichton
force-pushed the
alexcrichton:panic2abort
branch
from
a9e4f62
to
30fbd36
Apr 12, 2016
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Apr 14, 2016
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
force-pushed the
alexcrichton:panic2abort
branch
from
30fbd36
to
2ef34ad
Apr 14, 2016
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
alexcrichton
force-pushed the
alexcrichton:panic2abort
branch
from
2ef34ad
to
155a9c6
Apr 14, 2016
This comment has been minimized.
This comment has been minimized.
alexcrichton
force-pushed the
alexcrichton:panic2abort
branch
from
155a9c6
to
cc62450
Apr 14, 2016
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
May 8, 2016
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
force-pushed the
alexcrichton:panic2abort
branch
from
4105144
to
451c9b4
May 9, 2016
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
May 9, 2016
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
force-pushed the
alexcrichton:panic2abort
branch
2 times, most recently
from
16ea0fa
to
3ac27d9
May 9, 2016
samlh
reviewed
May 9, 2016
| #[cfg(not(stage0))] | ||
| pub extern fn rust_eh_personality() {} | ||
| pub mod peronalities { |
This comment has been minimized.
This comment has been minimized.
alexcrichton
force-pushed the
alexcrichton:panic2abort
branch
from
3ac27d9
to
4ade7c1
May 10, 2016
alexcrichton
force-pushed the
alexcrichton:panic2abort
branch
from
4ade7c1
to
38e6e5d
May 10, 2016
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
May 10, 2016
This comment has been minimized.
This comment has been minimized.
bors
merged commit 38e6e5d
into
rust-lang:master
May 10, 2016
This was referenced May 10, 2016
This comment has been minimized.
This comment has been minimized.
|
19th time's the charm |
alexcrichton commentedApr 12, 2016
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
unwindorpanic, with the default beingunwind. This model affects how code is generated for the local crate, skippinggeneration of landing pads with
-C panic=abort.Panic implementations are then provided by crates tagged with
#![panic_runtime]and lazily required by crates with#![needs_panic_runtime]. The panic strategy (-C panicvalue) of the panicruntime must match the final product, and if the panic strategy is not
abortthen the entire DAG must have the same panic strategy.
With the
-C panic=abortstrategy, users can expect a stable method to disablegeneration of landing pads, improving optimization in niche scenarios,
decreasing compile time, and decreasing output binary size. With the
-C panic=unwindstrategy users can expect the existing ability to isolate failurein Rust code from the outside world.
Organizationally, this commit dismantles the
sys_common::unwindmodule infavor of some bits moving part of it to
libpanic_unwindand the rest into thepanickingmodule in libstd. The custom panic runtime support is pretty similarto the custom allocator support with the only major difference being how the
panic runtime is injected (takes the
-C panicflag into account).Closes #32837