From 0d630d193eeb58917ca6af595e3e2f85e14b1329 Mon Sep 17 00:00:00 2001 From: vchamarthi Date: Wed, 2 Sep 2026 12:29:53 -0500 Subject: [PATCH 1/3] fix: undefine __INTEL_LLVM_COMPILER for icx on Windows to restore _Dcomplex --- meson.build | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/meson.build b/meson.build index d8e6393c..c8b0dd1b 100644 --- a/meson.build +++ b/meson.build @@ -54,6 +54,15 @@ if cc.get_argument_syntax() == 'msvc' ] link_args = ['/NXCompat', '/DynamicBase'] + if cc.get_id() == 'intel-llvm-cl' + # icx defines __INTEL_LLVM_COMPILER, which numpy >=2.4.4 excludes from + # its _MSC_VER branch in npy_common.h, making npy_cdouble a native + # C99 _Complex instead of _Dcomplex but Windows UCRT's complex.h + # (creal/cimag/etc) is hard-typed to _Dcomplex regardless of compiler. + # Undefine the macro so numpy's header picks _Dcomplex again. + c_args += ['/U__INTEL_LLVM_COMPILER'] + endif + if cc.get_id().startswith('intel') c_args += [ '/Qimf-precision=high', '/Qprotect-parens', From 6f0b319bf6b623fb7f02a9f0116565c0b4f89809 Mon Sep 17 00:00:00 2001 From: vchamarthi Date: Wed, 2 Sep 2026 14:08:57 -0500 Subject: [PATCH 2/3] gate c_args with small compilation program --- meson.build | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index c8b0dd1b..ba12d88e 100644 --- a/meson.build +++ b/meson.build @@ -55,12 +55,36 @@ if cc.get_argument_syntax() == 'msvc' link_args = ['/NXCompat', '/DynamicBase'] if cc.get_id() == 'intel-llvm-cl' - # icx defines __INTEL_LLVM_COMPILER, which numpy >=2.4.4 excludes from - # its _MSC_VER branch in npy_common.h, making npy_cdouble a native - # C99 _Complex instead of _Dcomplex but Windows UCRT's complex.h - # (creal/cimag/etc) is hard-typed to _Dcomplex regardless of compiler. - # Undefine the macro so numpy's header picks _Dcomplex again. - c_args += ['/U__INTEL_LLVM_COMPILER'] + # workaround for icx _Dcomplex regression, see numpy/numpy#31337 + npy_complex_check = ''' + #include + #include + ''' + undef_llvm = '/U__INTEL_LLVM_COMPILER' + + if not cc.compiles( + npy_complex_check, + name: 'numpy complex helpers build with icx', + dependencies: py_dep, + include_directories: inc_np + ) + if cc.compiles( + npy_complex_check, + name: 'numpy complex helpers build with ' + undef_llvm, + args: undef_llvm, + dependencies: py_dep, + include_directories: inc_np + ) + c_args += undef_llvm + else + error( + 'numpy headers do not compile with icx on Windows: ' + + 'npy_cdouble conflicts with UCRT complex.h and ' + + undef_llvm + ' does not resolve it. ' + + 'See numpy/numpy#31337.' + ) + endif + endif endif if cc.get_id().startswith('intel') From e4bc5bcf9d2958dc67f5d3d532f7c9e8d897a0f9 Mon Sep 17 00:00:00 2001 From: vchamarthi Date: Wed, 2 Sep 2026 18:24:30 -0500 Subject: [PATCH 3/3] Apply pr suggestion --- meson.build | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/meson.build b/meson.build index ba12d88e..6048f493 100644 --- a/meson.build +++ b/meson.build @@ -54,7 +54,7 @@ if cc.get_argument_syntax() == 'msvc' ] link_args = ['/NXCompat', '/DynamicBase'] - if cc.get_id() == 'intel-llvm-cl' + if cc.get_id().startswith('intel') # workaround for icx _Dcomplex regression, see numpy/numpy#31337 npy_complex_check = ''' #include @@ -85,9 +85,7 @@ if cc.get_argument_syntax() == 'msvc' ) endif endif - endif - if cc.get_id().startswith('intel') c_args += [ '/Qimf-precision=high', '/Qprotect-parens', '/clang:-fveclib=SVML', '/clang:-fvectorize'