-
Notifications
You must be signed in to change notification settings - Fork 244
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
Having spirv-builder / num-traits as a build-dependency in a shader crate fails the shader build #986
Comments
Example use-caseI would like to have my shaders next to my cpu-code and not in two different directories, even if I then have to spam a lot of
To do this I'd need
Doesn't work, it fails exactly the same way, see the new branch |
This is unsupported and incredibly dangerous/misleading (by accidentally implying things about e.g. data layouts, that are not actually true), as Rust has nothing like CUDA/SYCL's hybrid compilations (and even those are either very hacky or have to force the host to behave more like the device, to ensure compatibility). IMO Rust-GPU will only be able to officially support this when same-crate proc macros are supported by Rust (which itself would be a huge endeavor), and maybe even that might not be enough. Far more likely that you'll end up using something like this instead:
That said, this makes me not want to close this issue as wontfix just yet, because this sounds like your Cargo workspace is stuck on Rust 2015 bug-compat mode (and you need to add |
Adding this to the root [workspace.package]
edition = "2021" or [workspace]
resolver = "2" Some official documentation regarding that would be quite helpful: :D |
Expected Behaviour
Being able to use
[build-dependencies]
with crates depending onnum-traits
in shader crates.Example & Steps To Reproduce
Example Repo: https://github.com/Firestar99/rust-gpu-build-dependecies-bug
(Note that I forced
use-installed-tools
feature in this repo)On the master branch you'll have a working rust-gpu setup with
/engine
being an std rust crate for cpu code and/shader
being the no-std shader crate with it'slib.rs
being copied from yoursimplest-shader
example. When youcargo run
the main function in theengine
crate will just build the shaders from the shader crate usingspirv_builder
.Now switch to branch broken, where in
/shader/Cargo.toml
the[build-dependencies]
the cratespirv-builder
will be added. From what I've understood build-dependencies only affect the dependencies for the build script and are completely independent from the normal dependencies. As the shader crate does NOT even have a build script, this should literally not affect the build in any way. But still building the shader crate (by running the engine crate) fails the build for the cratenum-traits
:I would have expected that num-traits would be build twice: first for target "x64" with default features "std" for the build script execution and then again for target "spirv" with features "libm" for the normal cross-compile build. But for some reason that second compile does not seem to happen, and instead cargo/rust decides to reuse the compile / features from the first compile.
Rust-gpu from master branch does not change the result (Branch broken-git-master).
BUT NOTE that copying this example into a rust-gpu checkout and adding the engine and shader crates to the workspace makes it build correctly for whatever reason. Similarly adding the build dependency to any of your shader crates in
/examples
works just fine. So if you are testing this issue you need to add rust-gpu via a standard dependency and may not have it in your workspace.Thanks and Have fun cracking this hard nut 😃
System Info
The text was updated successfully, but these errors were encountered: