Re: [dev] [scc] typeof is a gcc keyword

From: S. Gilles <sgilles_AT_math.umd.edu>
Date: Tue, 5 Jul 2016 14:55:41 -0400

On 2016-07-05T15:31:57-0300, Marc Collin wrote:
> I did some tests with 8cc (because it's easier to build than scc for me).
> My results are that the binaries aren't identical.
> Here's a script so you can try to reproduce it.
>
> #!/bin/sh
> mkdir test_comp
> cd test_comp
> git clone https://github.com/rui314/8cc
> mv 8cc 1c
> cp -r 1c 2c
> cp -r 1c Ac
> cp -r 1c Bc
>
> # compile 8cc with gcc
> cd 1c
> make cc=gcc
>
> # compile 8cc with clang
> cd ../2c
> make cc=clang

I don't think this does what you expect it to do. At least looking at
the 8cc makefile, the compiler is hardcoded as `cc', not the expansion
of the variable `cc'. Try

    make cc=/bin/false

or such.

> # compile 8cc with 8cc
> # using the binary that
> # was compiled with gcc
> cd ../Ac
> make cc=../1c/8cc
>
> # compile 8cc with 8cc
> # using the binary that
> # was compiled with clang
> cd ../Bc
> make cc=../2c/8cc
>
> cd ..
>
> # compare binaries
> md5sum Ac/8cc Bc/8cc
>

On my system, the resulting binaries include references to the path they
were compiled at.

    $ ls */8cc
    8cc/8cc other_8cc/8cc
    $ strings 8cc/8cc | grep home
    /home/sgilles/temp/a/8cc/include
    #include </home/sgilles/temp/a/8cc/include/8cc.h>
    /home/sgilles/temp/a/8cc
    $ strings other_8cc/8cc | grep home
    /home/sgilles/temp/a/other_8cc/include
    #include </home/sgilles/temp/a/other_8cc/include/8cc.h>
    /home/sgilles/temp/a/other_8cc

I suspect this is what actually causes the differences in md5sums.

-- 
S. Gilles
Received on Tue Jul 05 2016 - 20:55:41 CEST

This archive was generated by hypermail 2.3.0 : Tue Jul 05 2016 - 21:00:18 CEST