This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

loading shared objects via libffi on Android "CDECL does no denote a valid calling convention."


Hi! I am having trouble loading libSDL-1.2.so with libffi 3.2.1 (included with ecl) on my Android system. I get a Lisp error with "CDECL does no denote a valid calling convention."
Backtrace and error text to be found below.

Using git HEAD does not help either. Seems to be related to this issue:

https://stackoverflow.com/questions/9559855/does-ecl-support-callbacks

here is the error message where it appears in the code:
https://gitlab.com/embeddable-common-lisp/ecl/blob/develop/src/c/ffi.d#L419

The tricky part is: CL-OPENGL bindings compile/load against /system/lib/libGLESv2.so just fine. I know these SDL-1.2.so shared libs work, because i pulled them from a working build made with this SDL 1.2 android port: https://github.com/pelya/commandergenius

So we know that both GLES and SDL shared objects are working on the target system, but GLES loads fine via (ql:quickload :cl-opengl), but (ql:quickload :lispbuilder-sdl) subsequently fails as described. 

You can find the shared objects I built here: http://xelf.me/android-sdl-1.2-shared-objects.tar.gz 

Here are links to all the scripts I am using to make builds. They're adapted from the various documentation and are set up to use ~/src as a staging area.

https://gitlab.com/dto/xelf/blob/master/build/clean-ecl.sh
https://gitlab.com/dto/xelf/blob/master/build/clone-ecl.sh
https://gitlab.com/dto/xelf/blob/master/build/build-ecl-toolchain.sh
https://gitlab.com/dto/xelf/blob/master/build/build-ecl-android.sh
(optional) https://gitlab.com/dto/xelf/blob/master/build/insert-upstream-libffi.sh

My sequence of steps is as follows:

1. Build and install EclAndroid-debug.apk using the above scripts.
2. Download slime 2.14 from: https://github.com/slime/slime/archive/v2.14.tar.gz
3. Git clone https://github.com/3b/cl-opengl
4. Edit cl-opengl/gl/library.lisp and change the :UNIX line to this:
    (:unix (:or "libGLESv2.so" "libGLES_android.so")))
5. Start the Ecl app on the android device and eval "(get-quicklisp)"
   This is important because it creates directories in /data/data/org.lisp.ecl/... 
   where some missing pieces (swank and modified cl-opengl) must now go.
6. copy the slime-2.14 directory from your build machine to Android's /data/data/org.lisp.ecl/app_resources/home/
7. copy cl-opengl from your build machine to Android's 
/data/data/org.lisp.ecl/app_resources/home/quicklisp/local-projects/
8. I can't yet figure out how to get the libraries properly bundled in the APK, so I remount
   /system as a read/write filesystem, and then copy the SDL 1.2 shared objects *.so into 
   /system/lib/ 
9. Quit and restart ECL Android app. This time Swank should take a few moments so compile.
10. Click top right corner menu and choose Swank Server. You should see a message showing that it has started.
11. Connect from Emacs.




-------------------------------------------------------
And finally here is the error message and backtrace:
-------------------------------
CDECL does no denote a valid calling convention.
ÂÂ [Condition of type SIMPLE-ERROR]

Restarts:
Â0: [TRY-RECOMPILING] Recompile events and try loading it again
Â1: [RETRY] Retry loading FASL for #<cl-source-file "lispbuilder-sdl" "sdl" "events">.
Â2: [ACCEPT] Continue, treating loading FASL for #<cl-source-file "lispbuilder-sdl" "sdl" "events"> as having been successful.
Â3: [RETRY] Retry ASDF operation.
Â4: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the configuration.
Â5: [ABORT] Give up on "lispbuilder-sdl"
Â--more--

Backtrace:
 0: #<bytecompiled-function CALL-WITH-DEBUGGING-ENVIRONMENT>
