This document shows the steps required for creating a new GCC front end. It helps you to create a compiler of your own with the help of the GNU Compiler Collection. Basic information about tools like Bison and Flex is also provided to make the document self contained.
I assume that you have sound knowledge of the C programming language. A general idea about compilers will help you understand the document better. If you wish to make experiments of your own, please download the source code of GCC from http://gcc.gnu.org.
This version of the document will help you in developing basic language constructs. Succeeding revisions will be focussed on more complex issues.
This document may have mistakes in it because I am writing from my practical experiments with the front end. There may be faults in the way I have grasped things. Please inform me about the mistakes, so that I can correct them in the next version. I always welcome suggestions and criticisms. I can be contacted at email@example.com
I started out trying to add a small language to the GNU Compiler Collection. Even though there is an excellent manual which describes GCC internals, I found it a bit intimidating to the newbie hacker. I thought of documenting my experiments so that even novice programmers can start tinkering with the complex GCC code base.
Copyright (C)2002 Sreejith K Menon.
This document is free; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This document is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
This document is the by-product of an intensive `code reading' experiment conducted at the Government Engineering College, Trichur (GECT). Students were asked to read and tinker with the source code of reasonably complex systems software to give them a feel of how large systems are designed and maintained - some of us concentrated on the GCC front end, others on the back end (we hope to have a document on hacking the GCC backend soon!). Those who have a flair for Operating Systems had a chance to work on the Linux file system, scheduler, VM subsystem and the networking stack.
I am indebted to the Free Software community as a whole for giving me a chance to play with the source of useful(and exciting!) programs. My thanks to the faculty of the Department of Computer Science at GECT for their commitment to education. Thanks to Mr.Pramode C.E for leading me to Linux and compilers.
I am grateful to Tim Josling, who has created a small beautiful front end, which helped me in all my experiments.