cffi-tests won't quickload on M1 MacBook

Bug #1926022 reported by Bela Pecsek
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
CFFI
New
Undecided
Unassigned

Bug Description

When I try to test cffi with the arm64 port of SBCL 2.1.3 on my MacBook with M1 CPU running MacOSX I get the following error:

My system is M1 MacBook Air with 16Gb RAM.
% uname -a
Darwin BelasMacBookAir.local 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64

SBCL 2.1.3:
[SBCL] CL-USER> *features*
(:QUICKLISP :ASDF3.3 :ASDF3.2 :ASDF3.1 :ASDF3 :ASDF2 :ASDF :OS-MACOSX :OS-UNIX
 :NON-BASE-CHARS-EXIST-P :ASDF-UNICODE :ARM64 :GENCGC :64-BIT :ANSI-CL :BSD :COMMON-LISP :DARWIN
 :IEEE-FLOATING-POINT :LITTLE-ENDIAN :MACH-O :PACKAGE-LOCAL-NICKNAMES :SB-CORE-COMPRESSION :SB-LDB
 :SB-PACKAGE-LOCKS :SB-THREAD :SB-UNICODE :SBCL :UNIX)

[SBCL] CL-USER> (ql:quickload :cffi)
To load "cffi":
  Load 1 ASDF system:
    cffi
; Loading "cffi"
.
(:CFFI)

[SBCL] CL-USER> (ql:quickload :cffi-tests)
To load "cffi-tests":
  Load 1 ASDF system:
    cffi-tests
; Loading "cffi-tests"
; pkg-config libffi --cflags
-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi
; cc -o /Users/bpecsek/.cache/common-lisp/sbcl-2.1.3-macosx-arm64/Users/bpecsek/quicklisp/dists/quicklisp/software/cffi_0.24.1/libffi/libffi-types__grovel-tmpGHU3ALSV.o -c -g -Wall -Wundef -Wsign-compare -Wpointer-arith -O3 -g -Wall -O2 -fdollars-in-identifiers -fno-omit-frame-pointer -I/opt/local/include/ -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/ffi -fPIC -I/Users/bpecsek/quicklisp/dists/quicklisp/software/cffi_0.24.1/ /Users/bpecsek/.cache/common-lisp/sbcl-2.1.3-macosx-arm64/Users/bpecsek/quicklisp/dists/quicklisp/software/cffi_0.24.1/libffi/libffi-types__grovel.c
/Users/bpecsek/.cache/common-lisp/sbcl-2.1.3-macosx-arm64/Users/bpecsek/quicklisp/dists/quicklisp/software/cffi_0.24.1/libffi/libffi-types__grovel.c:81:41: error:
      use of undeclared identifier 'FFI_UNIX64'
  fprintf(output, "%"PRIiMAX, (intmax_t)FFI_UNIX64);
                                        ^
1 error generated.

debugger invoked on a CFFI-GROVEL:GROVEL-ERROR in thread #<THREAD "main thread" RUNNING {70058F16D3}>: Subprocess #<UIOP/LAUNCH-PROGRAM::PROCESS-INFO {70087DF533}>
 with command ("cc" "-o" "/Users/bpecsek/.cache/common-lisp/sbcl-2.1.3-macosx-arm64/Users/bpecsek/quicklisp/dists/quicklisp/software/cffi_0.24.1/libffi/libffi-types__grovel-tmpGHU3ALSV.o" "-c" "-g" "-Wall" "-Wundef" "-Wsign-compare" "-Wpointer-arith" "-O3" "-g" "-Wall" ...)
 exited with error code 1

If I uncomment the faulty line in libffi-types.lisp

#-(or freebsd windows)
(cenum abi
 ((:default-abi "FFI_DEFAULT_ABI"))
 #-x86-64
 ((:sysv "FFI_SYSV"))
 #-arm64
 ((:unix64 "FFI_UNIX64")))

cffi-test load without any warning or error, however when I run the test I get this:

[SBCL] CL-USER> (ql:quickload :cffi-tests)
To load "cffi-tests":
  Load 1 ASDF system:
    cffi-tests
; Loading "cffi-tests"
........
(:CFFI-TESTS)

[SBCL] CL-USER> (asdf:test-system :cffi-tests)
;;; running tests (uncompiled)
Doing 332 pending tests of 332 tests total.
 LOAD-CORE-FOUNDATION FUNCALL.CHAR FUNCALL.INT.1 FUNCALL.INT.2 FUNCALL.LONG
 FUNCALL.LONG-LONG FUNCALL.UNSIGNED-LONG-LONG FUNCALL.FLOAT FUNCALL.DOUBLE
 FUNCALL.STRING.1 FUNCALL.STRING.2 FUNCALL.STRING.3 FUNCALL.VARARGS.NOSTDLIB
Test FUNCALL.VARARGS.CHAR failed
Form: (WITH-FOREIGN-POINTER-AS-STRING (S 100)
        (SETF (MEM-REF S :CHAR) 0)
        (FOREIGN-FUNCALL-VARARGS "sprintf" (:POINTER S :STRING "%c") :INT 65 :INT))
Expected value: "A"
Actual value: "".
Test FUNCALL.VARARGS.INT failed
Form: (WITH-FOREIGN-POINTER-AS-STRING (S 100)
        (SETF (MEM-REF S :CHAR) 0)
        (FOREIGN-FUNCALL-VARARGS "sprintf" (:POINTER S :STRING "%d") :INT 1000 :INT))
Expected value: "1000"
Actual value: "0".
Test FUNCALL.VARARGS.LONG failed
Form: (WITH-FOREIGN-POINTER-AS-STRING (S 100)
        (SETF (MEM-REF S :CHAR) 0)
        (FOREIGN-FUNCALL-VARARGS "sprintf" (:POINTER S :STRING "%ld") :LONG 131072 :INT))
Expected value: "131072"
Actual value: "0".
Test FUNCALL.VARARGS.DOUBLE failed
Form: (WITH-FOREIGN-POINTER-AS-STRING (S 100)
        (SETF (MEM-REF S :CHAR) 0)
        (FOREIGN-FUNCALL-VARARGS "sprintf" (:POINTER S :STRING "%.0f") :DOUBLE (* PI 100.0d0) :INT))
Expected value: "314"
Actual value: "0".
rlwrap: warning: sbcl crashed, killed by SIGSEGV.
rlwrap itself has not crashed, but for transparency,
it will now kill itself (without dumping core) with the same signal

warnings can be silenced by the --no-warnings (-n) option
zsh: segmentation fault rlwrap sbcl

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.