Opened 15 years ago
Closed 15 years ago
#113 closed defect (fixed)
Crunch egg: bug in define-crunch-primitives / define-crunch-callback
Reported by: | Jeronimo Pellegrini | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | extensions | Version: | 4.2.x |
Keywords: | crunch | Cc: | |
Estimated difficulty: |
Description
In line 78 of crunch.scm , pair? is called with two arguments:
(and (pair? (car p) (c (r '+>) (cadr p)))))))
The version of Crunch is svn trunk (but that line is the same in version 0.7.2). I tested it with Chicken from git, commit 43a11082ddc109bfe1b4fdb400b6079ca64d024a
The following is a report of my attempt to debug the problem; since I'm new to Chicken Scheme, I may have made several silly mistakes along the way...
The following code (crunch-bug.scm) does not compile (I suppose I undertood how to use define-crunch-primitives and define-crunch-callback):
(cond-expand (crunched (import crunch)) (else (define-syntax crunch (syntax-rules () ((_ body ...) (begin (display "Crunch not working") body ...) ) ) ) ) ) (define-crunch-primitives ((foo int) -> void)) (define-crunch-callback (foo (int i)) void (display (format "Here's your int: ~a ~%" i))) (crunch (define work (lambda (max) (do ((k 0 (+ k 1))) ((>= k max)) (foo k)))) ) (work 10)
I tried fixing line 78 of crunch.scm, changing it to:
(and (pair? (car p) (c (r '+>) (cadr p)))))))
But then the code and declarations for the function (foo in the example above) are not generated properly in the C++ file:
$ csc -c++ -D crunched crunch-bug.scm Warning: reference to variable `unquote' possibly unintended crunch-bug.cpp: In function ‘type37 f36(type35)’: crunch-bug.cpp:58: error: ‘crunch_callback14’ was not declared in this scope crunch-bug.cpp: In function ‘void C_toplevel(long int, long int, long int)’:
That function is used in line 58 of the C++ file (I know line numbers in generated C++ could perhaps vary from my setup to others, but this is just to show the relative order of lines):
type55 t56 = crunch_callback14(t54);
but is only declared in line 76:
C_externexport void crunch_callback14(int t0);
And defined in line 135:
void crunch_callback14(int t0){ ... }
OK, so I manually added a declaration at the top of the file:
C_externexport void crunch_callback14(int t0);
and got this error:
crunch-bug.cpp: In function ‘type37 f36(type35)’: crunch-bug.cpp:62: error: conversion from ‘void’ to non-scalar type ‘type55’ requested
OK. It won't return anything, so I changed the function call from
type55 t56 = crunch_callback14(t54);
to:
crunch_callback14(t54);
(And verified that t56 is *not* referenced at all in the C++ code).
And, HEY, it compiles!!!
But the generated binary doesn't work:
$ g++ crunch-bug.o -lchicken $ ./crunch-bug Error: unbound variable: r Call history: r <--
I suppose this is the r here, in line 60 of crunch.scm:
(define-syntax (define-crunch-primitives x r c)
But I wasn't able to debug further.
Change History (25)
comment:1 Changed 15 years ago by
comment:2 Changed 15 years ago by
Thanks for reporting the bug. I have found another one related to callbacks and the following code compiles and executes for me:
(import crunch) (define-crunch-callback (foo (int i)) int (display (format "Here's your int: ~a ~%" i)) 0) (crunch (define (work max) (do ((k 0 (+ k 1))) ((>= k max)) (foo k)))) (work 10)
Version 0.7.3, just updated.
Note that the void
return-type for foo
is currently not working, I'll look into this as soon as I find the time.
comment:3 follow-up: 4 Changed 15 years ago by
Hi Felix,
The code you showed doesn't compile here (?)
I've updated crunch to 0.7.3, but
new-crunch-bug.cpp: In function ‘type32 f31(type30)’: new-crunch-bug.cpp:58: error: ‘crunch_callback8’ was not declared in this scope new-crunch-bug.cpp: In function ‘void C_toplevel(long int, long int, long int)’:
but crunch_callback8 is only declared in line 78.
Line 58 is:
type50 t51 = crunch_callback8(t49); // foo
I have put the declaration of crunch_callback8 at the top of the C++ file, and then it worked perfectly!
$ g++ -o new-crunch-bug -lchicken new-crunch-bug.o $ ./new-crunch-bug Here's your int: 0 Here's your int: 1 Here's your int: 2 Here's your int: 3 Here's your int: 4 Here's your int: 5 Here's your int: 6 Here's your int: 7 Here's your int: 8 Here's your int: 9
So, the only remaining issue seems to be that callbacks are not declared before they are used. (But maybe this depends on local setup? You said it worked for you)
As to the void problem, that's OK -- I can make all my callbacks return ints. :-)
comment:4 Changed 15 years ago by
Replying to jeronimo:
So, the only remaining issue seems to be that callbacks are not declared before they are used. (But maybe this depends on local setup? You said it worked for you)
Sorry, I forgot to mention that you should pass -emit-external-prototypes-first
to the compiler. It's a horrible hack, but it addresses exactly this problem.
As to the void problem, that's OK -- I can make all my callbacks return ints. :-)
That shouldn't be too hard to fix (but I don't know fir sure - crunch is a bit complicated).
comment:5 Changed 15 years ago by
Sorry, I forgot to mention that you should pass -emit-external-prototypes-first to the compiler.
OK, it works now!
Thanks a lot! :-)
comment:6 follow-up: 7 Changed 15 years ago by
BTW, since you mentioned that Crunch is kind of complicated, I suppose it would be difficult to make it accept more types as arguments for callbacks?
I'd like to do something like this:
;; m if a heterogeneous vector of f64vectors (define-crunch-callback (vector->f64vector-ref (SOME-TYPE m) (int i)) f64vector (vector-ref m i))
This is to compare different multidimensional matrix implementations (either as a single vector, or as vector-of-vectors). In the vector-of-vectors case, I'd have to use heterogeneous vectors in all dimensions but the last:
vector of vector of vector of f64vector
(This is because I have some evidence that it may actually be quite fast)
But I could not get it to work: I've tried c-pointer and blob as "SOME-TYPE" above. blob is not allowed that, and if I use c-pointer, the code compiles but later complains (at execution time) that the Scheme vector is not a c-pointer.
comment:7 Changed 15 years ago by
Replying to jeronimo:
(Sorry, I totally forgot about this ticket)
BTW, since you mentioned that Crunch is kind of complicated, I suppose it would be difficult to make it accept more types as arguments for callbacks?
I'd like to do something like this:
;; m if a heterogeneous vector of f64vectors (define-crunch-callback (vector->f64vector-ref (SOME-TYPE m) (int i)) f64vector (vector-ref m i))This is to compare different multidimensional matrix implementations (either as a single vector, or as vector-of-vectors). In the vector-of-vectors case, I'd have to use heterogeneous vectors in all dimensions but the last:
vector of vector of vector of f64vector
(This is because I have some evidence that it may actually be quite fast)
But I could not get it to work: I've tried c-pointer and blob as "SOME-TYPE" above. blob is not allowed that, and if I use c-pointer, the code compiles but later complains (at execution time) that the Scheme vector is not a c-pointer.
crunch has its own type-system and does not handle Scheme data well (since it generates a more or less direct translation to C++, it uses C++ data types). When I find the time, I'll try to look into this.
(Note that chicken 4.3.2 has heavily improved floating-point performance, particularly for unboxed SRFI-4 vectors, when compiled in unsafe mode)
comment:8 follow-up: 9 Changed 15 years ago by
crunch has its own type-system and does not handle Scheme data well (since it generates a more or less direct translation to C++, it uses C++ data types).
OK, I understand what you mean.
By the way, it seems that with current git HEAD, crunch doesn't compile loops properly.
The example in http://chicken.wiki.br/eggref/4/crunch fails (my other attempts to compile do-loops and named lets failed in the same way -- crunch claims that I've put a loop variable not in a tail position):
$ csc -o crunch-example -D crunched -c++ crunch-example.scm Error: during expansion of (crunch ...) - [crunch] (in string-reverse) call to loop variable not in tail position: doloop context: (define string-reverse ...) (let () ...) (let ((n (string-length str))) ...) (let ((s2 (make-string n #\space))) ...) (let ((i 0)) ...) (if (>= i n) ...) (doloop (add1 i)) Call history: <syntax> (##core#begin (crunch (define (string-reverse str) (let* ((n (string-length str)) (s2 (make-string n... <syntax> (crunch (define (string-reverse str) (let* ((n (string-length str)) (s2 (make-string n #\space))) (do... <-- Error: shell command terminated with non-zero exit status 17920: /usr/local/bin/chicken crunch-example.scm -output-file crunch-example.cpp -feature crunched
I just copied and paster the example from the doc page into crunch-example.scm, without changes.
comment:9 Changed 15 years ago by
Replying to jeronimo:
By the way, it seems that with current git HEAD, crunch doesn't compile loops properly.
The example in http://chicken.wiki.br/eggref/4/crunch fails (my other attempts to compile do-loops and named lets failed in the same way -- crunch claims that I've put a loop variable not in a tail position):
I cannot reproduce this. Which example are you using exactly?
comment:10 follow-up: 11 Changed 15 years ago by
Hi Felix,
This is what I've tried to compile:
(use crunch) (crunch (define (string-reverse str) (let* ((n (string-length str)) (s2 (make-string n #\space))) (do ((i 0 (add1 i))) ((>= i n)) (string-set! s2 (sub1 (- n i)) (string-ref str i))) s2)) ) (print (string-reverse "this is a test!"))
comment:11 Changed 15 years ago by
Replying to jeronimo:
Hi Felix,
This is what I've tried to compile:
(use crunch) (crunch (define (string-reverse str) (let* ((n (string-length str)) (s2 (make-string n #\space))) (do ((i 0 (add1 i))) ((>= i n)) (string-set! s2 (sub1 (- n i)) (string-ref str i))) s2)) ) (print (string-reverse "this is a test!"))
Can you try the HEAD of the experimental
git branch + svn trunk of crunch?
comment:12 follow-up: 13 Changed 15 years ago by
Hi Felix,
The same thing happened with experimental/HEAD and crunch from svn trunk.
I uninstalled both chicken and all eggs, then compiled from experimental, then reinstalled all eggs except crunch. Then installed crunch from the svn directory
(after doing svn up). Then tried to compile the example, and the same error message
showed up:
Error: during expansion of (crunch ...) - [crunch] (in string-reverse) call to loop variable not in tail position: doloop
comment:13 Changed 15 years ago by
Replying to jeronimo:
The same thing happened with experimental/HEAD and crunch from svn trunk.
I uninstalled both chicken and all eggs, then compiled from experimental, then reinstalled all eggs except crunch. Then installed crunch from the svn directory
(after doing svn up). Then tried to compile the example, and the same error message
showed up:
Can you attach the output of chicken-bug
? And are you using the crunch trunk or the latest tag (0.7.4)? (sorry for the dumb questions, but I'm a bit at a loss here). Please also attach the example file you are compiling and give me the output of
csc -compiler "chicken -:d" -c++ <example>.scm
What's the output of running sh tests.sh
?
comment:14 Changed 15 years ago by
Hi Felix!
I installed testeez and run the test.sh script in 4/crunch/trunk:
sh tests.sh [crunch] compiling *TOPLEVEL* ... [crunch] compiling fac ... [crunch] global: fac = ((number) -> int) [crunch] references: (* sub1 zero?) [crunch] compiling *TOPLEVEL* ... [crunch] compiling tak ... [crunch] global: tak = ((int int int) -> int) [crunch] references: (- not <) [crunch] compiling *TOPLEVEL* ... [crunch] compiling loop ... Error: during expansion of (crunch ...) - [crunch] (in loop) call to loop variable not in tail position: doloop context: (define loop ...) (let () ...) (let ((count 0)) ...) (let ((n m)) ...) (if (zero? n) ...) (doloop (sub1 n)) Call history: <syntax> (begin197 (testeez#%testeez:start-test data21 "simple loop" (quote198 (let () (crunch (define (loop m... <syntax> (testeez#%testeez:start-test data21 "simple loop" (quote198 (let () (crunch (define (loop m) (let ((...... <syntax> (quote198 (let () (crunch (define (loop m) (let ((count 0)) (do ((n m (sub1 n))) ((zero? n) (newline...... <syntax> (let199 ((result-list200 (#%call-with-values (lambda201 () (let () (crunch (define (loop m) (let ((c...... <syntax> (#%call-with-values (lambda201 () (let () (crunch (define (loop m) (let ((count 0)) (do ((n m (sub1 n... <syntax> (lambda201 () (let () (crunch (define (loop m) (let ((count 0)) (do ((n m (sub1 n))) ((zero? n) (new...... <syntax> (##core#begin (let () (crunch (define (loop m) (let ((count 0)) (do ((n m (sub1 n))) ((zero? n) (new...... <syntax> (let () (crunch (define (loop m) (let ((count 0)) (do ((n m (sub1 n))) ((zero? n) (newline)) (write-...... <-- Error: shell command terminated with non-zero exit status 17920: /usr/local/bin/chicken tests.sh -output-file a.cpp -feature DBGALLOC -feature crunch-debug
The output from chicken-bug is:
-------------------------------------------------- This is a bug report generated by chicken-bug(1). Date: Tue Feb 16 06:45:58 2010 User information: ("jeronimo" "x" 1001 1001 "Jeronimo Pellegrini" "/home/jeronimo" "/bin/bash") Host information: machine type: x86-64 software type: unix software version: linux build platform: gnu CHICKEN version is: Version 4.3.5 (experimental) linux-unix-gnu-x86-64 [ 64bit manyargs ptables ] compiled 2010-02-15 on newton (Linux) Home directory: /usr/local/share/chicken Include path: ("/usr/local/share/chicken") Features: chicken chicken-4 data-structures extras files gnu hygienic-macros irregex linux little-endian manyargs ports posix ptables regex srfi-0 srfi-10 srfi-12 srfi-13 srfi-14 srfi-17 srfi-2 srfi-23 srfi-28 srfi-30 srfi-39 srfi-55 srfi-6 srfi-61 srfi-62 srfi-8 srfi-88 srfi-9 srfi-98 syntax-rules tcp unix utils x86-64 chicken-config.h: #define HAVE_DIRENT_H 1 #define HAVE_DLFCN_H 1 #define HAVE_INTTYPES_H 1 #define HAVE_LIMITS_H 1 #define HAVE_LONG_LONG 1 #define HAVE_MEMMOVE 1 #define HAVE_MEMORY_H 1 #define HAVE_STDINT_H 1 #define HAVE_STDLIB_H 1 #define HAVE_STRERROR 1 #define HAVE_STRINGS_H 1 #define HAVE_STRING_H 1 #define HAVE_STRTOLL 1 #define HAVE_STRTOQ 1 #define HAVE_SYS_STAT_H 1 #define HAVE_SYS_TYPES_H 1 #define HAVE_UNISTD_H 1 #define HAVE_UNSIGNED_LONG_LONG 1 #define STDC_HEADERS 1 #define HAVE_ALLOCA 1 #define HAVE_ALLOCA_H 1 #define HAVE_GRP_H 1 #define HAVE_ERRNO_H 1 #define HAVE_GCVT 1 #define HAVE_SYSEXITS_H 1 #define HAVE_MEMMOVE 1 #define C_STACK_GROWS_DOWNWARD 1 #define C_HACKED_APPLY /* generated */ #define C_BUILD_TAG "compiled 2010-02-15 on newton (Linux)" #define C_CHICKEN_PROGRAM "chicken" #ifndef C_INSTALL_CC # define C_INSTALL_CC "gcc" #endif #ifndef C_INSTALL_CXX # define C_INSTALL_CXX "g++" #endif #ifndef C_INSTALL_CFLAGS # define C_INSTALL_CFLAGS "-fno-strict-aliasing -DHAVE_CHICKEN_CONFIG_H -DC_ENABLE_PTABLES -O3 -fomit-frame-pointer" #endif #ifndef C_INSTALL_LDFLAGS # define C_INSTALL_LDFLAGS " " #endif #ifndef C_INSTALL_PREFIX # define C_INSTALL_PREFIX "/usr/local" #endif #ifndef C_INSTALL_SHARE_HOME # define C_INSTALL_SHARE_HOME "/usr/local/share/chicken" #endif #ifndef C_INSTALL_BIN_HOME # define C_INSTALL_BIN_HOME "/usr/local/bin" #endif #ifndef C_INSTALL_EGG_HOME # define C_INSTALL_EGG_HOME "/usr/local/lib/chicken/5" #endif #ifndef C_INSTALL_LIB_HOME # define C_INSTALL_LIB_HOME "/usr/local/lib" #endif #ifndef C_INSTALL_STATIC_LIB_HOME # define C_INSTALL_STATIC_LIB_HOME "/usr/local/lib" #endif #ifndef C_INSTALL_INCLUDE_HOME # define C_INSTALL_INCLUDE_HOME "/usr/local/include" #endif #ifndef C_INSTALL_MORE_LIBS # define C_INSTALL_MORE_LIBS "-lm -ldl" #endif #ifndef C_INSTALL_MORE_STATIC_LIBS # define C_INSTALL_MORE_STATIC_LIBS "-lm -ldl" #endif #ifndef C_DEFAULT_TARGET_STACK_SIZE # define C_DEFAULT_TARGET_STACK_SIZE (256*1024) #endif #ifndef C_DEFAULT_TARGET_HEAP_SIZE # define C_DEFAULT_TARGET_HEAP_SIZE 0 #endif #ifndef C_STACK_GROWS_DOWNWARD # define C_STACK_GROWS_DOWNWARD 1 #endif #ifndef C_TARGET_MORE_LIBS # define C_TARGET_MORE_LIBS "-lm -ldl" #endif #ifndef C_TARGET_MORE_STATIC_LIBS # define C_TARGET_MORE_STATIC_LIBS "-lm -ldl" #endif #ifndef C_TARGET_CC # define C_TARGET_CC "gcc" #endif #ifndef C_TARGET_CXX # define C_TARGET_CXX "g++" #endif #ifndef C_TARGET_CFLAGS # define C_TARGET_CFLAGS "-fno-strict-aliasing -DHAVE_CHICKEN_CONFIG_H -DC_ENABLE_PTABLES -O3 -fomit-frame-pointer" #endif #ifndef C_TARGET_LDFLAGS # define C_TARGET_LDFLAGS " " #endif #ifndef C_CROSS_CHICKEN # define C_CROSS_CHICKEN 0 #endif #ifndef C_TARGET_BIN_HOME # define C_TARGET_BIN_HOME "/usr/local/bin" #endif #ifndef C_TARGET_LIB_HOME # define C_TARGET_LIB_HOME "/usr/local/lib" #endif #ifndef C_TARGET_RUN_LIB_HOME # define C_TARGET_RUN_LIB_HOME "/usr/local/lib" #endif #ifndef C_TARGET_SHARE_HOME # define C_TARGET_SHARE_HOME "/usr/local/share" #endif #ifndef C_TARGET_INCLUDE_HOME # define C_TARGET_INCLUDE_HOME "/usr/local/include" #endif #ifndef C_TARGET_STATIC_LIB_HOME # define C_TARGET_STATIC_LIB_HOME "/usr/local/lib" #endif #ifndef C_CHICKEN_PROGRAM # define C_CHICKEN_PROGRAM "chicken" #endif #ifndef C_CSC_PROGRAM # define C_CSC_PROGRAM "csc" #endif #ifndef C_CSI_PROGRAM # define C_CSI_PROGRAM "csi" #endif #ifndef C_CHICKEN_BUG_PROGRAM # define C_CHICKEN_BUG_PROGRAM "chicken-bug" #endif #ifndef C_WINDOWS_SHELL # define C_WINDOWS_SHELL 0 #endif #ifndef C_BINARY_VERSION # define C_BINARY_VERSION 5 #endif #ifndef C_BRANCH_NAME # define C_BRANCH_NAME "(experimental)" #endif CC seems to be gcc, trying to obtain version... Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.3-2' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable- shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-s uffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux -gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.4.3 (Debian 4.4.3-2)
Is there anything else I could do to help find what's going on?
comment:15 follow-up: 16 Changed 15 years ago by
I forgot to mention the way I installed crunch: went to the svn directory (4/crunch/trunk) then just typed "chicken-install". I suppose that does
what I expected (install the egg in the current dir).
comment:16 Changed 15 years ago by
Replying to jeronimo:
I forgot to mention the way I installed crunch: went to the svn directory (4/crunch/trunk) then just typed "chicken-install". I suppose that does
what I expected (install the egg in the current dir).
ok.
I installed testeez and run the test.sh script in 4/crunch/trunk:
Thanks, that's loads of info. An 64-bit machine - perhaps this is the problem.
I'll have to test this on another machine myself. This may take a while.
comment:17 Changed 15 years ago by
Oops... Forgot.
The example is:
(use crunch) (crunch (define (string-reverse str) (let* ((n (string-length str)) (s2 (make-string n #\space))) (do ((i 0 (add1 i))) ((>= i n)) (string-set! s2 (sub1 (- n i)) (string-ref str i))) s2)) ) (print (string-reverse "this is a test!"))
And the output of csc -compiler "chicken -:d" -c++ crunch-example.scm is:
[debug] application startup... [debug] heap resized to 500000 bytes [debug] stack bottom is 0x7fffffffb690. [debug] entering toplevel toplevel... [debug] [debug] stack resized to 262144 bytes [debug] entering toplevel library_toplevel... [debug] entering toplevel eval_toplevel... [debug] entering toplevel expand_toplevel... [debug] entering toplevel chicken_syntax_toplevel... [debug] entering toplevel srfi_1_toplevel... [debug] entering toplevel srfi_4_toplevel... [debug] entering toplevel utils_toplevel... [debug] entering toplevel extras_toplevel... [debug] entering toplevel data_structures_toplevel... [debug] entering toplevel ports_toplevel... [debug] entering toplevel srfi_13_toplevel... [debug] entering toplevel srfi_14_toplevel... [debug] entering toplevel posix_toplevel... [debug] resizing heap dynamically from 500k to 1026k ... [debug] entering toplevel scheduler_toplevel... [debug] entering toplevel regex_toplevel... [debug] entering toplevel files_toplevel... [debug] entering toplevel support_toplevel... [debug] entering toplevel compiler_toplevel... [debug] entering toplevel optimizer_toplevel... [debug] entering toplevel unboxing_toplevel... [debug] entering toplevel compiler_syntax_toplevel... [debug] entering toplevel scrutinizer_toplevel... [debug] entering toplevel driver_toplevel... [debug] entering toplevel platform_toplevel... [debug] entering toplevel backend_toplevel... [debug] entering toplevel srfi_69_toplevel... [debug] resizing heap dynamically from 1026k to 2053k ... ; loading /usr/local/lib/chicken/5/crunch.import.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/crunch.import.so' (handle is 0x848990) [debug] entering toplevel toplevel... ; loading /usr/local/lib/chicken/5/scheme.import.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/scheme.import.so' (handle is 0x8492e0) [debug] entering toplevel toplevel... ; loading /usr/local/lib/chicken/5/chicken.import.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/chicken.import.so' (handle is 0x849980) [debug] entering toplevel toplevel... ; loading /usr/local/lib/chicken/5/foreign.import.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/foreign.import.so' (handle is 0x84a020) [debug] entering toplevel toplevel... ; loading /usr/local/lib/chicken/5/crunch-compiler.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/crunch-compiler.so' (handle is 0x84a6c0) [debug] entering toplevel toplevel... [debug] resizing heap dynamically from 2053k to 4170k ... ; loading /usr/local/lib/chicken/5/defstruct.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/defstruct.so' (handle is 0x84ec70) [debug] entering toplevel toplevel... ; loading /usr/local/lib/chicken/5/matchable.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/matchable.so' (handle is 0x84f280) [debug] entering toplevel toplevel... ; loading /usr/local/lib/chicken/5/crunch-expander.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/crunch-expander.so' (handle is 0x84f8a0) [debug] entering toplevel toplevel... Error: during expansion of (crunch ...) - [crunch] (in string-reverse) call to loop variable not in tail position: doloop context: (define string-reverse ...) (let () ...) (let ((n (string-length str))) ...) (let ((s2 (make-string n #\space))) ...) (let ((i 0)) ...) (if (>= i n) ...) (doloop (add1 i)) Call history: <syntax> (##core#begin (crunch (define (string-reverse str) (let* ((n (string-length str)) (s2 (make-string n... <syntax> (crunch (define (string-reverse str) (let* ((n (string-length str)) (s2 (make-string n #\space))) (do... <-- Error: shell command terminated with non-zero exit status 17920: chicken -:d crunch-example.scm -output-file crunch-example.cpp
comment:18 Changed 15 years ago by
Ok, this seems to run fine on a 64-bit NetBSD machine. From the bug-report I gather that high-optimization settings are used, have you built with OPTIMIZE_FOR_SPEED=1
? If yes, try to build chicken with the default optimizations. If that works, you have a gcc bug.
comment:19 Changed 15 years ago by
Hi Felix,
I uninstalled, recompiled without OPTIMIZE_FOR_SPEED, removed all eggs, then
reinstalled them. The same thing happened.
What compiler did you use on other machines? I could try setting CC=gcc-4.3 to
see if that helps...
J.
The error, after recompiling chicken:
$ csc -compiler "chicken -:d" -c++ crunch-example.scm [debug] application startup... [debug] heap resized to 500000 bytes [debug] stack bottom is 0x7fffffffd3d0. [debug] entering toplevel toplevel... [debug] [debug] stack resized to 262144 bytes [debug] entering toplevel library_toplevel... [debug] entering toplevel eval_toplevel... [debug] entering toplevel expand_toplevel... [debug] entering toplevel chicken_syntax_toplevel... [debug] entering toplevel srfi_1_toplevel... [debug] entering toplevel srfi_4_toplevel... [debug] entering toplevel utils_toplevel... [debug] entering toplevel extras_toplevel... [debug] entering toplevel data_structures_toplevel... [debug] entering toplevel ports_toplevel... [debug] entering toplevel srfi_13_toplevel... [debug] entering toplevel srfi_14_toplevel... [debug] entering toplevel posix_toplevel... [debug] resizing heap dynamically from 500k to 1026k ... [debug] entering toplevel scheduler_toplevel... [debug] entering toplevel regex_toplevel... [debug] entering toplevel files_toplevel... [debug] entering toplevel support_toplevel... [debug] entering toplevel compiler_toplevel... [debug] entering toplevel optimizer_toplevel... [debug] entering toplevel unboxing_toplevel... [debug] entering toplevel compiler_syntax_toplevel... [debug] entering toplevel scrutinizer_toplevel... [debug] entering toplevel driver_toplevel... [debug] entering toplevel platform_toplevel... [debug] entering toplevel backend_toplevel... [debug] entering toplevel srfi_69_toplevel... [debug] resizing heap dynamically from 1026k to 2053k ... ; loading /usr/local/lib/chicken/5/crunch.import.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/crunch.import.so' (handle is 0x7f89b0) [debug] entering toplevel toplevel... ; loading /usr/local/lib/chicken/5/scheme.import.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/scheme.import.so' (handle is 0x7f9300) [debug] entering toplevel toplevel... ; loading /usr/local/lib/chicken/5/chicken.import.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/chicken.import.so' (handle is 0x7f99a0) [debug] entering toplevel toplevel... ; loading /usr/local/lib/chicken/5/foreign.import.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/foreign.import.so' (handle is 0x7fa040) [debug] entering toplevel toplevel... ; loading /usr/local/lib/chicken/5/crunch-compiler.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/crunch-compiler.so' (handle is 0x7fa6e0) [debug] entering toplevel toplevel... ; loading /usr/local/lib/chicken/5/defstruct.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/defstruct.so' (handle is 0x7fec90) [debug] entering toplevel toplevel... ; loading /usr/local/lib/chicken/5/matchable.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/matchable.so' (handle is 0x7ff2a0) [debug] entering toplevel toplevel... ; loading /usr/local/lib/chicken/5/crunch-expander.so ... [debug] loading compiled module `/usr/local/lib/chicken/5/crunch-expander.so' (handle is 0x7ff8c0) [debug] entering toplevel toplevel... Error: during expansion of (crunch ...) - [crunch] (in string-reverse) call to loop variable not in tail position: doloop context: (define string-reverse ...) (let () ...) (let ((n (string-length str))) ...) (let ((s2 (make-string n #\space))) ...) (let ((i 0)) ...) (if (>= i n) ...) (doloop (add1 i)) Call history: <syntax> (##core#begin (crunch (define (string-reverse str) (let* ((n (string-length str)) (s2 (make-string n... <syntax> (crunch (define (string-reverse str) (let* ((n (string-length str)) (s2 (make-string n #\space))) (do... <-- Error: shell command terminated with non-zero exit status 17920: chicken -:d crunch-example.scm -output-file crunch-example.cpp
Output from chicken-bug:
-------------------------------------------------- This is a bug report generated by chicken-bug(1). Date: Tue Feb 16 11:35:24 2010 User information: ("jeronimo" "x" 1001 1001 "Jeronimo Pellegrini" "/home/jeronimo" "/bin/bash") Host information: machine type: x86-64 software type: unix software version: linux build platform: gnu CHICKEN version is: Version 4.3.5 (experimental) linux-unix-gnu-x86-64 [ 64bit manyargs ptables ] compiled 2010-02-16 on newton (Linux) Home directory: /usr/local/share/chicken Include path: ("/usr/local/share/chicken") Features: chicken chicken-4 data-structures extras files gnu hygienic-macros irregex linux little-endian manyargs ports posix ptables regex srfi-0 srfi-10 srfi-12 srfi-13 srfi-14 srfi-17 srfi-2 srfi-23 srfi-28 srfi-30 srfi-39 srfi-55 srfi-6 srfi-61 srfi-62 srfi-8 srfi-88 srfi-9 srfi-98 syntax-rules tcp unix utils x86-64 chicken-config.h: /* GENERATED */ #define HAVE_DIRENT_H 1 #define HAVE_DLFCN_H 1 #define HAVE_INTTYPES_H 1 #define HAVE_LIMITS_H 1 #define HAVE_LONG_LONG 1 #define HAVE_MEMMOVE 1 #define HAVE_MEMORY_H 1 #define HAVE_STDINT_H 1 #define HAVE_STDLIB_H 1 #define HAVE_STRERROR 1 #define HAVE_STRINGS_H 1 #define HAVE_STRING_H 1 #define HAVE_STRTOLL 1 #define HAVE_STRTOQ 1 #define HAVE_SYS_STAT_H 1 #define HAVE_SYS_TYPES_H 1 #define HAVE_UNISTD_H 1 #define HAVE_UNSIGNED_LONG_LONG 1 #define STDC_HEADERS 1 #define HAVE_ALLOCA 1 #define HAVE_ALLOCA_H 1 #define HAVE_GRP_H 1 #define HAVE_ERRNO_H 1 #define HAVE_GCVT 1 #define HAVE_SYSEXITS_H 1 #define HAVE_MEMMOVE 1 #define C_STACK_GROWS_DOWNWARD 1 #define C_HACKED_APPLY #define C_BUILD_TAG "compiled 2010-02-16 on newton (Linux)" #define C_CHICKEN_PROGRAM "chicken" #ifndef C_INSTALL_CC # define C_INSTALL_CC "gcc" #endif #ifndef C_INSTALL_CXX # define C_INSTALL_CXX "g++" #endif #ifndef C_INSTALL_CFLAGS # define C_INSTALL_CFLAGS "-fno-strict-aliasing -DHAVE_CHICKEN_CONFIG_H -DC_ENABLE_PTABLES -Os -fomit-frame-pointer" #endif #ifndef C_INSTALL_LDFLAGS # define C_INSTALL_LDFLAGS " " #endif #ifndef C_INSTALL_PREFIX # define C_INSTALL_PREFIX "/usr/local" #endif #ifndef C_INSTALL_SHARE_HOME # define C_INSTALL_SHARE_HOME "/usr/local/share/chicken" #endif #ifndef C_INSTALL_BIN_HOME # define C_INSTALL_BIN_HOME "/usr/local/bin" #endif #ifndef C_INSTALL_EGG_HOME # define C_INSTALL_EGG_HOME "/usr/local/lib/chicken/5" #endif #ifndef C_INSTALL_LIB_HOME # define C_INSTALL_LIB_HOME "/usr/local/lib" #endif #ifndef C_INSTALL_STATIC_LIB_HOME # define C_INSTALL_STATIC_LIB_HOME "/usr/local/lib" #endif #ifndef C_INSTALL_INCLUDE_HOME # define C_INSTALL_INCLUDE_HOME "/usr/local/include" #endif #ifndef C_INSTALL_MORE_LIBS # define C_INSTALL_MORE_LIBS "-lm -ldl" #endif #ifndef C_INSTALL_MORE_STATIC_LIBS # define C_INSTALL_MORE_STATIC_LIBS "-lm -ldl" #endif #ifndef C_DEFAULT_TARGET_STACK_SIZE # define C_DEFAULT_TARGET_STACK_SIZE (256*1024) #endif #ifndef C_DEFAULT_TARGET_HEAP_SIZE # define C_DEFAULT_TARGET_HEAP_SIZE 0 #endif #ifndef C_STACK_GROWS_DOWNWARD # define C_STACK_GROWS_DOWNWARD 1 #endif #ifndef C_TARGET_MORE_LIBS # define C_TARGET_MORE_LIBS "-lm -ldl" #endif #ifndef C_TARGET_MORE_STATIC_LIBS # define C_TARGET_MORE_STATIC_LIBS "-lm -ldl" #endif #ifndef C_TARGET_CC # define C_TARGET_CC "gcc" #endif #ifndef C_TARGET_CXX # define C_TARGET_CXX "g++" #endif #ifndef C_TARGET_CFLAGS # define C_TARGET_CFLAGS "-fno-strict-aliasing -DHAVE_CHICKEN_CONFIG_H -DC_ENABLE_PTABLES -Os -fomit-frame-pointer" #endif #ifndef C_TARGET_LDFLAGS # define C_TARGET_LDFLAGS " " #endif #ifndef C_CROSS_CHICKEN # define C_CROSS_CHICKEN 0 #endif #ifndef C_TARGET_BIN_HOME # define C_TARGET_BIN_HOME "/usr/local/bin" #endif #ifndef C_TARGET_LIB_HOME # define C_TARGET_LIB_HOME "/usr/local/lib" #endif #ifndef C_TARGET_RUN_LIB_HOME # define C_TARGET_RUN_LIB_HOME "/usr/local/lib" #endif #ifndef C_TARGET_SHARE_HOME # define C_TARGET_SHARE_HOME "/usr/local/share" #endif #ifndef C_TARGET_INCLUDE_HOME # define C_TARGET_INCLUDE_HOME "/usr/local/include" #endif #ifndef C_TARGET_STATIC_LIB_HOME # define C_TARGET_STATIC_LIB_HOME "/usr/local/lib" #endif #ifndef C_CHICKEN_PROGRAM # define C_CHICKEN_PROGRAM "chicken" #endif #ifndef C_CSC_PROGRAM # define C_CSC_PROGRAM "csc" #endif #ifndef C_CSI_PROGRAM # define C_CSI_PROGRAM "csi" #endif #ifndef C_CHICKEN_BUG_PROGRAM # define C_CHICKEN_BUG_PROGRAM "chicken-bug" #endif #ifndef C_WINDOWS_SHELL # define C_WINDOWS_SHELL 0 #endif #ifndef C_BINARY_VERSION # define C_BINARY_VERSION 5 #endif #ifndef C_BRANCH_NAME # define C_BRANCH_NAME "(experimental)" #endif /* END OF FILE */ CC seems to be gcc, trying to obtain version... Using built-in specs. Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.4.3-2' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable- shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-s uffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux -gnu --target=x86_64-linux-gnu Thread model: posix gcc version 4.4.3 (Debian 4.4.3-2)
comment:20 Changed 15 years ago by
I can't recall the gcc version. Yes, please try 4.3, if you can.
When compiling the example, please add -D crunch-debug-total
and send me the output.
comment:21 follow-up: 22 Changed 15 years ago by
Hi Felix,
I can't recall the gcc version. Yes, please try 4.3, if you can.
How do I do that?
I tried setting the CC, CXX and CPP variables but the Makefile seems to ignore them.
comment:22 Changed 15 years ago by
Replying to jeronimo:
Hi Felix,
I can't recall the gcc version. Yes, please try 4.3, if you can.
How do I do that?
I tried setting the CC, CXX and CPP variables but the Makefile seems to ignore them.
pass C_COMPILER=gcc-4.3
to make
.
comment:23 follow-up: 24 Changed 15 years ago by
Hi Felix,
The problem is gone after compiling with gcc-4.3!
There was also a bit of confusion here: it actually works with gcc-4.4 *without* OPTIMIZE_FOR_SPEED.
The problem is that even after compiling chicken without OPTIMIZE_FOR_SPEED and gcc-4.4, I was using old binaries for crunch.
$ cd 4/crunch/trunk $ chicken-uninstall crunch $ chicken-install <== Wrong! the old crunch binaries were copied to /usr/local
(There is no Makefile in the crunch egg directory, that may have been the source of confusion)
So this time I did rm *.o chicken-crunch before reinstalling crunch and it worked with gcc-4.4.
Sorry for this confusion, and thanks a LOT for your help!
comment:24 Changed 15 years ago by
Replying to jeronimo:
The problem is gone after compiling with gcc-4.3!
Yay!
There was also a bit of confusion here: it actually works with gcc-4.4 *without* OPTIMIZE_FOR_SPEED.
I don't want to sound cocky, but I was somehow assuming this.
The problem is that even after compiling chicken without OPTIMIZE_FOR_SPEED and gcc-4.4, I was using old binaries for crunch.
$ cd 4/crunch/trunk $ chicken-uninstall crunch $ chicken-install <== Wrong! the old crunch binaries were copied to /usr/local
Argh.
So this time I did rm *.o chicken-crunch before reinstalling crunch and it worked with gcc-4.4.
Excellent.
Sorry for this confusion, and thanks a LOT for your help!
Thanks for YOUR help! I appreciate that you didn't give up. I hope crunch is useful to you (it is quite a hack, after all).
comment:25 Changed 15 years ago by
Resolution: | → fixed |
---|---|
Status: | new → closed |
I forgot to mention:
g++ is Debian 4.3.4-6
After generating the C++ file, I compiled it with
and when g++ generated the .o file, I then linked with