[Build] Define _USE_MATH_DEFINES for FlashMLA targets (#54007)
Signed-off-by: arcusbuilds <srijankeshri007@gmail.com> Co-authored-by: Shengqi Chen <harry-chen@outlook.com>
Srijan Keshri committed
Sep 12, 2026 at 15:15 UTC
6b153463a8a6721fd4bb89ec9afa014409bcce36
1 file changed
+9
cmake/external_projects/flashmla.cmake
+9
@@ -186,6 +186,15 @@ if(FLASH_MLA_ARCHS)
186
if(VLLM_GPU_LANG STREQUAL "CUDA")
187
target_compile_definitions(_flashmla_extension_C PRIVATE USE_CUDA)
188
endif()
189
+
190
+ # FlashMLA's sources use M_LOG2E from <cmath>. MSVC's UCRT only defines the
191
+ # M_* constants when _USE_MATH_DEFINES is set before <cmath> is first
192
+ # included, so define it for both targets on MSVC. Scoped to MSVC so the
193
+ # compile flags (and build caches) on other platforms stay unchanged.
194
+ if(MSVC)
195
+ target_compile_definitions(_flashmla_C PRIVATE _USE_MATH_DEFINES)
196
+ target_compile_definitions(_flashmla_extension_C PRIVATE _USE_MATH_DEFINES)
197
+ endif()
198
else()
199
message(STATUS "FlashMLA will not compile: unsupported CUDA architecture ${CUDA_ARCHS}")
200
# Create empty targets for setup.py on unsupported systems