From f1a92c422ab4d62eec5598cf4ac5db64658ed09e Mon Sep 17 00:00:00 2001 From: Marius Gerbershagen Date: Sun, 2 Feb 2020 16:33:41 +0100 Subject: [PATCH] cmp: Ignore compiler macros in (eval-when (:compile-toplevel)) Some of the compiler macros expand into FFI:C-INLINE forms, precluding the compilation of statements like (eval-when (:compile-toplevel :load-toplevel :execute) (print "test")). Commit b00e62f9d328662fad9b61de83a6ff6a2ae87621 (now reverted) attempted to fix this previously, but introduced other bugs (see #553). Instead of the naive solution of evaluating everything in (eval-when (:compile-toplevel)) directly with the bytecodes compiler, the approach used in this commit is to be more specific and ignore compiler macros during compile time evaluation (i.e. the output of the compiler macro is used only in the emitted C code, but not as input for CMP-EVAL). Fixes #553. --- src/cmp/cmptop.lsp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/cmp/cmptop.lsp b/src/cmp/cmptop.lsp index 122adad01..072329e45 100644 --- a/src/cmp/cmptop.lsp +++ b/src/cmp/cmptop.lsp @@ -52,8 +52,14 @@ (multiple-value-setq (fd success) (cmp-expand-macro fd form)) success)) - (push 'macroexpand *current-toplevel-form*) - (t1expr* fd)) + (when *compile-time-too* + ;; Ignore compiler macros during compile time evaluation + ;; (they may expand in ffi:c-inline which the bytecodes + ;; compiler can't execute). + (cmp-eval form)) + (let ((*compile-time-too* nil)) + (push 'macroexpand *current-toplevel-form*) + (t1expr* fd))) ((setq fd (cmp-macro-function fun)) (push 'macroexpand *current-toplevel-form*) (t1expr* (cmp-expand-macro fd form)))