Stream: project-ffi-unwind

Topic: panic=abort and libstd


view this post on Zulip nikomatsakis (Sep 02 2021 at 18:18):

Hey @Alex Crichton -- for libstd, we compile a dylib in panic=unwind, right? But when you actually panic, the code does an abort? Is that correct? If so, is there an if panicabort { abort() } in the code that starts a panic? Where is that code?

view this post on Zulip Alex Crichton (Sep 02 2021 at 18:24):

we do complie a libstd.so dylib which is panic=unwind

view this post on Zulip Alex Crichton (Sep 02 2021 at 18:24):

there's not actually a conditional, though, rather the behavior of a panic is defined by whether the panic_abort or panic_unwind crates are linked in

view this post on Zulip Alex Crichton (Sep 02 2021 at 18:25):

and you can only link one of those, so if you link to libstd.so you're forced into unwinding (because it links to panic_abort)

view this post on Zulip BatmanAoD (Kyle Strand) (Sep 02 2021 at 18:26):

Similarly, we only link one personality function in a given binary, correct?

view this post on Zulip nikomatsakis (Sep 02 2021 at 18:26):

Alex Crichton said:

there's not actually a conditional, though, rather the behavior of a panic is defined by whether the panic_abort or panic_unwind crates are linked in

ok

view this post on Zulip nikomatsakis (Sep 02 2021 at 18:27):

Alex Crichton said:

and you can only link one of those, so if you link to libstd.so you're forced into unwinding (because it links to panic_abort)

wat

view this post on Zulip nikomatsakis (Sep 02 2021 at 18:27):

am I very confused or is this sentence full of errors :)

view this post on Zulip Alex Crichton (Sep 02 2021 at 18:28):

er sorry, libstd.so links to panic_unwind

view this post on Zulip Alex Crichton (Sep 02 2021 at 18:28):

which forces libstd.so to always be unwinding

view this post on Zulip Alex Crichton (Sep 02 2021 at 18:29):

which means you can't compile with -Cpanic=abort and link to libstd.so

view this post on Zulip nikomatsakis (Sep 02 2021 at 18:29):

ok. that is surprising to me too, because I thought all Rust code linked to libstd.so (apart from no-std, of course)

view this post on Zulip BatmanAoD (Kyle Strand) (Sep 02 2021 at 18:29):

I thought that was something the error-handling group addressed?

view this post on Zulip nikomatsakis (Sep 02 2021 at 18:29):

but with panic=abort we link to something else?

view this post on Zulip BatmanAoD (Kyle Strand) (Sep 02 2021 at 18:30):

Does that mean that panic=abort needs to be no-std?

view this post on Zulip Alex Crichton (Sep 02 2021 at 18:31):

oh there's a difference between libstd.rlib and libstd.so, code linking to libstd.rlib has a choice of panic runtime, code by default doesn't link to libstd.so

view this post on Zulip Alex Crichton (Sep 02 2021 at 18:32):

with panic=abort it instructs the final link to link against panic-abort.rlib instead of panic-unwind.rlib


Last updated: Jan 26 2022 at 07:20 UTC