Skip to content
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

Rust version is older than the minimum Rust version required by the clap dependency in the spirv-builder-cli crate #45

Open
Makogan opened this issue Feb 10, 2025 · 12 comments

Comments

@Makogan
Copy link

Makogan commented Feb 10, 2025

My current setup (which relies on rustbuilder) is to put a shader crate inside of each example.

I tried testing cargo gpu to see if it could alleviate some woes so I did:

 cd examples/01_spinning_triangle/spinning_triangle_shader/
 cargo gpu build

I am getting this error:

error: package `clap_builder v4.5.23` cannot be built because it requires rustc 1.74 or newer, while the currently active rustc version is 1.71.0-nightly
Either upgrade to rustc 1.74 or newer, or use
cargo update -p clap_builder@4.5.23 --precise ver
where `ver` is the latest version of `clap_builder` supporting rustc 1.71.0-nightly
[2025-02-10T05:18:06Z ERROR cargo_gpu] ...build error!
Error: ...build error!

Clap is not a dependency of the shader crate at all:

[package]
name = "spinning-triangle-shader"
version = "0.0.0"
publish = false

[lib]
crate-type = ["lib", "dylib"]

[dependencies]
spirv-std = "0.9.0"
bytemuck = { version = "1.20.0", features = ["derive"] }

So I don't understand why it's trying to get compiled?

@tombh
Copy link
Collaborator

tombh commented Feb 10, 2025

This is a known bug, we already have a PR fix at #41 Would you be interested in trying it? You'd need to check out the PR locally and run cargo from the repo itself, with something like: RUST_LOG=debug cargo run --bin cargo-gpu -- build --shader-crate /path/to/your/shader/crate/root --force-spirv-cli-rebuild --auto-install-rust-toolchain.

