◐ Shell
clean mode source ↗

bpo-41100: ctypes fixes for arm64 Mac OS by lawrence-danna-apple · Pull Request #21249 · python/cpython

added 2 commits

June 30, 2020 17:53
This updates setup.py to default to the system libffi on Mac OS 10.15 and forward.   It also updates
detect_ctypes to prefer finding libffi in the Xcode SDK, rather than /usr/include
On arm64 the calling convention for variardic functions is different
than the convention for fixed-arg functions of the same arg types.

ctypes needs to use ffi_prep_cif_var to tell libffi which calling
convention to use.

@lawrence-danna-apple

@blurb-it

@claui claui mentioned this pull request

Jul 1, 2020

9 tasks

This was referenced

Jul 2, 2020

SMillerDev pushed a commit to Homebrew/homebrew-core that referenced this pull request

Jul 4, 2020
This set of patches includes the following upstream pull requests:

- python/cpython#21114
  "Support `arm64` in Mac/Tools/pythonw"

- python/cpython#21224
  "allow python to build for macosx-11.0-arm64"

- python/cpython#21249
  "ctypes fixes for arm64 Mac OS"

Adding the patches before upstream has released them is warranted here
because `python@3.8` is widely used as a dependency, and the patch is
needed to enable testing dependent formulae on arm64.

CC: Sean Molenaar <1484494+SMillerDev@users.noreply.github.com>

archoversight

Co-authored-by: Arch Oversight <archoversight@gmail.com>

ronaldoussoren

@claui claui mentioned this pull request

Jul 15, 2020

claui added a commit to Homebrew/formula-patches that referenced this pull request

Jul 15, 2020
This set of patches includes the following upstream pull requests,
in this order:

- PR 20171, "Fix _tkinter use"
  python/cpython#20171
  (prerequisite for patch #21249 to apply)

- PR 21114, "Support `arm64` in Mac/Tools/pythonw"
  python/cpython#21114

- PR 21224, "allow python to build for macosx-11.0-arm64"
  python/cpython#21224

- PR 21249, "ctypes fixes for arm64 Mac OS"
  python/cpython#21249

The patches for 20171 and 21249 have been minimally modified in order
to backport them to 3.8.3.

Note that these have been successfully tested for `python@3.8`
but not for `python@3.7`.

The patch directive should be surrounded by an `if Hardware::CPU.arm?`
block.

claui pushed a commit to xvilo/homebrew-core that referenced this pull request

Jul 15, 2020

@lawrence-danna-apple

BrewTestBot pushed a commit to Homebrew/homebrew-core that referenced this pull request

Jul 16, 2020

@lawrence-danna-apple

ned-deily

ronaldoussoren

ronaldoussoren added a commit to ronaldoussoren/cpython that referenced this pull request

Jul 20, 2020
This is support for ctypes on macOS/arm64 based
on PR 21249 by Lawrence D'Anna (Apple).

Changes:
- changed __builtin_available tests from 11.0 to 10.15
- added test to setup.py for ffi_closure_alloc and use
  that in malloc_closure.c
- Minor change in the code path for ffi_prep_closure_var
  (coding style change)

@lawrence-danna-apple

jmroot

@minrk minrk mentioned this pull request

Dec 2, 2020