shaderc icon indicating copy to clipboard operation
shaderc copied to clipboard

How to build against a given (prebuilt) version of glslang

Open DanOlivier opened this issue 8 years ago • 2 comments

Hi, I'm asking because I need to work against a version of glslang (and spirv-tools and spirv-headers) from another tree where I build Vulkan (VulkanTools, specifically, which contains a submodule of Vulkan-LoaderAndValidationLayers, which "imports" and builds in-tree glslang and its dependencies using update_glslang_sources.sh). Wouldn't it be possible to build against an installed version of these dependencies? I mean, I would like to build glslang (with or without Vulkan drivers and tools) and its dependencies, and then install them to, say, usr/local or /tmp/glslang-debug, and then build shaderc against those built artifacts (headers, libraries, binaries). I tried modifying third_party/CMakeLists.txt to use the existing versions of the 3rd-party dependencies, but I was not really successful. The CMake files of shaderc expect to include those dependencies as sources, rather than installed products. Has anyone done this? Thanks

DanOlivier avatar Feb 22 '18 21:02 DanOlivier

In principle this should work, with some possibly rough edges. The functional interface between Shaderc and Glslang is generally very stable.

I don't know someone who has done this. Generally the shader compiler tooling projects build from sources rather than installed components.

I think the main thing to do is use Shaderc's CMakeLists.txt file use find_library to find the installed glslang. I would happy to accept a PR along these lines, where using an installed version of glslang is a fallback or a CMake option.

The rough edge is that Shaderc tests check for error conditions and messages coming out of Glslang. So sometimes Shaderc tests will start failing due to an independent update in Glslang. Shaderc has to adjust for those changes. For example see https://github.com/google/shaderc/pull/425

dneto0 avatar Feb 26 '18 18:02 dneto0

This isn't building from prebuilts, but if you want to make sure your versions match, you should at least be able to set the cmake variables:

SHADERC_GOOGLE_TEST_DIR SHADERC_SPIRV_TOOLS_DIR SHADERC_SPIRV_HEADERS_DIR SHADERC_GLSLANG_DIR

and point them at the sources that are pulled down from Vulkan-LoaderAndValidationLayers. This is still a build from source, but at least all of the versions will match.

AWoloszyn avatar Mar 08 '18 16:03 AWoloszyn