Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

bjia56
Copy link
Contributor

@bjia56 bjia56 commented Sep 27, 2023

When cross compiling for arm64 Macs, the bundled cpython libffi throws an unsupported cpu error. This change makes it so that Mac compilation skips the bundled libffi if a system libffi was requested.

This change also now makes it possible to build universal python binaries for x86_64/arm64, though that also requires pre-compiling dependencies (including libffi) from source for both architectures.

@bjia56
Copy link
Contributor Author

bjia56 commented Sep 27, 2023

I see from the CI tests that this ended up disabling ctypes on regular x86_64 macos, will tweak to restore prior behavior.

@bjia56 bjia56 changed the title MacOS: skip bundled libffi if a system one is provided MacOS: skip bundled libffi on non-x86_64 Sep 27, 2023
@theartful
Copy link

What's the status on this? I was about to do a PR doing exactly the same thing, but then found out you already did it.

${SRC_DIR}/Modules/_ctypes/darwin
DEFINITIONS MACOSX
)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND CMAKE_OSX_ARCHITECTURES STREQUAL "x86_64")
Copy link

@theartful theartful Sep 14, 2025

Choose a reason for hiding this comment

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

I'm testing this PR, and trying to build python on an arm macos for x86_64, and then for arm64 (I made a wrong review that I deleted before, disregard it if you saw it).

I failed locally to build for x86_64 on an arm machine (ctypes didn't work), since I get CMAKE_SYSTEM_PROCESSOR = arm64, while CMAKE_OSX_ARCHITECTURES = x86_64.

I think it's better to check only for CMAKE_OSX_ARCHITECTURES

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants