pip install CFFI fails on macOS 11

1,421 views
Skip to first unread message

Gábor Gajdos

unread,
Aug 21, 2020, 4:44:02 PM8/21/20
to python-cffi
This is the error message

    c/_cffi_backend.c:5854:2: error: Apple Arm64 ABI requires ffi_prep_cif_var
    #error Apple Arm64 ABI requires ffi_prep_cif_var

I did not provide any flags to compile binaries fro arm64, it is doing it automatically somehow.


Gábor Gajdos

unread,
Aug 21, 2020, 4:44:51 PM8/21/20
to python-cffi
OFC this error message is on x86_64 as I do not have the Apple Developer Platform :)

Armin Rigo

unread,
Aug 22, 2020, 4:35:38 AM8/22/20
to pytho...@googlegroups.com
Hi Gábor,

On Fri, 21 Aug 2020 at 22:44, Gábor Gajdos <gazsi...@gmail.com> wrote:
> OFC this error message is on x86_64 as I do not have the Apple Developer Platform :)

That line should only trigger if ``__arm64__`` is defined, though.
Maybe you're trying to build a "fat binary" that would work on all
macOS 11 platforms including arm64? Things to try:

- comment out the #error and see if you get something that works on x86-64.

- try to read https://foss.heptapod.net/pypy/cffi/-/issues/464 and
https://foss.heptapod.net/pypy/cffi/-/issues/463.

Please tell me if you find a workaround, or otherwise please add a
comment to https://foss.heptapod.net/pypy/cffi/-/issues/463 describing
your problem; I'm sure @odidev has a better idea than I do.


A bientôt,

Armin.

Robert Boehne

unread,
Sep 11, 2020, 5:09:06 PM9/11/20
to python-cffi
I have access to a DTK machine, and a similar problem, CFFI won't build from source because of ./c/_cffi_backend.c line 5854 where it requires a function that's not available.  I would have thought there wold be an issue regarding this, since it's explicitly spelled out in the code,  but I didn't find one.
I'm happy to fix this, but a little background would be helpful.

xcrun -sdk macosx clang -arch x86_64 -arch arm64 -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -DUSE__THREAD -DHAVE_SYNC_SYNCHRONIZE -I/usr/include/ffi -I/usr/include/libffi -I/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ffi -I/Applications/Xcode-beta.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c c/_cffi_backend.c -o build/temp.macosx-10.14.6-arm64-3.8/c/_cffi_backend.o

c/_cffi_backend.c:6304:9: warning: 'ffi_prep_closure' is deprecated [-Wdeprecated-declarations]

    if (ffi_prep_closure(closure, &cif_descr->cif,

        ^

/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ffi/ffi.h:350:18: note: 

      'ffi_prep_closure' has been explicitly marked deprecated here

  __attribute__((deprecated))

                 ^

1 warning generated.

c/_cffi_backend.c:5854:2: error: Apple Arm64 ABI requires ffi_prep_cif_var

#error Apple Arm64 ABI requires ffi_prep_cif_var

 ^

c/_cffi_backend.c:6304:9: error: implicit declaration of function 'ffi_prep_closure' is invalid in C99

      [-Werror,-Wimplicit-function-declaration]

    if (ffi_prep_closure(closure, &cif_descr->cif,

        ^

2 errors generated.

error: command 'xcrun' failed with exit status 1




Armin Rigo

unread,
Sep 12, 2020, 1:25:13 AM9/12/20
to pytho...@googlegroups.com
Hi Robert,

On Fri, 11 Sep 2020 at 23:09, Robert Boehne <rbo...@gmail.com> wrote:
> I have access to a DTK machine, and a similar problem, CFFI won't build from source because of ./c/_cffi_backend.c line 5854 where it requires a function that's not available.

It seems you're targeting arm64 on OS X 10.14.6. The define
``HAVE_FFI_PREP_CIF_VAR`` is only declared on OS X 10.15 or newer.
Can you check if the fix is simply to always define
``HAVE_FFI_PREP_CIF_VAR`` on OS X for arm64? If that function
``ffi_prep_cif_var()`` is really not defined on your machine, then
there is no way cffi can work in your case on OS X for arm64,
sorry---variadic functions require a different ABI than non-variadic
functions with the same call signature, on that precise platform.


A bientôt,

Armin.

Robert Boehne

unread,
Sep 24, 2020, 1:10:59 AM9/24/20
to python-cffi
Ok, taking a look at this again, this machine is running OS X Beta 11.0 "Big Sur", so I should target 11.0 - However when I look at cffi source, setup.py line 74 has a function `macosx_deployment_target` that is returning 10.14.6

robb@AppleDTK cffi-branch-default % python3

Python 3.8.2 (default, Jun  8 2020, 15:20:04) 

[Clang 12.0.0 (clang-1200.0.22.19)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import sys

>>> import platform

>>> from distutils.sysconfig import get_config_var

>>> get_config_var("MACOSX_DEPLOYMENT_TARGET")

'10.14.6'

>>> platform.uname()

uname_result(system='Darwin', node='AppleDTK.local', release='20.0.0', version='Darwin Kernel Version 20.0.0: Sun Jun 14 21:36:36 PDT 2020; root:Bridge_xnu-7090.111.5.2~1/RELEASE_ARM64_T8020', machine='arm64', processor='arm')

>>> ^D

That is probably the source of the problem.  How would I change the value for MACOSX_DEPLOYMENT_TARGET ?

Thanks,

Rob Boehne
Reply all
Reply to author
Forward
0 new messages