Skip to content

Commit 698d19b

Browse files
authored
ggml: improve SPIR-V headers detection with __has_include (ggml-org#21918)
* ggml: improve SPIR-V headers detection with __has_include while preserving original _WIN32 logic * Address review comments: fix fallback logic and add FreeBSD support * Remove spirv_cross fallback as per review * Remove redundant __has_include check
1 parent 50494a2 commit 698d19b

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

ggml/src/ggml-vulkan/ggml-vulkan.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,19 @@ DispatchLoaderDynamic & ggml_vk_default_dispatcher();
2020
#define VULKAN_HPP_DEFAULT_DISPATCHER ggml_vk_default_dispatcher()
2121

2222
#include <vulkan/vulkan.hpp>
23-
// SPIRV-Headers: LunarG Windows SDK uses Include/spirv-headers/spirv.hpp (not spirv/unified1/). MinGW/MSYS2 and
24-
// Linux packages use Khronos layout spirv/unified1/spirv.hpp. See docs/build.md#vulkan.
25-
#if defined(_WIN32) && !defined(__MINGW32__)
26-
#include <spirv-headers/spirv.hpp>
23+
24+
// SPIR-V Headers: different SDK installations expose different include paths.
25+
// LunarG Vulkan SDK on Windows typically provides <spirv-headers/spirv.hpp>.
26+
// Linux packages, MSYS2 and MinGW often use the Khronos layout <spirv/unified1/spirv.hpp>.
27+
#if __has_include(<spirv/unified1/spirv.hpp>)
28+
# include <spirv/unified1/spirv.hpp>
29+
#elif __has_include(<spirv-headers/spirv.hpp>)
30+
# include <spirv-headers/spirv.hpp>
31+
#elif __has_include(<spirv.hpp>)
32+
# include <spirv.hpp>
2733
#else
28-
#include <spirv/unified1/spirv.hpp>
34+
// Fallback to let the compiler throw a standard "file not found" error
35+
# include <spirv/unified1/spirv.hpp>
2936
#endif
3037

3138
#include <algorithm>

0 commit comments

Comments
 (0)