From 99aee964fdcb8549ab20d0acc77028253381fde7 Mon Sep 17 00:00:00 2001 From: Richard Palethorpe Date: Fri, 30 Oct 2026 11:12:26 +0000 Subject: [PATCH 1/2] vulkan: Explicitly include SPIRV-Headers Distros that don't put the headers in a system include path need to specify it to the compiler. So we use the appropriate CMake target to include it. Assisted-by: Codex --- ggml/src/ggml-vulkan/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ggml/src/ggml-vulkan/CMakeLists.txt b/ggml/src/ggml-vulkan/CMakeLists.txt index 682b90e1629b..90722fcac9db 100644 --- a/ggml/src/ggml-vulkan/CMakeLists.txt +++ b/ggml/src/ggml-vulkan/CMakeLists.txt @@ -120,7 +120,7 @@ if (Vulkan_FOUND) "GGML_VULKAN_FLOAT_E4M3_GLSLC_SUPPORT" ) - target_link_libraries(ggml-vulkan PRIVATE Vulkan::Vulkan) + target_link_libraries(ggml-vulkan PRIVATE Vulkan::Vulkan SPIRV-Headers::SPIRV-Headers) target_include_directories(ggml-vulkan PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) # Workaround to the "can't dereference invalidated vector iterator" bug in clang-cl debug build From a7b9f1162e9bfc8b03221f16eeec457614175724 Mon Sep 17 00:00:00 2001 From: Richard Palethorpe Date: Fri, 30 Oct 2026 17:04:39 +0000 Subject: [PATCH 2/2] vulkan: Add explicit headers location to workaround OSX CI runner conf --- ci/run.sh | 2 ++ ggml/CMakeLists.txt | 1 + ggml/src/ggml-vulkan/CMakeLists.txt | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/ci/run.sh b/ci/run.sh index 346b116c7307..b0988ac26473 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -122,6 +122,8 @@ if [ ! -z ${GG_BUILD_VULKAN} ]; then MACOS_RUNNER_CUSTOM_SPIRV_HEADERS_LOCATION="${MACOS_RUNNER_CUSTOM_VULKAN_CMAKE_LOCATION}/SPIRV-Headers/SPIRV-HeadersConfig.cmake" if [[ -f "${MACOS_RUNNER_CUSTOM_SPIRV_HEADERS_LOCATION}" || -h "${MACOS_RUNNER_CUSTOM_SPIRV_HEADERS_LOCATION}" ]]; then CMAKE_EXTRA="${CMAKE_EXTRA} -DSPIRV-Headers_DIR=${MACOS_RUNNER_CUSTOM_VULKAN_CMAKE_LOCATION}/SPIRV-Headers" + # SPIRV-Headers walks up three directories and appends /include, yielding /usr/local/lib/include; the extra vulkan/ level likely breaks its prefix calculation. + CMAKE_EXTRA="${CMAKE_EXTRA} -DGGML_VULKAN_SPIRV_INCLUDE_DIR=/usr/local/include" fi fi diff --git a/ggml/CMakeLists.txt b/ggml/CMakeLists.txt index 03fc428a8149..3afe6ee89ddb 100644 --- a/ggml/CMakeLists.txt +++ b/ggml/CMakeLists.txt @@ -228,6 +228,7 @@ option(GGML_VULKAN_MEMORY_DEBUG "ggml: enable Vulkan memory debug ou option(GGML_VULKAN_SHADER_DEBUG_INFO "ggml: enable Vulkan shader debug info" OFF) option(GGML_VULKAN_VALIDATE "ggml: enable Vulkan validation" OFF) option(GGML_VULKAN_RUN_TESTS "ggml: run Vulkan tests" OFF) +set (GGML_VULKAN_SPIRV_INCLUDE_DIR "" CACHE PATH "ggml: override the SPIRV-Headers include directory") option(GGML_WEBGPU "ggml: use WebGPU" OFF) option(GGML_WEBGPU_DEBUG "ggml: enable WebGPU debug output" OFF) option(GGML_WEBGPU_CPU_PROFILE "ggml: enable WebGPU profiling (CPU)" OFF) diff --git a/ggml/src/ggml-vulkan/CMakeLists.txt b/ggml/src/ggml-vulkan/CMakeLists.txt index 90722fcac9db..791753a8cf9a 100644 --- a/ggml/src/ggml-vulkan/CMakeLists.txt +++ b/ggml/src/ggml-vulkan/CMakeLists.txt @@ -13,6 +13,11 @@ if (DEFINED ENV{VULKAN_SDK}) endif() find_package(SPIRV-Headers CONFIG REQUIRED) +if (GGML_VULKAN_SPIRV_INCLUDE_DIR) + set_property(TARGET SPIRV-Headers::SPIRV-Headers PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${GGML_VULKAN_SPIRV_INCLUDE_DIR}") +endif() + if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") # Parallel build object files add_definitions(/MP)