~mcf/cproc

1

chibicc can bootstrap cproc

Seo Sanghyeon
Details
Message ID
<YURWIIhHtkxhlD+l@rust>
DKIM signature
pass
Download raw message
I am not sure whether this is of interest to anyone, but I already
did debugging so I thought I'd let you know.

There were four issues. Diff is attached.

1. chibicc does not understand -pipe option (see configure).
2. chibicc fails to parse function type parameter without identifier
   (see util.h).
   This is https://github.com/rui314/chibicc/issues/63.
3. chibicc miscompiles anonymous union (see cc.h).
   This is https://github.com/rui314/chibicc/issues/45.
4. chibicc fails to parse nested designator (see type.c).
   This is https://github.com/rui314/chibicc/issues/62.

After these workarounds, chibicc successfully bootstraps cproc
on x86_64. Here is full script.

git clone https://github.com/rui314/chibicc.git
cd chibicc
git checkout 90d1f7f199cc55b13c7fdb5839d1409806633fdb
make
cd ..

git clone https://github.com/michaelforney/cproc.git
cd cproc
git checkout ab3946c6801be3520beeb79f5500ed1a944d4667
patch -p1 <../cproc-chibicc
make qbe
export PATH=qbe/obj:$PATH
./configure
make bootstrap CC=../chibicc/chibicc
cd ..
Details
Message ID
<CAGw6cBvt8sBOOijYfiuFUd8G=k9_3wzSnwnnKbY_dNM1tSOZcw@mail.gmail.com>
In-Reply-To
<YURWIIhHtkxhlD+l@rust> (view parent)
DKIM signature
missing
Download raw message
On 2021-09-17, Seo Sanghyeon <sanxiyn@gmail.com> wrote:
> I am not sure whether this is of interest to anyone, but I already
> did debugging so I thought I'd let you know.

I am definitely interested in this, thanks for working on it! The more
compilers that can build cproc the better.

> There were four issues. Diff is attached.
>
> 1. chibicc does not understand -pipe option (see configure).

This one is mostly just habit, I don't think it makes any sort of
noticeable difference in compilation time when building with gcc, and
cproc always uses pipes.

Could you commit that part of your diff and send it as a patch with
commit message? I am happy to apply it. Or, if you prefer, I could
write up a commit message and commit it listing you as author.

> 2. chibicc fails to parse function type parameter without identifier
>    (see util.h).
>    This is https://github.com/rui314/chibicc/issues/63.
> 3. chibicc miscompiles anonymous union (see cc.h).
>    This is https://github.com/rui314/chibicc/issues/45.
> 4. chibicc fails to parse nested designator (see type.c).
>    This is https://github.com/rui314/chibicc/issues/62.

These ones I'd like to see fixed in chibicc. (2) is valid syntax all
the way back to C89, and (4) is part of designated initializers
introduced in C99.

As for (3), I've been thinking recently to try to stick to C99 as the
source language of cproc rather than C11. My biggest worry is with
these anonymous unions, since I don't really want to clutter the code
with `u.` everywhere. But, I may make this change at some point.

> After these workarounds, chibicc successfully bootstraps cproc
> on x86_64. Here is full script.
>
> git clone https://github.com/rui314/chibicc.git
> cd chibicc
> git checkout 90d1f7f199cc55b13c7fdb5839d1409806633fdb
> make
> cd ..
>
> git clone https://github.com/michaelforney/cproc.git
> cd cproc
> git checkout ab3946c6801be3520beeb79f5500ed1a944d4667
> patch -p1 <../cproc-chibicc
> make qbe
> export PATH=qbe/obj:$PATH
> ./configure
> make bootstrap CC=../chibicc/chibicc
> cd ..

Nice, I can confirm that these steps worked for me, too. (just had to
do a few workarounds for musl libc and other peculiarities of my
system).
Reply to thread Export thread (mbox)