Rust-GPU/rust-gpu

error: building from local source while `REQUIRED_RUST_TOOLCHAIN` doesn't match `rust-toolchain.toml`.

Opened this issue · 8 comments

Expected Behaviour

Build cargo run --bin example-runner-wgpu or cargo run --bin example-runner-ash successfully on macos.

Example & Steps To Reproduce

  1. Clone the repo on macos.
  2. Install rust environment etc.
  3. Run build command cargo run --bin example-runner-wgpu

System Info

  • Rust: [nightly-2024-04]
  • OS: [macOS 15.1.1]
  • GPU: [Apple M1 Max]
  • SPIR-V: [SPIRV-Tools v2024.4 v2024.4.rc1-0-g6dcc7e35, Target: SPIR-V 1.6]

Backtrace

Summary:

Error Cause: The rustc_codegen_spirv build script requires a specific Rust toolchain version, which does not match the version specified in rust-toolchain.toml.
Standard Output: A notification to rerun the build if the environment variable RUSTGPU_SKIP_TOOLCHAIN_CHECK changes.
Standard Error: Clearly states the toolchain mismatch as the cause of the build failure.

   Compiling internal-iterator v0.2.3
   Compiling pin-project-lite v0.2.15
   Compiling profiling v1.0.16
   Compiling same-file v1.0.6
   Compiling futures-task v0.3.31
   Compiling futures-io v0.3.31
   Compiling pin-utils v0.1.0
   Compiling longest-increasing-subsequence v0.1.0
   Compiling spirv-std-types v0.9.0 (/Users/nilg/Workspace/Code/Rust/rust-gpu/crates/spirv-std/shared)
   Compiling litrs v0.4.1
   Compiling futures-util v0.3.31
   Compiling spirv-std-macros v0.9.0 (/Users/nilg/Workspace/Code/Rust/rust-gpu/crates/spirv-std/macros)
   Compiling walkdir v2.5.0
   Compiling document-features v0.2.10
   Compiling crossbeam-channel v0.5.13
   Compiling block2 v0.3.0
   Compiling hashbrown v0.11.2
   Compiling smallvec v1.13.2
error: failed to run custom build command for `rustc_codegen_spirv v0.9.0 (/Users/nilg/Workspace/Code/Rust/rust-gpu/crates/rustc_codegen_spirv)`

Caused by:
  process didn't exit successfully: `/Users/nilg/Workspace/Code/Rust/rust-gpu/target/debug/build/rustc_codegen_spirv-901cad1f3df6d18a/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=RUSTGPU_SKIP_TOOLCHAIN_CHECK

  --- stderr
  error: building from local source while `REQUIRED_RUST_TOOLCHAIN` (defined in `crates/rustc_codegen_spirv/build.rs`) doesn't match `/Users/nilg/Workspace/Code/Rust/rust-gpu/rust-toolchain.toml`
warning: build failed, waiting for other jobs to finish...

Hmm, I am on the same OS version with a M1 Pro and can't repro. I get a different (known, #29) error which can be worked around with --release:

cargo run --release --bin example-runner-wgpu
schell commented

I came here to say that it might be the --release error, but you beat me to it @LegNeato :)

Passing --release is worth a try @nilanjan 🤞

I have tried this with --release and still it fails with the same error.

   Compiling thiserror-impl v1.0.69
   Compiling rustc_codegen_spirv v0.9.0 (/Users/nilg/Workspace/Code/Rust/rust-gpu/crates/rustc_codegen_spirv)
   Compiling foreign-types v0.5.0
   Compiling metal v0.29.0
   Compiling derive_more v0.99.18
   Compiling spirv-std-macros v0.9.0 (/Users/nilg/Workspace/Code/Rust/rust-gpu/crates/spirv-std/macros)
error: failed to run custom build command for `rustc_codegen_spirv v0.9.0 (/Users/nilg/Workspace/Code/Rust/rust-gpu/crates/rustc_codegen_spirv)`

Caused by:
  process didn't exit successfully: `/Users/nilg/Workspace/Code/Rust/rust-gpu/target/release/build/rustc_codegen_spirv-a09c5ce28002f53d/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=RUSTGPU_SKIP_TOOLCHAIN_CHECK

  --- stderr
  error: building from local source while `REQUIRED_RUST_TOOLCHAIN` (defined in `crates/rustc_codegen_spirv/build.rs`) doesn't match `/Users/nilg/Workspace/Code/Rust/rust-gpu/rust-toolchain.toml`
warning: build failed, waiting for other jobs to finish...

Version details:

~/Workspace/Code/Rust/rust-gpu main*                                                                                                                                                                                                                    1m 31s py_venv 07:28:31 PM
❯ rustup toolchain list 
stable-aarch64-apple-darwin (default)
nightly-2024-04-24-aarch64-apple-darwin (override)

~/Workspace/Code/Rust/rust-gpu main*                                                                                                                                                                                                                           py_venv 07:30:34 PM
❯ rustc --version      
rustc 1.79.0-nightly (244da22fa 2024-04-23)
eddyb commented

(Just a minor GitHub style note: you need 3 backticks, i.e. ```, not just a single one, for multiline code blocks. I've also edited the existing comments for readability)

This is the error:

error: building from local source while REQUIRED_RUST_TOOLCHAIN (defined in crates/rustc_codegen_spirv/build.rs) doesn't match /Users/nilg/Workspace/Code/Rust/rust-gpu/rust-toolchain.toml

Maybe we should put it on multiple lines and/or use cargo::error to make this error more legible.

There is no crash at any point, so the OS or suggestions to use --release aren't relevant (or, well, they might be if you actually managed to build rustc_codegen_spirv).

I have no idea what state your code is in, but please make sure that crates/rustc_codegen_spirv/build.rs' const REQUIRED_RUST_TOOLCHAIN's contents are included in /Users/nilg/Workspace/Code/Rust/rust-gpu/rust-toolchain.toml.

On main these are:

const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
channel = "nightly-2024-04-24"
components = ["rust-src", "rustc-dev", "llvm-tools"]
# commit_hash = 244da22fabd9fa677bbd0ac601a88e5ca6917526"#;

[toolchain]
channel = "nightly-2024-04-24"
components = ["rust-src", "rustc-dev", "llvm-tools"]
# commit_hash = 244da22fabd9fa677bbd0ac601a88e5ca6917526

One or the other is likely changed locally for you, hence the error.

@nilanjan did you by any chance install Rust with brew? (I had similar issues when first building RustGpu projects, but uninstalled the brew one and then reinstalled via the official install script and all is well.)

I was able to install rust by following similar steps. Thanks for your input.

I was able to install rust by following similar steps. Thanks for your input.

@eddyb perhaps offering a Rust install via the official script (as opposed to homebrew) as a solution will allow us to close this one?