Conversation
|
These commits modify compiler targets. |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Hm, I see the point of not wanting to pay for panicking. On the other hand, I did use panic handlers. It’s nice to get an error message if an |
|
Hm, would you be open to setting |
|
Could we have abort for debug mode and immediate-abort for release mode? Edit: So, with debug-assertions you would get abort and without it would be immediate-abort. |
|
Not easily. If any crate is compiled with panic=immediate-abort, then all crates must be compiled with it, including the standard library. In fact panic=immediate-abort mostly works by swapping out some functions in libcore. |
^ Exactly this. It's unfortunate, that specifying it by hand is currently not so easy. Having
I wouldn't consider the necessity to recompile everything a problem for our use case. For amdgcn and NVPTX we have to do this anyway to produce correct code. To me it looks like this is mostly a build system problem since the Cargo flags required to do that are experimental and therefore are not nicely integrated into it. |
|
I guess the bloat related to the bounds checks doesn't come directly from the bounds check themselves as they still need to run? Then I assume the difference in the IR level could be a trap or a call to the panic handler, but inlining of the panic handler happens and whatever goes on there is copied into the function itself? If the panic handler is defined as a trap instruction, will the two versions end up the same in the final artifact (ptx for nvptx) such that this is mostly a bloated LLVM-IR/BC issue? Using a custom panic handler with stdout printing together with a "release with debug" profile to immediately expose invariants that are not upheld is a valuable use case. Using explicit |
You can already define the panic handler as a trap instruction in user code. If changing the panic handler suffices, you don't even need to have this conversation. I strongly suspect that simply changing the panic handler will not clean up enough code, because the panic handler is called over FFI (think about it, that's how the panic handler implementation which is called into by The only way you'd be able to get the code cleaned up just by swapping the panic handler is if something runs after LLVM and supports LTO-style optimizations. Normally I'd assume that no such optimizations exist, but you say
Which only makes sense if they do 🤷 so you tell me? |
|
For NVPTX, we normally use Is this something that could be coordinated across I also do not see any other targets using This would also change the behavior of existing working code by silently ignoring its panic handler. At the very least, that would require properly notifying users. Given my limited knowledge of the future plans for this feature and for It is also unfortunate that enabling it for the offload device target enables it for the host as well. Is support for separate configurations for the host and offload device planned anyway? |
When looking at the IR of some GPU benchmarks, we noticed that even with panic=abort we ended up with quite a lot of extra IR from the panic machinery. With
panic=immediate-abort, those become simple branches to a trap call:We mostly see it being generated from bounds checks.
Specifying immediate-abort by hand is quite annoying.
cargo clean.-Zbuild-std=core,panic_abortThe only benefit of abort over immediate-abort is the ability to hook in your own panic handler. I think that's a rarely needed feature on GPUs, so we should prioritize better codegen, especially if it's so annoying to specify by hand otherwise.
@Flakebi @kjetilkjeka @kulst are you ok with this as target maintainers?
r? @saethlin