|[2 earlier articles]|
|Re: Compiler bootstrapping and the standard header files firstname.lastname@example.org (Christian Gollwitzer) (2020-03-20)|
|Re: Compiler bootstrapping and the standard header files email@example.com (Christopher F Clark) (2020-03-20)|
|Re: Compiler bootstrapping and the standard header files firstname.lastname@example.org (cvo) (2020-03-20)|
|Re: Compiler bootstrapping and the standard header files email@example.com (2020-03-21)|
|Re: Compiler bootstrapping and the standard header files DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2020-03-22)|
|Re: Compiler bootstrapping and the standard header files firstname.lastname@example.org (Christopher F Clark) (2020-03-22)|
|Re: Compiler bootstrapping and the standard header files email@example.com (Kaz Kylheku) (2020-03-23)|
|From:||Kaz Kylheku <firstname.lastname@example.org>|
|Date:||Mon, 23 Mar 2020 13:49:38 +0000 (UTC)|
|Organization:||Aioe.org NNTP Server|
|References:||20-03-018 20-03-019 20-03-021 20-03-023 20-03-028|
|Injection-Info:||gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="230"; mail-complaints-to="email@example.com"|
|Posted-Date:||23 Mar 2020 11:12:28 EDT|
On 2020-03-22, Christopher F Clark <firstname.lastname@example.org> wrote:
> cvo asked:
> Your assumptions up to this one seemed correct to me.
> If so the the final and my first question is:
> Given a gcc in a linux environment with its C headers and
> with its C libraries, and given my compiler with its C headers
> and with its C libraries, as long as my C headers and C libraries
> conform semantically to the C standard, why cannot I use them
> in the first step, point (1), in place of host ones?
> If you header and libraries are written in standard C, and the
> original compiler works properly when you use them with it.
Your replacement C library, if it is to be actually stand-alone (not
depending on system libraries) can't be written entirely in standard C.
For example, I/O requires system calls, which use bits of assembly code,
inline or otherwise.
If that library has to be boostrapped with the host compiler, it may
have to rely on /its/ extensions (like inline assembler). If those
kinds of extensions look different in your own compiler, and you want
to be able to rebuild the library with it, /that/ code will have to be
written twice just due to the compiler differences, never mind all
the times it has to be written for different machines.
You're making a lot of extra work for yourself, including future
portability chores, if you make your own library.
> But listen carefully, to John, our moderators, comments and consider
> not writing your own library when writing your own compiler. I can
> probably count on one hand with fingers left over the number of times
> he's been wrong in the years I've been reading here. More importantly.
> Don't make unnecessary work for yourself. Writing a compiler is
> plenty to do. Adding more work on that pile, just means you won't do
> as good a job on it as you would if you had it as your only task.
A C library is not only a language library; it's platform abstraction
layer. Platform vendors provide these. If you want a compiler that can
be ported to many platforms, you can't be replicating the work of all
those vendors; it is not tractable.
A compiler may have to have a special run-time library to implement
certain things that have to do with the language itself, like any math
operators that can't be implemented in-line.
A compiler could ship with some interesting library that the compiler
vendor promotes. Like say that your compiler provides some interesting
features like dynamic compilation. Of course, you have to provide your
own API to it which accompanies the compiler.
Just don't go re-implementing POSIX and ISO C, I think.
Return to the
Search the comp.compilers archives again.