Path: csiph.com!xmission!news.snarked.org!border2.nntp.dca1.giganews.com!nntp.giganews.com!news.iecc.com!.POSTED.news.iecc.com!nerds-end From: Christian Gollwitzer Newsgroups: comp.compilers Subject: Re: Compiler bootstrapping and the standard header files Date: Fri, 20 Mar 2020 10:21:11 +0100 Organization: A noiseless patient Spider Lines: 28 Sender: news@iecc.com Approved: comp.compilers@iecc.com Message-ID: <20-03-020@comp.compilers> References: <20-03-018@comp.compilers> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="85200"; mail-complaints-to="abuse@iecc.com" Keywords: practice Posted-Date: 20 Mar 2020 11:43:08 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:2491 Hi codevisio, Am 19.03.20 um 13:40 schrieb codevisio@gmail.com: > I've been going through come compiler sources available online and study > them, in particular C compilers. > > 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. No, such a rule does not exist and it would not make sense, either. The easiest way to see this is by considering a cross-compiler. Assume that your new compiler runs on host A (e.g. x86 PC) and compiles a program for host B (e.g. ARM Raspberry Pi). Then for running the compiler on the PC, you need the headers for the Raspi on the PC. But the resulting binary does not run there. The compiler itself must have been compiled by a compiler on the PC - because if you compile it with itself, it would not run on th PC. Therefore, to compile the compiler, you need the host compiler of the PC and the headers and libraries from there. Actually, a "cross compiler" is the regular case, and a "non-cross compiler" is a special case, albeit many developers only use one machine for compilation and testing, and therefore use a "non-cross compiler" where the target is the same as the host.