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

SEXP_USE_MUTABLE_STRINGS 0 is pretty broken #991

Closed
ghost opened this issue Jun 2, 2024 · 1 comment
Closed

SEXP_USE_MUTABLE_STRINGS 0 is pretty broken #991

ghost opened this issue Jun 2, 2024 · 1 comment

Comments

@ghost
Copy link

ghost commented Jun 2, 2024

Enable the option:

diff --git a/include/chibi/features.h b/include/chibi/features.h
index 9431514f..35d91fed 100644
--- a/include/chibi/features.h
+++ b/include/chibi/features.h
@@ -244,7 +244,7 @@
 /* uncomment this to disable the string-set! opcode */
 /*   By default (non-literal) strings are mutable. */
 /*   Making them immutable allows for packed UTF-8 strings. */
-/* #define SEXP_USE_MUTABLE_STRINGS 0 */
+#define SEXP_USE_MUTABLE_STRINGS 0
 
 /* uncomment this to enable precomputed index->cursor tables for strings */
 /*   This makes string-ref faster at the expensive of making string */

Get mondo warnings, but it builds:

cc -c  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3  -o main.o main.c
cc -c  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o gc.o gc.c
cc -c  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o sexp.o sexp.c
cc -c  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o bignum.o bignum.c
cc -c  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o gc_heap.o gc_heap.c
cc -c  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o opcodes.o opcodes.c
cc -c  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o vm.o vm.c
cc -c  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o eval.o eval.c
cc -c  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o simplify.o simplify.c
cc  -dynamiclib -install_name /usr/local/lib/libchibi-scheme.0.11.0.dylib -o libchibi-scheme.0.11.0.dylib gc.o sexp.o bignum.o gc_heap.o opcodes.o vm.o eval.o simplify.o    -ldl -lm
ln -sf libchibi-scheme.0.11.0.dylib libchibi-scheme.0.dylib
ln -sf libchibi-scheme.0.dylib libchibi-scheme.dylib
cc  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o chibi-scheme main.o -L.  -lchibi-scheme
LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme -q tools/chibi-ffi lib/chibi/filesystem.stub
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/filesystem.dylib lib/chibi/filesystem.c -L.   -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/weak.dylib lib/chibi/weak.c -L.   -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/heap-stats.dylib lib/chibi/heap-stats.c -L.   -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/disasm.dylib lib/chibi/disasm.c -L.   -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/ast.dylib lib/chibi/ast.c  -L.  -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/json.dylib lib/chibi/json.c -L.   -lchibi-scheme
LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme -q tools/chibi-ffi lib/chibi/emscripten.stub
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/emscripten.dylib lib/chibi/emscripten.c -L.   -lchibi-scheme
LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme -q tools/chibi-ffi lib/chibi/process.stub
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/process.dylib lib/chibi/process.c -L.   -lchibi-scheme
LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme -q tools/chibi-ffi lib/chibi/time.stub
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/time.dylib lib/chibi/time.c -L.   -lchibi-scheme
LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme -q tools/chibi-ffi lib/chibi/system.stub
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/system.dylib lib/chibi/system.c -L.   -lchibi-scheme
LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme -q tools/chibi-ffi lib/chibi/stty.stub
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/stty.dylib lib/chibi/stty.c -L.   -lchibi-scheme
LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme -q tools/chibi-ffi lib/chibi/pty.stub
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/pty.dylib lib/chibi/pty.c -L.   -lchibi-scheme -lutil
LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme -q tools/chibi-ffi lib/chibi/net.stub
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/net.dylib lib/chibi/net.c -L.   -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/srfi/18/threads.dylib lib/srfi/18/threads.c -L.   -lchibi-scheme
LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme -q tools/chibi-ffi lib/chibi/io/io.stub
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/io/io.dylib lib/chibi/io/io.c -L.   -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/optimize/rest.dylib lib/chibi/optimize/rest.c -L.   -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/optimize/profile.dylib lib/chibi/optimize/profile.c -L.   -lchibi-scheme
LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme -q tools/chibi-ffi lib/chibi/crypto/crypto.stub
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/chibi/crypto/crypto.dylib lib/chibi/crypto/crypto.c -L.   -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/srfi/27/rand.dylib lib/srfi/27/rand.c -L.   -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/srfi/151/bit.dylib lib/srfi/151/bit.c -L.   -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/srfi/39/param.dylib lib/srfi/39/param.c -L.   -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/srfi/69/hash.dylib lib/srfi/69/hash.c -L.   -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/srfi/95/qsort.dylib lib/srfi/95/qsort.c -L.   -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/srfi/98/env.dylib lib/srfi/98/env.c -L.   -lchibi-scheme
LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme -q tools/chibi-ffi lib/srfi/144/math.stub
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/srfi/144/math.dylib lib/srfi/144/math.c -L.   -lchibi-scheme
LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme -q tools/chibi-ffi lib/srfi/160/uvprims.stub
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/srfi/160/uvprims.dylib lib/srfi/160/uvprims.c -L.   -lchibi-scheme
LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme -q tools/chibi-ffi lib/scheme/bytevector.stub
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/scheme/bytevector.dylib lib/scheme/bytevector.c -L.   -lchibi-scheme
cc  -dynamiclib  -Iinclude  -DSEXP_USE_NTPGETTIME -DSEXP_USE_INTTYPES -Wall -g -g3 -O3   -o lib/scheme/time.dylib lib/scheme/time.c -L.   -lchibi-scheme
find lib/chibi/ -name \*.sld | \
	 LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme tools/generate-install-meta.scm 0.11.0 > lib/.chibi.meta
