Hello,

I'm trying to determine the status of Quicklisp with GCL, especially
considering the advances in ANSI compliance. I've found some apparently
fixable issues, but stumbled into one that seems substantially more
involved - but maybe I'm wrong on both counts!

1. ASDF and chdir
=================

The current asdf.lisp file has:

:  (defun chdir (x)
:     "Change current directory, as per POSIX chdir(2), to a given pathname 
object"
:     (if-let (x (pathname x))
:     [...]
:           #+gcl (system:chdir x)


It doesn't seem that chdir is exported though:

: $ gcl
: GCL (GNU Common Lisp)  2.7.1 Thu Apr 10 09:38:27 PM EDT 2025  ANSI    git: 
Version_2_7_0
: [...]
: >(fboundp 'system:chdir)
: 
: Error:
: Fast links are on: do (si::use-fast-links nil) for debugging
: Signalled by "AN ANONYMOUS FUNCTION".
: 
: INTERNAL-SIMPLE-ERROR: Cannot find the external symbol CHDIR in #<"SYSTEM" 
package>.
: 
: Broken at NIL.  Type :H for Help.
:     1  Return to top level. 
: >>1
: 
: Top level.
: >(fboundp 'system::chdir)
: 
: T


*Fix*: (system::chdir) works, but if it's supposed to be exported, then
 something is wrong. Otherwise, ASDF should be updated.

2. ASDF (declaim (ftype ...))
=============================

Loading asdf.lisp will them give this:

: Error: The FTYPE proclamation (FTYPE FUNCTION ENSURE-PATHNAME) is illegal.

This is because of:

: (with-upgradability ()
:    (declaim (ftype function ensure-pathname)) ; forward reference

I've read the HyperSpec
(http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Body/dec_ftype.html)
on FTYPE, and... well, I can see it both ways, this is likely something
debated to death in terms of spirit vs letter of the spec. I would think
that "function" by itself would work, but GCL expects (function ...).

This seems to do the trick:

: ;; GCL
:  (declaim (ftype (function (&rest t) t) ensure-pathname))

*Fix*: if the above is correct, adding a +gcl option that uses it would
 solve this (or, if there's a consensus that it's the best approach, AND
 if every other compiler also uses it, change it for all). Either way,
 easily fixable (unless I'm drastically simplifying things).

3. LET* and LAMBDA-PARAMETERS-LIMIT < 64
========================================

I'm not sure if I got the root cause of this correct, but this is the
more complex issue. It surfaces when loading Quicklisp setup.lisp, but
is still in ASDF. This is what happens:

: ;; Loading "init.lsp"
: ;; Loading #P"/home/fsmunoz/src/lisp/quicklisp-gcl/asdf.lisp"
: ;; Compiling /tmp/gazonk_543141_0.lsp.
: [...]
: ;; Finished loading #P"/tmp/gazonk_543141_0.o"
: ;; Finished loading #P"/home/fsmunoz/src/lisp/quicklisp-gcl/asdf.lisp"
: ;; Loading #P"/home/fsmunoz/src/lisp/quicklisp-gcl/quicklisp.lisp"
: 
:   ==== quicklisp quickstart 2015-01-28 loaded ====
: 
:     To continue with installation, evaluate: (quicklisp-quickstart:install)
: 
:     For installation options, evaluate: (quicklisp-quickstart:help)
: 
: ;; Finished loading #P"/home/fsmunoz/src/lisp/quicklisp-gcl/quicklisp.lisp"
: ;; Loading "~/quicklisp/setup.lisp"
: ;; Finished loading "~/quicklisp/setup.lisp"
: ;; Compiling /tmp/gazonk_543141_0.lsp.
: ;; End of Pass 1.  
: ;; End of Pass 2.  
: OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3
: ;; Finished compiling /tmp/gazonk_543141_0.o.
: ;; Loading #P"/tmp/gazonk_543141_0.o"
: ;; start address for /tmp/gazonk_543141_0.o 0x3681010
: ;; Finished loading #P"/tmp/gazonk_543141_0.o"
: (ql:quickload "alexandria")
: Error:
: Signalled by LET*.
: Condition in LET* [or a callee]: INTERNAL-SIMPLE-PROGRAM-ERROR: LET* [or a 
callee] requires less than sixty-four arguments.
: 
: Broken at SYSTEM::BREAK-LEVEL.  Type :H for Help.
: [...]
:   148  Return to debug level 1. 
:   149  Segmentation violation: c stack ok:signalling errorSegmentation 
violation: c stack ok:signalling error
: Unrecoverable error: Segmentation violation..

This happens in (ql:quickload "alexandria"), but seemingly due to
(asdf:load-system :alexandria) being called:

: ; Loading "init.lsp"
: ;; Loading #P"/home/fsmunoz/src/lisp/quicklisp-gcl/asdf.lisp"
: Finished loading "init.lsp"
: GCL (GNU Common Lisp)  2.7.1 Thu Apr 10 09:38:27 PM EDT 2025  ANSI    git: 
Version_2_7_0
: [...]
: 
: (asdf:load-system :alexandria)
: 
: ;; Compiling /tmp/gazonk_545577_0.lsp.
: ;; End of Pass 1.  
: ;; End of Pass 2.  
: OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3
: ;; Finished compiling /tmp/gazonk_545577_0.o.
: ;; Loading #P"/tmp/gazonk_545577_0.o"
: ;; start address for /tmp/gazonk_545577_0.o 0x367d420
: ;; Finished loading #P"/tmp/gazonk_545577_0.o"
: ;; Compiling /tmp/gazonk_545577_0.lsp.
: ;; End of Pass 1.  
: ;; End of Pass 2.  
: OPTIMIZE levels: Safety=0 (No runtime error checking), Space=0, Speed=3
: ;; Finished compiling /tmp/gazonk_545577_0.o.
: ;; Loading #P"/tmp/gazonk_545577_0.o"
: ;; start address for /tmp/gazonk_545577_0.o 0x367e1c0
: ;; Finished loading #P"/tmp/gazonk_545577_0.o"
: 
: Error:
: Signalled by LET*.
: Condition in LET* [or a callee]: INTERNAL-SIMPLE-PROGRAM-ERROR: LET* [or a 
callee] requires less than sixty-four arguments.
: 
: Broken at SYSTEM::BREAK-LEVEL.  Type :H for Help.
: Error:
: Signalled by SYSTEM:LAMBDA-CLOSURE.
: 
:     1  Segmentation violation: c stack ok:signalling error
: Condition in SYSTEM:LAMBDA-CLOSURE [or a callee]: INTERNAL-SIMPLE-ERROR: 
Caught fatal error [memory may be damaged]: Segmentation violation.

The reason I'm mentioning LAMBDA-PARAMETERS-LIMIT and PCL is because, and after
trial and error and following different breadcrumbs, I added this to
test the PCL hypothesis:

: ;; init.lsp (same dir)
: [...]
: (defvar *current-gf* nil)
: (defvar *gf-log* nil)
: 
: ;; Capture the funcall
: (let ((original (symbol-function 'pcl::set-dfun)))
:   (setf (symbol-function 'pcl::set-dfun)
:         (lambda (gf dfun cache info)
:           (setf *current-gf* gf)
:           (push (pcl::generic-function-name gf) *gf-log*)
:           (funcall original gf dfun cache info))))
: 
: ;; Add to the debugger hook to print the last iteratction
: (setf *debugger-hook*
:       (lambda (condition hook)
:         (declare (ignore hook))
:         (format t "Condition: ~A~%" condition)
:         (dotimes (i (min 30 (si::ihs-top)))
:           (format t "~2D: ~A~%" i
:                   (subseq (prin1-to-string (si::ihs-fun i)) 0 80)))
:         (si::bye 1)))
: ;; Load alexandria
: (asdf:load-system :alexandria)

... which gives this:

: ;; Finished loading #P"/tmp/gazonk_553291_0.o"
: Condition: Condition in LET* [or a callee]: INTERNAL-SIMPLE-PROGRAM-ERROR: 
LET* [or a callee] requires less than sixty-four arguments.
:  0: NIL
:  1: #<function 000000002db3cb40>
:  2: (SYSTEM:LAMBDA-CLOSURE
:  NIL NIL NIL
:  (ASDF/SYSTEM:SYSTEM
:   &REST ASDF/OPERATE::K
:  3: (BLOCK
:  ASDF/OPERATE:LOAD-SYSTEM
:  (APPLY
:   'ASDF/OPERATE:OPERATE 'ASDF/LISP-ACTI
:  4: #<function 0000000001c006a0>
:  5: #<function 0000000001c57190>
:  6: #<function 0000000001c52c00>
:  7: #<function 000000002db324c0>
:  8: (SYSTEM:LAMBDA-CLOSURE
:  NIL NIL NIL
:  (PCL::.PV-CELL.
:   PCL::.NEXT-METHOD-CALL. A
:  9: (BLOCK
:  ASDF/OPERATE::|(PCL::FAST-METHOD OPERATE :AROUND (T T))|
:  (MACROLET
:   ((
: 10: (MACROLET
:  ((PCL::PV-ENV
:    ((PCL::PV PCL::CALLS PCL::PV-TABLE-SYMBOL PCL::PV-PA
: 11: (MACROLET
:  ((PCL::CALL-NEXT-METHOD-BIND
:    (&BODY PCL::BODY) (LIST* 'LET NIL PCL
: 12: (LET
:  NIL
:  (FLET
:   ((CALL-NEXT-METHOD
:     (&REST PCL::CNM-ARGS) (DECLARE (DYNAMI
: 13: (FLET
:  ((CALL-NEXT-METHOD
:    (&REST PCL::CNM-ARGS) (DECLARE (DYNAMIC-EXTENT PCL:
: 14: (LET*
:  ((#:G157
:    (LIST*
:     ASDF/OPERATION:OPERATION ASDF/COMPONENT:COMPONENT 
: 15: (BLOCK
:  ASDF/OPERATE:OPERATE
:  (UIOP/UTILITY:NEST
:   (ASDF/SESSION:WITH-ASDF-SESSI
: [...]

I'm not sure what to make of this (or even the validity), but the idea
that there's a conflict between how the PCL dispatch works, possibly
accumulating arguments that exceed the (relatively low)
MAX_ARGS/LAMBDA-PARAMETERS-LIMIT of GCL (SBCL has 1073741824, for
example).

I'm using a init.lsp in the CWD... maybe I've missed it, but if not,
it would actually be a good thing to have a ~/.gclrc or something.

Anyway, I'm sure that this is probably the wrong take, but if nothing
else I wanted to share it with others, perhaps there's something that
can be done to improve ASDF/Quicklisp support - which would be a
significant feature IMO.

All the best,

-- 
Frederico
[email protected]

Reply via email to