From 6962f0b0458d8f3514482de69222421bb4b8aee5 Mon Sep 17 00:00:00 2001 From: Craig Andrews Date: Wed, 26 Nov 2025 13:15:06 -0500 Subject: [PATCH] ggml-cpu: BMI2 is only available on amd64 MSVC doesn't define __BMI2__ so it must be defined by by CMake. It was being set whenever GGML_BMI2 is set, but that results in a failure (`error LNK2019: unresolved external symbol __pdep_u64`) when targeting x86 (aka 32 bit) Windows. The fix is to only set __BMI2__ when targeting amd64. --- src/ggml-cpu/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ggml-cpu/CMakeLists.txt b/src/ggml-cpu/CMakeLists.txt index e52e050a8..39835c797 100644 --- a/src/ggml-cpu/CMakeLists.txt +++ b/src/ggml-cpu/CMakeLists.txt @@ -308,7 +308,10 @@ function(ggml_add_cpu_backend_variant_impl tag_name) endif() if (GGML_BMI2) # MSVC does not define macro __BMI2__ - list(APPEND ARCH_DEFINITIONS __BMI2__ GGML_BMI2) + if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "amd64") + # BMI2 is only available on amd64 + list(APPEND ARCH_DEFINITIONS __BMI2__ GGML_BMI2) + endif() endif() else () if (GGML_NATIVE)