Rust-SDL2 / rust-sdl2

SDL2 bindings for Rust
MIT License
2.67k stars 465 forks source link

glsl-to-spirv fails to compile on FreeBSD 12.2 and 13.0 #1095

Open koodikone opened 3 years ago

koodikone commented 3 years ago

I am unable to compile rust-sdl2 (0.34.4) examples on Freebsd 12.2 and 13.0. The culprit seem to be "glsl-to-spirv-0.1.7" crate which Clang is not happy about.

Command: cargo run --example=demo

Error log:

process didn't exit successfully: /usr/home/koodikone/projects/rust-sdl2/target/debug/build/glsl-to-spirv-ca515f4b07c377fa/build-script-build (exit code: 101) --- stdout cargo:rerun-if-changed=build/glslangValidator.exe running: "cmake" "/usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang" "-DCMAKE_INSTALL_PREFIX=/usr/home/koodikone/projects/rust-sdl2/target/debug/build/glsl-to-spirv-ed2ba8e6d261712c/out" "-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_C_COMPILER=/usr/bin/cc" "-DCMAKE_CXX_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_CXX_COMPILER=/usr/bin/c++" "-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC -m64" "-DCMAKE_ASM_COMPILER=/usr/bin/cc" "-DCMAKE_BUILD_TYPE=Debug" -- Google Mock was not found - tests based on that will not build -- Configuring done -- Generating done -- Build files have been written to: /usr/home/koodikone/projects/rust-sdl2/target/debug/build/glsl-to-spirv-ed2ba8e6d261712c/out/build running: "cmake" "--build" "." "--target" "install" "--config" "Debug" "--" [ 3%] Built target OSDependent [ 5%] Building CXX object SPIRV/CMakeFiles/SPVRemapper.dir/SPVRemapper.cpp.o [ 8%] Built target OGLCompiler [ 10%] Building CXX object hlsl/CMakeFiles/HLSL.dir/hlslAttributes.cpp.o [ 14%] Built target glslang-default-resource-limits [ 15%] Building CXX object hlsl/CMakeFiles/HLSL.dir/hlslParseHelper.cpp.o [ 17%] Building CXX object hlsl/CMakeFiles/HLSL.dir/hlslScanContext.cpp.o In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/hlslParseHelper.cpp:37: In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/hlslParseHelper.h:39: In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/parseVersions.h:41: /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/../Public/ShaderLang.h:81:22: warning: 'fastcall' calling convention is not supported for this target [-Wignored-attributes] SH_IMPORT_EXPORT int fastcall ShFinalize(); ^ /usr/include/sys/cdefs.h:368:35: note: expanded from macro 'fastcall'

define fastcall attribute((fastcall__))

^ In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/hlslAttributes.cpp:36: In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/hlslAttributes.h:41: In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/hlslScanContext.h:44: In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/ParseHelper.h:47: In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/parseVersions.h:41: /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/../Public/ShaderLang.h:81:22: warning: 'fastcall' calling convention is not supported for this target [-Wignored-attributes] SH_IMPORT_EXPORT int fastcall ShFinalize(); ^ /usr/include/sys/cdefs.h:368:35: note: expanded from macro 'fastcall'

define fastcall attribute((fastcall__))

^ In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/hlslScanContext.cpp:45: In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/Include/Types.h:41: In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/Include/../Include/Common.h:99: /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/Include/PoolAlloc.h:314:54: error: 'operator=' is a private member of 'glslang::TPoolAllocator' void setAllocator(TPoolAllocator a) { allocator = a; }


/usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/Include/PoolAlloc.h:244:21: note: declared private here
TPoolAllocator& operator=(const TPoolAllocator&);  // don't allow assignment operator
^
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/hlslScanContext.cpp:45:
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/Include/Types.h:43:
/usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/Include/../Public/ShaderLang.h:81:22: warning: '__fastcall__' calling convention is not supported for this target [-Wignored-attributes]
SH_IMPORT_EXPORT int __fastcall ShFinalize();
^
/usr/include/sys/cdefs.h:368:35: note: expanded from macro '__fastcall'
#define __fastcall      __attribute__((__fastcall__))
^
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/SPIRV/SPVRemapper.cpp:45:
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/SPIRV/../glslang/Include/Common.h:99:
/usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/SPIRV/../glslang/Include/PoolAlloc.h:314:54: error: 'operator=' is a private member of 'glslang::TPoolAllocator'
void setAllocator(TPoolAllocator* a) { allocator = *a; }
~~~~~~~~~ ^ ~~
/usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/SPIRV/../glslang/Include/PoolAlloc.h:244:21: note: declared private here
TPoolAllocator& operator=(const TPoolAllocator&);  // don't allow assignment operator
^
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/hlslParseHelper.cpp:37:
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/hlslParseHelper.h:39:
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/parseVersions.h:42:
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/../Include/InfoSink.h:38:
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/../Public/../Include/../Include/Common.h:99:
/usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/../Public/../Include/PoolAlloc.h:314:54: error: 'operator=' is a private member of 'glslang::TPoolAllocator'
void setAllocator(TPoolAllocator* a) { allocator = *a; }
~~~~~~~~~ ^ ~~
/usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/../Public/../Include/PoolAlloc.h:244:21: note: declared private here
TPoolAllocator& operator=(const TPoolAllocator&);  // don't allow assignment operator
^
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/hlslAttributes.cpp:36:
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/hlslAttributes.h:41:
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/hlslScanContext.h:44:
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/ParseHelper.h:47:
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/parseVersions.h:42:
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/../Include/InfoSink.h:38:
In file included from /usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/../Public/../Include/../Include/Common.h:99:
/usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/../Public/../Include/PoolAlloc.h:314:54: error: 'operator=' is a private member of 'glslang::TPoolAllocator'
void setAllocator(TPoolAllocator* a) { allocator = *a; }
~~~~~~~~~ ^ ~~
/usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/../glslang/MachineIndependent/../Public/../Include/PoolAlloc.h:244:21: note: declared private here
TPoolAllocator& operator=(const TPoolAllocator&);  // don't allow assignment operator
^
/usr/home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/glsl-to-spirv-0.1.7/glslang/hlsl/hlslParseHelper.cpp:8743:33: warning: lambda capture 'this' is not used [-Wunused-lambda-capture]
const auto isOutputPatch = [this](TFunction& patchConstantFunction, int param) {
^~~~
1 warning and 1 error generated.
*** [all] Error code 6
make: stopped in /usr/home/koodikone/projects/rust-sdl2/target/debug/build/glsl-to-spirv-ed2ba8e6d261712c/out/build
make: stopped in /usr/home/koodikone/projects/rust-sdl2/target/debug/build/glsl-to-spirv-ed2ba8e6d261712c/out/build
--- stderr
1 error
thread 'main' panicked at '
command did not execute successfully, got: exit code: 2

 build script failed, must exit now', /home/koodikone/.cargo/registry/src/github.com-1ecc6299db9ec823/cmake-0.1.45/src/lib.rs:894:5
Cobrand commented 3 years ago

glsl_to_spirv dependency is one only used for one example, being raw-window-handle-with-wgpu, which is pretty specific. If you want to fix it, I think you can try to disable this example at compile time (until glsl_to_spirv is fixed upstream), and put the glsl_to_spirv as an optionnal dev-dependency in Cargo.toml.

In the meantime, this compilation error should only happen when you compile a demo directly from this crate. If you copy paste the demo code into a new project a put rust-sdl2 as a dependency, you might get another error but at least you won't get the same one for sure.

koodikone commented 3 years ago

Great! If I remove "glsl_to_spirv" as devdependency, it compiles and works! However, will it ever get fixed upstream? Isn't glsl_to_spirv deprecated?

Cobrand commented 3 years ago

Indeed, rather than fixing it upstream, we would need to change glsl_to_spirv dev-dependency to shaderc-rs, adapt the code and hope it works for your platform then.