gcc compiler modification to cater for new programming language

David Brown david@westcontrol.com
Mon Jun 11 09:24:00 GMT 2012


On 11/06/2012 09:45, Chris Jones wrote:
> Is it possible to modify the source code of gcc to enable to compilation
> of a completely new programming language, as yet unrecognized? How much
> of a big job would I be looking at for such a task?
>

I would think that would depend entirely on the language you want to 
implement.  If your language has similar principles to existing gcc 
languages, then most of the middle-end and back-end could be left 
untouched.  But if it has major differences, you might need to change 
gcc in all sorts of difficult places.

I guess the best guide here would be to look at the integration of Go 
into gcc - I believe it is the most recent addition to gcc.

You could also consider a stepping stone of making a translator between 
your new language and C (or C++, D, Go, etc.), then using gcc to compile 
the C code.  It is not going to be optimal, but it could be useful in 
developing your language, testing the concepts, developing the 
libraries, etc.  And it will also help answer your question - if you can 
make a reasonably efficient translator to C (using any gcc extensions as 
needed), then you can expect a reasonably straightforward job in writing 
a gcc front-end to the language.  But if you find concepts that are 
particularly alien to C, then you are going to have a bigger job writing 
a gcc front-end.




More information about the Gcc mailing list