-
Notifications
You must be signed in to change notification settings - Fork 11
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
base: main
Are you sure you want to change the base?
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 |
Wow, great write up, thank you. This is actually awesome, there's so many improvements, it's going to make a big difference. |
629a4f9
to
7ec968a
Compare
9239d3c
to
b401f77
Compare
I'm looking forward to this work landing @Firestar99, thanks! |
Oh f*ck off windows |
4920a39
to
4aebc9a
Compare
Watch works on Linux, but doesn't work on windows due to rust-gpu's
Has it ever worked before my refactor? Had other difficulties testing that. |
@tombh @schell @LegNeato I think this is ready for review. The merge procedure will be to first merge Rust-GPU/rust-gpu#245, then update this PR to point to rust-gpu's master and merge it as well (which is why I won't yet mark this PR as ready). I think the remaining todos can be done in followup PRs. Please don't squash these commits on either PR, they change so much it would probably be better to keep them around. |
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.
Everything looks great. Just a couple of minor suggestions.
@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 |
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
cargo
with the requiredrustc-codegen-spirv
flags attached, likeSpirvbuilder
does currently? And remove the complicated setup of spawning a newspirv-builder-cli
process to callSpirvbuilder
and parsing it all back out?The key observation is that
SpirvBuilder
doesn't care at all what toolchain you use to build it, only it's dependencyrustc_codegen_spirv
has 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 onSpirvBuilder
and still build on stable. We just need to supply ourSpirvBuilder
with alibrustc_codegen_spirv.so
orrustc_codegen_spirv.dll
prebuilt using the specific toolchain it requires, which significantly simplifies the build process.This requires
SpirvBuilder
to stay be backwards compatible for all future versions, and we need to add support for past versions.User-facing changes
--debug
)--no-default-features
)path
support forrust-gpu
rustc_codegen_spirv
in that local path, no need to compile twicerust-gpu
repo cloning, instead reuse cargo's cacheInternal changes, including to
SpirvBuilder
spirv_builder_cli
cratemod spirv_cli
intospirv_source
,install_toolchain
andlockfile
BuildArgs
members toSpirvBuilder
SpirvBuilder
, replacing setters (but keeping them around)SpirvBuilder
deriveserde::Serialize
,serde::Deserialize
SpirvBuilder
(masked by clap feature)BuildArgs
has a newSpirvBuilder
member withclap(flatten)
andserde(flatten)
cargo tree
calls withcargo_metadata
crate, cherry-picked from Switch to cargo metadata #66 by @tmvkrpxl0, required to "retrieve path to manifest" during installTodo
Cargo.lock
for some reason0.9.0
&0.8.0
: complains about invalid target-specs jsonspirv-tools
build failforce_overwrite_lockfiles_v4_to_v3
)rustc_backend_spirv
dylibs #69 (comment)