Open hatoo opened 2 years ago
Looks like that rust-gpu panic was on this:
fn eh_personality(&self) -> Self::Value {
todo!()
}
Which for this type of no-std builds one has to implement oneself (docs).
We do this in spirv-std
but looks like your dependency is not including that so in that case you'll have to do some of that set up manually. https://github.com/EmbarkStudios/rust-gpu/blob/132b960e8320d7e607fd912142cff7da05d49d92/crates/spirv-std/src/lib.rs#L128-L129
We should improve the rust-gpu todo panic though to be clear about this rather than crashing
We can probably return a zombie (or even a non-function instead of panicking, since we don't actually do any kind of exception handling, so rust_eh_personality
shouldn't actually be necessary.
Wait, no, any use of .eh_personality()
's result is itself a todo!()
, and I'm not sure we even need #[lang = "eh_personality"]
ourselves...
We force -C panic=abort
in the target spec: https://github.com/EmbarkStudios/rust-gpu/blob/132b960e8320d7e607fd912142cff7da05d49d92/crates/rustc_codegen_spirv/src/target.rs#L93
The relevance of cargo clippy
is also suspect, since it's invoking a build script that should be using spirv-builder
(and seems to, by all accounts), maybe it's caused by Clippy inserting itself as a rustc
proxy?
A quick look around found that clippy indeed turns off MIR optimizations (which are likely needed for panic=abort
to remove unwinding logic from MIR).
The decision logic for whether or not to run in "clippy mode" doesn't seem to consider build scripts?
We may need to unset the RUSTC_WRAPPER
env var in spirv-builder
to avoid clippy interference.
Though ideally clippy should check for --emit=rmeta
to tell whether the cargo check
invocation (started by cargo clippy
) is actually doing a "check" build, or something else is going on (like a nested build script build).
We can probably start by adding this assert to rustc_codegen_spirv
:
assert_ne!(
sess.opts.debugging_opts.mir_opt_level, Some(0),
"`-Z mir-opt-level=0` not supported \
(if using `cargo clippy`, it may have added the flag automatically)"
);
Was able to reproduce in-tree like this:
rustup target add wasm32-unknown-unknown
cargo clippy -p example-runner-wgpu --target=wasm32-unknown-unknown
The reason it doesn't repro for the host target is the hotloading support.
Alternatively, commenting out these lines should also repro: https://github.com/EmbarkStudios/rust-gpu/blob/685c79a9725f9fb68ce17dd00e742b98a03f3870/examples/runners/wgpu/build.rs#L15-L17
Can't really repro on 0.6.1
with above instructions. This needs further investigation whether this is indeed fixed now, and why.
Adding the assert from https://github.com/EmbarkStudios/rust-gpu/issues/864#issuecomment-1102593603 does get tripped with the repro instructions (the ones about commenting out the android/wasm check), but I don't understand why that doesn't break anything.
Probably requires going back to see which nightly made -C panic=abort
not require MIR optimizations.
What clippy is doing here is still sketchy (AFAICT the relevant parts of its code haven't changed since I investigated a year ago above), but it sounds like it maybe no longer breaks Rust-GPU?
Expected Behaviour
cargo clippy
works without a crash in this project.It worked fine in older
rust-gpu
.Example & Steps To Reproduce
cargo clippy
System Info
Backtrace
Backtrace
```
```