From 8c4662876c80a9076d1263814582d220fe40acd8 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Thu, 14 Nov 2024 19:12:02 +0000 Subject: [PATCH] Ensure glslang include directories are specified before Vulkan SDK ones Otherwise some compilation units may use the definitions of inline glslang functions from the Vulkan SDK's copy of glslang instead of the glslang we're using, and if the necessary linker warnings aren't enabled and set as errors (they're not), this can cause ABI issues. I noticed this after encountering stack corruption in glslang::GlslangToSpv as the Vulkan SDK version 1.3.296 provides glslang 15.0.0, where glslang::SpvOptions is ten bytes, whereas I was using glslang 14.3.0, where it's only nine bytes, so initialising defaultOptions would spill one byte past the object's end. Fixing the include order ensures all TUs use the right function implementation and the linker won't randomly pick the wrong one. --- src/vsg/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vsg/CMakeLists.txt b/src/vsg/CMakeLists.txt index 263122d5a..229faee43 100644 --- a/src/vsg/CMakeLists.txt +++ b/src/vsg/CMakeLists.txt @@ -268,7 +268,7 @@ set(LIBRARIES PUBLIC ) if (${VSG_SUPPORTS_ShaderCompiler}) - list(APPEND LIBRARIES PRIVATE glslang::glslang glslang::glslang-default-resource-limits glslang::SPIRV) + list(INSERT LIBRARIES 0 PRIVATE glslang::glslang glslang::glslang-default-resource-limits glslang::SPIRV) endif() # Check for std::atomic