Tracking issue for cross-compilation needs and issues
See original GitHub issueCross-compiling with numpy.distutils
isn’t really supported, and we regularly receive issues related to that. With the move to Meson (gh-13615), cross-compiling becomes supported. This issue aims to provide an overview of cross-compiling needs users have expressed in the past. That will help when implementing cross-compilation support and coming up with relevant test cases.
- Yocto Linux has come up multiple times:
- gh-8571 (main issue, still open - mentions successful result in this comment on gh-8571)
- gh-10770
- gh-8226
- Buildroot has come up several times as well:
- gh-9875
- https://news.ycombinator.com/item?id=27953673 (multiple mentions of cross-compiling SciPy in those comments)
- Pyodide is cross-compiling to WebAssembly:
- gh-15290 (overview issue)
- https://github.com/scipy/scipy/pull/15288#issuecomment-1002834295 (some discussion on Meson & Emscripten)
- Void Linux is cross-compiling SciPy; the
numpy.distutils
based build worked, and the move to Meson yielded one problem - see gh-16783. For the cross-compile support files in Void, see here - Linaro has a repo for cross-compiling packages for Windows on ARM at https://gitlab.com/Linaro/windowsonarm/packages. It does not contain SciPy yet; it’d be interesting to see that though. Meson cross-compiling support should work with that toolchain; invoking the build through
pip
orbuild
may have a few rough edges (not sure until it’s tried). See this NumPy mailing list thread for more details.
Both Yocto and Buildroot are ways to generate an embedded Linux distribution through cross-compilation. We should aim to test at least one of those, preferably in CI. Related build systems that were mentioned are OpenEmbedded and Bitbake. https://github.com/scipy/scipy/issues/8571#issuecomment-715877299 mentions crossenv (not quite a build system, more virtualenv trickery for distutils) to build for Yocto.
- Cross-compiling to 32-bit ARM: gh-10727
- Cross-compiling on Cray XT (old, not so relevant anymore): gh-1857
- An effort to make
numpy.distutils
more amenable to cross-compilation: https://github.com/numpy/numpy/issues/17620 (also mentions Yocto/OpenEmbedded). - The one place we are successfully cross-compiling is in https://github.com/MacPython/scipy-wheels to produce
arm64
macOS wheels fromx86_64
macOS CI jobs - and that happens to work because the differences betweenx86_64
andarm64
builds are fairly limited.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:25 (18 by maintainers)
@rgommers congratulations, it works. I manually modified the “libnpyrandom” and libnpymath" path, in scipy/meson.build, and it worked.
If you have a patch file (*.patch) that was generated so that it applies correctly at the base of the scipy repo, you can simply put it in buildroot/package/python-scipy, and buildroot will automatically apply it before “configure” step, see other existing patches
Thanks @gwbres, that worked out of the box on Arch Linux after installing
cpio
and upgrading to GCC 9.support/misc/cross-compilation.conf.in
generates for the scipy package build this cross file (as./output/build/python-scipy-1.9.0/build/cross-compilation.conf
):Looking at the build log in
output/build/python-scipy-1.9.0/build/meson-logs/meson-log.txt
, it finds the host Python:Then here is when it goes wrong in determining the correct path to
libnpymath.a
:libnpymath.a
is present on the target:I think one confusing thing is that we use
python
for code generation tasks (in which case host python - in Buildroot’s terminology, so on the build machine - is fine), for obtaining paths to source code like the f2py and pybind11 sources (in which case host python and host f2py/pybind11 is also fine), and for obtaining paths to two static libraries:libnpymath.a
andlibnpyrandom.a
(those need to come from the target).And finally we also use the
py3.extension_module
etc.; herepy3
is the host Python but Meson knows it’s cross-compiling and does its thing to build extensions for the target Python, as can be seen in the detailed log above from Meson looking forpython-3.10
via pkg-config and then including this in the compile flags:Okay, so far so good. We just need to override the paths to the two static libraries we need it looks like.