GCC Compiler – Addressing the Chicken-and-Egg Issue

ccompilergcc

Since 4.8 release, the C++ compiler GCC (the G++ part of it) is written not in C anymore, but in C++ itself. I have a hypothetical question on this.

I wonder how to compile the C++ code of GCC on a new platform that has no C++ compiler yet. Of course, you could use prebuilt binaries compiled on other machines. Or you could use an older version of GCC that was written in C and compile the current version with it.

However, without prebuilt binaries and just the newest version, you were stuck, right? If not, are there other implications on this situation raised by the switch from C to C++ of the GCC project?

Best Answer

This is actually a well-known concept called bootstrapping. Basically, there exists, somewhere, a minimal C codebase to build a version of GCC that's capable of building the current GCC codebase. Self-hosting languages have been doing things like that for decades.

Related Topic