EmbarkStudios / rust-gpu

🐉 Making Rust a first-class language and ecosystem for GPU shaders 🚧

Home Page:https://shader.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compile with Proc Macro

coolcatcoder opened this issue · comments

commented

I notice that in the getting started guide, it says you must use the same rustc version that it is expecting. Could we have a proc macro that takes a path to a rust file, and then compiles it using the correct rustc version, and then returns the compiled stuff? (Sorry for sounding so vague, I just started reading the getting started guide, so I don't really know what I'm talking about, lol.) This seems like it should be simple by using Command::new("rustc") in some way.

Not really. spirv-builder invokes cargo with rustc_codegen_spirv as the backend for rustc. rustc_codegen_spirv links directly to rustc internals, and these are very unstable, so this needs to be the exact same toolchain, not just a nightly.
So in theory spirv-builder itself could use an arbitrary toolchain, stable even, but rustc_codegen_spirv must be used with the same nightly it was compiled with.
Proc macros are more or less supposed to consume and produce tokens, though some do read from files or even compile source code.

commented

Surely there would be some way to check what toolchain it needs, and then check if it installed, and if not install it, then compile with that toolchain. It might be janky, but I reckon it would be possible. I'll close for now, but I'll mess around with it and see if I can get a basic implementation working.