Rust-GPU/rust-gpu

Add `tracing` support to `rustc_codegen_spirv`

Closed this issue · 2 comments

When working on or debugging the rust-gpu compiler backend, it is extremely hard to see what is going on. Ideally we have tracing support so that we can put logs and spans in to see what the compiler is doing (behind a feature).

rustc already has support: https://rustc-dev-guide.rust-lang.org/tracing.html

One complication is that rustc_codegen_spirv is used as a dylib and I don't believe tracing works in that situation. I found https://github.com/JakkuSakura/tracing-shared-rs, but it doesn't look great.

For posterity that page mentions that the official compiler includes tracing for info:

"This is an info! log rather than a debug! log so it will work on the official compilers."

Looks like we can reuse rustc's version, but again we hit the only info is supported. Rustdoc deals with this by using both:

https://github.com/rust-lang/rust/blob/bf6f8a4d328f7f3b0f6ea8205ad28591cc11aafd/src/librustdoc/lib.rs#L167

I am investigating this solution.