如何引导GCC和g ++? [英] How are GCC and g++ bootstrapped?

查看:91
本文介绍了如何引导GCC和g ++?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这已经困扰了我一段时间。 GCC和g ++如何自行编译?

This has been bugging me for a while. How do GCC and g++ compile themselves?

我猜每个修订都使用先前构建的修订进行编译。这是真的?如果是的话,是否意味着最旧的g ++和GCC版本是用汇编编写的?

I'm guessing that every revision gets compiled with a previously built revision. Is this true? And if it is, does it mean that the oldest g++ and GCC versions were written in assembly?

推荐答案

最旧的GCC版本是使用另一个C编译器编译的,因为在编写时还有其他编译器。 PDP-11 程序集或在是B之前的B编程语言,但无论如何B编译器都是用汇编语言编写的。 同样,第一个C ++编译器(CPre / Cfront ,1979-1983)可能最早是用C实现的,然后用C ++重写。

The oldest version of GCC was compiled using another C compiler, since there were others when it was written. The very first C compiler ever (ca. 1973, IIRC) was implemented either in PDP-11 assembly, or in the B programming language which preceded it, but in any case the B compiler was written in assembly. Similarly, the first ever C++ compiler (CPre/Cfront, 1979-1983) were probably first implemented in C, then rewritten in C++.

编译GCC或任何其他自托管编译器时,完整的构建顺序为:

When you compile GCC or any other self-hosting compiler, the full order of building is:


  1. 使用现有的C编译器构建GCC的新版本

  2. 使用刚刚构建的GCC重新构建新的GCC版本

  3. (可选)重复第2步以进行验证。

此过程称为引导。它测试编译器的编译能力,并确保生成的编译器是使用其自身实现的所有优化构建的。

This process is called bootstrapping. It tests the compiler's capability of compiling itself and makes sure that the resulting compiler is built with all the optimizations that it itself implements.

EDIT : Drew Dormann在评论中指出了Bjarne Stroustrup对最早的C ++实现的描述。它是用C ++实现的,但被Stroustrup称为从C ++到C的预处理器进行了翻译。按照他的定义,它并不是一个完整的编译器,但是C ++仍然是用C语言引导的。

EDIT: Drew Dormann, in the comments, points to Bjarne Stroustrup's account of the earliest implementation of C++. It was implemented in C++ but translated by what Stroustrup calls a "preprocessor" from C++ to C; not a full compiler by his definition, but still C++ was bootstrapped in C.

这篇关于如何引导GCC和g ++?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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