Compilation


The command for compiling ATS programs is atscc, which is stored in the directory "$ATSHOME/bin/" after ATS/Anairiats is installed. The ATS compiler translates ATS programs into C code, which is then compiled by the GNU C compiler gcc.

atscc accepts all the flags gcc recognizes and passes them to gcc directly. The following is a list of flags that are special to atscc:

If a C compiler other than gcc is to be used, please set the environment variable ATSCCOMP to the command name of this C compiler.

As an example, the following command only typechecks the ATS code in "foo.dats" and "bar.sats":

atscc -tc foo.dats bar.sats
while the following command compiles "foo.dats" and "bar.sats" into "foo_dats.c" and "bar_sats.c", respectively, if typechecking "foo.dats" and bar.sats" succeeds:
atscc -cc foo.dats bar.sats
Typically, atscc is used as follows:
atscc -o foobar -O3 foo.dats bar.sats
When this command is issued, atscc first generates "foo_dats.c" and "bar_sats.c", and then invokes gcc to compile "foo_dats.c" and "bar_sats.c" to generate an executable file named "foobar". The flag "-O3" requires that gcc perform all optimizations classified at level 3 or below. We may also issue the following command to produce some debugging information for tools like gdb and valgrind:
atscc -o foobar -g foo.dats bar.sats
ATS programs can run with or without (systematic) garbage collection. If garbage collection is needed, then the following command can be issued to generate the executable "foobar":
atscc -o foobar -O3 foo.dats bar.sats -D_ATS_GCATS 

For your information, the command atscc is not implemented in a scripting language. It is one of the very first programs implemented in ATS/Geizella (and then ported to ATS/Anairiats). The code for atscc (and several other commands) can be found at utils/scripts/.