flycast icon indicating copy to clipboard operation
flycast copied to clipboard

(build) glslang build error only when `USE_HOST_GLSLANG=ON`??

Open wongandj opened this issue 11 months ago • 2 comments

This applies to both v2.4 and the latest git... With USE_VULKAN=ON and USE_HOST_GLSLANG=OFF, building completes without a hitch. When compiling with USE_HOST_GLSLANG=ON, however, Flycast does not build, with the following error:

In file included from /tmp/guix-build-flycast-2.4.drv-0/source/core/deps/glslang/SPIRV/GlslangToSpv.h:42,
                 from /tmp/guix-build-flycast-2.4.drv-0/source/core/rend/vulkan/shaders.h:23,
                 from /tmp/guix-build-flycast-2.4.drv-0/source/core/rend/vulkan/quad.h:24,
                 from /tmp/guix-build-flycast-2.4.drv-0/source/core/rend/vulkan/vulkan_context.h:89,
                 from /tmp/guix-build-flycast-2.4.drv-0/source/core/wsi/switcher.cpp:29:
/tmp/guix-build-flycast-2.4.drv-0/source/core/deps/glslang/SPIRV/SpvTools.h:50:10: fatal error: glslang/MachineIndependent/localintermediate.h: No such file or directory
   50 | #include "glslang/MachineIndependent/localintermediate.h"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/flycast.dir/build.make:3383: CMakeFiles/flycast.dir/core/wsi/switcher.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[2]: Leaving directory '/tmp/guix-build-flycast-2.4.drv-0/build'
make[1]: *** [CMakeFiles/Makefile2:230: CMakeFiles/flycast.dir/all] Error 2
make[1]: Leaving directory '/tmp/guix-build-flycast-2.4.drv-0/build'
make: *** [Makefile:139: all] Error 2

This is very strange--according to the root CMakeLists.txt, core/deps/glslang shouldn't even be building, if I read correctly (if--Please forgive me if I'm missing something obvious).

if(USE_VULKAN)
	if(USE_HOST_GLSLANG)
		find_package(glslang REQUIRED)
	else()
		option(BUILD_EXTERNAL "Build external dependencies in /External" OFF)
		option(SKIP_GLSLANG_INSTALL "Skip installation" ON)
		option(ENABLE_SPVREMAPPER "Enables building of SPVRemapper" OFF)
...

Stranger, USE_VULKAN=ON and USE_HOST_GLSLANG=ON, the log for the configure phase is missing the 'found glslang' message.

wongandj avatar Feb 10 '25 11:02 wongandj

This is likely due to this line in CMakeLists.txt:

target_include_directories(${PROJECT_NAME} PRIVATE core core/deps core/deps/stb core/deps/json core/deps/asio/asio/include)

It adds core/deps to the include path, which contains glslang/SPIRV/GlslangToSpv.h

flyinghead avatar Feb 10 '25 11:02 flyinghead

Is that a mistake? Edit: aha, my distro's version of glslang is missing include/glslang/MachineIndependent/localintermediate.h. Edit 2: Or, wait, shouldn't core/rend/vulkan/shaders.h:23 refer to my system's SPIRV/GlslangToSpv.h, not the one in core/deps/glslang? Edit 3: Yes, my distro's version of glslang's GlslangToSpv.h does not include these lines that are in the vendored version, and neither does the upstream.

#if defined(_MSC_VER) && _MSC_VER >= 1900
    #pragma warning(disable : 4464) // relative include path contains '..'
#endif

#include "SpvTools.h"
#include "glslang/Include/intermediate.h"

But anyways, if anything, the build should be complaining about the files in my system's glslang, not the vendored one. I'm sorry, I'm a bit in over my head here

wongandj avatar Feb 11 '25 05:02 wongandj