-
Notifications
You must be signed in to change notification settings - Fork 234
-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: CIBW is ignoring MACOS arch #2003
Comments
This is as designed, unfortunately. The Xcode toolchain can cross-compile, but it's not supported to tell Pip that you want to install x86_64 wheels when running on a arm64 machine. The best thing to do is compile on the target architecture, if you can. But in this case, because you're going from arm64 to x86_64, there might also be a workaround - you could use the Rosetta emulation to do the compilation, by using Our macOS multi-arch support was created when x86_64 runners were common, so cross-compilation was our only option. However, as arm64 becomes more common on the host side, it might make sense to do the x86_64 compilation in emulation... 🤔 |
Also, when you download a package, you often want to run it on the host (such as calling |
In fact, symbols are mangled in wheels, so do you ever do a link to them? Usually you want Python code and headers, which you want the native wheel for, not the cross-compiled wheels. This is certainly true for NumPy, which is the example given here. Is it actually causing a problem, or are is it just that it's printing this in the logs? Tests should work since that's emulated. |
Yes, NumPy provides arch-specific math libraries which need to match the target build. In our build there is a warning from ld about finding arm libraries when linking x86_64 binaries. When these are run they raise with symbol not found. This behavior is currently breaking statamodels on MacOS. The short term fix is to revert guthub's MacOS rubber from macos-latest to macos-13. Latest runs on M1 while 13 is still hosted on x86_64. This restores the correct behavior for building both arm and x86_64. |
This would seem to be the logical way forward so that both could be correctly compiled irrespective of host arch. For now it only works correctly when the host is x86_64. |
Okay, I'd strongly recommend macos-13 for Intel builds and macos-14/macos-latest for ARM builds for now. That's fastest, and actually runs your tests (Intel can't run ARM tests). As the last Intel runner, I expect macos-13 will be around for a while (macos-12 was just deprecated). Why is the Intel one working cross compiling to ARM? |
It is just how we always did it. CIBW is only used for releases so changes like the asymmetry introduced by the different runners is not easy to detect. I imagine we will eventually move to distinct runners for the different arch builds. |
I wonder if CIBW should refuse to compile x86_64 on arm64 since it doesn't have a mechanism to know it can build correctly. An early exit would have simplified finding out things were broken. |
The tests failed, right? It can't know beforehand that either your build system can't cross-compile, or that some wheel is going to do something specific (in this case, it seems numpy doing something strange with ARM math libraries). (To be fair, not many projects are cross compiling Intel from ARM yet, that's probably going to be somewhat rare until macos-13 is deprecated, maybe in a year or so). Do you have the exact error message? A bit curious, though I use pybind11 which doesn't require NumPy at all at build time. |
You are manually trying to link to numpy/_core/lib/libnpymath.a, which is being pulled from the ARM wheel rather than the target platform. Is that public? It seems you have to manually construct the path by going up and then back down from the include path you are given. If you could rebuild it, it would be fine. And if you didn't need to link to it, it would also be fine. This shouldn't work the other direction, though? Why can the ARM build link to libnpymath.a on Intel? |
From the docs: https://numpy.org/doc/stable/reference/c-api/coremath.html#linking-against-the-core-math-library-in-an-extension Note Keep in mind that when you are cross compiling, you must use the So it sounds like cross-compiling ARM from Intel is not supported either; if you use this library, you have to avoid cross-compiling. There's also this: Note An effort is underway to make So it's also incorrect to use this with a different compiler than NumPy was built with... |
Description
I am trying to build for only x86_64 and CIBW is downloading arm wheels.
Really just need the top and the bottom.
architectures: x86_64
is correct, but at the bottom you see wheel download likeDownloading numpy-2.1.1-cp312-cp312-macosx_14_0_arm64.whl (5.1 MB)
.Build log
No response
CI config
No response
The text was updated successfully, but these errors were encountered: