-
Notifications
You must be signed in to change notification settings - Fork 247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider build CLI (e.g. cargo gpu
) mapping spirv-std
deps to toolchain & backend versions.
#1137
Comments
Look who has |
Food for thought, though I don't want this to be come like JS where every tool has its own config file, having a |
See https://doc.rust-lang.org/cargo/reference/manifest.html#the-metadata-table With And you have to keep in mind that we can't remove the |
krnl has krnlc, which includes rustc_codgen_spirv into the binary and at runtime copies it back to the target dir. I found I had to sym link the rust sys root libs as well. So that's a working example of a cli instead of a builder / build script. It does something similar to what @eddyb describes with spirv-std, krnl has krnl-core which links to spirv-std, and krnlc looks for krnl-core via cargo_metadata, checks that the version is compatible, and copies that dependency into the generated Cargo.toml for the device crate. This ensures that host and device crates have identical krnl-core / krnl-macros versions. Macros are used to generate host / device bindings, so identical versions means that the private interface can be unstable. One thing that is somewhat awkward is needing to install krnlc with a specific nightly version, so that it isn't as easy to update and it's more cumbersome to mix two different versions. The spirv-builder dependency means krnlc has to have its own workspace. Considering that rust-gpu requires a specific nightly, I'm not sure it would make sense to have something like krnlc be installable on stable or even just nightly, but it could. So if rust-gpu handled installing the required nightly + components + rustc_codegen_spirv, that makes it easier for other tools like krnlc or naga to use it. |
I was looking at minimal shader
Cargo.toml
s and they're often mainly:In the past (e.g. #911 (comment)) any speculation was focused on the backend (
rustc_codegen_spirv
) being built in some way tied to whatever interface (e.g.spirv-builder
, or some future CLI) was being used to actually build, and therefore their versions being tied.For example we thought maybe we could have a way to "install Rust-GPU 0.123.0" but then you will have to install a new one every Rust-GPU release, and anyone who wants to interact with your shader crates has to do the same etc.
Also, as big as it is, the (still unmerged) PR I made on a whim a few months ago also has that limitation:
rustc_codegen_spirv
with the right toolchain via build script. #1103But what if we instead made a future-compatible tool (usable as build dep/CLI/etc.) that:
cargo_metadata
to understand the shader's dependency graph (fromCargo.toml
, workspace etc.)spirv-std
dependency, and uses it to get the actual toolchain+backendrustc_codegen_spirv
with the right toolchain via build script. #1103:spirv-std
instead ofspirv-builder
spirv-std
's build script build the backend, or anything that silly, I would just be worried about making it too much a house of cardsspirv-std
would work (just like the PR which does this forspirv-build
)rustup
and builds the right version ofrustc_codegen_spirv
spirv-builder
's build script)cargo gpu check
/cargo gpu clippy
! (tricky to expose right now)I'm not sure if I've heard this kind of "dependency consequence inversion" being used anywhere - usually libraries might be driven by compiler versions, not the other way around. If anyone had suggested this for Rust-GPU in the past, I apologize for being unfamiliar with your game because all my other ideas until now have been mediocre compromises at bets.
EDIT1: forgot to mention an incidental source of inspiration - back around Rust-GPU
0.4
(which had to change how#[spirv(...)]
works due to upstreamrustc
changes), we considered makingspirv-std-macros
turn#[spirv(foo)]
into#[rust_gpu_0_9_0_git9d8095177::spirv_foo]
(or some other kind of verbose encoding of a version) - and once you have that kind of "self-awareness" inspirv-std
about the backend version it wants, a build tool can pull that out. (stricter checks around that would've saved me from some confusing build failures just earlier, which is probably why it was on my mind)EDIT2: in theory, this is comparable to if Rust itself let you do:
and have that act as a
rust-toolchain.toml
replacement. (likely unviable without replacing (parts of)rustup
+cargo
+rustc
CLIs all at once with a combinedrust
one or something similarly extreme)Actually, if we allow more "conceptual" dependencies, the comparison becomes
And we do have the
rust-gpu
package oncrates.io
so that could be used instead ofspirv-std
to be more explicit (and then "namespaced dependencies" likerust-gpu/spirv-std
, or reallyrust_gpu::spirv_std
could exist? also the attribute could then not have to go intospirv-std
etc.)The text was updated successfully, but these errors were encountered: