Open Kamefrede opened 1 year ago
By default, cffi-object performs object allocation optimization when generating function definitions. This requires a large amount of heap memory on SBCL. Therefore, you have the following options:
(setf cobj::*optimize-object-allocation-p* nil)
before (ql:quickload :claw-raylib)
.--dynamic-space-size 4096
parameter when loading claw-raylib
for the first time. Once claw-raylib
is compiled into FASL, you can run it with the default heap memory size.❯ LD_LIBRARY_PATH="$LD_LIBRARY_PATH;/Users/emanuelferraz/common-lisp/claw-raylib/lib" sbcl --dynamic-space-size 4096
This is SBCL 2.3.8, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (ql:quickload :claw-raylib)
To load "claw-raylib":
Load 1 ASDF system:
claw-raylib
; Loading "claw-raylib"
..........................
debugger invoked on a TYPE-ERROR @70035F113C in thread
#<THREAD "main thread" RUNNING {7012490563}>:
The value
(CFFI::EXPLODE-PATH-ENVIRONMENT-VARIABLE "LD_LIBRARY_PATH")
is not of type
(OR STRING SYMBOL CHARACTER)
when binding SB-IMPL::STRING2
Type HELP for debugger help, or (SB-EXT:EXIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [TRY-RECOMPILING ] Recompile library and try loading it again
1: [RETRY ] Retry
loading FASL for #<CL-SOURCE-FILE "claw-raylib" "library">.
2: [ACCEPT ] Continue, treating
loading FASL for #<CL-SOURCE-FILE "claw-raylib" "library">
as having been successful.
3: Retry ASDF operation.
4: [CLEAR-CONFIGURATION-AND-RETRY] Retry ASDF operation after resetting the
configuration.
5: Retry ASDF operation.
6: Retry ASDF operation after resetting the
configuration.
7: [ABORT ] Give up on "claw-raylib"
8: [REGISTER-LOCAL-PROJECTS ] Register local projects and try again.
9: Exit debugger, returning to top level.
(SB-KERNEL:TWO-ARG-STRING= "/Users/emanuelferraz/common-lisp/claw-raylib/lib/" (CFFI::EXPLODE-PATH-ENVIRONMENT-VARIABLE "LD_LIBRARY_PATH")) [external]
After the most recent commit in the prebuild
branch and with some manual tinkering (i'll submit a new issue after this comment) with compiling, it now fails on this stage, trying to read the type of the variable it returns as this:
* (type-of (CFFI::EXPLODE-PATH-ENVIRONMENT-VARIABLE "LD_LIBRARY_PATH"))
CONS
Can you provide the complete error stack trace? This seems to be an internal issue with CFFI. library.lisp
is mainly responsible for locating dynamic libraries and opening them. It compiles and runs correctly on Windows and GNU/Linux, but it haven't been tested on macOS yet.
After examining the source code of CFFI, my suspicion that the issue lies with CFFI has increased. Can you execute the following form to override the original definition of CFFI and retry compiling claw-raylib
?
(defparameter cffi::*foreign-library-directories*
(if (featurep :darwin)
(list (explode-path-environment-variable "LD_LIBRARY_PATH")
(explode-path-environment-variable "DYLD_LIBRARY_PATH")
(uiop:getcwd)
(darwin-fallback-library-path))
'())
"List onto which user-defined library paths can be pushed.")
@bohonghuang FYI, I ran into the same problem on my Arch Linux box, except it was a bit more nefarious because Quicklisp just froze without any error indication (even with verbose t
). This was using the prebuild
branch. Using --dynamic-space-size 8192
solved the issue (didn't try a lower amount). Maybe a note in the README would be good (I can make a PR if you don't have time).
Maybe a note in the README would be good
I will add a statement in the README for SBCL. Thank you for your feedback.
OS: macOS 14 running on an M2 Macbook Air
Using the prebuild branch (so as to not compile llvm from scratch) and trying to load the library with quicklisp
(ql:quickload :claw-raylib)
as per the instructions yields a heap exhaustion error and drops down the lisp repl to ldb.Log below: