Since the last month or so, stage1 tests (make check-stage1
) don’t work. The shallow cause is @alexcrichton’s PR 27176, which changed the behaviour of -Z no-landing-pads
.
Landing pads are required to clean resources owned by the current process on unwinding. Programs that run multiple tasks in a single process and desire high availability require it to limit the effect of logic errors.
rustc, like many programs, is neither of these, and does not need that sort of cleanup. Landing pads have a compile-time, and potentionally a run-time, cost, which were once measured to be about 20% in total in the case of rustc. Therefore, it is desirable to compile it without landing pads. Currently, stage2, the final compilation output product, is compiled with them, but as an optimization stage1 does not use them.
However, rustc uses panics as part of its error handling mechanism - both to bail out of nested code, e.g. in the case of trait overflow while evaluating built-in kinds (while this is suboptimal, avoiding it in this case would significantly complicate the compiler), as well as to handle internal compiler errors which are unfortunately all too common.
Rust’s native reaction to panics is to print an ugly message to stderr and unwind. This is not desirable at least in rustc’s case, so it disables the ugly message and catches the panic, and then exits, potentiality after displaying a nicer message if there was an ICE. Obviously, leaking the stack is irrelevant here.
The problematic patch had made unwinding crash when used on a program compiled without landing pads. This change is probably for the better, as it makes programs compiled without landing pads not depend on unwinding in any way. Unfortunately, it makes rustc crash after it reports a fatal error, which breaks the tests on stage1, and requires compiling stage2 to run them. This can be easily fixed by not trying to unwind, see e.g. PR 28206 by yours truly.
@alexcrichton prefers to enable landing pads on stage1. His position isn’t clear to me and I would like for him to clarify it.
An additional, but small, issue is that libtest
, and compiletest
which depends on it, use panics to handle test failures. Until this is changed, they must always be compiled with landing pads enabled. This does not seem to be a point of significant interest.