[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Some patches

From: Petr Skocik
Subject: Re: [Tinycc-devel] Some patches
Date: Tue, 3 Apr 2018 16:25:54 +0200

Thanks for the accepts.

Feel free to ignore the realpath patch then.

But if you want to get into it:

Basically my current library build setup has an include directory
(cpath_component) with a
namespacing subdirectory directory (dir) and the subdirectory has a
symlink to '.' named the same as its parent:


        mkdir -p cpath_component/dir/
        ln -sfT . cpath_component/dir/dir
        tree cpath_component
                cd cpath_component/dir

        cat > h0.h<<EOF
        #pragma once

        cat > h1.h<<EOF
        #pragma once
        #include "dir/h0.h"

        cat > h2.h<<EOF
        #pragma once
        #include "dir/h0.h"
        #include "dir/h1.h"

(The idea behind this was so I could rename the namespacing directory
from outside without
 breaking internal double-quote-based includes.)

This works fine with clang and gcc but caused double includes on the
unpatched tcc.

Example (with the above setup):

        cat > main.c <<EOF
        #include "dir/h0.h"
        #include "dir/h2.h"
        int main(){}
        export "CPATH=$PWD/cpath_component"
        for CC in tcc gcc clang; do
                echo $CC
                $CC  -E main.c |grep '\.h"'

Anyway, I found another minor recently yesterday in

It seems tcc treats `vla+0` as compatible with `vla`, whereas
with regular arrays or with the `&vla[0]` notation instead of `vla+0`,
they're INcompatible
as they should be. (There's also problems with
__builtin_types_compatible_p with enums but I guess that's already
understood, judging by the comment in the code.).

        tcc -x c - -DN=argc <<<'int main(int argc, char**argv){  char a[N];
return __builtin_types_compatible_p(__typeof(a),__typeof(a+0)); }' &&
./a.out; echo $?
        #regular array
        tcc -x c - -DN=2 <<<'int main(int argc, char**argv){  char a[N];
return __builtin_types_compatible_p(__typeof(a),__typeof(a+0)); }' &&
./a.out; echo $?
        #vla + other notation
        tcc -x c - -DN=argc <<<'int main(int argc, char**argv){  char a[N];
return __builtin_types_compatible_p(__typeof(a),__typeof(&a[0])); }'
&& ./a.out; echo $?

I'm not super motivated to try and fix this one, though, cuz i can
simply fix my problem by using &a[0] in my code instead of a+0.

Petr Skocik

On 4/3/18, Ag, D.E Chatzimanikas <address@hidden> wrote:
> On Sun, Apr 01, at 12:57 Michael Matz wrote:
>> Hi,
>> On Sat, 31 Mar 2018, Petr Skocik wrote:
>> > The first takes symlinks into account with header file caching (I need
>> > it with my build setup which uses a symlink in a weird way -- gcc and
>> > clang don't have problems with it but tcc did).
>> Can you clarify what the problem is exactly?  Thing is: realpath isn't
>> available on WIN32, and using it causes many additional syscalls (per
>> directory component for each tried include path).
> Hi guys,
> I think there is a solution, and i wonder why nobody ever thought about
> this before (but anyway),
> so, how about to make a wrapper function (let me see: oh yes, i've found
> it, over their GetFullPathName()), and send it over to microsoft guys to
> patch their API?
> It's a win win situation here. They will get a patch for free (free as
> beer),
> and the poor developers will stop to cannibalize their code with those
> horrible
> ifdef's.
> So please, tell me that is a good idea, or what i'm missing here!.
>> Ciao,
>> Michael.
> Bye,
>   Αγαθοκλής
>   _______________________________________________
>> Tinycc-devel mailing list
>> address@hidden
>> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
> _______________________________________________
> Tinycc-devel mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel

reply via email to

[Prev in Thread] Current Thread [Next in Thread]