SUIF2 is the infrastructure for compiler development. If you want to develop a compiler in 2 weeks, SUIF2 may be a good choice for you, at least in SUIF2 documentation, it looks quite powerful and easy to extend.
The distance of the dream and reality makes our lives more colorful. The SUIF2 can not be compiled with the modern C++ compiler, such as GCC-4.1.1-r3 in my Gentoo. I googled and found there is literally NO success story to compile SUIF2 with GCC 3.x, let alone GCC 4.x. I do believe some graduate students have ported it to the latest GCC as in-house work, but nobody would like to share this work. Ok, let’s face the music, since gcc 2.96 would mess up my Gentoo’s profile, I decided to install RedHat 7.0 on my old Pentium III box.
It took a little while to find the legacy ISO, but the install procedure was quite smooth, the ugly text installation wizard reminded me the time in my college, some Linux fans scratched heads to make X works. The bottom line is a Linux box with GCC 2.96 and SSH access.
Besides the dependency on gcc 2.96, SUIF2 also depends on the graphviz and gv for the graphics output. I could not find the RPM for graphviz due to the “RPM dependency hell” of RedHat. This is just the option. Let’s move on.
Just follow this HOWTO.
cd /path/to/the/expected/destination/of/suif2 tar xvfz ~/tmp/basesuif-2.2.0-4.tar.gz cd nci patch -p1
NOTICE install would setup the
$NCIHOME_ to the current working
directory, you may override it after the build.
Here is a canonical helloworld in
the indented output is generated, the basic suif2 environment is setup
To invoke the SUIF2, you still need PGI C Compiler front end, pgcpp1. You
could get it from the
SUIF2 website. And
you might need to setup the
LD_LIBRARY_PATH to load all SUIF2 and pgcpp’s
shared objects. In my case, SUIF2 is installed in
export PATH=$PATH:$HOME/opt/nci/bin export LD_LIBRARY_PATH=$HOME/opt/nci/lib:$HOME/opt/nci/solib
Now, for a road test, just prepare a helloworld.c, and run
If you get helloworld.suif, bravo!
The suif output is for the machine to parse, not readable for human being. So we might need to install extra viewer for SUIF2.
cd ../ wget http://suif.stanford.edu/pub/suif/extras-2.2.0-4.tar.gz tar xvfz extras*.tar.gz cd nci make
Extras would install several viewer for
.suif file, for example,
suif2c helloworld.suif would generate
helloworld.out.c to inspect.