Results 1 to 9 of 9
When I was intalling GCC to my Linux, I think there must be another C compiler compiling GCC files ,what is that?...
- 08-31-2009 #1Just Joined!
- Join Date
- Aug 2009
- Posts
- 3
I have a question about GCC
When I was intalling GCC to my Linux, I think there must be another C compiler compiling GCC files ,what is that?
- 08-31-2009 #2
Depending on how you did the installation there might be the possibility that you didn't need a compiler.
There aren't many distributions that use the actual source code to install the actual applications. The distributions that do, are probably not suitable for newbies.
Depending on your distribution you downloaded a deb or rpm file which contained the binary image of the compiler. Installing the binaries is generally speaking faster than compiling from source.
To me it is unlikely you have compiled the compiler, as that would take up a lot of time (on my systems it takes about 3 hours) and it would be pretty much unlikely you can compile GCC without GCC as GCC is written to be compiled using (indeed) GCC.
- 08-31-2009 #3
Bemk is correct. When you installed gcc, you actually installed a precompiled version. You did not actually compile any C source files.
Even a distro like Gentoo, which does do source-based package management, bootstraps your system with a binary GCC. You can then compile the GCC source for yourself (and all future GCC installations are compiled from source), but that first one has to be prebuilt.DISTRO=Arch
Registered Linux User #388732
- 09-01-2009 #4Just Joined!
- Join Date
- Aug 2009
- Posts
- 3
Thank you for the help !
I have another question , How the first C compiler compile itself?
- 09-01-2009 #5
The very first C compiler wasn't compiled using C but using a different language. The very first programming language (assembler) was developed by programmers who could write binary code.
Assembler isn't used that much nowadays, but to develop a better understanding of how your system works, it could be nice to learn it, as the instructions you type in, are just ascii synonyms for the binary code that will roll out.
The place assembler is used mostly, these days, is in the bootstrapping code of operating systems and boot loaders. The rest is all developed in higher level programming languages, such as C, C++, Pascal, Delphi, etc.
- 09-01-2009 #6
Indeed. The very first programs were in fact series of 0 and 1 that were input by hand by the programmer. After a while of doing this, assemblers were born. Assemblers take human-readable assembly instructions and turn them into a series of 0 and 1. An example might be (in MIPS):
This is a program to add 5 and 10, and then print the result. It is basically the same as writing a sequence of 0s and 1s, except that it is more human-readable.Code:li $s0, 5 addi $s0, $s0, 10 mov $a0, $s0 li $v0, 1 syscall
At this point, it is possible to build bigger and bigger programs. So in assembly, a compiler for C could be written. With this C compiler, we can write new languages using C (the Perl interpreter, for instance, is written in C). And now that we have a C compiler, we can even write a _better_ C compiler in C).
It's complicated, but it works.DISTRO=Arch
Registered Linux User #388732
- 09-01-2009 #7
As far as I know these questions are also answered at Wikipedia, so if you want to learn more, that is one good place to start searching.
Something I haven't figured out though is how a compiler works on algorithm level. I know I have to because it is my dream to design and write a full OS (be it a basic one) in which I can compile the OS itself, meaning I will have to cross-compile a compiler for the system I am designing at the moment.
If you think I won't succeed, just give me some time, in a year or 4 there might be a project running. It will probably start as closed source though.
- 09-01-2009 #8
I actually took a Compilers class last year in college. It's a bit tough until you get to register allocation, at which point it becomes very complicated. Building a compiler does require a certain knowledge of assembly language and lower-level concepts, however.
If you're interested in compiler design, my class employed this book:
Modern Compiler Implementation in ML
However, I know that this book is very, very popular:
Dragon Book (computer science) - Wikipedia, the free encyclopediaLast edited by Cabhan; 09-02-2009 at 09:46 PM.
DISTRO=Arch
Registered Linux User #388732
- 09-02-2009 #9
Well, I expect it to be really complex indeed, but I will grasp the idea once, I suppose, if I just try hard enough, it will once all fall into place.
I am not devoting all of my time to it, for I have more urgent things to do. (an example: school)


Reply With Quote