Skip to content

Fix SPIRV-Headers target to ggml-vulkan - #28951

Closed
uilianries wants to merge 1 commit into
ggml-org:masterfrom
uilianries:fix/spirv-headers-target
Closed

uilianries wants to merge 1 commit into
ggml-org:masterfrom
uilianries:fix/spirv-headers-target

Conversation

@uilianries

Copy link
Copy Markdown
Contributor

Overview

Greetings! As we are updating llama-cpp in Conan Center, during a build with Vulkan support enabled on Linux, the following error was noted:

/home/conan/.conan2/p/b/llama56e1356afc47a/b/src/ggml/src/ggml-vulkan/ggml-vulkan.cpp: In function ‘bool ggml_vk_strip_decode_vector(const uint32_t*, size_t, std::vector<unsigned int>&)’:
/home/conan/.conan2/p/b/llama56e1356afc47a/b/src/ggml/src/ggml-vulkan/ggml-vulkan.cpp:2881:33: error: ‘spv’ has not been declared
 2881 |         uint32_t wc   = word >> spv::WordCountShift;

You can see the full build log here: llama-cpp-0.4.1-linux-amd64-gcc13-release-shared-error.log

Investigating a little, the find_package(SPIRV-Headers CONFIG REQUIRED) (added in #22009, refined in #23215) only guarantees that the SPIRV-Headers config package is found. It does not propagate SPIRV-Headers::SPIRV-Headers's include directories anywhere, since nothing in ggml/src/ggml-vulkan/CMakeLists.txt links that target. Only Vulkan::Vulkan is linked into ggml-vulkan.

When using sysroot/SDK-based setups (system packages), the SPIR-V headers happen to live
in the same globally-visible include tree as Vulkan itself, so ggml-vulkan.cpp resolves regardless of what's actually linked.

That assumption breaks for package managers that install SPIRV-Headers into an isolated, non-shared prefix, like Conan. For every __has_include branch that fails, the unconditional fallback include also fails to resolve the header, and the spv:: namespace ends up undeclared.

The upstream, SPIRV-Headers, offers an official CMake target for its module: SPIRV-Headers::SPIRV-Headers. See: https://github.com/KhronosGroup/SPIRV-Headers/blob/04fd3caa1e8267e4d95c806cad901181728e1006/CMakeLists.txt#L41

This PR links SPIRV-Headers::SPIRV-Headers explicitly into ggml-vulkan so its include directories are always propagated, independent of how SPIRV-Headers was installed. The same pattern is already used for ggml-cpu a few lines below (#24444).

After applying this patch, I can build without errors: llama-cpp-0.4.1-linux-amd64-gcc13-release-shared-patched.log

Requirements

Signed-off-by: Uilian Ries <uilianries@gmail.com>
@uilianries
uilianries requested a review from a team as a code owner September 15, 2026 13:57
@github-actions github-actions Bot added Vulkan Issues specific to the Vulkan backend ggml changes relating to the ggml tensor library for machine learning labels Sep 15, 2026
@0cc4m

0cc4m commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

The gpu-vulkan-apple CI failure is real, this change does not yet work on MacOS, at least on the runner.

@0cc4m

0cc4m commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Resolved by #31416

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ggml changes relating to the ggml tensor library for machine learning Vulkan Issues specific to the Vulkan backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants