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
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
generates object filesfoo.o1
,foo.o2
,foo.o3
, etc. These are ordinary object files likefoo.o
from the C compiler but have a running number at the end of the filename. Beware of commands likeobjdump -d foo.o1
that refer to a particular number; it may be an old object file left over from a previousgsc
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.