-
Notifications
You must be signed in to change notification settings - Fork 278
Closed
Description
Description
I was trying to use CMake on iOS (it's one of the examples for xbuild-tools
, but I get this message:
CMake Error: Could not find CMAKE_ROOT !!!
CMake has most likely not been installed correctly.
Modules directory not found in
CMake Error: Error executing cmake::LoadCache(). Aborting.
It seems to not to be able to find and load the built-in modules directory.
Build log
https://github.com/scikit-hep/boost-histogram/actions/runs/15335417534/job/43151563524?pr=1016
Activity
freakboy3742 commentedon May 30, 2025
This sounds very similar to the problem I reported in the PR adding support for xbuild-tools. Based on @mayeut's comment, this was a known issue with a homebrew version of cmake, and was fixed in cmake 4.0
henryiii commentedon May 30, 2025
Perfect, upgrading cmake made it past to:
So looks like I need to set up iOS testing for pybind11. Guessing I'll do it with cibuildwheel if I can (I do that for pyodide, so should be able to).
What's the status of free-threading and subinterpreters on iOS? This is part of the subinterpter support. Also, can one set the min iOS version?
We might want to add a note in the docs until GHA upgrades their images (hopefully they won't stick to 3.x too long!).
freakboy3742 commentedon May 30, 2025
That's a very familiar error to me: it indicates that you haven't got
IPHONEOS_DEPLOYMENT_TARGET
set in your build environment (or, at least, it's not being passed down to the context that is runningclang++
).The
thread_local
keyword wasn't available on iOS until iOS 7; and if you don't specify a minimum iOS version, it assumes it's building for iOS 1. In the context of a numpy build, it needs to be passed in as a CIBW_ENVIRONMENT valueSubinterpreters work fine, and are tested as part of a standard CI run on CPython.
I haven't tried free-threading yet (it's on a long list of stuff I need to test out...). However, I'm not aware of any reason it shouldn't work (other than the normal free-threading-headache sort of issues).
henryiii commentedon May 30, 2025
Is iOS 1 fine for CPython? I know we set minimum versions for the user for macOS based on CPython's needs (10.9, 10.13, or 11). Maybe we should do the same for iOS? Isn't there some minimum for 64 bit iOS?
henryiii commentedon May 30, 2025
Also, are there iOS numpy wheels in a wheelhouse somewhere?
freakboy3742 commentedon May 30, 2025
A CPython build for iOS defaults to a minimum iOS version of 13.0 - that's the lowest version that will build CPython without any warnings. However, the minimum version is configurable at build time. 12.0 will build, but with some warnings about SQLite features. Earlier versions might be possible to support, but I haven't tested; however, it's highly unlikely it will work for any version early than iOS 8, as that was the first release to allow apps to dynamically load libraries. iOS 14 was the first release that was 64-bit only.
In practice, an iOS 13 minimum covers something like 98% of all iPhone users; and you need iOS 16.4 or newer to use the Accelerate implementation of BLAS/LINPACK.
As for enforcing an IPHONEOS_DEPLOYMENT_TARGET value - cibuildwheel already does put IPHONEOS_DEPLOYMENT_TARGET in the environment. I'm not sure why that wouldn't be picked up in the pybind11 case.
I've got some quite old numpy versions here; I've been holding off publishing more recent versions while all the meson et al changes land.
henryiii commentedon May 30, 2025
Not working for me (now on pybind11 adding a job for iOS) even set to 17: https://github.com/pybind/pybind11/actions/runs/15340789425/job/43166409369
freakboy3742 commentedon May 30, 2025
Ah - wait - this might be a manifestation of python/cpython#133183. In which case, it's another reason I need to push out updates to the iOS support packages.
[-]CMake on iOS[/-][+]iOS issues[/+]joerick commentedon May 30, 2025
@freakboy3742 do you have a timeline for that? i'm wondering if we want to hold up releasing v3.0 until we have the updated support package.
henryiii commentedon May 30, 2025
Is there a way to detect this when compiling C/C++ code? I'd like to say "if compiling for iOS and deployment target is less than 17 (assuming you meant 17 not 7?), don't enable support for subinterpreters" in pybind11 (for now).
freakboy3742 commentedon Jun 1, 2025
We definitely want to release v3.0 with the new support package; I'll put the support package at the top of my todo list for today.
I definitely meant iOS 7, not 17. The standard CPython build is compiled for iOS 13, and it runs all the subinterpreter tests that don't involve using subprocesses.
As for detection - I'm not sure exactly what sort of detection you're thinking of. "The build environment must define IPHONEOS_DEPLOYMENT_TARGET, and it must be >= 7 (and in practice, >=13)" is the only real restriction here; and that should be passed through correctly (noting the fix to come in the next support package).
henryiii commentedon Jun 2, 2025
CPython's TLS works fine, pybind11 uses that already, it's just C/C++'s
thread_local
that's a problem currently. We are trying a rewrite that uses the Python TLS implementation for subinterpreters too, I'll let you know if it works.If 13+ is normally required, and
thread_local
works in 7+, that's great, and only a "currently" issue. I don't currently don't know how to set up a unit test (or anything outside of cibuildwheel) for iOS to check. (for Pyodide and now iOS, I'm using cibuildwheel and scikit-build-core to test pybind11).For detection, I meant "can I write a
#if <thing>
that tells me that I'm compiling for iOS, and what version of iOS is targeted?". I wanted to disable subinterperters on versions that didn't support it. But if it's normally not a problem modulo a bug that will soon be fixed, that's not an issue, and I think we will get our rewrite in and it won't be an issue regardless.freakboy3742 commentedon Jun 2, 2025
To check if you're on iOS at all, you can use:
If you also want to target tvOS, watchOS, and visionOS, you can use
TARGET_OS_IPHONE
To check for a specific version, of iOS, you can use:
You may also need to do some
defined()
checks for those symbols, depending on which other platforms you want to support at the same time.Regarding the updated iOS support package - the best laid plans of mice and men etc... I've hit the dual complications of an issue with the build tooling that creates the support package, and some other fires that have arisen this morning that have prevented me from fixing those problems. I'm hoping I'll be able to resolve both of these by tomorrow and get an updated package released.
henryiii commentedon Jun 2, 2025
That's fine, I think we can get a beta/RC out soon, then get this in for the final release in a couple of days. That's likely to be the criteria for the final release, probably. :)
(And that was exactly what I was wanting to know, thanks!)
henryiii commentedon Jun 2, 2025
pybind11's test suite passes with pybind/pybind11#5709 so we should be able to avoid needing any adjustments on iOS. :)
henryiii commentedon Jun 2, 2025
Is this true? When I built on
macOS-latest
I think it only did the two ARM targets.freakboy3742 commentedon Jun 2, 2025
An early version of the PR did build all targets by default; the final version that landed implements "all for current architecture", with "all" being an option. Looks like I missed a reference in the docs as that was changed. Fixed in #2441.
freakboy3742 commentedon Jun 3, 2025
I've finally ironed out all the issues I was having with the support package build, and I've published 3.13-b7. It should be picked up by the
bin/upgrade_pythons.py
script; do you want/need me to run that script and submit a PR with the update?henryiii commentedon Jun 3, 2025
No, CI can do it: #2443
henryiii commentedon Jun 3, 2025
Do you know why the new build fails in #2443? (Or why the old build fails in #2442 with a different reason, for that matter?) Was there a workaround we need to remove? I forget why were were waiting for the update originally, the more recent reason (iOS deployment target) is the thing I do remember.
joerick commentedon Jun 3, 2025
I believe the failure in #2442 is because we are asserting on the output of the test-command - there was/is a known bug in the iOS simulator where occasionally some of the stdout from the simulator wouldn't make it into our logs. I actually thought this was fixed, given that we had these asserts in and I hadn't seen it fail, but here it is again.
The workaround for us will be to not rely on the output of the test-command for our asserts somehow. I don't know how exactly!
I've done some investigation into #2443, raised an issue at cpython for it python/cpython#135101, and a corresponding PR python/cpython#135102
freakboy3742 commentedon Jun 4, 2025
@henryiii Looks like @joerick has identified the cause; fixes (including an updated support package) are on their way.
freakboy3742 commentedon Jun 4, 2025
A new support package (with the testbed patch from CPython) has been published. That should resolve the CI testing issue, and I've added an explicit test of the testbed to my release process to ensure this stays fixed.