Re: Bootstraping compilers ?

Chris Hills <chris@phaedsys.org>
Fri, 18 Apr 2008 11:45:12 +0100

          From comp.compilers

Related articles
Bootstraping compilers ? pocm@soton.ac.uk (2008-04-16)
Re: Bootstraping compilers ? chris@phaedsys.org (Chris Hills) (2008-04-18)
Re: Bootstraping compilers ? roland.leissa@googlemail.com (=?ISO-8859-1?Q?Roland_Lei=DFa?=) (2008-04-18)
Re: Bootstraping compilers ? damian.thomas@unisys.com (Damian Thomas) (2008-04-18)
Re: Bootstraping compilers ? marcov@stack.nl (Marco van de Voort) (2008-04-18)
Re: Bootstraping compilers ? marcov@stack.nl (Marco van de Voort) (2008-04-18)
Re: Bootstraping compilers ? lindahl@pbm.com (Greg Lindahl) (2008-04-18)
Re: Bootstraping compilers ? cdb@nullstone.com (Christopher Glaeser) (2008-04-19)
[7 later articles]
| List of all articles for this month |

From: Chris Hills <chris@phaedsys.org>
Newsgroups: comp.compilers
Date: Fri, 18 Apr 2008 11:45:12 +0100
Organization: Phaedrus Systems
References: 08-04-059
Keywords: design
Posted-Date: 18 Apr 2008 11:59:10 EDT

Paulo Jorge de O. C. de Matos <pocm@soton.ac.uk> writes
>I am wondering if a compiler should always be able to compile
>itself. gcc for example seems to do it, but is this good practice or
>should this always happen?


No. Many compilers are cross compilers (the target is not the same as
the host). For this reason many Gcc compilers may not be able to
compile themselves either.


>My guess is that this is definitely not necessary.


That is a different question. (Assuming host and target are the same).
Being able to easily do something and it being necessary are two
different things.


>Imagine developing a compiler for C99 written in C89. In this case,
>we would have a C99 compiler not able to compile itself, right?
>[given that I don't think that C89 is a subset of C90]


C89 is a subset of C90... :-) but you are correct that C89/90 is not the
same as C99.


However once you have written a C99 compiler (using C95) you can then
write a C99 compiler and compile it with itself (after the first
compilation using the C99 compiler written in C95)


The first compiler for a new version of the language will always have
to be compiled with the old compiler. After that it should be able to
compile itself assuming the host and target are the same.


>test it. On the third hand, read this Ken Thompson classic
>http://cm.bell-labs.com/who/ken/trust.html -John]


This of course is the well known login legend. This is not a problem
where the source code is not available as in most commercial
compilers. So MS may have a hack in the compiler but only MS would
know this and it will seriously harm their business if word of it ever
gets out.


For things like the Gcc compilers where the source is readily
available from multiple sources :-) it is another matter. One could
"infect" a compiler and spread that binary around where it would
indeed infect any other compiler compiled with it.


--
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
\/\/\/\/\ Chris Hills Staffs England /\/\/\/\/
\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
[By the way, it's not a legend. Ken really did it. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.