Uh oh!
There was an error while loading. Please reload this page.
refactor: use SpirvBuilder directly, just manage rustc_backend_spirv dylibs - #69
Conversation
Firestar99
commented
Apr 29, 2025
Firestar99
commented
Apr 29, 2025
I would like to see the Switch to cargo metadata PR to be merged first (or integrated into here), as you can't just use it for more efficient version querying. It also tells you where Sample: {
"name": "rustc_codegen_spirv",
"version": "0.9.0",
"id": "git+https://github.com/Rust-GPU/rust-gpu?rev=82a0f69#rustc_codegen_spirv@0.9.0",
"license": "MIT OR Apache-2.0",
"license_file": null,
"description": "SPIR-V code generator backend for rustc",
"source": "git+https://github.com/Rust-GPU/rust-gpu?rev=82a0f69#82a0f69008414f51d59184763146caa6850ac588",
..."manifest_path": "/home/firestar99/.cargo/git/checkouts/rust-gpu-d06d15e2ba0f0ae2/82a0f69/crates/rustc_codegen_spirv/Cargo.toml",
...
}, |
… cargo gpu This is bandaid fix, it now ignores RUSTC environment variable set from elsewhere, like when shader crate is part of a workspace. As of today, it fails to compile on workspace which uses nightly because an additional restriction was added to target specification json file on nightly. Even though enforcing specific rustc version seems like good idea for the purpose of cargo-gpu, target specification json file should be updated as well if we were to ever bump up required rustc version.
tombh
commented
Apr 30, 2025
This looks great! So let me see if I have a rough idea of what the change is here. In short, we're replacing |
tombh
commented
Apr 30, 2025
I think this PR would also fix this Rust-GPU/rust-gpu#208 |
Firestar99
commented
Apr 30, 2025
Ignore |
@tombh feel free to rereview and merge, but I got one followup question: cargo-gpu/crates/xtask/src/main.rs Lines 154 to 188 in 6408188 Why are we installing one rust-gpu version (whatever is in the repo, currently a rev), then replace the version with what was specified in the cmdline and when building, reinstall a different rust-gpu version? I was wondering why our 0.9.0 and 0.8.0 builds were taking twice as much as the latest does. Any specific reason it has been done like that, or should we unify to testing only one version? |
tombh
commented
May 7, 2025
Wow, that doesn't seem right. I can't think of any reason why that might be. I wonder if @schell does? I think as long as the tests pass then just a single |
tmvkrpxl0
commented
May 7, 2025
I like how we are discovering what it does along the way |
schell
commented
May 10, 2025
No clue why it does that, but it's probably just cruft from having us all hack on it with abandon, as they say :) |
| Usage: cargo-gpu show capabilities | ||
| Options: |
There was a problem hiding this comment.
I wish there were a way we could keep the usage in the README in sync with the tool without having to manually insert it here. 🤔
There was a problem hiding this comment.
Thank you for doing it, though, obviously.
Uh oh!
There was an error while loading. Please reload this page.
schell
left a comment
There was a problem hiding this comment.
Great work! I checked out the source and this compiles my project.
I only had some quick nitpicks about typos. Can't wait to see this merge.
Firestar99
commented
May 10, 2025
The version 0.8.0 and 0.9.0 builds are now just as fast as latest on ubuntu (not to speak of windows taking twice as long...) |
Firestar99
commented
May 12, 2025
@tombh as you requested changes earlier, github wants your approval before we can merge |
Firestar99
commented
May 12, 2025
Added a few more things:
|
tombh
commented
May 12, 2025
Apologies, was under the impression that we only needed one approval to merge. Noted. I'll take the opportunity again to say how great this PR is. Thank you. |
Firestar99
commented
May 12, 2025
I can only squash and merge. Could we switch it to just merging (no squashing) for just this PR, as it does change a lot? |
tombh
commented
May 12, 2025
I don't appear to have permissions for that, I'm sure @schell does. Just to throw in my 2 cents, I'm not totally convinced that these commits would be better merged as they are over being squashed. Whilst they do tell an important story, they also clutter up main, making reading said story harder in other contexts, say for bisecting a bug. But don't let that stop you merging! Just wanted to mention it. |
| ]); | ||
| .env_remove("RUSTC"); | ||
| if source_is_path { | ||
| build_command.args(["-p", "rustc_codegen_spirv", "--lib"]); |
There was a problem hiding this comment.
Generally better to use full argument names in places like this for improved readability:
| build_command.args(["-p","rustc_codegen_spirv","--lib"]); | |
| build_command.args(["--package","rustc_codegen_spirv","--lib"]); |
rust-gpu PR: Rust-GPU/rust-gpu#245
closes#55
closes#68
closesRust-GPU/rust-gpu#208
The current version of cargo gpu roughly works like this, imagine it as stack frames:
And then we back-propagate the results:
The core idea: Why not have cargo gpu directly call
cargowith the requiredrustc-codegen-spirvflags attached, likeSpirvbuilderdoes currently? And remove the complicated setup of spawning a newspirv-builder-cliprocess to callSpirvbuilderand parsing it all back out?The key observation is that
SpirvBuilderdoesn't care at all what toolchain you use to build it, only it's dependencyrustc_codegen_spirvhas to be built by a specific toolchain. In Rust-GPU/rust-gpu#245 I make this dependency optional and hide it behind the featurerustc_codegen_spirv, which allows us to directly depend onSpirvBuilderand still build on stable. We just need to supply ourSpirvBuilderwith alibrustc_codegen_spirv.soorrustc_codegen_spirv.dllprebuilt using the specific toolchain it requires, which significantly simplifies the build process.This requires
SpirvBuilderto stay be backwards compatible for all future versions, and we need to add support for past versions.User-facing changes
--debug)--no-default-features)--force-spirv-cli-rebuild->--rebuild-codegenpathsupport forrust-gpurustc_codegen_spirvin that local path, no need to compile twicerust-gpurepo cloning, instead reuse cargo's cacherustc_codegen_spirvafter successful buildInternal changes, including to
SpirvBuilderspirv_builder_clicratemod spirv_cliintospirv_source,install_toolchainandlockfileBuildArgsmembers toSpirvBuilderSpirvBuilder, replacing setters (but keeping them around)SpirvBuilderderiveserde::Serialize,serde::DeserializeSpirvBuilder(masked by clap feature)BuildArgshas a newSpirvBuildermember withclap(flatten)andserde(flatten)cargo treecalls withcargo_metadatacrate, cherry-picked from Switch to cargo metadata #66 by @tmvkrpxl0, required to "retrieve path to manifest" during installTodo
Cargo.lockfor some reason0.9.0&0.8.0: complains about invalid target-specs jsonspirv-toolsbuild failforce_overwrite_lockfiles_v4_to_v3)rustc_backend_spirvdylibs #69 (comment)