[CM] S7 questions and libc issue

Fernando Oleo Blanco irvise_ml at irvise.xyz
Tue Jun 28 11:58:49 PDT 2022


Sorry if you receive this email duplicated. I forgot to "Reply All".

I am back and I bring some extra information regarding the
compilation/cross-compilation of S7 with support for libc.scm. My
motivation to continue digging was [1]. S7 has great performance and it
also has outstanding R7RS support if we follow those results. I
personally thought it had worst support.

A bit of background first. When Chibi wants to compile itself
"staticly", with all of its libraries as part of the executable, it
requires a two step compilation process.
- First it compiles itself normally (dynamic linking, only the
  interpreter) for the host.
- Then using the native Chibi executable that was just created, it
  generates a C file which is just the translation of all of its Scheme
  libraries and dumps them together.
- Finally, the compilation of Chibi is ran again but this time, it
  links itself with the new generated C file that contains absolutely
  everything. The resulting binary is all of Chibi in one binary.

So that got me thinking... Can this be done for S7 if I want to
cross-compile it with libc support and link it staticly?

So here is what I did:

- Compile S7 for the host normally.
- Run the interpreter ala "./s7 r7rs.scm" so that it generates the
  libc_s7.{c,so} files.
- Cross-compile S7 for my RISC-V board staticly (which as previously
  said, it works) and WITH_C_LOADER so that it can read .so files.
- Generate a libc_s7.so for the target architecture. Basically, another

However, I am running into a problem... or maybe a few of them. I
actually do not know how S7 generates the libc_s7.so. I took a look at
the cload.scm and I think I reverse engineer what it is trying to do.
However, in the end, my staticly compiled S7 in my RISC-V board always
fails to run with libc... It either fails because it cannot find some
symbols (such as s7_f) even though I used GCC and passed
-DWITH_C_LOADER=1 or it aborts... I know the generated .so is for
RISC-V and it has the symbols.

Has anybody tried this before? I think it should just work... I have
also documented this process in the Scheme comparison table (currently,
footnote 25) [2]. The exact execution commands are also in [2]

I may be extremely slow to respond, as my worklife is currently a
black hole.

[1] https://ecraven.github.io/r7rs-benchmarks/
[2] https://irvise.xyz/Blog/scheme-implementation-comparison.html#fn.25

Best regards, and thank you for your time!

More information about the Cmdist mailing list