[CM] S7 questions and libc issue

Fernando Oleo Blanco irvise_ml at irvise.xyz
Sat May 14 12:13:37 PDT 2022


Thank you for you answer,

I have a few more comments/issues, but no more questions.

Am Thu, 12 May 2022 14:52:26 -0700
schrieb <bil at ccrma.Stanford.EDU>:

> > ;unbound variable (symbol "\x7f;ELF\x02;\x01;\x01;")
>
> This happens if you try to dynamically load an object file
> but don't have the dynamic loading functions -- when you
> build it without libdl (WITH_C_LOADER=0 probably).  It treats
> libc_s7.so as a scheme (text) file.
>

I tried to do everything from scratch just in case I was doing
something wrong. Here is all the input/output and how it went (comments
below):

```
fernando at linux:~/Builds/S7-scheme> git clone --depth 1
https://cm-gitlab.stanford.edu/bil/s7.git
Klone nach 's7'... remote:
Counting objects: 94, done. remote: Compressing objects: 100% (93/93),
done. remote: Total 94 (delta 1), reused 0 (delta 0)
Entpacke Objekte: 100% (94/94), 2.47 MiB | 1.25 MiB/s, fertig.

fernando at linux:~/Builds/S7-scheme> ls
s7  s7-riscv  s7-riscv-all-c  s7.tar.gz

fernando at linux:~/Builds/S7-scheme> rm s7.tar.gz

fernando at linux:~/Builds/S7-scheme> cd s7

fernando at linux:~/Builds/S7-scheme/s7> gcc -o s7 s7.c -I. -lm
-DWITH_MAIN -ldl -pthread

fernando at linux:~/Builds/S7-scheme/s7> ./s7
r7rs.scm s7: 16-May-2022
load r7rs.scm
writing libc_s7.c
loading libc_s7.so
load /home/fernando/Builds/S7-scheme/s7/libc_s7.so failed:
/home/fernando/Builds/S7-scheme/s7/libc_s7.so: undefined symbol: s7_f

;unbound variable (symbol "\x7f;ELF\x02;\x01;\x01;")
;    (symbol "\x7f;ELF\x02;\x01;\x01;")
;    libc_s7.so, line 1, position: 7
; ((delete-file o-file-name))
; ((load so-file-name cur-env))
; ((curlet))

fernando at linux:~/Builds/S7-scheme/s7> gcc -o s7 s7.c -I. -lm
-DWITH_MAIN -WITH_C_LOADER=1 -ldl -pthread gcc: error: unrecognized
command-line option ‘-WITH_C_LOADER=1’

fernando at linux:~/Builds/S7-scheme/s7> gcc -o s7 s7.c -I. -lm
-DWITH_MAIN -DWITH_C_LOADER=1 -ldl -pthread

fernando at linux:~/Builds/S7-scheme/s7> ./s7 r7rs.scm s7: 16-May-2022
load r7rs.scm loading libc_s7.so
load /home/fernando/Builds/S7-scheme/s7/libc_s7.so failed:
/home/fernando/Builds/S7-scheme/s7/libc_s7.so: undefined symbol: s7_f

;unbound variable (symbol "\x7f;ELF\x02;\x01;\x01;")
;    (symbol "\x7f;ELF\x02;\x01;\x01;")
;    libc_s7.so, line 1, position: 7
; ((format *stderr* "writing ~A~%" c-file-n...
; ((load so-file-name cur-env))
; ((curlet))
```

With a clean git clone, and trying the different WITH_C_LOADER options,
I cannot make it work. The s7_f symbol seems to keep being deleted. I
am using GCC 11.2.1 in OpenSUSE Tumbleweed. If I use TCC, the s7_f
symbol/function error disappears (it is probably getting compiled).
However, S7 still tries to interpret the .so as a .scm:

```
fernando at linux:~/Builds/S7-scheme/s7> rm libc_s7.*

fernando at linux:~/Builds/S7-scheme/s7> rm s7

fernando at linux:~/Builds/S7-scheme/s7> tcc -o s7 s7.c -I. -lm
-DWITH_MAIN -ldl -pthread s7.c:71: error: include file 'mus-config.h'

not found fernando at linux:~/Builds/S7-scheme/s7> touch mus-config.h

fernando at linux:~/Builds/S7-scheme/s7> tcc -o s7 s7.c -I. -lm
-DWITH_MAIN -ldl -pthread

fernando at linux:~/Builds/S7-scheme/s7> ./s7
r7rs.scm s7: 16-May-2022
load r7rs.scm
writing libc_s7.c
loading libc_s7.so

;unbound variable (symbol "\x7f;ELF\x02;\x01;\x01;")
;    (symbol "\x7f;ELF\x02;\x01;\x01;")
;    libc_s7.so, line 1, position: 7
; ((delete-file o-file-name))
; ((load so-file-name cur-env))
; ((curlet))
```

Does S7 use GCC when it tries to compile libc_s7.c? Maybe the same
compiler that was used when compiling S7? There is not much
informational output of what it is actually trying to do...

> r7rs.scm needs the libc stuff; it starts with (require libc.scm).
> I suppose you could make a separate C program that loads s7.o
> and libc_s7.so.  There is no way to do this with just s7.c itself.
> There are examples in s7.html of how to do this sort of thing.
> Also r7rs.scm is not a full r7rs implementation, and I have no
> plans to make it one.
>

A full R7RS implementation is not a problem. I still need to see what
we actually need, so I cannot make a judgement now.

Thank you for your time! I will look deeper now into Chibi to see how
it compares with the others. And S7 is a pretty cool piece of software!

Regards,
Fer




More information about the Cmdist mailing list