From 92d6c8a5caa2c11b3fb49a7a201b568d040be4b2 Mon Sep 17 00:00:00 2001 From: SaidSultani <62264302+SaidSultani@users.noreply.github.com> Date: Thu, 12 Nov 2026 22:52:56 +0100 Subject: [PATCH] fix(hexagon): make host build work with clang-cl on Windows ARM64 (#32011) * fix(hexagon): make host build work with clang-cl on Windows ARM64 Two CMake fixes for building ggml-hexagon natively on Windows-on-ARM64 with x64-hosted clang-cl (validated on Snapdragon X Elite, discussion in qualcomm/GenieX#1390): - Some clang drivers (e.g. x64-hosted toolchains used on ARM64) don't predefine the arch macro, which makes winnt.h fail with "No Target Architecture". Define _M_ARM64/_ARM64_ explicitly for the host TUs. - The Hexagon SDK's incs/stddef include (AEEStdDef.h and friends) poisons the MSVC header chain when it leaks onto dependent TUs' include paths via htp_iface's PUBLIC includes. Keep it PRIVATE to the interface stub and system-level for the backend's own TUs (which include directly). Originally validated 2026-08-26 as reported in the issue; applies cleanly to 15759e0. * hex-cmake: trim down excessive comments --------- Co-authored-by: Max Krasnyansky --- ggml/src/ggml-hexagon/CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ggml/src/ggml-hexagon/CMakeLists.txt b/ggml/src/ggml-hexagon/CMakeLists.txt index 9444f7321..fea5770c1 100644 --- a/ggml/src/ggml-hexagon/CMakeLists.txt +++ b/ggml/src/ggml-hexagon/CMakeLists.txt @@ -33,10 +33,11 @@ add_library(htp_iface OBJECT set_target_properties(htp_iface PROPERTIES POSITION_INDEPENDENT_CODE ON) target_include_directories(htp_iface PUBLIC ${HEXAGON_SDK_ROOT}/incs - ${HEXAGON_SDK_ROOT}/incs/stddef ${HEXAGON_SDK_ROOT}/utils/examples ${CMAKE_CURRENT_SOURCE_DIR}/htp ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(htp_iface PRIVATE + ${HEXAGON_SDK_ROOT}/incs/stddef) build_idl(htp/htp_iface.idl htp_iface) @@ -65,8 +66,14 @@ ggml_add_backend_library(${TARGET_NAME} libdl.h ../../include/ggml-hexagon.h) +if (WIN32) + # some clang-cl drivers do not predefine ARM64 macros for winnt.h + target_compile_definitions(${TARGET_NAME} PRIVATE _M_ARM64=1 _ARM64_=1) +endif() + target_link_libraries(${TARGET_NAME} PRIVATE htp_iface) target_include_directories(${TARGET_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/htp ${CMAKE_CURRENT_BINARY_DIR}) +target_include_directories(${TARGET_NAME} SYSTEM PRIVATE ${HEXAGON_SDK_ROOT}/incs/stddef) # Build HTP skels set(HTP_SKELS)