-
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
random-state does not compile on Allegro Common Lisp #14
Comments
Could this be related to the use of Also the entry for |
The compiler macro isn't used, this is a setf function being invoked here. |
Or at least it should be. I don't know why Allegro is using the compiler macro. |
Looks very much like a miscompilation to me? I see nothing problematic in the code. |
I don't know -- what seems to be wrong is that there is no entry for |
Well exactly that line in implementation.lisp that it's choking on. |
Very weird, because when I do this at the ACL repl, I get the right result:
|
Yeah, so the ACL file-compiler on M1 is broken, expanding the compiler macro for some reason, instead of invoking the setf function. |
For now, can I just |
No, it just removes an optimisation around accessing it. |
I thought that was generally true about compiler macros, but wanted to check. Thanks! I will report this to Franz. |
BTW, have you tested this on older Allegro? If I could report that it worked there, that would probably help them |
I have not, no. I generally don't have the time to test on other implementations |
OK, when I get a chance, I can pass you a GitHub action script that will test on a bunch of implementations. |
I have just hit this as well, although the source seems to be different. First of all, I needed to move the definition site of (in-package :random-state)
(defvar *generator* *random-state*) Second, there's something odd going on with macro expansion. The compiler reports:
Complaining about something that has expanded to (define-compiler-macro random-unit (&whole whole generator &optional (type ''single-float) &environment env)
(if (constantp type env)
`(scale-float (coerce (random-bytes ,generator (load-time-value (float-digits (coerce 0 ,type)))) ,type)
(load-time-value (- (float-digits (coerce 0 ,type)))))
whole)) which only seems to be called here: (defun random-float (generator from to)
(let ((from from)
(to to))
(when (< to from)
(rotatef from to))
(+ from (* (- to from) (random-unit generator (type-of from)))))) which likewise seems only called here: (defun random (max &optional (generator *generator*))
(macrolet ((gen (&rest types)
`(etypecase max
((integer 0)
(random-int generator 0 (1- max)))
,@(loop for (type alias) in types
for zero = (coerce 0 type)
unless (and alias (subtypep type alias))
collect `((,type ,zero)
(random-float generator ,zero max))))))
(gen (short-float single-float)
(single-float)
(double-float)
(long-float double-float)))) Otherwise, hard to say what's occurring. By extension this is also affecting anything that depends on FSet. |
@fosskers -- on Allegro, as well? Or some other CL implementation. I think Franz may have patched this issue -- incorrect use of compiler macro -- in their compiler (Allegro 11), but haven't had time to check. |
It's on Allegro 11 that I'm seeing the above issue. |
@fosskers As a workaround for FSet, you can go into |
Random-state, apparently through no fault of its own, tickles a bug in Allegro 11 having to do with the use of 'load-time-value' in a compiler macro (yow!). See: Shinmera/random-state#14
@slburson is the use of |
Personally I'd rather someone suggest a way to #+allegro fix random-state :) |
@fosskers It's just for testing. I've now pushed a reversion to FSet that switches it back to MT19937, which it used for years. @Shinmera Looking at the 1/17 comment above, I think something is badly broken in Allegro's handling of compiler macros. |
There was a bug in Allegro's handling of compiler macros. A fully-patched Allegro 11.0 should, I think, not encounter this error. @fosskers Does this error persist after |
I just loaded Unless someone else can replicate this bug in a fully-patched Allegro 11, I suggest we close it. |
I will test this as soon as I get word back from Franz about Allegro being busted on Arch. |
Turns out it's due to the new I'm able to compile both |
I ran |
The Error
Trying to compile random-state from master (put a clone in
~/quicklisp/local-projects/
gives me the following error:Possible Cause
make-generator
is invoked as a side-effect of the following line in implementation.lisp:That causes invocation of
(method %make-generator ((type symbol))
, in generator.lisp, which first tries to find the symbol named "SYSTEM" in the random-state package. It does not find this, so it falls through to(call-next-method)
which fails with the above error.Honestly, I don't know why this works on SBCL, but it does. Interestingly, when I invoke
(%make-generator :system)
at the repl in SBCL, I get the same error, which suggests that there might be something different in howworks on Allegro and SBCL.
Note that you can test on Allegro (at least the hobbyist version) by using one of the Docker images that Eric Timmons has created for the various implementations, either directly or in GitHub actions.
Also note that I have been running this on Allegro for the M1, which is brand new, so it's possible that this is a bug in the lisp implementation.
The text was updated successfully, but these errors were encountered: