Hi,
I was curious how far would ecl get when compiling sbcl and found that ecl seems to struggle with compiling local functions (error log bellow).
The problem is that the huge function parse-lambda-list being compiled has a flet (scan-opt/key) inside, which is compiled into a separate C function which does not see the other stuff, namely "volatile struct ecl_cclosure aux_closure;" is missing in the separate C function for flet scan-opt/key.
I could not find a reduced testcase but I guess this is a bug in the ecl compiler?
Tomas
=====
;;; Compiling src/compiler/parse-lambda-list.lisp. ;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=0 ;;; ;;; Compiling (DEFMACRO LAMBDA-LIST-KEYWORD-MASK ...). ;;; Compiling (DEFUN LL-KWDS-RESTP ...). ;;; Compiling (DEFUN LL-KWDS-KEYP ...). ;;; Compiling (DEFUN LL-KWDS-ALLOWP ...). ;;; Compiling (DEFUN PARSE-LAMBDA-LIST ...). ;;; Compiling (DEFUN PARSE-DS-LAMBDA-LIST ...). ;;; Compiling (DEFMACRO WITH-DS-LAMBDA-LIST-PARTS ...). ;;; Compiling (DEFUN PARSE-OPTIONAL-ARG-SPEC ...). ;;; Compiling (DEFUN PARSE-KEY-ARG-SPEC ...). ;;; Compiling (DEFUN META-ABSTRACTIFY-DS-LAMBDA-LIST ...). ;;; Compiling (DEFUN MAKE-LAMBDA-LIST ...). ;;; Compiling (DEFUN UNPARSE-DS-LAMBDA-LIST ...). ;;; Compiling (DEFUN DS-LAMBDA-LIST-VARIABLES ...). ;;; Compiling (DEFUN DS-LAMBDA-LIST-MATCH-P ...). ;;; Compiling (DEFUN DS-LAMBDA-LIST-MATCHER ...). ;;; Compiling (DEFUN EMIT-DS-LAMBDA-LIST-MATCH ...). ;;; Compiling (DEFUN EMIT-DS-BIND-CHECK ...). ;;; Compiling (DEFUN EXPAND-DS-BIND ...). ;;; Compiling (DEFUN COMPILER-MACRO-ARGS ...). ;;; Compiling (DEFUN GET-DS-BIND-CONTEXT ...). ;;; Compiling (DEFUN DS-BIND-ERROR ...). ;;; Compiling (DEFUN CHECK-DS-BIND-KEYS ...). ;;; Compiling (DEFUN CHECK-DS-LIST ...). ;;; Compiling (DEFUN CHECK-DS-LIST/&REST ...). ;;; Compiling (DEFUN CHECK-DS-LIST/&KEY ...). ;;; Compiling (DEFUN CMACRO-CHECK-DS-LIST/&KEY ...). ;;; Compiling (DEFUN DS-GETF ...). ;;; Compiling (DEF!MACRO NAMED-DS-BIND ...). ;;; Compiling (DEFUN MAKE-MACRO-LAMBDA ...). ;;; Compiling (DEFVAR *STRIP-LAMBA-LIST-RETAIN-AUX* ...). ;;; Compiling (DEFUN STRIP-LAMBDA-LIST ...). ;;; End of Pass 1. ;;; Emitting code for LAMBDA-LIST-KEYWORD-MASK. ;;; Emitting code for LL-KWDS-RESTP. ;;; Emitting code for LL-KWDS-KEYP. ;;; Emitting code for LL-KWDS-ALLOWP. ;;; Emitting code for PARSE-LAMBDA-LIST. ;;; Emitting code for CROAK. ;;; Emitting code for DEFAULTP. ;;; Emitting code for NEED-BINDABLE. ;;; Emitting code for NEED-SYMBOL. ;;; Emitting code for NEED-ARG. ;;; Emitting code for REPORT-SUSPICIOUS. ;;; Emitting code for CHECK-SUSPICIOUS. ;;; Emitting code for PROBABLY-LL-KEYWORD-P. ;;; Emitting code for DESTRUCTURING-P. ;;; Emitting code for SCAN-OPT/KEY. ;;; Emitting code for PARSE-DS-LAMBDA-LIST. ;;; Emitting code for PARSE*. ;;; Emitting code for PARSE. ;;; Emitting code for #:G116. ;;; Emitting code for #:G117. ;;; Emitting code for WITH-DS-LAMBDA-LIST-PARTS. ;;; Emitting code for PARSE-OPTIONAL-ARG-SPEC. ;;; Emitting code for PARSE-KEY-ARG-SPEC. ;;; Emitting code for META-ABSTRACTIFY-DS-LAMBDA-LIST. ;;; Emitting code for RECURSE. ;;; Emitting code for PROCESS-OPT/KEY. ;;; Emitting code for #:G175. ;;; Emitting code for MAKE-LAMBDA-LIST. ;;; Emitting code for UNPARSE-DS-LAMBDA-LIST. ;;; Emitting code for MEMOIZE. ;;; Emitting code for RECURSE. ;;; Emitting code for MAYBE-DEFAULT. ;;; Emitting code for PROCESS-OPT. ;;; Emitting code for #:G230. ;;; Emitting code for DS-LAMBDA-LIST-VARIABLES. ;;; Emitting code for SCAN. ;;; Emitting code for SUPPLIEDP-VAR. ;;; Emitting code for COPY. ;;; Emitting code for RECURSE. ;;; Emitting code for DS-LAMBDA-LIST-MATCH-P. ;;; Emitting code for RECURSE. ;;; Emitting code for DS-LAMBDA-LIST-MATCHER. ;;; Emitting code for EMIT-DS-LAMBDA-LIST-MATCH. ;;; Emitting code for EMIT-DS-BIND-CHECK. ;;; Emitting code for EXPAND-DS-BIND. ;;; Emitting code for DESCEND. ;;; Emitting code for GEN-TEST. ;;; Emitting code for BIND-IF. ;;; Emitting code for BIND-PAT. ;;; Emitting code for CAST/POP. ;;; Emitting code for COMPILER-MACRO-ARGS. ;;; Emitting code for GET-DS-BIND-CONTEXT. ;;; Emitting code for DS-BIND-ERROR. ;;; Emitting code for CHECK-DS-BIND-KEYS. ;;; Emitting code for CHECK-DS-LIST. ;;; Emitting code for CHECK-DS-LIST/&REST. ;;; Emitting code for CHECK-DS-LIST/&KEY. ;;; Emitting code for CMACRO-CHECK-DS-LIST/&KEY. ;;; Emitting code for DS-GETF. ;;; Emitting code for NAMED-DS-BIND. ;;; Emitting code for MAKE-MACRO-LAMBDA. ;;; Emitting code for #:G485. ;;; Emitting code for STRIP-LAMBDA-LIST. ;;; Emitting code for #:G489. ;;; Emitting code for #:G509. In file included from /nix/store/4ha569nsijgnp7ywq89prpn6643h132m-ecl-16.1.2/include/ecl/ecl.h:84:0, from /nix/store/4ha569nsijgnp7ywq89prpn6643h132m-ecl-16.1.2/include/ecl/ecl-cmp.h:29, from obj/from-host/src/compiler/parse-lambda-list.c:5: obj/from-host/src/compiler/parse-lambda-list.c: In function 'LC14scan_opt_key': obj/from-host/src/compiler/parse-lambda-list.c:1222:15: error: 'aux_closure' undeclared (first use in this function) if (Null((aux_closure.env=env0,cl_env_copy->function=(cl_object)&aux_closure,LC12defaultp(2, v5arg, v2what_kind)))) { goto L8; } ^ /nix/store/4ha569nsijgnp7ywq89prpn6643h132m-ecl-16.1.2/include/ecl/cons.h:27:27: note: in definition of macro 'Null' #define Null(x) ((x)==ECL_NIL) ^ obj/from-host/src/compiler/parse-lambda-list.c:1222:15: note: each undeclared identifier is reported only once for each function it appears in if (Null((aux_closure.env=env0,cl_env_copy->function=(cl_object)&aux_closure,LC12defaultp(2, v5arg, v2what_kind)))) { goto L8; } ^ /nix/store/4ha569nsijgnp7ywq89prpn6643h132m-ecl-16.1.2/include/ecl/cons.h:27:27: note: in definition of macro 'Null' #define Null(x) ((x)==ECL_NIL) ^ obj/from-host/src/compiler/parse-lambda-list.c:1222:31: error: 'env0' undeclared (first use in this function) if (Null((aux_closure.env=env0,cl_env_copy->function=(cl_object)&aux_closure,LC12defaultp(2, v5arg, v2what_kind)))) { goto L8; } ^ /nix/store/4ha569nsijgnp7ywq89prpn6643h132m-ecl-16.1.2/include/ecl/cons.h:27:27: note: in definition of macro 'Null' #define Null(x) ((x)==ECL_NIL) ^ ;;; Internal error: ;;; ** Error code 1 when executing ;;; (RUN-PROGRAM "gcc" ("-I." "-I/nix/store/4ha569nsijgnp7ywq89prpn6643h132m-ecl-16.1.2/include/" "-I/nix/store/6f3nbgg28xxyq2mdzdxl0j06dry90sgl-gmp-5.1.3/include" "-I/nix/store/nnjvmplfmzpc22ls4p9h4c7c61rppzc5-libffi-3.2.1/include" "-D_GNU_SOURCE" ...)) Condition of type: SIMPLE-ERROR couldn't compile "src/compiler/parse-lambda-list.lisp"
Available restarts:
1. (RESTART-TOPLEVEL) Go back to Top-Level REPL.
Broken at SB-COLD::LOAD-OR-CLOAD-XCOMPILER. In: #<process TOP-LEVEL>. File: #P"/tmp/nix-build-sbcl-1.3.3.drv-0/sbcl-1.3.3/src/cold/defun-load-or-cload-xcompiler.lisp" (Position #1305)
Hej, I believe I've fixed this bug recently. Could you check with the git head version?
Regards, Daniel
Dnia 7 kwietnia 2016 23:36:59 CEST, Tomas Hlavaty tom@logand.com napisał(a):
Hi,
I was curious how far would ecl get when compiling sbcl and found that ecl seems to struggle with compiling local functions (error log bellow).
The problem is that the huge function parse-lambda-list being compiled has a flet (scan-opt/key) inside, which is compiled into a separate C function which does not see the other stuff, namely "volatile struct ecl_cclosure aux_closure;" is missing in the separate C function for flet scan-opt/key.
I could not find a reduced testcase but I guess this is a bug in the ecl compiler?
Tomas
=====
;;; Compiling src/compiler/parse-lambda-list.lisp. ;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=0 ;;; ;;; Compiling (DEFMACRO LAMBDA-LIST-KEYWORD-MASK ...). ;;; Compiling (DEFUN LL-KWDS-RESTP ...). ;;; Compiling (DEFUN LL-KWDS-KEYP ...). ;;; Compiling (DEFUN LL-KWDS-ALLOWP ...). ;;; Compiling (DEFUN PARSE-LAMBDA-LIST ...). ;;; Compiling (DEFUN PARSE-DS-LAMBDA-LIST ...). ;;; Compiling (DEFMACRO WITH-DS-LAMBDA-LIST-PARTS ...). ;;; Compiling (DEFUN PARSE-OPTIONAL-ARG-SPEC ...). ;;; Compiling (DEFUN PARSE-KEY-ARG-SPEC ...). ;;; Compiling (DEFUN META-ABSTRACTIFY-DS-LAMBDA-LIST ...). ;;; Compiling (DEFUN MAKE-LAMBDA-LIST ...). ;;; Compiling (DEFUN UNPARSE-DS-LAMBDA-LIST ...). ;;; Compiling (DEFUN DS-LAMBDA-LIST-VARIABLES ...). ;;; Compiling (DEFUN DS-LAMBDA-LIST-MATCH-P ...). ;;; Compiling (DEFUN DS-LAMBDA-LIST-MATCHER ...). ;;; Compiling (DEFUN EMIT-DS-LAMBDA-LIST-MATCH ...). ;;; Compiling (DEFUN EMIT-DS-BIND-CHECK ...). ;;; Compiling (DEFUN EXPAND-DS-BIND ...). ;;; Compiling (DEFUN COMPILER-MACRO-ARGS ...). ;;; Compiling (DEFUN GET-DS-BIND-CONTEXT ...). ;;; Compiling (DEFUN DS-BIND-ERROR ...). ;;; Compiling (DEFUN CHECK-DS-BIND-KEYS ...). ;;; Compiling (DEFUN CHECK-DS-LIST ...). ;;; Compiling (DEFUN CHECK-DS-LIST/&REST ...). ;;; Compiling (DEFUN CHECK-DS-LIST/&KEY ...). ;;; Compiling (DEFUN CMACRO-CHECK-DS-LIST/&KEY ...). ;;; Compiling (DEFUN DS-GETF ...). ;;; Compiling (DEF!MACRO NAMED-DS-BIND ...). ;;; Compiling (DEFUN MAKE-MACRO-LAMBDA ...). ;;; Compiling (DEFVAR *STRIP-LAMBA-LIST-RETAIN-AUX* ...). ;;; Compiling (DEFUN STRIP-LAMBDA-LIST ...). ;;; End of Pass 1. ;;; Emitting code for LAMBDA-LIST-KEYWORD-MASK. ;;; Emitting code for LL-KWDS-RESTP. ;;; Emitting code for LL-KWDS-KEYP. ;;; Emitting code for LL-KWDS-ALLOWP. ;;; Emitting code for PARSE-LAMBDA-LIST. ;;; Emitting code for CROAK. ;;; Emitting code for DEFAULTP. ;;; Emitting code for NEED-BINDABLE. ;;; Emitting code for NEED-SYMBOL. ;;; Emitting code for NEED-ARG. ;;; Emitting code for REPORT-SUSPICIOUS. ;;; Emitting code for CHECK-SUSPICIOUS. ;;; Emitting code for PROBABLY-LL-KEYWORD-P. ;;; Emitting code for DESTRUCTURING-P. ;;; Emitting code for SCAN-OPT/KEY. ;;; Emitting code for PARSE-DS-LAMBDA-LIST. ;;; Emitting code for PARSE*. ;;; Emitting code for PARSE. ;;; Emitting code for #:G116. ;;; Emitting code for #:G117. ;;; Emitting code for WITH-DS-LAMBDA-LIST-PARTS. ;;; Emitting code for PARSE-OPTIONAL-ARG-SPEC. ;;; Emitting code for PARSE-KEY-ARG-SPEC. ;;; Emitting code for META-ABSTRACTIFY-DS-LAMBDA-LIST. ;;; Emitting code for RECURSE. ;;; Emitting code for PROCESS-OPT/KEY. ;;; Emitting code for #:G175. ;;; Emitting code for MAKE-LAMBDA-LIST. ;;; Emitting code for UNPARSE-DS-LAMBDA-LIST. ;;; Emitting code for MEMOIZE. ;;; Emitting code for RECURSE. ;;; Emitting code for MAYBE-DEFAULT. ;;; Emitting code for PROCESS-OPT. ;;; Emitting code for #:G230. ;;; Emitting code for DS-LAMBDA-LIST-VARIABLES. ;;; Emitting code for SCAN. ;;; Emitting code for SUPPLIEDP-VAR. ;;; Emitting code for COPY. ;;; Emitting code for RECURSE. ;;; Emitting code for DS-LAMBDA-LIST-MATCH-P. ;;; Emitting code for RECURSE. ;;; Emitting code for DS-LAMBDA-LIST-MATCHER. ;;; Emitting code for EMIT-DS-LAMBDA-LIST-MATCH. ;;; Emitting code for EMIT-DS-BIND-CHECK. ;;; Emitting code for EXPAND-DS-BIND. ;;; Emitting code for DESCEND. ;;; Emitting code for GEN-TEST. ;;; Emitting code for BIND-IF. ;;; Emitting code for BIND-PAT. ;;; Emitting code for CAST/POP. ;;; Emitting code for COMPILER-MACRO-ARGS. ;;; Emitting code for GET-DS-BIND-CONTEXT. ;;; Emitting code for DS-BIND-ERROR. ;;; Emitting code for CHECK-DS-BIND-KEYS. ;;; Emitting code for CHECK-DS-LIST. ;;; Emitting code for CHECK-DS-LIST/&REST. ;;; Emitting code for CHECK-DS-LIST/&KEY. ;;; Emitting code for CMACRO-CHECK-DS-LIST/&KEY. ;;; Emitting code for DS-GETF. ;;; Emitting code for NAMED-DS-BIND. ;;; Emitting code for MAKE-MACRO-LAMBDA. ;;; Emitting code for #:G485. ;;; Emitting code for STRIP-LAMBDA-LIST. ;;; Emitting code for #:G489. ;;; Emitting code for #:G509. In file included from /nix/store/4ha569nsijgnp7ywq89prpn6643h132m-ecl-16.1.2/include/ecl/ecl.h:84:0, from /nix/store/4ha569nsijgnp7ywq89prpn6643h132m-ecl-16.1.2/include/ecl/ecl-cmp.h:29, from obj/from-host/src/compiler/parse-lambda-list.c:5: obj/from-host/src/compiler/parse-lambda-list.c: In function 'LC14scan_opt_key': obj/from-host/src/compiler/parse-lambda-list.c:1222:15: error: 'aux_closure' undeclared (first use in this function) if (Null((aux_closure.env=env0,cl_env_copy->function=(cl_object)&aux_closure,LC12defaultp(2, v5arg, v2what_kind)))) { goto L8; } ^ /nix/store/4ha569nsijgnp7ywq89prpn6643h132m-ecl-16.1.2/include/ecl/cons.h:27:27: note: in definition of macro 'Null' #define Null(x) ((x)==ECL_NIL) ^ obj/from-host/src/compiler/parse-lambda-list.c:1222:15: note: each undeclared identifier is reported only once for each function it appears in if (Null((aux_closure.env=env0,cl_env_copy->function=(cl_object)&aux_closure,LC12defaultp(2, v5arg, v2what_kind)))) { goto L8; } ^ /nix/store/4ha569nsijgnp7ywq89prpn6643h132m-ecl-16.1.2/include/ecl/cons.h:27:27: note: in definition of macro 'Null' #define Null(x) ((x)==ECL_NIL) ^ obj/from-host/src/compiler/parse-lambda-list.c:1222:31: error: 'env0' undeclared (first use in this function) if (Null((aux_closure.env=env0,cl_env_copy->function=(cl_object)&aux_closure,LC12defaultp(2, v5arg, v2what_kind)))) { goto L8; } ^ /nix/store/4ha569nsijgnp7ywq89prpn6643h132m-ecl-16.1.2/include/ecl/cons.h:27:27: note: in definition of macro 'Null' #define Null(x) ((x)==ECL_NIL) ^ ;;; Internal error: ;;; ** Error code 1 when executing ;;; (RUN-PROGRAM "gcc" ("-I." "-I/nix/store/4ha569nsijgnp7ywq89prpn6643h132m-ecl-16.1.2/include/" "-I/nix/store/6f3nbgg28xxyq2mdzdxl0j06dry90sgl-gmp-5.1.3/include" "-I/nix/store/nnjvmplfmzpc22ls4p9h4c7c61rppzc5-libffi-3.2.1/include" "-D_GNU_SOURCE" ...)) Condition of type: SIMPLE-ERROR couldn't compile "src/compiler/parse-lambda-list.lisp"
Available restarts:
- (RESTART-TOPLEVEL) Go back to Top-Level REPL.
Broken at SB-COLD::LOAD-OR-CLOAD-XCOMPILER. In: #<process TOP-LEVEL>. File: #P"/tmp/nix-build-sbcl-1.3.3.drv-0/sbcl-1.3.3/src/cold/defun-load-or-cload-xcompiler.lisp" (Position #1305)
Hi Daniel,
Hej, I believe I've fixed this bug recently. Could you check with the git head version?
yes it is fixed there, thank you!
Getting further, the next error is:
;;; Compiling (DEFUN EVENT-STATISTICS ...). ;;; Error: ;;; in file macros.lisp, position 41357 ;;; at (DEFUN EVENT-STATISTICS ...) ;;; * The macro form (INFO V) was not expanded successfully. ;;; Error detected: ;;; Too few arguments supplied to a macro or a destructuring-bind form: ;;; (INFO V) Condition of type: SIMPLE-ERROR couldn't compile "src/compiler/macros.lisp" Broken at SB-COLD::LOAD-OR-CLOAD-XCOMPILER. In: #<process TOP-LEVEL>. File: #P"/tmp/nix-build-sbcl-1.3.4.drv-1/sbcl-1.3.1/src/cold/defun-load-or-cload-xcompiler.lisp" (Position #974)
The info in macrolet has (&rest args) so "Too few arguments" error should not happen. There also exists a function info with three arguments in the sbcl sources so it might be that it somehow clashes with the macrolet info. If I extract all relevant code for event-statistics, it does compile without problems even if I define a potentially "clashing" defun info with three args. Not sure how to get simpler testcase than compiling sbcl.
Tomas
Hey Tomas,
thanks for this report. I've put it on the gitlab to investigate it later. I've added it here: https://gitlab.com/embeddable-common-lisp/ecl/issues/237 .
Regards, Daniel
Tomas Hlavaty writes:
Hi Daniel,
Hej, I believe I've fixed this bug recently. Could you check with the git head version?
yes it is fixed there, thank you!
Getting further, the next error is:
;;; Compiling (DEFUN EVENT-STATISTICS ...). ;;; Error: ;;; in file macros.lisp, position 41357 ;;; at (DEFUN EVENT-STATISTICS ...) ;;; * The macro form (INFO V) was not expanded successfully. ;;; Error detected: ;;; Too few arguments supplied to a macro or a destructuring-bind form: ;;; (INFO V) Condition of type: SIMPLE-ERROR couldn't compile "src/compiler/macros.lisp" Broken at SB-COLD::LOAD-OR-CLOAD-XCOMPILER. In: #<process TOP-LEVEL>. File: #P"/tmp/nix-build-sbcl-1.3.4.drv-1/sbcl-1.3.1/src/cold/defun-load-or-cload-xcompiler.lisp" (Position #974)
The info in macrolet has (&rest args) so "Too few arguments" error should not happen. There also exists a function info with three arguments in the sbcl sources so it might be that it somehow clashes with the macrolet info. If I extract all relevant code for event-statistics, it does compile without problems even if I define a potentially "clashing" defun info with three args. Not sure how to get simpler testcase than compiling sbcl.
Tomas