Skip to content

Conversation

@freakboy3742
Copy link
Contributor

When building for iOS, and Python is a dependency, linking against the Python framework is required. This is done automatically for all the standard library modules.

This behavior differs from macOS. On macOS, binary modules are linked with -undefined dynamic_lookup; that option is marked as deprecated for the iOS compiler, so it can't be used.

It also differs from Unix platforms that link against libPython - the link must be against the framework, not the library, as iOS doesn't allow "normal" dynamic library linking. As a result, existing link_libpython can't be used.

@freakboy3742
Copy link
Contributor Author

The macOS test failures don't appear to be due to anything from this patch - they seem to be a fundamental build environment problem.

Comment on lines 367 to 372
self.paths.get('platinclude')])
self.paths.get('platinclude')
])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks unrelated.

Comment on lines 360 to 363
elif self.platform.startswith('ios-'):
# iOS doesn't use link_libpython - it links with the *framework*.
self.link_args = ["-framework", "Python", "-F", self.variables.get('prefix')]
self.is_found = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • consistent (single) quotes?
  • This only matches if link_libpython is false. That assumes that sysconfig defines LIBPYTHON as an empty string, which is e.g. true on Linux with python 3.13 and I suppose is true for iOS builds as well. Hopefully this is a guarantee, but, maybe it makes sense to do the iOS check first anyway, given that self.platform is more fine-grained and stable than "the Makefile defined LIBPYTHON for substitution in configured files such as python.pc and python-config.sh"

@freakboy3742 freakboy3742 requested a review from eli-schwartz May 1, 2025 02:16
@eli-schwartz
Copy link
Member

Thanks, could you rebase and merge the fixups into the parent commit?

@freakboy3742 freakboy3742 force-pushed the ios-framework-linking branch from 0ea3b81 to af2f05b Compare May 1, 2025 22:13
@freakboy3742
Copy link
Contributor Author

@eli-schwartz Done - but that didn't fix the problem.

The same failure is occurring on the master branch - it looks like something fundamental about the pip 25.1 release (or the 25.0.1 release) - pip can't be upgraded. I thought it might have been the order of upgrading setuptools before pip, but that doesn't appear to have resolved the problem either.

@freakboy3742
Copy link
Contributor Author

Oh - sorry - now I see you were asking for the style fixes to be merged in. I'll do that now.

@freakboy3742 freakboy3742 force-pushed the ios-framework-linking branch from 6c81bc9 to 1214047 Compare May 1, 2025 22:30
@freakboy3742
Copy link
Contributor Author

And it looks like the CI failure is caused by pypa/pip#13359, and an incompatibility with Python3.9.

@bonzini bonzini added OS:macos Issues specific to Apple Operating Systems like MacOS and iOS modules:python Issues specific to the python module dependencies and removed modules:python Issues specific to the python module labels May 2, 2025
@bonzini bonzini added this to the 1.9 milestone May 2, 2025
@freakboy3742 freakboy3742 force-pushed the ios-framework-linking branch 3 times, most recently from 6f4dfe2 to 93a54f4 Compare May 4, 2025 04:24
@freakboy3742 freakboy3742 force-pushed the ios-framework-linking branch from 93a54f4 to 3965d8d Compare May 4, 2025 04:39
@freakboy3742
Copy link
Contributor Author

I've found a fix for the macOS CI issue; it's included here, but also submitted independently as #14556.

@eli-schwartz eli-schwartz merged commit c98cd76 into mesonbuild:master May 4, 2025
31 checks passed
@freakboy3742 freakboy3742 deleted the ios-framework-linking branch May 4, 2025 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies OS:macos Issues specific to Apple Operating Systems like MacOS and iOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants