Project for CSC 255/455, Spring 2009


In the project, you will add your own optimization passes in the Gnu C compiler, GCC 4.2.2. It is not the most recent GCC, but should be sufficient for our project. You have to know the basic framework of GCC and how to manipulate the intermediate form, the gimple tree, for program analysis and transformation. This page includes many suggestions that will help you in the process. Please read the entire page and the pages about source browsing and debugging before you start.

Compilation and installation

  • Check out the code by using subversion, and install.
        mkdir gcc
        cd gcc
        svn co file:///p/compiler/repos/gcc-4.2.2/trunk gcc-4.2.2
           // if outside the firewall, use
           // svn co svn+ssh:// gcc-4.2.2
        mkdir obj
        cd obj
        ../gcc-4.2.2/configure --prefix=INSTALL_DIR
          // INSTALL_DIR is the directory you want to install the binary
        make install
  • For those who have no access to department research network, please download gcc-4.2.2.tar.bz2 and unzip it with the command tar -jxvf gcc-4.2.2.tar.bz2. For undergraduates, TBD.
  • Use either our desktop or personal machine or one of the public use machines in the CS department. When using department machines, due to the shortage of space for the /home directory, it is better to put your code under /localdisk .
  • To prevent the problem of hardware incompatibility, you'd better build your compiler and use it and run the compiled executables on the same kind of machines.
  • If you are not familiar with subversion, take a look at the VersionStuff page.
  • Gnu's wiki page on the generic installation procedure for GCC.

Browsing GCC code

  • Gnu's wiki page on GCC getting started.
    • You can open in a web browser the following file /p/compiler/built/gcc-4.2.2/doxygen/ and start with index.html for a local copy of Gcc 4.2.2 documentation by doxygen. If you copy, the directory needs about 600MB disk space.
    • Installing and using Doxygen to generate your own documentation
    • Good Assorted Topics Page from developer site also has a decent overview.
  • Using Emacs (especially useful when you work remotely)
  • Using Eclipse (w/ CDT). You can download Eclipse IDE for C/C++ Developers (68 MB) from here.


  • Dumping gimple-node
Actually, gcc you called when you do compilation is just a driver for real compiler cc1, assembler as and linker collect2. Use option -v you can see the exact command sequence. For direct debugging you should run gdb cc1. Refer to gdb documentation on how to set break points, print the current call stack, and examine variable values. You can modify variable values and call program functions within the debugger, making it a good test environment for trying your coding ideas.

Gcc has helper functions for examining the gimple tree. See the Q&A on examining an gimple node.

To make it easy to use the debugger later, you may want to change the optimization level in obj/Makefile after configure and before make, by replacing all O2 with O1.


Edit | Attach | Watch | Print version | History: r30 | r8 < r7 < r6 < r5 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r6 - 2009-01-26 - BinBao
  • Edit
  • Attach
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding URCS? Send feedback