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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

dto xelf.me
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