glslang icon indicating copy to clipboard operation
glslang copied to clipboard

Build problem cross-compiling from LInux to

Open John-Nagle opened this issue 3 years ago • 4 comments

Cross-compiling on Linux with target Windows. It almost works. Trouble is at

  In file included from /home/john/.cargo/registry/src/github.com-1ecc6299db9ec823/shaderc-sys-0.6.3/build/glslang/StandAlone/StandAlone.cpp:44:
  /home/john/.cargo/registry/src/github.com-1ecc6299db9ec823/shaderc-sys-0.6.3/build/glslang/StandAlone/Worklist.h:89:14: error: ‘mutex’ in namespace ‘std’ does not name a type
     89 |         std::mutex mutex;
        |              ^~~~~
  /home/john/.cargo/registry/src/github.com-1ecc6299db9ec823/shaderc-sys-0.6.3/build/glslang/StandAlone/Worklist.h:41:1: note: ‘std::mutex’ is defined in header ‘<mutex>’; did you forget to ‘#include <mutex>’?
     40 | #include <mutex>
    +++ |+#include <mutex>
     41 | #include <string>

John-Nagle avatar Mar 15 '21 02:03 John-Nagle

Full listing of build attached. What's going on here is that I'm building Rend3, a Rust portable wrapper for Vulkan. Here I'm trying to build it for Windows while running on Linux. Yes, I realize this is somewhat unusual. Works fine built native on Linux (both Ubuntu 18.04 LTS and Ubuntu 20.04 LTS.) Here, glslang is being built as part of the build process for Rend3.

GCC is complaning that std::mutex is not a type. Even though <mutex> was included. I don't see why that should fail with reasonable default libraries. That's pretty basic. Perhaps somewhere an include path has a problem. It's so close to working.

Fails on both 20.04 LTS and 18.04 LTS, in the same way.

gslang-build-fail.txt

To reproduce the error, install current Rust, get Rend3 from Github, and try to build on Linux with

cargo build --target x86_64-pc-windows-gnu

At first you may get errors telling you to install libraries, depending on what you have installed. Those are easy to get past. Then there's a long compile, failing as shown here.

Please let me know if any further info is required. Thanks.

John-Nagle avatar Mar 15 '21 02:03 John-Nagle

Have you looked at this?: https://stackoverflow.com/questions/14191566/c-mutex-in-namespace-std-does-not-name-a-type

greg-lunarg avatar Mar 15 '21 21:03 greg-lunarg

I do not consider this a bug since no bad glslang code has been identified. Rather I consider this a request for an enhancement to the build.

I am currently not funded to make this improvement, but I am open to a PR that solves this problem and maintains current capability.

greg-lunarg avatar Mar 15 '21 21:03 greg-lunarg

Ah. That explains the problem. Thanks. Looks easy to fix for someone who understands the gslang build system.

(I don't want to dig into their build system; I'd probably break some other platform fixing this one.)

John-Nagle avatar Mar 15 '21 21:03 John-Nagle

This is problem only when using GCC with the win32 threading model. When using the posix threading model, everything is fine.

On my system (Ubuntu WSL), this can be tested using update-alternatives to switch to the win32 threading model:

sudo update-alternatives --config x86_64-w64-mingw32-gcc
sudo update-alternatives --config x86_64-w64-mingw32-g++

JohannesKauffmann avatar Nov 24 '22 20:11 JohannesKauffmann