This guide shows how to compile, optimize and deploy code in various Scheme implementations. It does not go in depth into implementation internals and how to optimize code for particular tasks.
The CHICKEN compiler translates Scheme to C, and then calls upon the system C compiler to turn that C into executable files, object files or shared object files.
To build an executable called foo
from the file foo.scm
:
csc foo.scm
To build a shared object foo.so
which can be loaded into a running
Scheme program using load
:
csc -shared foo.scm
To build a shared object for embedding into a C program:
csc -shared -embedded foo.scm
The translator is called chicken
, but for most normal uses you want
to use the csc
frontend which will call the C compiler for you.
csc -help
shows usage. There is also a manpage: man csc
.
The CHICKEN manual has details.
The CHICKEN mailing list and IRC channel are the best places to ask for help with more difficult problems.
This command will show you the expressions after final analysis, in CPS form:
csc -debug 7 foo.scm
By default, the compiler will delete the intermediate C files it
generates. To keep generated files, use -k
:
csc -k foo.scm
csc foo.scm && objdump -d foo
The Gambit compiler translates Scheme to C, and then calls upon the system C compiler to turn that C into standard object files (ELF, COFF or Mach-O).
The compiler is gsc
(also accessible by the alias gsc-script
— on
some operating systems gsc
is GhostScript, not Gambit). gsc
is the
same program as the interpreter gsi
but includes extra libraries
that implement the compiler.
gsc -help
shows usage.
The Gambit manual has details.
The Gambit mailing list is the best place to ask for help with more difficult problems.
gsc -expansion foo.scm
rm -f foo.o1 && gsc foo.scm && objdump -d foo.o1
gsc
generates object files foo.o1
, foo.o2
, foo.o3
, etc.
These are ordinary object files like foo.o
from the C compiler but
have a running number at the end of the filename. Beware of commands
like objdump -d foo.o1
that refer to a particular number; it may
be an old object file left over from a previous gsc
run.
If a pre-release version of gsc
produces a mysterious failure, try
removing all object and executable files generated by previous runs
in the same directory and compiling your code from scratch. gsc
can use existing files as cached build steps, and things sometimes
get out of sync.
doc.scheme.org is a community subdomain of scheme.org.
schemedoc
mailing list (archives,
subscribe), GitHub issues.