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
To build a shared object
foo.so which can be loaded into a running
Scheme program using
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:
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
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
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
objdump -d foo.o1 that refer to a particular number; it may
be an old object file left over from a previous
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.
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.
schemedocmailing list (archives, subscribe), GitHub issues.