find lib/srfi/ -name \*.sld | \
	 LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme tools/generate-install-meta.scm 0.11.0 > lib/.srfi.meta
find lib/scheme/ -name \*.sld | \
	 LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme tools/generate-install-meta.scm 0.11.0 > lib/.scheme.meta

But then it fails rather a lot of the test suite:

LD_LIBRARY_PATH=".:" DYLD_LIBRARY_PATH=".:" CHIBI_IGNORE_SYSTEM_PATH=1 CHIBI_MODULE_PATH=lib ./chibi-scheme tests/r7rs-tests.scm
�[1mR7RS: �[22m
 
    �[1m4.1 Primitive expression types: �[22m
     ...........................
    �[32m27 out of 27 (100.0%)�[39m tests passed in 0.007436990737915039 seconds.
    �[1m4.2 Derived expression types: �[22m
     ..........................................................................
     
    �[32m74 out of 74 (100.0%)�[39m tests passed in 0.035043954849243164 seconds.
    �[1m4.3 Macros: �[22m
     .........................
    �[32m25 out of 25 (100.0%)�[39m tests passed in 0.023190975189208984 seconds.
    �[1m5 Program structure: �[22m
     ...............
    �[32m15 out of 15 (100.0%)�[39m tests passed in 0.007798910140991211 seconds.
    �[1m6.1 Equivalence Predicates: �[22m
     .........................
    �[32m25 out of 25 (100.0%)�[39m tests passed in 0.00926518440246582 seconds.
    �[1m6.2 Numbers: �[22m
     ..........................................................................
     ..........................................................................
     ...............................................................
    �[32m211 out of 211 (100.0%)�[39m tests passed in 0.059996843338012695 seconds.
    �[1m6.3 Booleans: �[22m
     ..................
    �[32m18 out of 18 (100.0%)�[39m tests passed in 0.0037419795989990234 seconds.
    �[1m6.4 Lists: �[22m
     .................................................................
    �[32m65 out of 65 (100.0%)�[39m tests passed in 0.02360391616821289 seconds.
    �[1m6.5 Symbols: �[22m
     .................
    �[32m17 out of 17 (100.0%)�[39m tests passed in 0.00618290901184082 seconds.
    �[1m6.6 Characters: �[22m
     ..........................................................................
     .....
    �[32m79 out of 79 (100.0%)�[39m tests passed in 0.02087998390197754 seconds.
    �[1m6.7 Strings: �[22m
     ...............�[4m�[31m!�[39m�[24m�[4m�[31m!�[39m�[24m.........................................................
     ..............................................�[4m�[31m!�[39m�[24m�[4m�[31m!�[39m�[24m�[4m�[31m!�[39m�[24m�[4m�[31m!�[39m�[24m�[4m�[31m!�[39m�[24m�[4m�[31m!�[39m�[24m�[4m�[31m!�[39m�[24m�[4m�[31m!�[39m�[24m�[4m�[31m!�[39m�[24m�[4m�[31m!�[39m�[24m
    118 out of 130 (90.8%) tests passed in 0.039335012435913086 seconds.
    �[4m�[31m12 errors (9.2%).�[39m�[24m
    �[31mERROR: �[39m(let ((str (string #\a #\b #\c))) (string-set! str 1 #\-) str)
        Exception: undefined variable: string-set!
        on line 1320 of file "tests/r7rs-tests.scm"
    �[31mERROR: �[39m(let ((s (string #\a #\b #\c))) (string-set! s 1 #\🜀) s)
        Exception: undefined variable: string-set!
        on line 1323 of file "tests/r7rs-tests.scm"
    �[31mERROR: �[39m(let ((str (make-string 5 #\x))) (string-fill! str #\-) str)
        Exception: undefined variable: string-set!
        on line 1457 of file "tests/r7rs-tests.scm"
    �[31mERROR: �[39m(let ((str (make-string 5 #\x))) (string-fill! str #\- 2) str)
        Exception: undefined variable: string-set!
        on line 1459 of file "tests/r7rs-tests.scm"
    �[31mERROR: �[39m(let ((str (make-string 5 #\x))) (string-fill! str #\- 2 3) str)
        Exception: undefined variable: string-set!
        on line 1461 of file "tests/r7rs-tests.scm"
    �[31mERROR: �[39m...str
        Exception: undefined variable: string-set!
        on line 1464 of file "tests/r7rs-tests.scm"
    �[31mERROR: �[39m(let ((str (make-string 5 #\x))) (string-copy! str 0 "-----") str)
        Exception: undefined variable: string-set!
        on line 1466 of file "tests/r7rs-tests.scm"
    �[31mERROR: �[39m...str
        Exception: undefined variable: string-set!
        on line 1468 of file "tests/r7rs-tests.scm"
    �[31mERROR: �[39m...str
        Exception: undefined variable: string-set!
        on line 1470 of file "tests/r7rs-tests.scm"
    �[31mERROR: �[39m...str
        Exception: undefined variable: string-set!
        on line 1472 of file "tests/r7rs-tests.scm"
    �[31mERROR: �[39m...str
        Exception: undefined variable: string-set!
        on line 1476 of file "tests/r7rs-tests.scm"
    �[31mERROR: �[39m...str
        Exception: undefined variable: string-set!
        on line 1478 of file "tests/r7rs-tests.scm"
    �[1m6.8 Vectors: �[22m
     ...........................................
    �[32m43 out of 43 (100.0%)�[39m tests passed in 0.017297983169555664 seconds.
    �[1m6.9 Bytevectors: �[22m
     ................................�[31mx�[39m�[31mx�[39m�[31mx�[39m....
    36 out of 39 (92.3%) tests passed in 0.012196063995361328 seconds.
    �[31m3 failures (7.7%).�[39m
    �[31mFAIL: �[39m(utf8->string #u8(0 #x41 #x42 #x43) 1)
        expected "ABC" but got "ABC�[32m\x00;�[39m"
        on line 1627 of file "tests/r7rs-tests.scm"
    �[31mFAIL: �[39m(utf8->string #u8(0 #x41 #x42 #x43 0) 1 4)
        expected "ABC" but got "ABC�[32m\x00;�[39m"
        on line 1628 of file "tests/r7rs-tests.scm"
    �[31mFAIL: �[39m(utf8->string #u8(0 #xCE #xBB 0) 1 3)
        expected "λ" but got "λ�[32m\x00;�[39m"
        on line 1629 of file "tests/r7rs-tests.scm"
    �[1m6.10 Control Features: �[22m
     ..................................
    �[32m34 out of 34 (100.0%)�[39m tests passed in 0.016185998916625977 seconds.
    �[1m6.11 Exceptions: �[22m
     ..............................
    �[32m30 out of 30 (100.0%)�[39m tests passed in 0.015750885009765625 seconds.
    �[1m6.12 Environments and evaluation: �[22m
     ....
    �[32m4 out of 4 (100.0%)�[39m tests passed in 0.0019350051879882812 seconds.
    �[1m6.13 Input and output: �[22m
     ...............................................................
        �[1mRead syntax: �[22m
         ......................................................................
         .......................
        �[32m93 out of 93 (100.0%)�[39m tests passed in 0.030590057373046875 seconds.
        �[1mNumeric syntax: �[22m
         ......................................................................
         ......................................................................
         ......................................................................
         ..........
        �[32m220 out of 220 (100.0%)�[39m tests passed in 0.09760308265686035 seconds.
    �[32m376 out of 376 (100.0%)�[39m tests passed in 0.15198516845703125 seconds.
    �[32m2 out of 2 (100.0%)�[39m subgroups passed.
    �[1m6.14 System interface: �[22m
     .............
    �[32m13 out of 13 (100.0%)�[39m tests passed in 0.005388975143432617 seconds.
1210 out of 1225 (98.8%) tests passed in 0.46364307403564453 seconds.
�[31m3 failures (0.2%).�[39m
�[4m�[31m12 errors (1.0%).�[39m�[24m
16 out of 18 (88.9%) subgroups passed.

And every REPL prompt and invocation of any kind, it spits out WARNING: reference to undefined variable string-set!

I think the failing tests and the warning should be disabled in case SEXP_USE_MUTABLE STRINGS 0.

@ashinn
Copy link
Owner

ashinn commented Jun 3, 2024

Chibi is built in layers, and states this in the documentation.

To get the full Chibi and R7RS support you need most of the default compiler options.
Toggling these options is intended only for custom builds, in most cases to strip the size down for embedded executables or extension language use. Given that, SEXP_USE_MUTABLE STRINGS 0 works surprisingly well here.

@ashinn ashinn closed this as completed Jun 3, 2024
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