Yesterday I built a binary on win10 in release mode and copied it to a new folder named "xxx". The cmd I used was:
cargo run --target-dir "D:/rust_build/all" --release --example button
Today I deleted all content under D:/rust_build/all and changed the cmd to the following and rebuilt it:
cargo run --target-dir "D:/rust_build/" --release --example button
Then of course no error occurred to the new binary. But the following error occurred when I ran the old binary under folder "xxx":
thread '<unnamed>' panicked at 'Failed to execute glslangValidator: Os { code: 2, kind: NotFound, message: "系统找不到指定的文件。" }', C:\Users\Administrator\.cargo\registry\src\mirrors.sjtug.sjtu.edu.cn-4f7dbcce21e258a2\bevy-glsl-to-spirv-0.1.7\src\lib.rs:59:18
"系统找不到指定的文件" means "The system cannot find the specified file"
hmm very interesting. looks like its failing to find the glslLangValidator binary (which makes sense given its a standalone executable). https://github.com/cart/glsl-to-spirv/blob/7c4b23dc3c2386e85dad4f0492353b54e61c2fb8/src/lib.rs#L59
This is absolutely a problem that needs solving.
I can think of three fixes:
The issue is we do "on demand shader compilation" based on run time state. Shaderc (or naga) is really the perfect fit for this kind of thing.
We don't use the shaderc rust bindings because they complicate the builds, especially on windows, but that would also be a fix.
It might be nice to have a bevy_shaderc plugin/optional feature? Naga is still a ways out from being usable even though a lot of progress has been made.
The error 'Failed to execute glslangValidator' also occurs if you move the bevy folder.
To reproduce:
git clone https://github.com/bevyengine/bevy.git && cd bevycargo run --example 3d_scene (works)cd .. && mkdir otherfoldermv bevy otherfolder && cd otherfolder/bevycargo run --example 3d_scene (fails)~/.../otherfolder/bevy >>> cargo run --example 3d_scene
Finished dev [unoptimized + debuginfo] target(s) in 0.11s
Running `target/debug/examples/3d_scene`
thread '<unnamed>' panicked at 'Failed to execute glslangValidator: Os { code: 2, kind: NotFound, message: "No such file or directory" }', /home/elias/.cargo/registry/src/github.com-1ecc6299db9ec823/bevy-glsl-to-spirv-0.1.7/src/lib.rs:59:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
To fix:
cargo cleancargo run --example 3d_scene (works)To fix (if you use sccache)
rm -rf ~/.cache/sccache (note: this will delete everything sccache has cached!)cargo cleancargo run --example 3d_scene (works)These fixes work for now. Let's work towards using naga :)
Hey all, I hit this today too. I'm new to this ecosystem and not sure what the pros / cons of naga vs shaderc are; I note that docs say that shaderc should be used in place of bevy-glsl-to-spirv.
@cart could you elaborate on the build issues with shaderc? Are they discussed somewhere? Would you be willing to accept a PR adding shaderc to solve this problem?
There's already a PR out for it. I explain my rationale there: https://github.com/bevyengine/bevy/pull/324
I managed to work around this by forking glsl-to-spirv (https://github.com/szunami/glsl-to-spirv/blob/master/src/lib.rs#L31)
Obviously this is a bit jank, but I should be ok for now. Thanks all!
@cart I'm tackling this as part of moving glsl-to-spirv to using glslang as a library. Could you assign the issue to me?
Sure, but lets sync up on what your plan is first. I would like to retain the "works without additional setup" properties of the current approach if we can, which would mean providing precompiled binaries.
We have a few "solutions" to the problem in general:
Most helpful comment
The error 'Failed to execute glslangValidator' also occurs if you move the bevy folder.
To reproduce:
git clone https://github.com/bevyengine/bevy.git && cd bevycargo run --example 3d_scene(works)cd .. && mkdir otherfoldermv bevy otherfolder && cd otherfolder/bevycargo run --example 3d_scene(fails)To fix:
cargo cleancargo run --example 3d_scene(works)To fix (if you use sccache)
rm -rf ~/.cache/sccache(note: this will delete everything sccache has cached!)cargo cleancargo run --example 3d_scene(works)These fixes work for now. Let's work towards using naga :)