chibi-scheme
chibi-scheme copied to clipboard
make chibi-scheme-static executable doesn't work on Debian
Hey there! I am loving Chibi Scheme so much! Just putting this here for whoever has time to look into this!
When I try to make chibi-scheme-static && ./chibi-scheme-static
or make && make chibi-scheme-static && ./chibi-scheme-static
in the root of this repository, I get the following errors:
ERROR: couldn't load dynamic library: "./lib/srfi/69/hash.so"
called from <anonymous> on line 211 of file ./lib/meta-7.scm
called from <anonymous> on line 1213 of file ./lib/init-7.scm
called from <anonymous> on line 280 of file ./lib/init-7.scm
called from <anonymous> on line 1280 of file ./lib/init-7.scm
called from for1 on line 75 of file ./lib/init-7.scm
called from for1 on line 75 of file ./lib/init-7.scm
called from <anonymous> on line 280 of file ./lib/init-7.scm
called from call-with-current-continuation on line 848 of file ./lib/init-7.scm
called from <anonymous> on line 280 of file ./lib/init-7.scm
called from <anonymous> on line 246 of file ./lib/meta-7.scm
called from <anonymous> on line 280 of file ./lib/init-7.scm
called from for1 on line 75 of file ./lib/init-7.scm
called from for1 on line 75 of file ./lib/init-7.scm
called from <anonymous> on line 280 of file ./lib/init-7.scm
called from <anonymous> on line 245 of file ./lib/meta-7.scm
called from <anonymous> on line 280 of file ./lib/init-7.scm
called from for1 on line 75 of file ./lib/init-7.scm
called from for1 on line 75 of file ./lib/init-7.scm
called from <anonymous> on line 280 of file ./lib/init-7.scm
called from <anonymous> on line 245 of file ./lib/meta-7.scm
called from <anonymous> on line 280 of file ./lib/init-7.scm
called from for1 on line 75 of file ./lib/init-7.scm
called from for1 on line 75 of file ./lib/init-7.scm
called from <anonymous> on line 280 of file ./lib/init-7.scm
called from <anonymous> on line 245 of file ./lib/meta-7.scm
called from <anonymous> on line 280 of file ./lib/init-7.scm
called from for1 on line 75 of file ./lib/init-7.scm
called from <anonymous> on line 235 of file ./lib/meta-7.scm
However, if I do a make && make test && sudo make install && make chibi-scheme-static && ./chibi-scheme-static
, then I have no problem getting a REPL up and going, but I do notice the chibi-scheme-static
executable doesn't seem to work on another machine with the same architecture and on Debian as well.
It would be super handy to be able to have the portable executable to just throw into a little project! :D.
Thanks so much for your hard work.
Please only address this when you have time! (Or maybe I'm doing something wrong!)
Hi Jesse. Glad you're enjoying Chibi!
The problem here is that the default language is (scheme small)
which transitively depends on (srfi 69)
for cycle-aware equal?
, so it's trying to dynamically load hash.so. It works if you already have Chibi installed because then it knows where to find hash.so. I think it should also work in the local directory if you run make all-libs
after building the static version.
You can change the language to avoid using hash tables, e.g. with chibi-scheme-static -q
loading only the core language.
Alternatively, you can include this and other libraries statically, by running make clibs.c
before make chibi-scheme-static
. Let me know if the explanation of this in the docs is unclear or the current steps broken.
Thanks so much for the quick reply! I'm about to start work, but I'll definitely try out the make clibs.c
trick before make chibi-scheme-static
! The info about the dynamic loading is handy too!
Alternatively, you can include this and other libraries statically, by running make clibs.c before make chibi-scheme-static. Let me know if the explanation of this in the docs is unclear or the current steps broken.
Having something that explicitly mentions that make clibs.c
needs to be run before make chibi-scheme-static
would be handy! If it's already there, sorry for not noticing! haha.
If I have time (just became a father 4 months ago!) I'd love to try to help out with the documentation, but feel free to update it in your own way in the meantime!
Amazing work <3
Hi,
The issue with running make clibs.c and then make ....static, is that the latter completely disregards clibs.c:
cc -Wall -g -g3 -O3 -static -DSEXP_USE_DL=0 -o chibi-scheme-static main.o gc.o sexp.o bignum.o gc_heap.o opcodes.o vm.o eval.o simplify.o -lm -ldl -lutil
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: gc_heap.o: in function `load_image_fn':
/home/nawal/data/Loki/deps/chibi-scheme/gc_heap.c:500: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
If I try to add clibs.c to this, I get further errors:
loki-fhs-chrootenv:nawal@heisenbug:~/data/Loki/deps/chibi-scheme$ cc -Wall -g -g3 -O3 -static -DSEXP_USE_DL=0 -o chibi-scheme-static clibs.c main.o gc.o sexp.o bignum.o gc_heap.o opcodes.o vm.o eval.o simplify.o -I./include -lm -ldl -lutil
clibs.c:10602:10: fatal error: ../../opt/opcode_names.h: No such file or directory
10602 | #include "../../opt/opcode_names.h"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Changing #include "../../opt/opcode_names.h" to #include "opt/opcode_names.h" in clibs.c gives:
loki-fhs-chrootenv:nawal@heisenbug:~/data/Loki/deps/chibi-scheme$ cc -Wall -g -g3 -O3 -static -DSEXP_USE_DL=0 -o chibi-scheme-static clibs.c main.o gc.o sexp.o bignum.o gc_heap.o opcodes.o vm.o eval.o simplify.o -I./include -lm -ldl -lutil
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:3: multiple definition of `_huff_tab21'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:3: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:85: multiple definition of `_huff_tab1'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:85: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:89: multiple definition of `_huff_tab2'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:89: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:53: multiple definition of `_huff_tab9'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:53: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:57: multiple definition of `_huff_tab10'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:57: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:61: multiple definition of `_huff_tab8'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:61: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:45: multiple definition of `_huff_tab11'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:45: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:49: multiple definition of `_huff_tab12'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:49: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:65: multiple definition of `_huff_tab7'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:65: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:77: multiple definition of `_huff_tab4'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:77: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:37: multiple definition of `_huff_tab13'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:37: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:41: multiple definition of `_huff_tab14'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:41: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:69: multiple definition of `_huff_tab5'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:69: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:73: multiple definition of `_huff_tab6'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:73: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:81: multiple definition of `_huff_tab3'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:81: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:7: multiple definition of `_huff_tab19'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:7: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:11: multiple definition of `_huff_tab20'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:11: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:15: multiple definition of `_huff_tab18'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:15: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:20: multiple definition of `_huff_tab17'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:20: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:27: multiple definition of `_huff_tab16'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:27: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: sexp.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:32: multiple definition of `_huff_tab15'; /run/user/1000/ccMSbQZn.o:/home/nawal/data/Loki/deps/chibi-scheme/include/chibi/sexp-hufftabs.h:32: first defined here
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: gc_heap.o: in function `load_image_fn':
/home/nawal/data/Loki/deps/chibi-scheme/gc_heap.c:500: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: /run/user/1000/ccMSbQZn.o: in function `sexp_getgrgid_r_stub':
/home/nawal/data/Loki/deps/chibi-scheme/clibs.c:5684: warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: /run/user/1000/ccMSbQZn.o: in function `sexp_getgrnam_r_stub':
/home/nawal/data/Loki/deps/chibi-scheme/clibs.c:5658: warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: /run/user/1000/ccMSbQZn.o: in function `sexp_getpwnam_r_stub':
/home/nawal/data/Loki/deps/chibi-scheme/clibs.c:5710: warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: /run/user/1000/ccMSbQZn.o: in function `sexp_getpwuid_r_stub':
/home/nawal/data/Loki/deps/chibi-scheme/clibs.c:5736: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: /run/user/1000/ccMSbQZn.o: in function `sexp_25_get_address_info_stub':
/home/nawal/data/Loki/deps/chibi-scheme/clibs.c:7835: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
collect2: error: ld returned 1 exit status
Whereas trying without that:
loki-fhs-chrootenv:nawal@heisenbug:~/data/Loki/deps/chibi-scheme$ cc -Wall -g -g3 -O3 -static -DSEXP_USE_DL=0 -o chibi-scheme-static clibs.c main.o gc.o sexp.o bignum.o gc_heap.o opcodes.o vm.o eval.o simplify.o -I./include -DSEXP_USE_STATIC_LIBS -lm -ldl -lutil
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: gc_heap.o: in function `load_image_fn':
/home/nawal/data/Loki/deps/chibi-scheme/gc_heap.c:500: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: /run/user/1000/ccvEfpLW.o: in function `sexp_getgrgid_r_stub':
/home/nawal/data/Loki/deps/chibi-scheme/clibs.c:5684: warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: /run/user/1000/ccvEfpLW.o: in function `sexp_getgrnam_r_stub':
/home/nawal/data/Loki/deps/chibi-scheme/clibs.c:5658: warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: /run/user/1000/ccvEfpLW.o: in function `sexp_getpwnam_r_stub':
/home/nawal/data/Loki/deps/chibi-scheme/clibs.c:5710: warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: /run/user/1000/ccvEfpLW.o: in function `sexp_getpwuid_r_stub':
/home/nawal/data/Loki/deps/chibi-scheme/clibs.c:5736: warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: /run/user/1000/ccvEfpLW.o: in function `sexp_25_get_address_info_stub':
/home/nawal/data/Loki/deps/chibi-scheme/clibs.c:7835: warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: /run/user/1000/ccvEfpLW.o: in function `disasm':
/home/nawal/data/Loki/deps/chibi-scheme/clibs.c:10750: undefined reference to `sexp_opcode_names'
collect2: error: ld returned 1 exit status
I'm guessing static linking isn't routinely tested? Do you know roughly when was the last time it worked, so I can try to work out when it broke?
To answer my own question above - 0.7.3 was the last time the static stuff worked as advertised:
git checkout 0.7.3
make clibs.c
make -B chibi-scheme-static SEXP_USE_DL=0 CPPFLAGS=-DSEXP_USE_STATIC_LIBS
What changed after 0.7.3 was the flags for using static libs and for including clibs.c were separated to allow the flexibility of specifying your own libs.
The manual clearly states the necessary command:
make -B chibi-scheme-static SEXP_USE_DL=0 \
CPPFLAGS="-DSEXP_USE_STATIC_LIBS -DSEXP_USE_STATIC_LIBS_NO_INCLUDE=0"
This is one of the many configurations automatically tested before every release with make test-build
.
Respectfully, the manual says:
make -B chibi-scheme-static SEXP_USE_DL=0 CPPFLAGS=-DSEXP_USE_STATIC_LIBS
which ends in
cc -Wall -DSEXP_USE_DL=0 -g -g3 -O3 -static -DSEXP_USE_DL=0 -o chibi-scheme-static main.o gc.o sexp.o bignum.o gc_heap.o opcodes.o vm.o eval.o simplify.o -lm -ldl -lutil
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: eval.o: in function `sexp_find_static_library':
/home/nawal/data/Loki/deps/chibi-scheme/eval.c:1409: undefined reference to `sexp_static_libraries'
/nix/store/8x25mhcdrnglaj55n80w8pnkwaqcp3sw-binutils-2.35.2/bin/ld: eval.o: in function `sexp_add_static_libraries':
/home/nawal/data/Loki/deps/chibi-scheme/eval.c:1388: undefined reference to `sexp_static_libraries'
collect2: error: ld returned 1 exit status
make: *** [Makefile:143: chibi-scheme-static] Error 1
Your comment with the additional "-DSEXP_USE_STATIC_LIBS_NO_INCLUDE=0" does help it compile a static version correctly, so thank you!
I had copy and pasted that command directly from the manual, however it was the latest copy of the manual: https://github.com/ashinn/chibi-scheme/blob/master/doc/chibi.scrbl#L82
which was updated after the last release (0.10).
Oh that makes more sense, thank you!