[cffi-devel] [Fwd: Re: [Lisp] testing CFFI]

Kenny Tilton ktilton at nyc.rr.com
Sat Sep 17 17:30:41 UTC 2005


Luis,

Got this report from a fello Lispnyk (thx, dimitri). Looks to my 
uninformed eyes as if the x86 and >0.9.3 requirements for callbacks are 
met. Thoughts?

kenny

-------- Original Message --------
Subject: 	Re: [Lisp] testing CFFI
Date: 	Sat, 17 Sep 2005 12:19:59 -0400
From: 	Dimitry Gashinsky <digash at gmail.com>
Reply-To: 	i at digash.com
To: 	Kenny Tilton <ktilton at nyc.rr.com>
CC: 	LISP NYC <lisp at lispnyc.org>
References: 	<432AE74A.9060603 at nyc.rr.com>



Hi Kenny,

I just tried running CFFI on Linux X86_64. I found couple of problems.

CL-USER(3): :c cffi-tests

; loading system definition from
; /home/dig/src/cffi-luis-050916-0148/cffi-tests.asd into #<PACKAGE "ASDF4061">
; registering #<SYSTEM CFFI-TESTS {1000F01F11}> as CFFI-TESTS
; loading system definition from /usr/share/common-lisp/systems/rt.asd into
; #<PACKAGE "ASDF4088">
; registering #<SYSTEM :RT {10009C6D51}> as RT
; $ cd /home/dig/src/cffi-luis-050916-0148/tests/; make
gcc -o libtest.so -shared -lm -Wall -ansi -pedantic libtest.c
/usr/lib/gcc/x86_64-pc-linux-gnu/3.4.4/../../../../x86_64-pc-linux-gnu/bin/ld:
/tmp/ccsyYRJ7.o: relocation R_X86_64_32 against `a local symbol' can
not be used when making a shared object; recompile with -fPIC
/tmp/ccsyYRJ7.o: could not read symbols: Bad value
collect2: ld returned 1 exit status
make: *** [libtest.so] Error 1

debugger invoked on a ASDF:OPERATION-ERROR in thread #<THREAD "initial
thread" {1000003981}>:
  erred while invoking #<COMPILE-OP NIL {100105BA71}> on
  #<C-TEST-LIB "libtest" {10011559F1}>

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [RETRY ] Retry performing #<ASDF:COMPILE-OP NIL {100105BA71}> on
              #<CFFI-TESTS-SYSTEM::C-TEST-LIB "libtest" {10011559F1}>.
  1: [ACCEPT] Continue, treating #<ASDF:COMPILE-OP NIL {100105BA71}> on
              #<CFFI-TESTS-SYSTEM::C-TEST-LIB "libtest" {10011559F1}> as having
              been successful.
  2: [ABORT ] Exit debugger, returning to top level.

((SB-PCL::FAST-METHOD ASDF:PERFORM
                      (ASDF:COMPILE-OP CFFI-TESTS-SYSTEM::C-TEST-LIB))
 #<unused argument>
 #<unused argument>
 #<ASDF:COMPILE-OP NIL {100105BA71}>
 #<CFFI-TESTS-SYSTEM::C-TEST-LIB "libtest" {10011559F1}>)
source: (ERROR 'ASDF:OPERATION-ERROR
               :COMPONENT
               CFFI-TESTS-SYSTEM::C
               :OPERATION
               CFFI-TESTS-SYSTEM::O)
0] 


The first problem coud be easily resolved by adding -fPIC to LDFLAGS.


; file: /home/dig/src/cffi-luis-050916-0148/tests/callbacks.lisp
; in: DEFCALLBACK SUM-CHAR
;     (CFFI:DEFCALLBACK CFFI-TESTS::SUM-CHAR
;                     :CHAR
;                     ((CFFI-TESTS::A :CHAR) (CFFI-TESTS::B :CHAR))
;                     "Test if the named block is present and the
docstring too."
;                     (RETURN-FROM CFFI-TESTS::SUM-CHAR
;                       (+ CFFI-TESTS::A CFFI-TESTS::B)))
; --> PROGN CFFI-SYS:%DEFCALLBACK SETF LET* LET* MULTIPLE-VALUE-BIND LET
; --> ALIEN-SAP LOCALLY PROGN ALIEN-SAP SB-ALIEN::ALIEN-LAMBDA
; ==>
;   (SB-ALIEN-INTERNALS:ALIEN-CALLBACK (FUNCTION CHAR CHAR CHAR)
;                                      (LAMBDA (CFFI-TESTS::A CFFI-TESTS::B)
;                                        (CFFI::INVERSE-TRANSLATE-OBJECTS
;                                         (CFFI-TESTS::A CFFI-TESTS::B)
;                                         (:CHAR :CHAR)
;                                         :CHAR
;                                         (BLOCK CFFI-TESTS::SUM-CHAR
;                                           (RETURN-FROM CFFI-TESTS::SUM-CHAR
;                                             #)))))
;
; caught ERROR:
;   (in macroexpansion of (SB-ALIEN-INTERNALS:ALIEN-CALLBACK # #))
;   (hint: For more precise location, try *BREAK-ON-SIGNALS*.)
;   The function SB-ALIEN-INTERNALS:ALIEN-CALLBACK-ACCESSOR-FORM is undefined.

This seems that my SBCL does not support ALIEN-CALLBACK-ACCESSOR-FORM.
Here is my features.

This is SBCL 0.9.4, an implementation of ANSI Common Lisp.
...
(:ASDF :SB-THREAD
       :ANSI-CL
       :COMMON-LISP
       :SBCL
       :UNIX
       :SB-DOC
       :SB-PACKAGE-LOCKS
       :SB-UNICODE
       :IEEE-FLOATING-POINT
       :X86-64
       :ELF
       :LINUX
       :GENCGC
       :STACK-GROWS-DOWNWARD-NOT-UPWARD
       :C-STACK-IS-CONTROL-STACK
       :LINKAGE-TABLE
       :STACK-ALLOCATABLE-CLOSURES
       :OS-PROVIDES-DLOPEN
       :OS-PROVIDES-DLADDR)

If I accept callback failure and continue with testing all the tests
pass! I guess there is no tests for CALLBACK yet.

Hope this helps,
Dig

On 9/16/05, Kenny Tilton <ktilton at nyc.rr.com> wrote:
> Thought I would make it a little easier:
> 
> 1. Download latest CFFI-LUIS from here (last is latest):
> 
>      http://common-lisp.net/project/cffi/tarballs/
> 
> 2. Download RT from here:
> 
>      http://files.b9.com/rt/
> 
> 3: Adjust the following to match where you put stuff:
> 
> #-asdf
>  (load "/0devtools/asdf.lisp")
> 
> (progn
>   #+lispworks
>   (setf hcl::*handle-existing-defpackage* (list :add))
> 
>   (push (make-pathname :directory '(:absolute "0devtools" "cffi"))
>     asdf:*central-registry*)
> 
>   (push (make-pathname :directory '(:absolute "0devtools" "rt"))
>     asdf:*central-registry*)
> 
>   (asdf:operate 'asdf:load-op 'cffi-tests))
> 
> Ok, now you can run the tests:
> 
>    (cffi-tests::do-tests) ;; runs all tests trapping errors, reporting
> only number of failures
> 
> To see what the first failure (if any) is:
> 
>    (let ((cffi-tests::*catch-errors* nil))
>        (cffi-tests::do-tests))
> 
> Thx.
> 
> --
> Kenny
> 
> Why Lisp? http://wiki.alu.org/RtL_Highlight_Film
> 
> "I've wrestled with reality for 35 years, Doctor, and I'm happy to state I finally won out over it."
>     Elwood P. Dowd, "Harvey", 1950
> 
> 
> 
> _______________________________________________
> Lisp mailing list
> Lisp at lispnyc.org
> http://www.lispnyc.org/mailman/listinfo.cgi/lisp
> 


-- 
((LAMBDA (LAMBDA) `(,LAMBDA ',LAMBDA)) '(LAMBDA (LAMBDA) `(,LAMBDA ',LAMBDA)))




-- 
Kenny

Why Lisp? http://wiki.alu.org/RtL_Highlight_Film

"I've wrestled with reality for 35 years, Doctor, and I'm happy to state I finally won out over it."
    Elwood P. Dowd, "Harvey", 1950






More information about the cffi-devel mailing list