Path: csiph.com!xmission!news.alt.net!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: gah4@u.washington.edu Newsgroups: comp.compilers Subject: Re: Compiler bootstrapping and the standard header files Date: Sat, 21 Mar 2020 15:32:56 -0700 (PDT) Organization: Compilers Central Lines: 45 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <20-03-025@comp.compilers> References: <20-03-018@comp.compilers> Mime-Version: 1.0 Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="29579"; mail-complaints-to="abuse@iecc.com" Keywords: GCC, history Posted-Date: 21 Mar 2020 20:44:14 EDT X-submission-address: compilers@iecc.com X-moderator-address: compilers-request@iecc.com X-FAQ-and-archives: http://compilers.iecc.com In-Reply-To: <20-03-018@comp.compilers> Xref: csiph.com comp.compilers:2496 On Thursday, March 19, 2020 at 2:45:16 PM UTC-7, cvo wrote: > I've been going through come compiler sources available online and study > them, in particular C compilers. One reason for the inability to use such is copyright. But for now, I will assume that isn't the question. > Since all of them implement the C standards headers, my assumption was that > during the development of the compiler I cannot use the the standard headers > coming from the host environment & C compiler, but instead I have to use my > own standard headers I created for my compiler. As well as I remember the early days of gcc, though I wasn't so interested in it at the time, it was a replacement for an existing compiler, such as the one for SunOS. For some years, Sun had only one C compiler, distributed with SunOS, but at some point they licensed it separately. The compiler that came with SunOS was only meant to be enough to compile the kernel modules needed for sysgen. (But I believe gcc started before this.) In any case, at that time they used the existing SunOS (and maybe others, but I was mostly using Sun at the time) library. Much of the C header files have data structures (C struct) that match with library routines. I believe that gcc was trying to build a better optimizing compiler, and to get people to use it over the SunOS compiler. (Personal opinion, so anyone can disagree if they want to.) It was only sometime later that GNU wrote their own glibc as a replacement for the C library. Some data structures match system calls, and so are system dependent, where others are only need to be library internally consistent. As for cross compilers, much of the data structures are consistent across different architectures for the same system version, such as 68020 SunOS and Sparc SunOS, such that the header files would be the same, or almost the same. (As well as I remember, Sun keeps the system dependent ones separate, with a symbolic link to the actual version.) Writing the compiler first, using the existing library, conveniently allows one to get something working earlier.