If the first C compiler was written in C... how could it be first C compiler? How could you compile the first C compiler?
The very first B compiler was written in BCPL by Ken Thompson. B later became self-hosting, i.e. the BCPL compiler compiled the B compiler, but this had another set of challenges due to the extreme memory constraints. It was an iterative process where a new feature was added such that it pushed the memory limit and then the compiler was rewritten to use the new feature to bring the memory usage down. C was heavily in…
First C compiler ported to GCC
81–90 of 90 posts
Re: First C compiler ported to GCC
#82Did this compiler really support "auto" as a variable type, as seen in example fizzbuzz ?
"auto" in c is a storage class specifier, like "register", "extern" or "static". https://en.cppreference.com/w/c/language/storage_duration It was considered pretty useless by most, so c++11 recycled the keyword to mean something different.
K&R (Second Ed). Makes no mention of the auto keyword in Section 1.10, but it does say,
> Each local variable in a function comes into existence only when the function is called, and disappears when the function is exited. This is why such variables are usually known as automatic [sic] variables[...]
Re: First C compiler ported to GCC
#83Earlier quoted context omitted.
"auto" in c is a storage class specifier, like "register", "extern" or "static". https://en.cppreference.com/w/c/language/storage_duration It was considered pretty useless by most, so c++11 recycled the keyword to mean something different.
Auto is the implicit default right? As in function scoped, stack allocated, and lives until the function is returned? K&R (Second Ed). Makes no mention of the auto keyword in Section 1.10, but it does say, > Each local variable in a function comes into existence only when the function is called, and disappears when the function is exited. This is why such variables are usually known as automatic [sic] variables[...]
Re: First C compiler ported to GCC
#84Earlier quoted context omitted.
Why can't it be 64-bit? I don't see any reason why we can't have an ILP64 data model. If int and int* were both 64-bit then it would restore so much of the original beauty of C.
It can be, and is, on platforms where supporting large arrays (if integers are 32 bits, arrays can ‘only’ have 2³¹ entries (#)) is deemed more important than memory usage. (#) https://software.intel.com/content/www/us/en/develop/documen... seems to imply that limit is 2³¹-1. I don’t understand why that would be true.
Re: First C compiler ported to GCC
#85Earlier quoted context omitted.
The very first B compiler was written in BCPL by Ken Thompson. B later became self-hosting, i.e. the BCPL compiler compiled the B compiler, but this had another set of challenges due to the extreme memory constraints. It was an iterative process where a new feature was added such that it pushed the memory limit and then the compiler was rewritten to use the new feature to bring the memory usage down. C was heavily in…
How was gcc bootstrapped?
https://en.wikipedia.org/wiki/GNU_Compiler_Collection#Histor...
Re: First C compiler ported to GCC
#86If the first C compiler was written in C... how could it be first C compiler? How could you compile the first C compiler?
Because to be the first, it has to be bootstrapped in an intermediate host language… You have to get a parser running, then the syntax, then the etc… etc…
( immense plug of the Ahl book here…)
To be the first complier in a language, as was pointed out, long before I was born, the compiler has to compile itself, so before it could compile itself, it had to have other language processing programs creating the parsing, the syntax, the etc…
Porting it to GCC just means that they could compile it with GCC, the big test is to get it to compile itself, on what ever platform that is the target platform, because finally, if it cannot generate object code/machine language in the target machine’s binary, then its not really ported.
Later on, UNIX came with tools to build compilers with, YACC and LEX.
If they got it to produce PDP-7 Code, its not really much of a port, really.
Re: First C compiler ported to GCC
#87Earlier quoted context omitted.
The first B compiler was actually written in TMG, and once it was bootstrapped that way in B itself. BCPL was only the inspiration for the language.
Wow, TMG was a new one for me. From the Wiki article on it: "Douglas McIlroy ported TMG to an early version of Unix. According to Ken Thompson, McIlroy wrote TMG in TMG on a piece of paper and "decided to give his piece of paper his piece of paper," hand-compiling assembly language that he entered and assembled on Thompson's Unix system running on PDP-7." We are not worthy, friends. We are not worthy.
Re: First C compiler ported to GCC
#88Earlier quoted context omitted.
Probably out of topic, but are there real examples of compiler attacks due to bootstrapping ? I did not hear about them before reading the scifi classic Accelerando by C. Stross
Oh, the thing with bootstrapping attacks is you never know are there any real examples. I recommend this[0] paper by Ken Thompson dated 1984 and still relevant. [0]: https://www.cs.cmu.edu/~rdriley/487/papers/Thompson_1984_Ref...
Re: First C compiler ported to GCC
#89If the first C compiler was written in C... how could it be first C compiler? How could you compile the first C compiler?
The question of if the first C compiler was written in C, how could it be the first C Compiler? Because to be the first, it has to be bootstrapped in an intermediate host language… You have to get a parser running, then the syntax, then the etc… etc… ( immense plug of the Ahl book here…) To be the first complier in a language, as was pointed out, long before I was born, the compiler has to compile itself, so before i…
It wasn't the first C compiler, it was the first self-hosted C compiler, which is different.
Re: First C compiler ported to GCC
#90Earlier quoted context omitted.
The first B compiler was actually written in TMG, and once it was bootstrapped that way in B itself. BCPL was only the inspiration for the language.
Wow, TMG was a new one for me. From the Wiki article on it: "Douglas McIlroy ported TMG to an early version of Unix. According to Ken Thompson, McIlroy wrote TMG in TMG on a piece of paper and "decided to give his piece of paper his piece of paper," hand-compiling assembly language that he entered and assembled on Thompson's Unix system running on PDP-7." We are not worthy, friends. We are not worthy.