Home   –   Publications   –   Compiler   –   Download   –   Examples   –   Try it

Safe compiler download

A development (alpha) version of the Safe compiler is available for download. Notice that currently only the front-end is implemented and therefore no executable is generated. At the moment the program is typechecked in order to prove the absence of dangling pointers at runtime.

Download the Safe compiler front-end: Linux (i386)   Linux (amd64)

Compiler usage

The executable safecomp receives a phase number and a safe program. It compiles a program up to the specified phase and returns a pretty-printed representation of the resulting abstract syntax tree together with its decorations, which depend on the given phase.

$ ./safecomp {PhaseNumber} {FileName}

Where {PhaseNumber} specifies the compiler phase to execute, according to the following table:

Number Phase / Analysis
0 Lexical analysis
1 Preprocessing
2 Parsing
3 Renaming / Contextual constraints check
4 Hindley-Milner and region inference
5 Core-Safe transform
6 Sharing analysis
7 Safe type inference

Notice that all the phases are cumulative, that is, phase 6 entails the execution of phases 0-5. See the compiler page for defails on these phases and the related publications for information on the resulting decorations.

Execution example

$ ./safecomp 4 dynamicprog.safe

Utility script

An utility script is provided in order to execute all the phases and generate all the intermediate results with one command. It requires to have the Tcl interpreter installed.


$ ./run {FileName.safe}

A folder FileName (without the extension) will be created and the files 0.sf ... 7.sf will be written on it. Each .sf file contains the result of the corresponding compiler phase. If this folder already exists, all the .sf contained within will be removed before the generation of the new ones.


Four example programs are contained within the tarball.