ÂÂÂÂÂ Locals:
ÂÂÂÂÂÂÂ SWANK/BACKEND::DEBUGGER-LOOP-FN = #<bytecompiled-closure #<bytecompiled-function 6e3420f0>>
ÂÂÂÂÂÂÂ SWANK/BACKEND::F = #<bytecompiled-closure #<bytecompiled-function SWANK/BACKEND:CALL-WITH-DEBUGGING-ENVIRONMENT>>
 1: #<bytecompiled-function DEBUG-IN-EMACS>
 2: #<bytecompiled-function INVOKE-SLIME-DEBUGGER>
 3: #<bytecompiled-function 6e342410>
 4: #<bytecompiled-function CALL-WITH-DEBUGGER-HOOK>
 5: #<bytecompiled-function CALL-WITH-DEBUGGER-HOOK>
 6: #<bytecompiled-function SWANK-DEBUGGER-HOOK>
 7: #<bytecompiled-function BYTECODES>
 8: #<bytecompiled-function 6d9d5c30>
 9: #<bytecompiled-function CALL-WITH-MACROEXPAND-PROGRESS>
Â10: #<bytecompiled-function APPLY-LOAD-STRATEGY>
Â11: #<bytecompiled-function AUTOLOAD-SYSTEM-AND-DEPENDENCIES>
Â12: #<bytecompiled-function QL>
Â13: #<bytecompiled-function %CALL-WITH-QUIET-COMPILATION>
Â14: #<bytecompiled-function CALL-WITH-QUIET-COMPILATION>
Â15: #<bytecompiled-function QUICKLOAD>
Â16: #<bytecompiled-function CALL-NEXT-METHOD>
Â17: #<bytecompiled-function 6d9d5168>
Â18: #<bytecompiled-function CALL-WITH-CONSISTENT-DISTS>
Â19: #<bytecompiled-function 6d9d50f0>
Â20: #<bytecompiled-function BYTECODES>
Â21: #<bytecompiled-function EVAL-REGION>
Â22: #<bytecompiled-function 6e56ab68>
Â23: #<bytecompiled-function TRACK-PACKAGE>
Â24: #<bytecompiled-function 6e56ab40>
Â25: #<bytecompiled-function CALL-WITH-RETRY-RESTART>
Â26: #<bytecompiled-function 6e56ab18>
Â27: #<bytecompiled-function 6df94140>
Â28: #<bytecompiled-function CALL-WITH-SYNTAX-HOOKS>
Â29: #<bytecompiled-function CALL-WITH-BUFFER-SYNTAX>
Â30: #<bytecompiled-function REPL-EVAL>
Â31: #<bytecompiled-function LISTENER-EVAL>
Â32: #<bytecompiled-function BYTECODES>
Â33: #<bytecompiled-function EVAL-FOR-EMACS>
Â34: #<bytecompiled-function PROCESS-REQUESTS>
Â35: #<bytecompiled-function 6e2af7a8>
Â36: #<bytecompiled-function HANDLE-REQUESTS>
Â37: #<bytecompiled-function 6e2e5320>
Â38: #<bytecompiled-function CALL-WITH-BINDINGS>
Â39: #<bytecompiled-function REPL-INPUT-STREAM-READ>
Â40: #<bytecompiled-function 6e2e53e8>
Â41: #<bytecompiled-function 6e1bcb18>
Â42: #<bytecompiled-function CALL-WITH-LOCK-HELD>
Â43: #<bytecompiled-function CALL-WITH-LOCK-HELD>
Â44: #<bytecompiled-function STREAM-READ-CHAR>
Â45: #<bytecompiled-function SIMPLE-REPL>
Â46: #<bytecompiled-function 6e2e5690>
Â47: #<bytecompiled-function 6e2e55c8>
Â48: #<bytecompiled-function CALL-WITH-USER-BREAK-HANDLER>
Â49: #<bytecompiled-function CALL-WITH-USER-BREAK-HANDLER>
Â50: #<bytecompiled-function 6e2e55a0>
Â51: #<bytecompiled-function CALL-WITH-DEBUGGER-HOOK>
Â52: #<bytecompiled-function CALL-WITH-DEBUGGER-HOOK>
Â53: #<bytecompiled-function 6e2e5528>
Â54: #<bytecompiled-function CALL-WITH-BINDINGS>
Â55: #<bytecompiled-function SIMPLE-SERVE-REQUESTS>
Â56: #<bytecompiled-function SERVE-REQUESTS>
Â57: #<bytecompiled-function ACCEPT-CONNECTIONS>
Â58: #<bytecompiled-function SERVE>
Â59: #<bytecompiled-function SERVE-LOOP>
Â60: #<bytecompiled-function SETUP-SERVER>
Â61: #<bytecompiled-function CREATE-SERVER>
Â62: #<bytecompiled-function 6e3fe0f0>
Â63: NIL


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]