This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Support cross compilation on macOS
Type: enhancement Stage:
Components: macOS Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Alex.Willmer, autoantwort, ned.deily, ronaldoussoren
Priority: normal Keywords:

Created on 2022-02-14 14:23 by autoantwort, last changed 2022-04-11 14:59 by admin.

Messages (2)
msg413224 - (view) Author: autoantwort (autoantwort) Date: 2022-02-14 14:23
Currently you get the following output:
```
➜  debug git:(main) ✗ ../configure --host=x86_64-apple-darwin --build=arm64-apple-darwin --with-build-python=./python3.11
checking for git... found
checking build system type... aarch64-apple-darwin
checking host system type... x86_64-apple-darwin
checking for --with-build-python... ./python3.11
checking for Python interpreter freezing... ./python3.11
checking for python3.11... (cached) ./python3.11
checking Python for regen version... Python 3.11.0a5+
checking for x86_64-apple-darwin-pkg-config... no
checking for pkg-config... /opt/homebrew/bin/pkg-config
configure: WARNING: using cross tools not prefixed with host triplet
checking pkg-config is at least version 0.9.0... yes
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... configure: error: cross build not supported for x86_64-apple-darwin
```

Is "needed" for https://github.com/microsoft/vcpkg/issues/22603
msg413265 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2022-02-14 21:24
We don't currently support cross-building a single macOS architecture on another, i.e. building an x86_64 only build on an Apple Silicon Mac. However, we do support building a multi-architecture build on either on current releases of Python 3.9 and 3.10, with what is known as a universal or fat build. In this case, you'd want to add these two options:

./configure --enable-universalsdk --with-universal-archs=universal2 ...

For this to succeed, you will also need to provide universal builds of any of the third-party libraries used by standard modules you need and that are not otherwise provided by macOS, the most common being OpenSSL and XZ (and perhaps newer versions of SQLite and Tcl/Tk). For the most part, those are straightforward to build yourself but also may be available through some third-party distributors like MacPorts and possibly HomeBrew. The Mac/README.rst file in repo has some more details about universal builds and there may be some useful hints at building the third-party libraries in Mac/BuildScript/build-installer.py although it is not intended to be used for this purpose. The resulting universal2 build can be used as is on either Intel-64 or Apple Silicon Macs but, if you truly need to have only Intel binaries you should be able to use the macOS lipo command to separate out the desired architecture from the built executables and shared libraries into other files. If you want to run these binaries on a range of macOS versions, you can also set the MACOSX_DEPLOYMENT_TARGET environment variable when building the libs and Python; we currently test and support back to 10.9.
History
Date User Action Args
2022-04-11 14:59:56adminsetgithub: 90905
2022-02-14 21:25:38ned.deilysetnosy: + ronaldoussoren
components: + macOS, - Cross-Build
2022-02-14 21:24:58ned.deilysetnosy: + ned.deily
messages: + msg413265
2022-02-14 14:24:18autoantwortsetnosy: + Alex.Willmer
components: + Cross-Build, - Build
2022-02-14 14:23:11autoantwortcreate