Add internal RUSTC_INTERNAL_FORCE_PANIC_ABORT env var for libpanic_abort#66311
Closed
Aaron1011 wants to merge 1 commit intorust-lang:masterfrom
Closed
Add internal RUSTC_INTERNAL_FORCE_PANIC_ABORT env var for libpanic_abort#66311Aaron1011 wants to merge 1 commit intorust-lang:masterfrom
RUSTC_INTERNAL_FORCE_PANIC_ABORT env var for libpanic_abort#66311Aaron1011 wants to merge 1 commit intorust-lang:masterfrom
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently, we require
libpanic_abortto always be build with theabortpanic strategy, regardless of what panic strategy wouldnormally be passed to
rustc(e.g.unwindwhen buildinglibstd).This ensures that when downstream crates build against
libpanic_abort,it is properly detected as the panic runtime for the
abortstrategy.Previously, this was done by special-casing
libpanic_abortinbootstrap. This meant that building
libpanic_abortwithout usingx.py(e.g by usingxargo) would result in the wrong panic strategybeing applied, leading to an error when trying to build against it:
This is a problem for tools like Miri, which require a custom-build
libstd, and cannot use
x.py.To fix this, we add a special environment variable
RUSTC_INTERNAL_FORCE_PANIC_ABORT. This is set in thebuild.rsfor
libpanic_abort, and checked by the compiler when determining thepanic strategy of the current crate. While this is still a hack, it's a
much better one - the special case is now represented in the
libpanic_abortcrate itself, rather than inbootstrap.Ideally, this would be an internal attribute (e.g.
#[rustc_panic_abort]) that we apply tolibpanic_abort.Unfortunately,
emscriptentargets require that we be able to determinethe panic strategy very early on, before we've even started parsing the
crate:
rust/src/librustc_codegen_llvm/llvm_util.rs
Line 77 in 3fc30d8
To avoid invasive changes to emscripten and/or the codewgen backend
infrastructure, I chose to add a new environment variable.
Note that the hack in bootstrap needs to remain until this changes makes
its way into the bootstrap compiler, to ensure that we can still build a
correct
libpanic_abortwith a bootstrap compiler that doesn't knowabout this special environment variable.