Skip to content

Commit 68e9116

Browse files
committed
Fix build failure with ICX 2026 on Windows
ICX 2026 in clang-cl mode strictly enforces that C99 _Complex double cannot be passed to UCRT's creal/cimag functions which expect _Dcomplex (an MSVC struct type). This causes hard compilation errors in all three build targets when C_STANDARD 99 is set, because CMake translates that to -Qstd:c99 for ICX, enabling strict C99 complex type semantics. numpy's npy_common.h defines npy_cdouble as 'double _Complex' for IntelLLVM compilers regardless of platform. numpy's npy_math.h then calls creal()/cimag() on npy_cdouble values. Under ICX 2025 this was a warning; under ICX 2026 it is a hard error. Fix: on Windows with IntelLLVM, unset C_STANDARD for all three targets so CMake does not inject -Qstd:c99. ICX in its default clang-cl compatibility mode handles the _Complex/_Dcomplex coercion without error, matching the behavior of ICX 2025 and earlier. Note: the underlying incompatibility is in numpy's npy_math.h which should guard creal/cimag calls for __INTEL_LLVM_COMPILER on Windows, similar to how npy_common.h already guards the npy_cdouble typedef.
1 parent 2a16a65 commit 68e9116

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ set_target_properties(${_trgt} PROPERTIES
109109
CMAKE_POSITION_INDEPENDENT_CODE ON
110110
C_STANDARD 99
111111
)
112+
if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM")
113+
# ICX 2026 on Windows strictly enforces that C99 _Complex double (npy_cdouble as defined
114+
# by numpy for IntelLLVM) cannot be passed to UCRT's creal/cimag which expect _Dcomplex.
115+
# This is triggered by the -Qstd:c99 flag injected via C_STANDARD 99 above.
116+
# Removing the C standard constraint for ICX on Windows leaves the compiler in its
117+
# default clang-cl compatibility mode, which does not enforce this type mismatch.
118+
set_property(TARGET ${_trgt} PROPERTY C_STANDARD)
119+
endif()
112120
target_include_directories(${_trgt} PUBLIC mkl_umath/src/ ${Python_NumPy_INCLUDE_DIRS} ${Python_INCLUDE_DIRS})
113121
target_link_libraries(${_trgt} PUBLIC MKL::MKL ${Python_LIBRARIES})
114122
target_link_options(${_trgt} PUBLIC ${_linker_options})
@@ -129,6 +137,9 @@ target_compile_definitions(_ufuncs PUBLIC NPY_NO_DEPRECATED_API=NPY_1_7_API_VERS
129137
target_link_options(_ufuncs PRIVATE ${_linker_options})
130138
target_link_libraries(_ufuncs PRIVATE mkl_umath_loops)
131139
set_target_properties(_ufuncs PROPERTIES C_STANDARD 99)
140+
if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM")
141+
set_property(TARGET _ufuncs PROPERTY C_STANDARD)
142+
endif()
132143
if (UNIX)
133144
set_target_properties(_ufuncs PROPERTIES INSTALL_RPATH "$ORIGIN/../..;$ORIGIN/../../..;$ORIGIN")
134145
endif()
@@ -140,6 +151,9 @@ target_include_directories(_patch_numpy PRIVATE "mkl_umath/src/" ${Python_NumPy_
140151
target_compile_definitions(_patch_numpy PUBLIC NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION)
141152
target_link_libraries(_patch_numpy PRIVATE mkl_umath_loops)
142153
set_target_properties(_patch_numpy PROPERTIES C_STANDARD 99)
154+
if(WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "IntelLLVM")
155+
set_property(TARGET _patch_numpy PROPERTY C_STANDARD)
156+
endif()
143157
if (UNIX)
144158
set_target_properties(_patch_numpy PROPERTIES INSTALL_RPATH "$ORIGIN/../..;$ORIGIN/../../..;$ORIGIN")
145159
endif()

0 commit comments

Comments
 (0)