gcc C编译器是用C本身编写的吗? [英] Is gcc C compiler written in C itself?

查看:29
本文介绍了gcc C编译器是用C本身编写的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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 ?

推荐答案

gcc 的具体历史在 GCC Wiki.更一般的一点是,编译器通常最初是与其他一些编译器一起编译的,直到它们足够强大来编译自己.或者,可以编写一个基本编译器,它可以处理汇编程序中的一部分功能,并从那里构建.但同样,这几乎不再需要了.有很多可用的编译器,有多种语言.即使当 Stephen Johnson 编写 pcc(最早的 C 编译器之一)时,也有可用的 B 编译器以及许多其他语言.gcc 最初有几个编译器可供选择来构建它,RMS 说他至少在最初的开发过程中使用的是 Pastel 编译器.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