vulkano-rs / vulkano

Safe and rich Rust wrapper around the Vulkan API
Apache License 2.0
4.48k stars 433 forks source link

glsl-to-spirv: Cross compile. #1232

Closed cheako closed 4 years ago

cheako commented 5 years ago

As glsl-to-spirv is somehow related to vulkano, but this relationship is not clear on cursory inspection, it's difficult to be clear.

CC=x86_64-w64-mingw32-gcc-posix CXX=x86_64-w64-mingw32-g++-posix CARGO_TARGET_X86_64_PC_WINDOWS_GNU_LINKER=x86_64-w64-mingw32-gcc-posix cargo build --target x86_64-pc-windows-gnu

As this is a simple matter I don't see how the crate here has much influence, but to be complete: https://gitlab.com/cheako/simulide-rs/tree/imgui_success_001

error: failed to run custom build command for `glsl-to-spirv v0.1.7`

Caused by:
  process didn't exit successfully: `/home/cheako/src/github/simulide-rs/target/debug/build/glsl-to-spirv-cc02f8530994cbe7/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=build/glslangValidator.exe
running: "cmake" "/home/cheako/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang" "-DCMAKE_INSTALL_PREFIX=/home/cheako/src/github/simulide-rs/target/debug/build/glsl-to-spirv-21430fb4aa6a5acb/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/x86_64-w64-mingw32-gcc-posix" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/x86_64-w64-mingw32-g++-posix" "-DCMAKE_BUILD_TYPE=Debug"
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc-posix
-- Check for working C compiler: /usr/bin/x86_64-w64-mingw32-gcc-posix -- broken
-- Configuring incomplete, errors occurred!
See also "/home/cheako/src/github/simulide-rs/target/debug/build/glsl-to-spirv-21430fb4aa6a5acb/out/build/CMakeFiles/CMakeOutput.log".
See also "/home/cheako/src/github/simulide-rs/target/debug/build/glsl-to-spirv-21430fb4aa6a5acb/out/build/CMakeFiles/CMakeError.log".

--- stderr
fatal: not a git repository (or any of the parent directories): .git
CMake Error at /usr/share/cmake-3.13/Modules/CMakeTestCCompiler.cmake:52 (message):
  The C compiler

    "/usr/bin/x86_64-w64-mingw32-gcc-posix"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/cheako/src/github/simulide-rs/target/debug/build/glsl-to-spirv-21430fb4aa6a5acb/out/build/CMakeFiles/CMakeTmp

    Run Build Command:"/usr/bin/make" "cmTC_47371/fast"
    /usr/bin/make -f CMakeFiles/cmTC_47371.dir/build.make CMakeFiles/cmTC_47371.dir/build
    make[1]: Entering directory '/home/cheako/src/github/simulide-rs/target/debug/build/glsl-to-spirv-21430fb4aa6a5acb/out/build/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_47371.dir/testCCompiler.c.o
    /usr/bin/x86_64-w64-mingw32-gcc-posix   -ffunction-sections -fdata-sections -fPIC -m64    -o CMakeFiles/cmTC_47371.dir/testCCompiler.c.o   -c /home/cheako/src/github/simulide-rs/target/debug/build/glsl-to-spirv-21430fb4aa6a5acb/out/build/CMakeFiles/CMakeTmp/testCCompiler.c
    Linking C executable cmTC_47371
    /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_47371.dir/link.txt --verbose=1
    /usr/bin/x86_64-w64-mingw32-gcc-posix  -ffunction-sections -fdata-sections -fPIC -m64     -rdynamic CMakeFiles/cmTC_47371.dir/testCCompiler.c.o  -o cmTC_47371 
    x86_64-w64-mingw32-gcc-posix: error: unrecognized command line option ‘-rdynamic’
    make[1]: *** [CMakeFiles/cmTC_47371.dir/build.make:87: cmTC_47371] Error 1
    make[1]: Leaving directory '/home/cheako/src/github/simulide-rs/target/debug/build/glsl-to-spirv-21430fb4aa6a5acb/out/build/CMakeFiles/CMakeTmp'
    make: *** [Makefile:121: cmTC_47371/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:20 (project)

thread 'main' panicked at '
command did not execute successfully, got: exit code: 1

build script failed, must exit now', /home/cheako/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.41/src/lib.rs:835:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: build failed

https://www.reddit.com/r/rust/comments/csdrmt/cross_compiling_ccpp_with_rust_providing_threads/

AustinJ235 commented 4 years ago

We no longer use glsl-to-spirv, so I am not sure why you are running into this issue.

cheako commented 4 years ago

What replaces glsl-to-spirv? I'm using it directly and don't know how to report issues.

rukai commented 4 years ago

https://github.com/google/shaderc-rs

cheako commented 4 years ago

@rukai Shaderc tackles a different issue and when it's appropriate my project uses it. glsl-to-spirv does compile-time compilation of shaders, where shaderc can be used to compile shaders at run-time.

rukai commented 4 years ago

Well I don't think glsl-to-spirv actually does that, but it's been a while...

Regardless what you actually want is https://github.com/Ralith/vk-shader-macros

cheako commented 4 years ago

Sorry, I think I'm confused. https://crates.io/crates/glsl-to-spirv-macros

rukai commented 4 years ago

Ahah, makes sense, I haven't seen glsl-to-spirv-macros before. I recommend vk-shader-macros as it is maintained and does not result in undefined behaviour due to incorrect alignment

cheako commented 4 years ago

One feature vk-shader-macros is missing is inline glsl, so I don't think I'll switch. Thanks though.