`cargo run` fails on WebAssembly target due to `CARGO_BUILD_TARGET` leaking into `rustc_codegen_spirv` build
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Quiet
- Tech stack
- rust, wasm
- Domain
- build-system
Research direction
Start with node-graph/nodes/raster/shaders/build.rs and the cargo_gpu::Install::from_shader_crate(...) call. Reproduce the failure with cargo run, then verify the inner build uses the host target rather than the inherited WebAssembly target. Done means the standard cargo run workflow completes past raster-nodes-shaders without the dylib error.
Written by the indexing model from the issue text.
Description
Summary
When running the standard cargo run development workflow, the build fails while compiling the web frontend (wasm-pack build ./wrapper --dev --target=web).
The failure occurs in the raster-nodes-shaders crate's build.rs script. The build script attempts to compile the rustc_codegen_spirv compiler backend, but the parent CARGO_BUILD_TARGET=wasm32-unknown-unknown environment variable is inherited by the inner cargo build. Because WebAssembly does not support dynamic libraries (dylib), the inner build fails.
Error Output
[INFO]: 🎯 Checking for the Wasm target...
[INFO]: 🌀 Compiling to Wasm...
Compiling raster-nodes-shaders v0.1.0 (../Graphite/node-graph/nodes/raster/shaders)
error: failed to run custom build command for `raster-nodes-shaders v0.1.0 (../Graphite/node-graph/nodes/raster/shaders)`
Caused by:
...
error: cannot produce dylib for `rustc_codegen_spirv v0.9.0 (https://github.com/Firestar99/rust-gpu-new?rev=c12f2161...#c12f2161)` as the target `wasm32-unknown-unknown` does not support these crate types
Steps to Reproduce
- Clone the repository.
- Ensure Node.js and Rust prerequisites are installed.
- Run
cargo run. - Observe the build crash when
wasm-packreachesraster-nodes-shaders.
Proposed Solution
The inner build initiated by cargo_gpu::Install inside node-graph/nodes/raster/shaders/build.rs needs to compile for the host OS, not the WebAssembly target.
Clearing the CARGO_BUILD_TARGET environment variable inside build.rs before it kicks off the cargo_gpu build resolves the issue and allows the compilation to succeed:
// node-graph/nodes/raster/shaders/build.rs
// Inside main():
unsafe { std::env::remove_var("CARGO_BUILD_TARGET"); }
// ... followed by the existing cargo_gpu::Install::from_shader_crate(...) logic
Environment
- OS: macOS 26.3.1 (Build 25D2128)
- Rust Version: rustc 1.92.0 (ded5c06cf 2025-12-08)
- Node.js: v22.21.1
🤖 AI disclosure
I used Gemini to help me understand the error message. This message and the fix are mine.
- Dominant language
- Rust
- Stars
- 27.3k
- Forks
- 1.3k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 54
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from GraphiteEditor/Graphite
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
GraphiteEditor/Graphite#4396 · 2 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
GraphiteEditor/Graphite#4311 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
GraphiteEditor/Graphite#4275 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 58/100
GraphiteEditor/Graphite#4544 · 2 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
GraphiteEditor/Graphite#4515 · 1 comment ·
All issues in GraphiteEditor/Graphite
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
gitbutlerapp/gitbutler#15998 · 1 comment ·
-
bug triage:deciding
Difficulty 1/5 Under an hour Newbie friendliness 88/100
open-telemetry/otel-arrow#4132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100