Commit 5a826c7
committed
Add internal
Currently, we require `libpanic_abort` to always be build with the
`abort` panic strategy, regardless of what panic strategy would
normally be passed to `rustc` (e.g. `unwind` when building `libstd`).
This ensures that when downstream crates build against `libpanic_abort`,
it is properly detected as the panic runtime for the `abort` strategy.
Previously, this was done by special-casing `libpanic_abort` in
bootstrap. This meant that building `libpanic_abort` without using
`x.py` (e.g by using `xargo`) would result in the wrong panic strategy
being applied, leading to an error when trying to build against it:
```
error: the crate `panic_abort` does not have the panic strategy `abort`
```
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 the `build.rs`
for `libpanic_abort`, and checked by the compiler when determining the
panic 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_abort` crate itself, rather than in `bootstrap`.
Ideally, this would be an internal attribute (e.g.
`#[rustc_panic_abort]`) that we apply to `libpanic_abort`.
Unfortunately, `emscripten` targets require that we be able to determine
the panic strategy very early on, before we've even started parsing the
crate:
https://github.com/rust-lang/rust/blob/3fc30d884ae0c988d98452a06737705cfe34806a/src/librustc_codegen_llvm/llvm_util.rs#L77
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_abort` with a bootstrap compiler that doesn't know
about this special environment variable.RUSTC_INTERNAL_FORCE_PANIC_ABORT env var for libpanic_abort
1 parent 56237d7 commit 5a826c7
3 files changed
+24
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
97 | 102 | | |
98 | 103 | | |
99 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
563 | 563 | | |
564 | 564 | | |
565 | 565 | | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
566 | 578 | | |
567 | 579 | | |
568 | 580 | | |
| |||
0 commit comments