-
Notifications
You must be signed in to change notification settings - Fork 60
Add support for building ARM64 iOS wheels on CI #181
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
base: main
Are you sure you want to change the base?
Conversation
Everything built fine on the branch: |
Newest run with macOS 15 passed as well: https://github.com/ambv/cffi/actions/runs/16519616901. |
Everything's still green after #178: https://github.com/ambv/cffi/actions/runs/16579222190 |
# Download prebuilt libffi from beeware/cpython-apple-source-deps | ||
platform="${{ matrix.platform }}" | ||
version="${CFFI_IOS_LIBFFI_VERSION}" | ||
url="https://github.com/beeware/cpython-apple-source-deps/releases/download/libFFI-${version}/libffi-${version}-${platform}.arm64.tar.gz" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While it looks a little weird to download binaries from beeware, cibuildwheel
internally actually does the same for the "iOS support" python
interpreter used to run python -m build
with.
The CI failures here are intermittent GitHub.com HTTPS availability issues. They'll pass if you kick them. |
Will try again in a few hours |
Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <[email protected]>
the last commit does not seem to work |
Yeah, that added |
This reverts commit c4e3a87.
@mattip do you need me to do anything here? |
LGTM. @nitzmahone would you like to take a look? |
- name: build wheel prereqs | ||
run: | | ||
set -eux | ||
python3 -m pip install --user --upgrade cibuildwheel>=3.1.0 | ||
brew uninstall --ignore-dependencies libffi 2>&1 || true | ||
|
||
- name: download libffi for iOS | ||
env: | ||
CFFI_IOS_LIBFFI_VERSION: '3.4.7-2' | ||
run: | | ||
set -eux | ||
|
||
# Download prebuilt libffi from beeware/cpython-apple-source-deps | ||
platform="${{ matrix.platform }}" | ||
version="${CFFI_IOS_LIBFFI_VERSION}" | ||
url="https://github.com/beeware/cpython-apple-source-deps/releases/download/libFFI-${version}/libffi-${version}-${platform}.arm64.tar.gz" | ||
|
||
echo "Downloading libffi for iOS (${platform})..." | ||
curl -L -o libffi-ios.tar.gz "${url}" | ||
|
||
# Extract libffi | ||
mkdir -p libffi-ios | ||
tar zxf libffi-ios.tar.gz -C libffi-ios | ||
|
||
# Set up paths for cibuildwheel | ||
echo "LIBFFI_IOS_DIR=$(pwd)/libffi-ios" >> "$GITHUB_ENV" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would make sense to plug this into the cibuildwheel
config so that it's usable outside the CI and isn't coupled with it.
@webknjaz every little change I make here requires somebody to manually approve the CI to run for me. Let's ignore the nits for now. |
@ambv do you happen to know offhand if the libffi build you're embedding (and/or iOS in general) needs the same trampoline dylib stub hacks that MacOS aarch64 does? It's been several years since I dug into that, but IIRC it was at least required to enable marking pages executable for dynamic codegen without using a highly-restricted entitlement. Most vanilla libffi builds were just delegating that part to the Apple-built stub (which has the necessary entitlement), which is of course very fragile for statically-linked stuff should it ever change. I also see a bunch of the tests around dynamic codegen have been disabled for iOS anyway, so maybe it's all moot, but the details escape me if libffi needed that stub dylib for anything else. |
Co-authored-by: Russell Keith-Magee <[email protected]>
@nitzmahone asks:
The bad news is that I have no idea about trampoline dylib stub hacks. The "good" news is that on iOS any form of marking pages for execution is disallowed by the kernel (no userland JITs supported due to security concerns), so it seems like at the moment it's not a problem either way. |
CI is quickly failing |
This reverts commit a0cf74a.
@mattip, reverted the breaking change. |
This will greatly enable the iOS platform in terms of support for other packages that depend on cffi. See PEP 730 for details about the iOS platform support in Python.
This was a little tricky to get right:
pkg-config
orhomebrew
is invalid;setup.py
in this repository can't be called directly, but rather throughcibuildwheel
, which effectively runspython -m build
but with a specialpython
that pretends it's running onsys.platform == "ios"
with an almost empty$PATH
to avoid pulling in ABI-incompatible dependencies;libffi
which additionally preferably are statically linked into our resulting wheel's.dylib
;cibuildwheel
docs suggest you should put inCIBW_TEST_SOURCES
.Now, the current status is such that we're running the
src/test_c.py
tests with some expected skips (callbacks = executable memory, disallowed on iOS) but also two unexpected failures. I marked one withxfail
, the other is askip
because it crashed the test runner with Python 3.13. Worth investigating after the fact once the CI is set up.The tests from
testing/
are not enabled for iOS since they depend onffi.verify()
, which attempts in-place compilation, impossible on iOS.