PDA

View Full Version : [ubuntu] How was the original gcc compiled?



camper365
June 6th, 2009, 04:06 PM
I was just wondering how they compiled the original gcc?

benj1
June 6th, 2009, 04:22 PM
heres the answer
http://en.wikipedia.org/wiki/Bootstrapping_(compilers)


although existentialists et al may have other suggestions

Matt Yun
June 6th, 2009, 04:25 PM
GCC compiled itself: http://gcc.gnu.org/wiki/History

Wikipedia: http://en.wikipedia.org/wiki/GCC

night_fox
June 6th, 2009, 04:39 PM
I dare say gcc was originally compiled with another c compiler.

The first c compiler would have to have been written in something else, like assembly language, and the first assembler would have had to be written in pure machine code, but it was probably for a machine with simple instructions. That would have made the assembly language easier, so you could have written a c compiler more easily.

gcc takes preprocessed c and produces assembly language. when asked to do anything else, it calls cpp (preprocessor), as (assembler), and ld (linker). The last two are in a package call binutils.

This tells you how to compile it. Some parts can only be built in gcc
http://gcc.gnu.org/install/build.html

It tells you how to build a cross compiler and a native compiler. To build a native compiler, gcc compiles itself', uses itself' to compile itself'' and uses itself'' to compile itself'''. It then makes sure itself'' is itself'''.

To build a compiler on another machine (target), you have to have a native compiler on your machine (host), then use that to cross compile gcc for the target machine. Then you have to move cross compiled gcc to the target machine and use it to compile a native gcc

benj1
June 6th, 2009, 05:38 PM
i think the lisp compiler is my favourite, they already had an interpreter before they had a compiler, so they wrote the compiler in lisp then they ran the compiler through the compiler through the interpreter.