Skip to content

[ggml] fix vulkan spv shadowing#22760

Merged
0cc4m merged 1 commit intoggml-org:masterfrom
miyanyan:spv
May 8, 2026
Merged

[ggml] fix vulkan spv shadowing#22760
0cc4m merged 1 commit intoggml-org:masterfrom
miyanyan:spv

Conversation

@miyanyan
Copy link
Copy Markdown
Contributor

@miyanyan miyanyan commented May 6, 2026

Overview

I found build errors on arm64 when I update ggml to 0.11.0 microsoft/vcpkg#51551

FAILED: [code=1] src/ggml-vulkan/CMakeFiles/ggml-vulkan.dir/ggml-vulkan.cpp.o 
/usr/bin/aarch64-linux-gnu-g++ -DGGML_SCHED_MAX_COPIES=4 -DGGML_VULKAN_BFLOAT16_GLSLC_SUPPORT -DGGML_VULKAN_COOPMAT2_GLSLC_SUPPORT -DGGML_VULKAN_COOPMAT_GLSLC_SUPPORT -DGGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORT -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D_XOPEN_SOURCE=600 -I/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/.. -I/mnt/vcpkg-ci/b/ggml/arm64-linux-dbg/src/ggml-vulkan -I/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/../include -isystem /mnt/vcpkg-ci/installed/arm64-linux/include -fPIC -g -std=gnu++17 -Wmissing-declarations -Wmissing-noreturn -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-array-bounds -Wextra-semi -MD -MT src/ggml-vulkan/CMakeFiles/ggml-vulkan.dir/ggml-vulkan.cpp.o -MF src/ggml-vulkan/CMakeFiles/ggml-vulkan.dir/ggml-vulkan.cpp.o.d -o src/ggml-vulkan/CMakeFiles/ggml-vulkan.dir/ggml-vulkan.cpp.o -c /mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp: In function ‘void ggml_vk_create_pipeline_func(vk_device&, vk_pipeline&, size_t, const void*, std::string, uint32_t, std::array<unsigned int, 3>, std::vector<unsigned int>, bool, bool, uint32_t)’:
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2167:42: error: ‘spv’ is not a class, namespace, or enumeration
 2167 |             uint32_t opcode = spv[pos] & spv::OpCodeMask;
      |                                          ^~~
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2168:43: error: ‘spv’ is not a class, namespace, or enumeration
 2168 |             uint32_t len    = spv[pos] >> spv::WordCountShift;
      |                                           ^~~
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2171:27: error: ‘spv’ is not a class, namespace, or enumeration
 2171 |             if (opcode == spv::OpCapability) {
      |                           ^~~
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2174:34: error: ‘spv’ is not a class, namespace, or enumeration
 2174 |             } else if (opcode == spv::OpExtension) {
      |                                  ^~~
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2176:34: error: ‘spv’ is not a class, namespace, or enumeration
 2176 |             } else if (opcode == spv::OpEntryPoint) {
      |                                  ^~~
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2179:34: error: ‘spv’ is not a class, namespace, or enumeration
 2179 |             } else if (opcode == spv::OpExecutionMode || opcode == spv::OpExecutionModeId) {
      |                                  ^~~
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2179:68: error: ‘spv’ is not a class, namespace, or enumeration
 2179 |             } else if (opcode == spv::OpExecutionMode || opcode == spv::OpExecutionModeId) {
      |                                                                    ^~~
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2191:41: error: ‘spv’ is not a class, namespace, or enumeration
 2191 |         uint32_t exec_mode[] = { (4u << spv::WordCountShift) | spv::OpExecutionMode, entry_point_id, spv::ExecutionModeRoundingModeRTE, 16 };
      |                                         ^~~
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2191:64: error: ‘spv’ is not a class, namespace, or enumeration
 2191 |         uint32_t exec_mode[] = { (4u << spv::WordCountShift) | spv::OpExecutionMode, entry_point_id, spv::ExecutionModeRoundingModeRTE, 16 };
      |                                                                ^~~
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2191:102: error: ‘spv’ is not a class, namespace, or enumeration
 2191 |         uint32_t exec_mode[] = { (4u << spv::WordCountShift) | spv::OpExecutionMode, entry_point_id, spv::ExecutionModeRoundingModeRTE, 16 };
      |                                                                                                      ^~~
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2198:58: error: ‘spv’ is not a class, namespace, or enumeration
 2198 |         extension[0] = (uint32_t)((1 + ext_str_words) << spv::WordCountShift) | spv::OpExtension;
      |                                                          ^~~
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2198:81: error: ‘spv’ is not a class, namespace, or enumeration
 2198 |         extension[0] = (uint32_t)((1 + ext_str_words) << spv::WordCountShift) | spv::OpExtension;
      |                                                                                 ^~~
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2203:42: error: ‘spv’ is not a class, namespace, or enumeration
 2203 |         uint32_t capability[] = { (2u << spv::WordCountShift) | spv::OpCapability, spv::CapabilityRoundingModeRTE };
      |                                          ^~~
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2203:65: error: ‘spv’ is not a class, namespace, or enumeration
 2203 |         uint32_t capability[] = { (2u << spv::WordCountShift) | spv::OpCapability, spv::CapabilityRoundingModeRTE };
      |                                                                 ^~~
/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/ggml-vulkan.cpp:2203:84: error: ‘spv’ is not a class, namespace, or enumeration
 2203 |         uint32_t capability[] = { (2u << spv::WordCountShift) | spv::OpCapability, spv::CapabilityRoundingModeRTE };
      |                                                                                    ^~~
[455/459] /usr/bin/aarch64-linux-gnu-g++ -DGGML_SCHED_MAX_COPIES=4 -DGGML_VULKAN_BFLOAT16_GLSLC_SUPPORT -DGGML_VULKAN_COOPMAT2_GLSLC_SUPPORT -DGGML_VULKAN_COOPMAT_GLSLC_SUPPORT -DGGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORT -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D_XOPEN_SOURCE=600 -I/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/ggml-vulkan/.. -I/mnt/vcpkg-ci/b/ggml/arm64-linux-dbg/src/ggml-vulkan -I/mnt/vcpkg-ci/b/ggml/src/v0.11.0-b5126d360d.clean/src/../include -isystem /mnt/vcpkg-ci/installed/arm64-linux/include -fPIC -g -std=gnu++17 -Wmissing-declarations -Wmissing-noreturn -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-array-bounds -Wextra-semi -MD -MT src/ggml-vulkan/CMakeFiles/ggml-vulkan.dir/mul_mm.comp.cpp.o -MF src/ggml-vulkan/CMakeFiles/ggml-vulkan.dir/mul_mm.comp.cpp.o.d -o src/ggml-vulkan/CMakeFiles/ggml-vulkan.dir/mul_mm.comp.cpp.o -c /mnt/vcpkg-ci/b/ggml/arm64-linux-dbg/src/ggml-vulkan/mul_mm.comp.cpp
ninja: build stopped: subcommand failed.

The failure is caused by a local variable named spv in ggml-vulkan.cpp, which shadows the spv namespace from SPIR-V Headers. As a result, references such as spv::OpCodeMask, spv::WordCountShift, and spv::OpCapability may be resolved against the local variable instead of the namespace and fail to compile.

This patch renames the local SPIR-V word buffer to avoid the name conflict.

Requirements

@miyanyan miyanyan requested a review from a team as a code owner May 6, 2026 13:25
@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 May 6, 2026
Copy link
Copy Markdown
Contributor

@0cc4m 0cc4m left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for the fix.

@0cc4m 0cc4m merged commit 6d57a49 into ggml-org:master May 8, 2026
47 checks passed
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.

3 participants