0

I have a problem that has caused me quite a few headaches and I would like some help from one of you.

I have a Linux operating system installed on my computer. The problem is that it doesn't have the GCC compiler and I would like to build it myself from source code.

The first thing I do is download GCC from its official repository (Latest version)

git clone git://gcc.gnu.org/git/gcc.git

Next, I unzip the GCC .tar.xz package and run the file called configure

At compile time, the process tells me that to compile GCC, I need gawk and bison, and this is where the problem comes.

To install either of those two tools (By source code), I need to have the compiler installed. So it goes like this,

  • GCC needs GAWK and BISON
  • GAWK and BISON needs GCC

What could I do?

Thank you!

  • 7
    Why do you want/need to build every package from source? – kaylum May 19 '22 at 05:43
  • 7
    To build anything from source, you need the tools to build it. For a compiler it's a catch-22. You need to install your distributions compiler before you can build your own. – Some programmer dude May 19 '22 at 05:43
  • 1
    If you're not using a popular distribution, you may at least has a cross compiler toolchain to build the compiler on target machine. – Louis Go May 19 '22 at 05:47
  • 1
    Even if you had `gawk` and `bison`, you couldn't compile `gcc` without a C compiler. (I think `gawk` and `bison` can be compiled with any reasonable compiler, just as `gcc` can.) But you can't get anywhere without a currently-working C compiler. – Dave M. May 19 '22 at 05:54
  • gcc is special, hence the seeming catch-22 you describe. If you don't have a native compiler or a cross-compiler on another system, there are options to bootstrap that process - I describe one. (1) Download binary distributions of gcc, gawk, bison for your platform (2) Use those tools to build a new gcc from source (3) Use the newly built gcc to build gawk and bison from source (4) Use those new-build tools to rebuild all the tools from source. The makefile for gcc (and also, IIRC, makefiles for gawk and bison) has several build targets to support multi-phase builds like this – Peter May 19 '22 at 06:10
  • Makes you wonder how this big old world of ours got started. Just sayin' – Paul Sanders May 19 '22 at 06:12
  • @PaulSanders Same sort of process as I described. The first compilers were quite simple (actually assemblers) were written by hand (by people who literally edited executables by hand). Then code was written for an assembler, and built using the first hand-built assembler, and that assembler was used to build a more capable/complicated assembler. An assembler was used to build the first compilers for higher-level languages. Some of those compilers were used to rebuild themselves, and then used to build more complicated compilers. And so on. – Peter May 19 '22 at 06:19
  • @peter I wasn't talking about computers :) – Paul Sanders May 19 '22 at 06:28
  • ... I am old enough to have debugged via a set of front panel lights ... – Paul Sanders May 19 '22 at 06:29
  • @PaulSanders You meant ["Let there be light"(The Last Question)?](https://en.wikipedia.org/wiki/The_Last_Question) – Louis Go May 19 '22 at 06:29
  • @PaulSanders bootstrapping... or "standing on the shoulders of giants". I used to debug with a strip of LEDs or even a single LED. – Weather Vane May 19 '22 at 06:31
  • @PaulSanders Same sort of thing. ;-) I know someone who debugged a program by interpreting cracking noises from vacuum tubes. His hair literally stood on end at times. – Peter May 19 '22 at 06:49
  • @WeatherVane You're a young pup. How do you think the first LEDs were constructed? :-) – Peter May 19 '22 at 06:51
  • @WeatherVane What's an LED? :) – Paul Sanders May 19 '22 at 07:28

0 Answers0