A brief explanation of the bug: cargo gpu actually makes a dedicated shader-specific spirv-builder-cli crate in the background. It's that crate that compiles the shader, using a version of Rust that is often different from your system's default Rust. In your case (and in one of my shader's too) the shader's required Rust version is older than the minimum Rust version required by the clap dependency in the spirv-builder-cli crate.

@schell schell changed the title Why does cargo gpu try to compile dependencies of the parent project? Rust version is older than the minimum Rust version required by the clap dependency in the spirv-builder-cli crate Feb 11, 2025
@schell
Copy link
Collaborator

schell commented Feb 11, 2025

I've updated the ticket title to reflect the actual underlying bug.

@schell
Copy link
Collaborator

schell commented Feb 11, 2025

But bumping your rust-gpu deps should fix this problem, if I'm not mistaken.

@tombh
Copy link
Collaborator

tombh commented Feb 12, 2025

I'm not OP, but at least for me, upgrading rust-gpu is not an option because of Rust-GPU/rust-gpu#46

@Makogan
Copy link
Author

Makogan commented Feb 12, 2025

I'm not OP, but at least for me, upgrading rust-gpu is not an option because of Rust-GPU/rust-gpu#46

I have this exact same problem

@PatD123
Copy link

PatD123 commented Feb 18, 2025

@tombh Just tried it(PR fix #41) on my Windows 11 computer. I had the exact same issue as @Makogan. I ran this command

cargo run --bin cargo-gpu -- build --shader-crate ..\demiurge\examples\01_spinning_triangle\spinning_triangle_shader --force-spirv-cli-rebuild --auto-install-rust-toolchain

in the root directory of your checked-out PR fix #41 and got the following issue.

Image

It can't find a certain program. The spinning_triangle_shader is the root dir of a shader crate. Don't know however if it is an argument issue or a path issue?

@tombh
Copy link
Collaborator

tombh commented Feb 18, 2025

Hello, so you saw the error mentioned here? Your screenshot seems to be a different error. From what I can see it seems your error is coming from rust-gpu's spirv-builder (the underlying crate that cargo-gpu ultimately calls). Parsing errors from spirv-builder is a bit difficult, I've actually made an issue for it on the rust-gpu repo. But anyway, my best guess is that spirv-builder isn't finding the rustc of the Rust toolchain installed by cargo-gpu for your shader. If that's the case then I wonder if there's some setup issue with your rustup install.

It'd be good to see the full build logs, perhaps pasted as text would be better. And seeing as this is likely a different error, I think it'd good to start a new issue.

@PatD123
Copy link

PatD123 commented Feb 18, 2025

Yes ultimately different error @tombh, but I was trying to say that I was doing cargo gpu build in a shader crate and it gave me the exact same error here in this issue. Your first reply to Makogan was to try your PR fix #45, so I tried it and I got this error.

Here are the full logs:

PS C:\Users\Patrick\Documents\__Projects__\cargo-gpu> cargo run --bin cargo-gpu -- build --shader-crate C:\Users\Patrick\Documents\__Projects__\demiurge\examples\01_spinning_triangle\spinning_triangle_shader --force-spirv-cli-rebuild --auto-install-rust-toolchain
warning: profiles for the non root package will be ignored, specify profiles at the workspace root:
package:   C:\Users\Patrick\Documents\__Projects__\cargo-gpu\crates\cargo-gpu\Cargo.toml
workspace: C:\Users\Patrick\Documents\__Projects__\cargo-gpu\Cargo.toml
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.54s
     Running `target\debug\cargo-gpu.exe build --shader-crate C:\Users\Patrick\Documents\__Projects__\demiurge\examples\01_spinning_triangle\spinning_triangle_shader --force-spirv-cli-rebuild --auto-install-rust-toolchain`
🦀 Compiling shader-specific `spirv-builder-cli` for C:\Users\Patrick\Documents\__Projects__\demiurge\examples\01_spinning_triangle\spinning_triangle_shader
warning: unused manifest key `lints` (may be supported in a future version)

consider passing `-Zlints` to enable this feature.
    Updating crates.io index
   Compiling spirv-builder-cli v0.1.0 (C:\Users\Patrick\AppData\Local\rust-gpu\spirv-builder-cli\v0_9_0+nightly-2023-05-27)
warning: unused import: `MetadataPrintout`
  --> src\main.rs:14:36
   |
14 | use spirv_builder::{CompileResult, MetadataPrintout, ModuleResult, SpirvBuilder};
   |                                    ^^^^^^^^^^^^^^^^
   |
   = note: `#[warn(unused_imports)]` on by default

warning: unused `Result` that must be used
   --> src\main.rs:138:9
    |
138 | /         builder.watch(move |compile_result| {
139 | |             handle_compile_result(&compile_result, &args_for_result);
140 | |         });
    | |__________^
    |
    = note: this `Result` may be an `Err` variant, which should be handled
    = note: `#[warn(unused_must_use)]` on by default
help: use `let _ = ...` to ignore the resulting value
    |
138 |         let _ = builder.watch(move |compile_result| {
    |         +++++++

warning: `spirv-builder-cli` (bin "spirv-builder-cli") generated 2 warnings (run `cargo fix --bin "spirv-builder-cli"` to apply 1 suggestion)
    Finished release [optimized] target(s) in 7.07s
🦀 Running `spirv-builder-cli` to compile shader at \\?\C:\Users\Patrick\Documents\__Projects__\demiurge\examples\01_spinning_triangle\spinning_triangle_shader...
thread 'main' panicked at 'failed to execute cargo build: Error { kind: NotFound, message: "program not found" }', C:\Users\Patrick\.cargo\registry\src\index.crates.io-6f17d22bba15001f\spirv-builder-0.9.0\src\lib.rs:738:10
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/1a5f8bce74ee432f7cc3aa131bc3d6920e06de10/library\std\src\panicking.rs:578
   1: core::panicking::panic_fmt
             at /rustc/1a5f8bce74ee432f7cc3aa131bc3d6920e06de10/library\core\src\panicking.rs:67
   2: core::result::unwrap_failed
             at /rustc/1a5f8bce74ee432f7cc3aa131bc3d6920e06de10/library\core\src\result.rs:1651
   3: spirv_builder::invoke_rustc
   4: spirv_builder::SpirvBuilder::build
   5: spirv_builder_cli::handle_compile_result
   6: <std::io::Write::write_fmt::Adapter<T> as core::fmt::Write>::write_str
   7: std::rt::lang_start::{{closure}}
   8: std::rt::lang_start_internal::closure$2
             at /rustc/1a5f8bce74ee432f7cc3aa131bc3d6920e06de10/library\std\src\rt.rs:148
   9: std::panicking::try::do_call
             at /rustc/1a5f8bce74ee432f7cc3aa131bc3d6920e06de10/library\std\src\panicking.rs:485
  10: std::panicking::try
             at /rustc/1a5f8bce74ee432f7cc3aa131bc3d6920e06de10/library\std\src\panicking.rs:449
  11: std::panic::catch_unwind
             at /rustc/1a5f8bce74ee432f7cc3aa131bc3d6920e06de10/library\std\src\panic.rs:142
  12: std::rt::lang_start_internal
             at /rustc/1a5f8bce74ee432f7cc3aa131bc3d6920e06de10/library\std\src\rt.rs:148
  13: main
  14: invoke_main
             at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
  15: __scrt_common_main_seh
             at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
  16: BaseThreadInitThunk
  17: RtlUserThreadStart
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[2025-02-18T16:48:26Z ERROR cargo_gpu] build failed

    Stack backtrace:
       0: std::backtrace_rs::backtrace::dbghelp64::trace
                 at /rustc/43ca9d18e333797f0aa3b525501a7cec8d61a96b/library\std\src\..\..\backtrace\src\backtrace\dbghelp64.rs:91
       1: std::backtrace_rs::backtrace::trace_unsynchronized
                 at /rustc/43ca9d18e333797f0aa3b525501a7cec8d61a96b/library\std\src\..\..\backtrace\src\backtrace\mod.rs:66
       2: std::backtrace::Backtrace::create
                 at /rustc/43ca9d18e333797f0aa3b525501a7cec8d61a96b/library\std\src\backtrace.rs:331
       3: std::backtrace::Backtrace::capture
                 at /rustc/43ca9d18e333797f0aa3b525501a7cec8d61a96b/library\std\src\backtrace.rs:296
       4: anyhow::Error::msg<ref$<str$> >
                 at C:\Users\Patrick\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\anyhow-1.0.94\src\backtrace.rs:27
       5: anyhow::__private::format_err
                 at C:\Users\Patrick\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\anyhow-1.0.94\src\lib.rs:691
       6: cargo_gpu::build::Build::run
                 at .\crates\cargo-gpu\src\build.rs:73
       7: cargo_gpu::run
                 at .\crates\cargo-gpu\src\main.rs:153
       8: cargo_gpu::main
                 at .\crates\cargo-gpu\src\main.rs:98
       9: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
                 at /rustc/43ca9d18e333797f0aa3b525501a7cec8d61a96b\library\core\src\ops\function.rs:250
      10: core::hint::black_box
                 at /rustc/43ca9d18e333797f0aa3b525501a7cec8d61a96b\library\core\src\hint.rs:477
      11: std::sys::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >
                 at /rustc/43ca9d18e333797f0aa3b525501a7cec8d61a96b\library\std\src\sys\backtrace.rs:152
      12: std::rt::lang_start::closure$0<tuple$<> >
                 at /rustc/43ca9d18e333797f0aa3b525501a7cec8d61a96b\library\std\src\rt.rs:199
      13: std::rt::lang_start_internal::closure$0
                 at /rustc/43ca9d18e333797f0aa3b525501a7cec8d61a96b/library\std\src\rt.rs:168
      14: std::panicking::try::do_call
                 at /rustc/43ca9d18e333797f0aa3b525501a7cec8d61a96b/library\std\src\panicking.rs:587
      15: std::panicking::try
                 at /rustc/43ca9d18e333797f0aa3b525501a7cec8d61a96b/library\std\src\panicking.rs:550
      16: std::panic::catch_unwind
                 at /rustc/43ca9d18e333797f0aa3b525501a7cec8d61a96b/library\std\src\panic.rs:358
      17: std::rt::lang_start_internal
                 at /rustc/43ca9d18e333797f0aa3b525501a7cec8d61a96b/library\std\src\rt.rs:164
      18: std::rt::lang_start<tuple$<> >
                 at /rustc/43ca9d18e333797f0aa3b525501a7cec8d61a96b\library\std\src\rt.rs:198
      19: main
      20: invoke_main
                 at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78
      21: __scrt_common_main_seh
                 at D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288
      22: BaseThreadInitThunk
      23: RtlUserThreadStart
Error: build failed
error: process didn't exit successfully: `target\debug\cargo-gpu.exe build --shader-crate C:\Users\Patrick\Documents\__Projects__\demiurge\examples\01_spinning_triangle\spinning_triangle_shader --force-spirv-cli-rebuild --auto-install-rust-toolchain` (exit code: 1)

Additionally, what installed toolchains do I need. This is what I get from mine:

installed toolchains
--------------------

stable-x86_64-pc-windows-msvc
nightly-2023-05-27-x86_64-pc-windows-msvc
nightly-2023-09-30-x86_64-pc-windows-msvc
nightly-2024-01-05-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-msvc (default)

active toolchain
----------------

nightly-x86_64-pc-windows-msvc (default)
rustc 1.86.0-nightly (43ca9d18e 2025-02-08)

@Makogan
Copy link
Author

Makogan commented Feb 18, 2025

This is a known bug, we already have a PR fix at #41 Would you be interested in trying it? You'd need to check out the PR locally and run cargo from the repo itself, with something like: RUST_LOG=debug cargo run --bin cargo-gpu -- build --shader-crate /path/to/your/shader/crate/root --force-spirv-cli-rebuild --auto-install-rust-toolchain.

A brief explanation of the bug: cargo gpu actually makes a dedicated shader-specific spirv-builder-cli crate in the background. It's that crate that compiles the shader, using a version of Rust that is often different from your system's default Rust. In your case (and in one of my shader's too) the shader's required Rust version is older than the minimum Rust version required by the clap dependency in the spirv-builder-cli crate.

I tried this on Manjaro and it worked for me.

@tombh
Copy link
Collaborator

tombh commented Feb 20, 2025

@PatD123 I see, thanks. In that case it looks like you've surfaced another separate error. Let's open a new issue for that.

@Makogan
Copy link
Author

Makogan commented Mar 15, 2025

But bumping your rust-gpu deps should fix this problem, if I'm not mistaken.

How do I try this?

@tombh
Copy link
Collaborator

tombh commented Mar 16, 2025

You just bump the version of spirv-std in your shader crate's Cargo.toml.

But I think the original issue here should be fixed on main now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants