gcc C编译器是用C本身编写的吗? [英] Is gcc C compiler written in C itself?
问题描述
gcc C 编译器是用 C 本身编写的吗?还是用汇编写的?如果编译器是用C写的,那么编译器用什么编译器来编译代码呢?
Is gcc C compiler written in C itself ? Or is it written in Assembly ? If the compiler is written in C, then what is the compiler used to compile the compiler code ?
推荐答案
The specific history to gcc is given at the GCC Wiki. The more general point is that compilers are generally originally compiled with some other compiler until they are powerful enough to compile themselves. Alternately, it is possible to write a basic compiler that can handle a subset of your features in assembler, and build up from there. But again, this is almost never needed anymore. There are plenty of compilers available, in a variety of languages. Even when Stephen Johnson was writing pcc (one of the first C compilers), there were compilers for B available, along with many other languages. gcc had several compilers to pick from to build it originally, and RMS says he was using the Pastel compiler at least during his initial development.
请记住,C 编译器并不要求用 C 语言编写.如果您愿意,可以用 Perl 编写它.不要求给定平台的编译器最初是在该平台上编写的(嵌入式系统几乎总是在其他系统上编译).因此,有很多方法可以让自己自力更生.
Remember, there is no requirement that a C compiler be written in C. You could write it in Perl if you wanted to. There is no requirement that a compiler for a given platform be originally written on that platform (embedded systems almost always are compiled on some other system). So there are many ways to get yourself bootstrapped.
这个问题有一些与引导编译器的第一个实例相关的有趣细节.如果你很聪明,你可以利用那个引导程序来做 一些不可思议的事情,辉煌而可怕.
This question has some interesting subtleties related to the first instance of bootstrapping the compiler. If you were very clever, you could make use of that bootstrap to do something incredible, brilliant and terrifying.
这篇关于gcc C编译器是用C本身编写的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!