From 6b153463a8a6721fd4bb89ec9afa014409bcce36 Mon Sep 17 00:00:00 2001 From: Srijan Keshri Date: Sat, 12 Sep 2026 15:15:32 +0530 Subject: [PATCH] [Build] Define _USE_MATH_DEFINES for FlashMLA targets (#54007) Signed-off-by: arcusbuilds Co-authored-by: Shengqi Chen --- cmake/external_projects/flashmla.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cmake/external_projects/flashmla.cmake b/cmake/external_projects/flashmla.cmake index 4cf1e421f0..382fd0289a 100644 --- a/cmake/external_projects/flashmla.cmake +++ b/cmake/external_projects/flashmla.cmake @@ -186,6 +186,15 @@ if(FLASH_MLA_ARCHS) if(VLLM_GPU_LANG STREQUAL "CUDA") target_compile_definitions(_flashmla_extension_C PRIVATE USE_CUDA) endif() + + # FlashMLA's sources use M_LOG2E from . MSVC's UCRT only defines the + # M_* constants when _USE_MATH_DEFINES is set before is first + # included, so define it for both targets on MSVC. Scoped to MSVC so the + # compile flags (and build caches) on other platforms stay unchanged. + if(MSVC) + target_compile_definitions(_flashmla_C PRIVATE _USE_MATH_DEFINES) + target_compile_definitions(_flashmla_extension_C PRIVATE _USE_MATH_DEFINES) + endif() else() message(STATUS "FlashMLA will not compile: unsupported CUDA architecture ${CUDA_ARCHS}") # Create empty targets for setup.py on unsupported systems