You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have it set up so that our Numpy tests try to link to npymath and found that this didn't work. From unzipping the Numpy wheels, it looks like the AMD64 one has the file _core/lib/npymath.lib while the ARM64 one has _core/lib/libnpymath.a (which doesn't seem right for a Windows build).
This looks to be the case for at least the Python 3.12 and 3.13 wheels.
With that said, I fixed the issue in the Cython tests by just removing the link to npymath, so this may be a non-issue where no-one really needs to link to it any more at all.
Build type: native build
Activating VS 17.14.9 (July 2025)
Project name: NumPy
Project version: 2.4.0.dev0+git20250816.4e00e4d
C compiler for the host machine: clang-cl (clang-cl 19.1.5)
C linker for the host machine: lld-link lld-link 19.1.5
C++ compiler for the host machine: clang-cl (clang-cl 19.1.5)
C++ linker for the host machine: lld-link lld-link 19.1.5
With that said, I fixed the issue in the Cython tests by just removing the link to npymath, so this may be a non-issue where no-one really needs to link to it any more at all.
SciPy still uses it. I'm not aware of other projects using it. So you might want to keep the test on x86-64.
It's unclear to me if this requires a change or not. SciPy win-arm64 builds seem fine with it. And I suspect it's a case of needing to use the same compiler for consuming this static library as was used to produce it.
With that said, I fixed the issue in the Cython tests by just removing the link to npymath, so this may be a non-issue where no-one really needs to link to it any more at all.
I think I'd like to go with this. The couple of projects that need this static library should really use the same compiler (clang-cl in this case) that was used to produce it, at which point there is no problem.
This is OK for library writers, but it is unfortunate to not be able to use the default toolchain on win-arm64, in case someone wanted to develop locally on win-arm64.
No easy fix following the path trying to use CIBW to build on win-arm64. I suspect that @rgommers suggestion effectively requires a meson-based build rather than setup.py-based build.
The action runs but then still end up with the standard platform compiler and linker
@bashtage I honestly don't mind it becoming a little harder to use libnpymath. We want it to go away after all (see gh-20880). That is really hard to communicate in a reasonable way, so this minor barrier hopefully causes more people to get that message. And I don't even know if it would work to use a different set of compilers - we certainly cannot guarantee that. We have jumped through strange hoops in the past to make mixed compilers used because we had to (MSVC + Mingw-w64, for SciPy), but it's a lot of obscure work and it's best effort (although you're using so little of npymath that it's very likely to work).
In statsmodels it's only used in Cython code - WDYT about moving to letting Cython generate C++ code? You only need a few complex number functions like npy_clog/np.cexp and with C++ you shouldn't need libnpymath at all. AFAIK the only reason we need those functions today is because MSVC's support for C is so poor.
The action runs but then still end up with the standard platform compiler and linker
The output you pasted shows cl.exe being used rather than clang-cl.exe. I quickly refreshed my memory, and it looks like pypa/distutils and setuptools never bothered to merge PRs with support forclang-cl (xref pypa/setuptools#2065). I think that says enough about whether one should still be using those packages .....
I suspect that @rgommers suggestion effectively requires a meson-based build rather than setup.py-based build.
scikit-build-core will work too, as will pretty much any other build system with sane support for common compilers.
Note that the reason we decided to use clang-cl is because MSVC was both missing features and crashing when building numpy (see #29174 (comment)), it wasn't arbitrary or us not wanting to support MSVC.
I did a bit of digging and it looks like we'd be able to switch to outputting a .lib instead of .a by tweaking this:
It'd be a one-line patch; it should be verified first that it doesn't affect building SciPy on win_arm64 with clang-cl.
I'd be interested in helping statsmodels remove the dependency on libnpymath and/or move to meson-python.
I'm also willing to help change to .lib in numpy 2.4.0 if statsmodels cares enough - but I'm not really interested in spending time beyond that to support setuptools+MSVC-on-arm+libnpymath - those are three things that are each pretty bad, and best moved away from.
And I don't even know if it would work to use a different set of compilers
Isn't ABI compatibility a promise of clang-cl? When I got NumPy building with clang-cl using the old build system, I recall it working for building downstream projects.
In statsmodels it's only used in Cython code - WDYT about moving to letting Cython generate C++ code? You only need a few complex number functions like npy_clog/np.cexp and with C++ you shouldn't need libnpymath at all. AFAIK the only reason we need those functions today is because MSVC's support for C is so poor.
I think the deeper issue is that MSVC's support for complex is poor. Specifically, here we use the NumPy version of the complex functions, which lets us avoid all of the pain of worrying about cross-platform compatibility.
The alternative is to copy the relevant parts from NumPy and build our own library to link to.
It'd be a one-line patch; it should be verified first that it doesn't affect building SciPy on win_arm64 with clang-cl.
If this worked, it would be appreciated for now, since it would allow the latest existing point release to be built for win-arm64.
Building a static library with one toolchain and then folding it into a shared library with another toolchain is not just about ABI (it's just a no no with no hard guarantees). Last time we had a problem it was because of some compiler-specific content in the .lib file that was not part of the ABI, just some internal directives that shouldn't matter to anyone unless they do something that's not supported like mix two toolchains to produce a single .pyd.
I think the deeper issue is that MSVC's support for complex is poor.
Yes, but only in C, not in C++.
If this worked, it would be appreciated for now
Okay, I'll give it a try. We'll just release some nightlies with the change, and if those work for you and no one else notices a problem, we can call it good for this issue.
Activity
theAeon commentedon Aug 18, 2025
Is it being built with clang-mingw? that's the only way this output makes any sense to me.
rgommers commentedon Aug 19, 2025
It's built with
clang-cl, unlike the x86-64 wheels which are built with MSVC. Compiler selected here:numpy/.github/workflows/wheels.yml
Lines 129 to 131 in db5bd74
And build log output from a recent log:
SciPy still uses it. I'm not aware of other projects using it. So you might want to keep the test on x86-64.
It's unclear to me if this requires a change or not. SciPy
win-arm64builds seem fine with it. And I suspect it's a case of needing to use the same compiler for consuming this static library as was used to produce it.carlkl commentedon Aug 20, 2025
Time to get rid of this library in scipy?
theAeon commentedon Aug 20, 2025
statsmodels needs it, for one.
rgommers commentedon Aug 20, 2025
Ah thank you, I wasn't aware.
Yes, but the effort to get that done stalled a bit. xref gh-20880 and scipy/scipy#17498
rgommers commentedon Aug 28, 2025
I think I'd like to go with this. The couple of projects that need this static library should really use the same compiler (
clang-clin this case) that was used to produce it, at which point there is no problem.da-woods commentedon Aug 28, 2025
Fine by me - I was flagging it as an inconsistency that might cause problems rather than because it was an issue for me
bashtage commentedon Sep 12, 2025
This is OK for library writers, but it is unfortunate to not be able to use the default toolchain on win-arm64, in case someone wanted to develop locally on win-arm64.
bashtage commentedon Sep 12, 2025
No easy fix following the path trying to use CIBW to build on win-arm64. I suspect that @rgommers suggestion effectively requires a meson-based build rather than setup.py-based build.
The action runs but then still end up with the standard platform compiler and linker
rgommers commentedon Sep 12, 2025
@bashtage I honestly don't mind it becoming a little harder to use
libnpymath. We want it to go away after all (see gh-20880). That is really hard to communicate in a reasonable way, so this minor barrier hopefully causes more people to get that message. And I don't even know if it would work to use a different set of compilers - we certainly cannot guarantee that. We have jumped through strange hoops in the past to make mixed compilers used because we had to (MSVC + Mingw-w64, for SciPy), but it's a lot of obscure work and it's best effort (although you're using so little ofnpymaththat it's very likely to work).In
statsmodelsit's only used in Cython code - WDYT about moving to letting Cython generate C++ code? You only need a few complex number functions likenpy_clog/np.cexpand with C++ you shouldn't needlibnpymathat all. AFAIK the only reason we need those functions today is because MSVC's support for C is so poor.The output you pasted shows
cl.exebeing used rather thanclang-cl.exe. I quickly refreshed my memory, and it looks likepypa/distutilsandsetuptoolsnever bothered to merge PRs with support forclang-cl(xref pypa/setuptools#2065). I think that says enough about whether one should still be using those packages .....scikit-build-corewill work too, as will pretty much any other build system with sane support for common compilers.Note that the reason we decided to use
clang-clis because MSVC was both missing features and crashing when buildingnumpy(see #29174 (comment)), it wasn't arbitrary or us not wanting to support MSVC.I did a bit of digging and it looks like we'd be able to switch to outputting a
.libinstead of.aby tweaking this:numpy/numpy/meson.build
Lines 31 to 41 in f346e58
It'd be a one-line patch; it should be verified first that it doesn't affect building SciPy on
win_arm64withclang-cl.I'd be interested in helping
statsmodelsremove the dependency onlibnpymathand/or move tomeson-python.I'm also willing to help change to
.libin numpy 2.4.0 ifstatsmodelscares enough - but I'm not really interested in spending time beyond that to support setuptools+MSVC-on-arm+libnpymath - those are three things that are each pretty bad, and best moved away from.bashtage commentedon Sep 12, 2025
Isn't ABI compatibility a promise of clang-cl? When I got NumPy building with clang-cl using the old build system, I recall it working for building downstream projects.
I think the deeper issue is that MSVC's support for complex is poor. Specifically, here we use the NumPy version of the complex functions, which lets us avoid all of the pain of worrying about cross-platform compatibility.
The alternative is to copy the relevant parts from NumPy and build our own library to link to.
If this worked, it would be appreciated for now, since it would allow the latest existing point release to be built for win-arm64.
rgommers commentedon Sep 12, 2025
Building a static library with one toolchain and then folding it into a shared library with another toolchain is not just about ABI (it's just a no no with no hard guarantees). Last time we had a problem it was because of some compiler-specific content in the
.libfile that was not part of the ABI, just some internal directives that shouldn't matter to anyone unless they do something that's not supported like mix two toolchains to produce a single.pyd.Yes, but only in C, not in C++.
Okay, I'll give it a try. We'll just release some nightlies with the change, and if those work for you and no one else notices a problem, we can call it good for this issue.
bashtage commentedon Sep 12, 2025
A little rethink and the statsmodels dependency appears to be easy to work around
PR in progress statsmodels/statsmodels#9631
BLD: change file extension for libnpymath on win-arm64 from .a to .lib
rgommers commentedon Sep 13, 2025
Awesome, thanks! PR for the
.a->.libchange up anyway at gh-29750.rgommers commentedon Sep 14, 2025
Implemented the change, nightly wheels should be available in about an hour.
BLD: change file extension for libnpymath on win-arm64 from .a to .lib
BLD: change file extension for libnpymath on win-arm64 from .a to .lib