Skip to content
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

On CCL, compiler-macros are invoked before loading magicl/ext-blas but not after it #178

Open
digikar99 opened this issue Sep 1, 2022 · 0 comments

Comments

@digikar99
Copy link

digikar99 commented Sep 1, 2022

EDIT: I'm able to boil down the issue to the loading of src/bindings/blas-cffi.lisp, and in particular:

(COMMON-LISP:DECLAIM
 (COMMON-LISP:OPTIMIZE (COMMON-LISP:SPEED 0) COMMON-LISP:SAFETY
  COMMON-LISP:DEBUG COMMON-LISP:COMPILATION-SPEED))

CLHS states:

As with other defining macros, it is unspecified whether or not the compile-time side-effects of a declaim persist after the file has been compiled.

So, it seems the responsibility to revert back the compilation policy to as they were before the file was loaded rests with the file. introspect-environment:policy-quality might be handy:

CL-USER> (mapcar (lambda (quality)
                   (cons quality (introspect-environment:policy-quality quality)))
                 '(speed safety debug compilation-speed))
((SPEED . 1) (SAFETY . 1) (DEBUG . 1) (COMPILATION-SPEED . 1))
CL-USER> (ql:quickload "magicl/ext-blas")
To load "magicl/ext-blas":
  Load 1 ASDF system:
    magicl/ext-blas
; Loading "magicl/ext-blas"

("magicl/ext-blas")
CL-USER> (mapcar (lambda (quality)
                   (cons quality (introspect-environment:policy-quality quality)))
                 '(speed safety debug compilation-speed))
((SPEED . 0) (SAFETY . 3) (DEBUG . 3) (COMPILATION-SPEED . 3))

ORIGINAL POST:

This definitely seems like a weird issue, but:

CL-USER> (defun fun () 'runtime-fun)
(define-compiler-macro fun () (print :invoked) ''compile-time-fun)
(defun bar () (fun))

:INVOKED
BAR
CL-USER> (ql:quickload "magicl/ext")
To load "magicl/ext":
  Load 1 ASDF system:
    magicl/ext
; Loading "magicl/ext"

("magicl/ext")
CL-USER> (defun fun () 'runtime-fun)
(define-compiler-macro fun () (print :invoked) ''compile-time-fun)
(defun bar () (fun))

:INVOKED
BAR
CL-USER> (ql:quickload "magicl/ext-blas")
To load "magicl/ext-blas":
  Load 1 ASDF system:
    magicl/ext-blas
; Loading "magicl/ext-blas"

("magicl/ext-blas")
CL-USER> (defun fun () 'runtime-fun)
(define-compiler-macro fun () (print :invoked) ''compile-time-fun)
(defun bar () (fun))
BAR
CL-USER> (bar)
RUNTIME-FUN
CL-USER> (lisp-implementation-version)
"Version 1.12.1 (v1.12.1) LinuxX8664"
CL-USER> (lisp-implementation-type)
"Clozure Common Lisp"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant