-
Notifications
You must be signed in to change notification settings - Fork 15
refactor: use SpirvBuilder directly, just manage rustc_backend_spirv dylibs
#69
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
Conversation
ba36f53 to
32c6d62
Compare
|
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#[email protected]",
"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.
b826762 to
f02f61c
Compare
|
This looks great! So let me see if I have a rough idea of what the change is here. In short, we're replacing |
|
I think this PR would also fix this Rust-GPU/rust-gpu#208 |
|
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? |
|
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 |
|
I like how we are discovering what it does along the way |
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for doing it, though, obviously.
schell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
|
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...) |
|
@tombh as you requested changes earlier, github wants your approval before we can merge |
d074885 to
a048eb5
Compare
|
Added a few more things:
|
|
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. |
|
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? |
|
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
closes Rust-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)