Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 24 additions & 13 deletions cmake/extensions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -382,19 +382,30 @@ if(WIN32)
endif()
else()
if(APPLE)
add_python_extension(_ctypes
SOURCES ${ctypes_COMMON_SOURCES}
_ctypes/malloc_closure.c
_ctypes/darwin/dlfcn_simple.c
_ctypes/libffi_osx/ffi.c
_ctypes/libffi_osx/x86/darwin64.S
_ctypes/libffi_osx/x86/x86-darwin.S
_ctypes/libffi_osx/x86/x86-ffi_darwin.c
_ctypes/libffi_osx/x86/x86-ffi64.c
INCLUDEDIRS ${SRC_DIR}/Modules/_ctypes/libffi_osx/include
${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

add_python_extension(_ctypes
SOURCES ${ctypes_COMMON_SOURCES}
_ctypes/malloc_closure.c
_ctypes/darwin/dlfcn_simple.c
_ctypes/libffi_osx/ffi.c
_ctypes/libffi_osx/x86/darwin64.S
_ctypes/libffi_osx/x86/x86-darwin.S
_ctypes/libffi_osx/x86/x86-ffi_darwin.c
_ctypes/libffi_osx/x86/x86-ffi64.c
INCLUDEDIRS ${SRC_DIR}/Modules/_ctypes/libffi_osx/include
${SRC_DIR}/Modules/_ctypes/darwin
DEFINITIONS MACOSX
)
else()
# non-x86_64 architectures, e.g. arm64 or arm64+x86_64 universal build
add_python_extension(_ctypes
REQUIRES LibFFI_INCLUDE_DIR LibFFI_LIBRARY
SOURCES ${ctypes_COMMON_SOURCES}
DEFINITIONS Py_BUILD_CORE_MODULE FFI_BUILDING
INCLUDEDIRS ${LibFFI_INCLUDE_DIR}
LIBRARIES ${LibFFI_LIBRARY}
)
endif()
else()
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64")
set(_libffi_system_extra_src
Expand Down