Libffi 3.3 porting notes/FFI SYSV

From Gentoo Wiki
Jump to: navigation, search

The problem

On amd64 libffi-3.3_rc0 stopped matching supported ABIs for x86 in the following upstream commit: https://github.com/libffi/libffi/commit/ef76205647bca77796882d31f6ab5e889f461f07

This causes build failures like:

CODE
polyffi.cpp:100:14: error: 'FFI_SYSV' was not declared in this scope
     {"sysv", FFI_SYSV},
              ^~~~~~~~

The fix

Namely instead using any of the following enum values

CODE
FFI_SYSV,
  FFI_UNIX64,   /* Unix variants all use the same ABI for x86-64  */
  FFI_THISCALL,
  FFI_FASTCALL,
  FFI_STDCALL,
  FFI_PASCAL,
  FFI_REGISTER,

FFI_UNIX64 should be used instead.

Example change could look like:

CODE
--- a/libpolyml/polyffi.cpp
+++ b/libpolyml/polyffi.cpp
@@ -98,5 +98,7 @@ static struct _abiTable { const char *abiName; ffi_abi abiCode; } abiTable[] =
     {"win64", FFI_WIN64},
+#elif defined (X86_64) || (defined (__x86_64__) && defined (X86_DARWIN))
+    {"sysv", FFI_UNIX64},
+    {"unix64", FFI_UNIX64},
 #elif defined(X86_ANY)
     {"sysv", FFI_SYSV},
-    {"unix64", FFI_UNIX64},
 #endif