cffi-libffi doesn't build with libffi from git due to changes in available ABIs (FFI_SYSV undefined)

Bug #1692751 reported by vydd
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
CFFI
New
Undecided
Unassigned

Bug Description

Loading cffi on openSuse Tumbleweed results in two errors.

The first one,

(FL-ERROR "Unable to load any of the alternatives:~% ~S" ("libffi.so.6" "libffi32.so.6" "libffi.so.5" "libffi32.so.5"))

is easily solved by providing ("libffi.so") as a value to be used instead.

This is because Tumbleweed comes with libffi7, from git. As far as I can tell from
their package changelog, it's https://github.com/libffi/libffi/tree/60e4250a77eb3fde500bfd68ec40519fe34b21bd .

This leads to another problem:

grov.c: In function ‘main’:
grov.c:72:41: error: ‘FFI_SYSV’ undeclared (first use in this function)
   fprintf(output, "%"PRIiMAX, (intmax_t)FFI_SYSV);

FFI_SYSV isn't defined because ffi_abi struct in ffitarget.h resolves to

#elif defined(X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
  FFI_FIRST_ABI = 1,
  FFI_UNIX64,
  FFI_WIN64,
  FFI_EFI64 = FFI_WIN64,
  FFI_LAST_ABI,
  FFI_DEFAULT_ABI = FFI_UNIX64

leaving FFI_SYSV undefined.

As a temporary fix, I added #define FFI_SYSV 1 to grovel/common.h, and compiling worked
just fine for my case (https://github.com/vydd/sketch/issues/17#issuecomment-303260982),
but a proper patch is needed.

EDIT: Proposed patch

2 files changed, 7 insertions(+), 2 deletions(-)
libffi/libffi-types.lisp | 7 ++++++-
libffi/libffi.lisp | 2 +-

modified libffi/libffi-types.lisp
@@ -65,7 +65,12 @@
  ((:sysv "FFI_SYSV"))
  ((:stdcall "FFI_STDCALL")))

-#-(or freebsd windows)
+#+(and x86-64 (not windows))
+(cenum abi
+ ((:default-abi "FFI_DEFAULT_ABI"))
+ ((:unix64 "FFI_UNIX64")))
+
+#-(or freebsd windows x86-64)
 (cenum abi
  ((:default-abi "FFI_DEFAULT_ABI"))
  ((:sysv "FFI_SYSV"))
modified libffi/libffi.lisp
@@ -31,7 +31,7 @@
   (:darwin (:or "libffi.dylib" "libffi32.dylib" "/usr/lib/libffi.dylib"))
   (:solaris (:or "/usr/lib/amd64/libffi.so" "/usr/lib/libffi.so"))
   (:openbsd "libffi.so")
- (:unix (:or "libffi.so.6" "libffi32.so.6" "libffi.so.5" "libffi32.so.5"))
+ (:unix (:or "libffi.so.6" "libffi32.so.6" "libffi.so.5" "libffi32.so.5" "libffi.so"))
   (:windows (:or "libffi-6.dll" "libffi-5.dll" "libffi.dll"))
(t (:default "libffi")))

I don't know nearly enough about cffi internals to be sure it doesn't break other stuff. Otherwise I'd post this as a pull request.

vydd (vidovicd)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.