Re: Compiler bootstrapping and the standard header files

cvo <codevisio@gmail.com>
Fri, 20 Mar 2020 15:52:02 -0700 (PDT)

          From comp.compilers

Related articles
Compiler bootstrapping and the standard header files codevisio@gmail.com (2020-03-19)
Re: Compiler bootstrapping and the standard header files DrDiettrich1@netscape.net (Hans-Peter Diettrich) (2020-03-20)
Re: Compiler bootstrapping and the standard header files auriocus@gmx.de (Christian Gollwitzer) (2020-03-20)
Re: Compiler bootstrapping and the standard header files christopher.f.clark@compiler-resources.com (Christopher F Clark) (2020-03-20)
Re: Compiler bootstrapping and the standard header files codevisio@gmail.com (cvo) (2020-03-20)
Re: Compiler bootstrapping and the standard header files gah4@u.washington.edu (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 christopher.f.clark@compiler-resources.com (Christopher F Clark) (2020-03-22)
Re: Compiler bootstrapping and the standard header files 493-878-3164@kylheku.com (Kaz Kylheku) (2020-03-23)
| List of all articles for this month |
From: cvo <codevisio@gmail.com>
Newsgroups: comp.compilers
Date: Fri, 20 Mar 2020 15:52:02 -0700 (PDT)
Organization: Compilers Central
References: 20-03-018 20-03-019 20-03-021
Injection-Info: gal.iecc.com; posting-host="news.iecc.com:2001:470:1f07:1126:0:676f:7373:6970"; logging-data="64814"; mail-complaints-to="abuse@iecc.com"
Keywords: practice
Posted-Date: 21 Mar 2020 16:48:28 EDT
In-Reply-To: 20-03-021

Hi Hans-Peter, Christian and Christopher.


Thanks for all of your answer.


I reply here but my answer is for you all.




I'm not going to consider the cross-compiler case now.
My intention was to stick with the simplest scenario.


(
Premise: I'd use the term 'libraries' instead of 'runtime libraries'
since the majority, I think, of C standard function definitions are
implemented without OS API calls. At the same time there are two
libraries concepts, static and dynamic libraries. So in theory I
could link together the static libraries definitions inside my executable.
At least from the Windows world, but I guess the *nix also has those.
)




If I right understood you, the following are the steps.


1) Host compiler + host compiler headers + host compiler libraries
are used to compile my first version of my new compiler getting:
mygcc0 + mygcc0 C libraries.


2) Then I use mygcc0 + mygcc0 C headers + mygcc0 C libraries
to compile my second version of my new compiler getting: mygcc1 +
mygcc1 C libraries.


3) Eventually I use mygcc1 + mygcc1 C headers (== mygcc0 C headers) +
mygcc1 C libraries to compile my third version of my new compiler
getting: mygcc2 + mygcc2 C libraries.


Q1) Is that correct?
    If so, then point (1) above is a starting point. Point (2) is the
    first necessary step. While mygcc0 has code generated by the host
    compiler using its headers and its library functions, mygcc1 and
    mgcc1 C libraries instead have been generated by my new compiler,
    mygcc0.
    Q1.2) Is that correct?
        If so then also point (3) is a necessary step, because while it
        is true that mygcc1 has been generated by mygcc0 (without any
        host compilers), it is also true that I need a new version of my
        compiler to compare mygcc1 with. That is mygcc2.
        Q1.3) Is that correct?
            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?


            Why do I ask that? Because I can start debugging and fixing my
            compiler along with my C libraries (and C headers) since the
            beginning instead of debugging my C libraries at step 2. In other
            words, it is true I can compile my C libraries at step 1, but I
            cannot debug their implementation yet because at step 1 I'm using
            the C libraries (and headers) from the host environment. I can
            debug my C libraries implementation only at step 2.




Thanks all.


[To your Q1.3, there is a lot of wiggle room in the C standard,
particularly in internal implementation details. For example, in
stdio.h there is a definition of FILE as a typedef of an opaque
structure. There is no reason that your C library's FILE structure
would be the same as gcc's. I hope you're not planning to write your
own C library, since there are good quality open source ones you can
adapt. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.