minor patches + standard compliant inline functions

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

minor patches + standard compliant inline functions

Petr Skočík
Hi,

I've pushed a bunch of patches to tinycc.


The first three:

- turn -fdollars-in-identifiers on by default (gcc/clang do it too)
- in c11 mode, skip __STDC_ISO_10646__ (was causing a redefinition
warning in simple hello world programs compiled on linux with -std=c11)
- make -h|-hh succeed if the output is successfully written

are small and should be noncontroversial.

The last one is largish and I welcome any input on it.

The issue was that tinycc's implementation of non-static inline
functions was very much nonconforming in terms of when
visible symbols would or would not be created. By looking at the at the
mailing list archive, it looks like it was discussed in 2013 but nothing
was done about it.

The supplied patch should be fixing it.

Best regards,

Petr Skocik

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: minor patches + standard compliant inline functions

Christian Jullien-3
Thanks for your patch,
FYI, for Windows compatibility:

turn -fdollars-in-identifiers on by default is Ol as it also applies to cl on Windows (the old VMS days :o)
Also ok to remove __STDC_ISO_10646__ as is not defined on Windows too.

Please note that a conforming C11 implementation should have <uchar.h> which is missing on Windows includes. Among others, on Windows it defines both:

__STDC_UTF_16_ _ The integer constant 1, intended to indicate that values of type char16_t are UTF−16 encoded. If some other encoding is used, the macro shall not be defined and the actual encoding used is implementation defined.

__STDC_UTF_32_ _ The integer constant 1, intended to indicate that values of type char32_t are UTF−32 encoded. If some other encoding is used, the macro shall not be defined and the actual encoding used is implementation defined.

To make tcc more C11 compatible on Windows, I propose to add to the win32 directory this file:

win32/include/uchar.h:

/**
 * This file has no copyright assigned and is placed in the Public Domain.
 * This file is part of the TinyCC package.
 * No warranty is given; refer to the file DISCLAIMER within this package.
 */

/**
  * __STDC_UTF_16__ The integer constant 1, intended to indicate that values of type char16_t are UTF−16 encoded.
 */
#define __STDC_UTF_16__ 1
/**
 * __STDC_UTF_32__ The integer constant 1, intended to indicate that values of type char32_t are UTF−32 encoded.
 */
#define __STDC_UTF_32__ 1

 typedef unsigned short char16_t;
 typedef unsigned int char32_t;



-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Petr Skocík
Sent: Tuesday, June 11, 2019 16:41
To: [hidden email]
Subject: [Tinycc-devel] minor patches + standard compliant inline functions

Hi,

I've pushed a bunch of patches to tinycc.


The first three:

- turn -fdollars-in-identifiers on by default (gcc/clang do it too)
- in c11 mode, skip __STDC_ISO_10646__ (was causing a redefinition
warning in simple hello world programs compiled on linux with -std=c11)
- make -h|-hh succeed if the output is successfully written

are small and should be noncontroversial.

The last one is largish and I welcome any input on it.

The issue was that tinycc's implementation of non-static inline
functions was very much nonconforming in terms of when
visible symbols would or would not be created. By looking at the at the
mailing list archive, it looks like it was discussed in 2013 but nothing
was done about it.

The supplied patch should be fixing it.

Best regards,

Petr Skocik

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: minor patches + standard compliant inline functions

Christian Jullien-3
Ooops, trying to compile tcc (after tcc has been compiled a first time) on Windows with your recent patch (and w/o uchar.h), I now get:

Building lib/libtcc1-32.a with tcc -m32
./include/winapi/winnt.h:1478: error: invalid operand reference after %

Here:
#if(defined(_X86_) && !defined(__x86_64))
  __CRT_INLINE VOID MemoryBarrier(VOID) {
    LONG Barrier;
    __asm__ __volatile__("xchgl %eax,%0 "
      :"=r" (Barrier));
  }


Here is the final version of uchar.h I'll push if nobody complains

win32/include/uchar.h:

/**
 * This file has no copyright assigned and is placed in the Public Domain.
 * This file is part of the TinyCC package.
 * No warranty is given; refer to the file DISCLAIMER within this package.
 */

#ifndef _INC_UCHAR
#define _INC_UCHAR

/*
 * The following defines are only valid when C11 (-std=c11) is used.
 */

#if __STDC_VERSION__ >= 201112L
/**
 * __STDC_UTF_16__ The integer constant 1, intended to indicate that
 * values of type char16_t are UTF-16 encoded.
 */
#define __STDC_UTF_16__ 1
/**
 * __STDC_UTF_32__ The integer constant 1, intended to indicate that
 * values of type char32_t are UTF-32 encoded.
 */
#define __STDC_UTF_32__ 1

typedef unsigned short char16_t;
typedef unsigned int char32_t;
#endif /* __STDC_VERSION__ */
#endif /* _INC_UCHAR */

-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Christian Jullien
Sent: Wednesday, June 12, 2019 06:49
To: [hidden email]
Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions

Thanks for your patch,
FYI, for Windows compatibility:

turn -fdollars-in-identifiers on by default is Ol as it also applies to cl on Windows (the old VMS days :o)
Also ok to remove __STDC_ISO_10646__ as is not defined on Windows too.

Please note that a conforming C11 implementation should have <uchar.h> which is missing on Windows includes. Among others, on Windows it defines both:

__STDC_UTF_16_ _ The integer constant 1, intended to indicate that values of type char16_t are UTF−16 encoded. If some other encoding is used, the macro shall not be defined and the actual encoding used is implementation defined.

__STDC_UTF_32_ _ The integer constant 1, intended to indicate that values of type char32_t are UTF−32 encoded. If some other encoding is used, the macro shall not be defined and the actual encoding used is implementation defined.

To make tcc more C11 compatible on Windows, I propose to add to the win32 directory this file:

win32/include/uchar.h:

/**
 * This file has no copyright assigned and is placed in the Public Domain.
 * This file is part of the TinyCC package.
 * No warranty is given; refer to the file DISCLAIMER within this package.
 */

/**
  * __STDC_UTF_16__ The integer constant 1, intended to indicate that values of type char16_t are UTF−16 encoded.
 */
#define __STDC_UTF_16__ 1
/**
 * __STDC_UTF_32__ The integer constant 1, intended to indicate that values of type char32_t are UTF−32 encoded.
 */
#define __STDC_UTF_32__ 1

 typedef unsigned short char16_t;
 typedef unsigned int char32_t;



-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Petr Skocík
Sent: Tuesday, June 11, 2019 16:41
To: [hidden email]
Subject: [Tinycc-devel] minor patches + standard compliant inline functions

Hi,

I've pushed a bunch of patches to tinycc.


The first three:

- turn -fdollars-in-identifiers on by default (gcc/clang do it too)
- in c11 mode, skip __STDC_ISO_10646__ (was causing a redefinition
warning in simple hello world programs compiled on linux with -std=c11)
- make -h|-hh succeed if the output is successfully written

are small and should be noncontroversial.

The last one is largish and I welcome any input on it.

The issue was that tinycc's implementation of non-static inline
functions was very much nonconforming in terms of when
visible symbols would or would not be created. By looking at the at the
mailing list archive, it looks like it was discussed in 2013 but nothing
was done about it.

The supplied patch should be fixing it.

Best regards,

Petr Skocik

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: minor patches + standard compliant inline functions

Christian Jullien-3
More specifically this one: "standard conformant inline functions"

-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Christian Jullien
Sent: Wednesday, June 12, 2019 07:20
To: [hidden email]; [hidden email]
Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions

Ooops, trying to compile tcc (after tcc has been compiled a first time) on Windows with your recent patch (and w/o uchar.h), I now get:

Building lib/libtcc1-32.a with tcc -m32
./include/winapi/winnt.h:1478: error: invalid operand reference after %

Here:
#if(defined(_X86_) && !defined(__x86_64))
  __CRT_INLINE VOID MemoryBarrier(VOID) {
    LONG Barrier;
    __asm__ __volatile__("xchgl %eax,%0 "
      :"=r" (Barrier));
  }


Here is the final version of uchar.h I'll push if nobody complains

win32/include/uchar.h:

/**
 * This file has no copyright assigned and is placed in the Public Domain.
 * This file is part of the TinyCC package.
 * No warranty is given; refer to the file DISCLAIMER within this package.
 */

#ifndef _INC_UCHAR
#define _INC_UCHAR

/*
 * The following defines are only valid when C11 (-std=c11) is used.
 */

#if __STDC_VERSION__ >= 201112L
/**
 * __STDC_UTF_16__ The integer constant 1, intended to indicate that
 * values of type char16_t are UTF-16 encoded.
 */
#define __STDC_UTF_16__ 1
/**
 * __STDC_UTF_32__ The integer constant 1, intended to indicate that
 * values of type char32_t are UTF-32 encoded.
 */
#define __STDC_UTF_32__ 1

typedef unsigned short char16_t;
typedef unsigned int char32_t;
#endif /* __STDC_VERSION__ */
#endif /* _INC_UCHAR */

-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Christian Jullien
Sent: Wednesday, June 12, 2019 06:49
To: [hidden email]
Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions

Thanks for your patch,
FYI, for Windows compatibility:

turn -fdollars-in-identifiers on by default is Ol as it also applies to cl on Windows (the old VMS days :o)
Also ok to remove __STDC_ISO_10646__ as is not defined on Windows too.

Please note that a conforming C11 implementation should have <uchar.h> which is missing on Windows includes. Among others, on Windows it defines both:

__STDC_UTF_16_ _ The integer constant 1, intended to indicate that values of type char16_t are UTF−16 encoded. If some other encoding is used, the macro shall not be defined and the actual encoding used is implementation defined.

__STDC_UTF_32_ _ The integer constant 1, intended to indicate that values of type char32_t are UTF−32 encoded. If some other encoding is used, the macro shall not be defined and the actual encoding used is implementation defined.

To make tcc more C11 compatible on Windows, I propose to add to the win32 directory this file:

win32/include/uchar.h:

/**
 * This file has no copyright assigned and is placed in the Public Domain.
 * This file is part of the TinyCC package.
 * No warranty is given; refer to the file DISCLAIMER within this package.
 */

/**
  * __STDC_UTF_16__ The integer constant 1, intended to indicate that values of type char16_t are UTF−16 encoded.
 */
#define __STDC_UTF_16__ 1
/**
 * __STDC_UTF_32__ The integer constant 1, intended to indicate that values of type char32_t are UTF−32 encoded.
 */
#define __STDC_UTF_32__ 1

 typedef unsigned short char16_t;
 typedef unsigned int char32_t;



-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Petr Skocík
Sent: Tuesday, June 11, 2019 16:41
To: [hidden email]
Subject: [Tinycc-devel] minor patches + standard compliant inline functions

Hi,

I've pushed a bunch of patches to tinycc.


The first three:

- turn -fdollars-in-identifiers on by default (gcc/clang do it too)
- in c11 mode, skip __STDC_ISO_10646__ (was causing a redefinition
warning in simple hello world programs compiled on linux with -std=c11)
- make -h|-hh succeed if the output is successfully written

are small and should be noncontroversial.

The last one is largish and I welcome any input on it.

The issue was that tinycc's implementation of non-static inline
functions was very much nonconforming in terms of when
visible symbols would or would not be created. By looking at the at the
mailing list archive, it looks like it was discussed in 2013 but nothing
was done about it.

The supplied patch should be fixing it.

Best regards,

Petr Skocik

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: minor patches + standard compliant inline functions

Petr Skočík
Hi, Christian Jullien.  Thanks for the feedback.

I don't have a Windows setup for tinycc to test it on right now, but
from a cursory glance, __CRT_INLINE is defined as `extern __inline__` in
./win32/include/_mingw.h. Before the patch, extern __inline__ would
create static functions (and only if the function was later referenced).
After the patch, it'll unconditionally instantiate the function (as an
extern). I think redefining it to `__CRT_INLINE` `static __inline__`
might fix the problem.

I'll try and get a tinycc build working on windows and see if it helps.

Cheers,
Petr S.

On 6/12/19 11:10 AM, Christian Jullien wrote:

> More specifically this one: "standard conformant inline functions"
>
> -----Original Message-----
> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Christian Jullien
> Sent: Wednesday, June 12, 2019 07:20
> To: [hidden email]; [hidden email]
> Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions
>
> Ooops, trying to compile tcc (after tcc has been compiled a first time) on Windows with your recent patch (and w/o uchar.h), I now get:
>
> Building lib/libtcc1-32.a with tcc -m32
> ./include/winapi/winnt.h:1478: error: invalid operand reference after %
>
> Here:
> #if(defined(_X86_) && !defined(__x86_64))
>   __CRT_INLINE VOID MemoryBarrier(VOID) {
>     LONG Barrier;
>     __asm__ __volatile__("xchgl %eax,%0 "
>       :"=r" (Barrier));
>   }
>
>
> Here is the final version of uchar.h I'll push if nobody complains
>
> win32/include/uchar.h:
>
> /**
>  * This file has no copyright assigned and is placed in the Public Domain.
>  * This file is part of the TinyCC package.
>  * No warranty is given; refer to the file DISCLAIMER within this package.
>  */
>
> #ifndef _INC_UCHAR
> #define _INC_UCHAR
>
> /*
>  * The following defines are only valid when C11 (-std=c11) is used.
>  */
>
> #if __STDC_VERSION__ >= 201112L
> /**
>  * __STDC_UTF_16__ The integer constant 1, intended to indicate that
>  * values of type char16_t are UTF-16 encoded.
>  */
> #define __STDC_UTF_16__ 1
> /**
>  * __STDC_UTF_32__ The integer constant 1, intended to indicate that
>  * values of type char32_t are UTF-32 encoded.
>  */
> #define __STDC_UTF_32__ 1
>
> typedef unsigned short char16_t;
> typedef unsigned int char32_t;
> #endif /* __STDC_VERSION__ */
> #endif /* _INC_UCHAR */
>
> -----Original Message-----
> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Christian Jullien
> Sent: Wednesday, June 12, 2019 06:49
> To: [hidden email]
> Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions
>
> Thanks for your patch,
> FYI, for Windows compatibility:
>
> turn -fdollars-in-identifiers on by default is Ol as it also applies to cl on Windows (the old VMS days :o)
> Also ok to remove __STDC_ISO_10646__ as is not defined on Windows too.
>
> Please note that a conforming C11 implementation should have <uchar.h> which is missing on Windows includes. Among others, on Windows it defines both:
>
> __STDC_UTF_16_ _ The integer constant 1, intended to indicate that values of type char16_t are UTF−16 encoded. If some other encoding is used, the macro shall not be defined and the actual encoding used is implementation defined.
>
> __STDC_UTF_32_ _ The integer constant 1, intended to indicate that values of type char32_t are UTF−32 encoded. If some other encoding is used, the macro shall not be defined and the actual encoding used is implementation defined.
>
> To make tcc more C11 compatible on Windows, I propose to add to the win32 directory this file:
>
> win32/include/uchar.h:
>
> /**
>  * This file has no copyright assigned and is placed in the Public Domain.
>  * This file is part of the TinyCC package.
>  * No warranty is given; refer to the file DISCLAIMER within this package.
>  */
>
> /**
>   * __STDC_UTF_16__ The integer constant 1, intended to indicate that values of type char16_t are UTF−16 encoded.
>  */
> #define __STDC_UTF_16__ 1
> /**
>  * __STDC_UTF_32__ The integer constant 1, intended to indicate that values of type char32_t are UTF−32 encoded.
>  */
> #define __STDC_UTF_32__ 1
>
>  typedef unsigned short char16_t;
>  typedef unsigned int char32_t;
>
>
>
> -----Original Message-----
> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Petr Skocík
> Sent: Tuesday, June 11, 2019 16:41
> To: [hidden email]
> Subject: [Tinycc-devel] minor patches + standard compliant inline functions
>
> Hi,
>
> I've pushed a bunch of patches to tinycc.
>
>
> The first three:
>
> - turn -fdollars-in-identifiers on by default (gcc/clang do it too)
> - in c11 mode, skip __STDC_ISO_10646__ (was causing a redefinition
> warning in simple hello world programs compiled on linux with -std=c11)
> - make -h|-hh succeed if the output is successfully written
>
> are small and should be noncontroversial.
>
> The last one is largish and I welcome any input on it.
>
> The issue was that tinycc's implementation of non-static inline
> functions was very much nonconforming in terms of when
> visible symbols would or would not be created. By looking at the at the
> mailing list archive, it looks like it was discussed in 2013 but nothing
> was done about it.
>
> The supplied patch should be fixing it.
>
> Best regards,
>
> Petr Skocik
>
> _______________________________________________
> Tinycc-devel mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
>
> _______________________________________________
> Tinycc-devel mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
>
> _______________________________________________
> Tinycc-devel mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
>
> _______________________________________________
> Tinycc-devel mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: minor patches + standard compliant inline functions

Christian Jullien-3
Hi Petr,

I prefer to let __CRT_INLINE as is. TinyCC shares Windows header with mingw64. I don't think it's a good idea to start to patch them.

Please note that TinyCC reports a syntax error " invalid operand reference after %" which, to me, is not related to extern/static linkage.

C.

-----Original Message-----
From: Petr Skočík [mailto:[hidden email]]
Sent: Wednesday, June 12, 2019 11:49
To: Christian Jullien; [hidden email]
Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions

Hi, Christian Jullien.  Thanks for the feedback.

I don't have a Windows setup for tinycc to test it on right now, but
from a cursory glance, __CRT_INLINE is defined as `extern __inline__` in
./win32/include/_mingw.h. Before the patch, extern __inline__ would
create static functions (and only if the function was later referenced).
After the patch, it'll unconditionally instantiate the function (as an
extern). I think redefining it to `__CRT_INLINE` `static __inline__`
might fix the problem.

I'll try and get a tinycc build working on windows and see if it helps.

Cheers,
Petr S.

On 6/12/19 11:10 AM, Christian Jullien wrote:

> More specifically this one: "standard conformant inline functions"
>
> -----Original Message-----
> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Christian Jullien
> Sent: Wednesday, June 12, 2019 07:20
> To: [hidden email]; [hidden email]
> Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions
>
> Ooops, trying to compile tcc (after tcc has been compiled a first time) on Windows with your recent patch (and w/o uchar.h), I now get:
>
> Building lib/libtcc1-32.a with tcc -m32
> ./include/winapi/winnt.h:1478: error: invalid operand reference after %
>
> Here:
> #if(defined(_X86_) && !defined(__x86_64))
>   __CRT_INLINE VOID MemoryBarrier(VOID) {
>     LONG Barrier;
>     __asm__ __volatile__("xchgl %eax,%0 "
>       :"=r" (Barrier));
>   }
>
>
> Here is the final version of uchar.h I'll push if nobody complains
>
> win32/include/uchar.h:
>
> /**
>  * This file has no copyright assigned and is placed in the Public Domain.
>  * This file is part of the TinyCC package.
>  * No warranty is given; refer to the file DISCLAIMER within this package.
>  */
>
> #ifndef _INC_UCHAR
> #define _INC_UCHAR
>
> /*
>  * The following defines are only valid when C11 (-std=c11) is used.
>  */
>
> #if __STDC_VERSION__ >= 201112L
> /**
>  * __STDC_UTF_16__ The integer constant 1, intended to indicate that
>  * values of type char16_t are UTF-16 encoded.
>  */
> #define __STDC_UTF_16__ 1
> /**
>  * __STDC_UTF_32__ The integer constant 1, intended to indicate that
>  * values of type char32_t are UTF-32 encoded.
>  */
> #define __STDC_UTF_32__ 1
>
> typedef unsigned short char16_t;
> typedef unsigned int char32_t;
> #endif /* __STDC_VERSION__ */
> #endif /* _INC_UCHAR */
>
> -----Original Message-----
> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Christian Jullien
> Sent: Wednesday, June 12, 2019 06:49
> To: [hidden email]
> Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions
>
> Thanks for your patch,
> FYI, for Windows compatibility:
>
> turn -fdollars-in-identifiers on by default is Ol as it also applies to cl on Windows (the old VMS days :o)
> Also ok to remove __STDC_ISO_10646__ as is not defined on Windows too.
>
> Please note that a conforming C11 implementation should have <uchar.h> which is missing on Windows includes. Among others, on Windows it defines both:
>
> __STDC_UTF_16_ _ The integer constant 1, intended to indicate that values of type char16_t are UTF−16 encoded. If some other encoding is used, the macro shall not be defined and the actual encoding used is implementation defined.
>
> __STDC_UTF_32_ _ The integer constant 1, intended to indicate that values of type char32_t are UTF−32 encoded. If some other encoding is used, the macro shall not be defined and the actual encoding used is implementation defined.
>
> To make tcc more C11 compatible on Windows, I propose to add to the win32 directory this file:
>
> win32/include/uchar.h:
>
> /**
>  * This file has no copyright assigned and is placed in the Public Domain.
>  * This file is part of the TinyCC package.
>  * No warranty is given; refer to the file DISCLAIMER within this package.
>  */
>
> /**
>   * __STDC_UTF_16__ The integer constant 1, intended to indicate that values of type char16_t are UTF−16 encoded.
>  */
> #define __STDC_UTF_16__ 1
> /**
>  * __STDC_UTF_32__ The integer constant 1, intended to indicate that values of type char32_t are UTF−32 encoded.
>  */
> #define __STDC_UTF_32__ 1
>
>  typedef unsigned short char16_t;
>  typedef unsigned int char32_t;
>
>
>
> -----Original Message-----
> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Petr Skocík
> Sent: Tuesday, June 11, 2019 16:41
> To: [hidden email]
> Subject: [Tinycc-devel] minor patches + standard compliant inline functions
>
> Hi,
>
> I've pushed a bunch of patches to tinycc.
>
>
> The first three:
>
> - turn -fdollars-in-identifiers on by default (gcc/clang do it too)
> - in c11 mode, skip __STDC_ISO_10646__ (was causing a redefinition
> warning in simple hello world programs compiled on linux with -std=c11)
> - make -h|-hh succeed if the output is successfully written
>
> are small and should be noncontroversial.
>
> The last one is largish and I welcome any input on it.
>
> The issue was that tinycc's implementation of non-static inline
> functions was very much nonconforming in terms of when
> visible symbols would or would not be created. By looking at the at the
> mailing list archive, it looks like it was discussed in 2013 but nothing
> was done about it.
>
> The supplied patch should be fixing it.
>
> Best regards,
>
> Petr Skocik
>
> _______________________________________________
> Tinycc-devel mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
>
> _______________________________________________
> Tinycc-devel mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
>
> _______________________________________________
> Tinycc-devel mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
>
> _______________________________________________
> Tinycc-devel mailing list
> [hidden email]
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: minor patches + standard compliant inline functions

Petr Skočík
After much struggle on an unfamiliar system, I figured out how to use
the lib-build.bat method to build tinycc on win.

Indeed, redefining __CRT_INLINE from `extern __inline__`  to `static
__inline__` does fix the problem, but it goes deeper.

It turns out the patch uncovers two assembly errors in
win32/include/winapi/winnt.h.
First:

    1477:     __asm__ __volatile__("xchgl %eax,%0 "

which should be
    1477:     __asm__ __volatile__("xchgl %%eax,%0 "

and second
    1489:     __asm__ __volatile__("int 0x2c ");
which should be
    1489:     __asm__ __volatile__("int $0x2c ");

The errors don't come up if the enclosing functions are static and
unused (the made them incorrectly static and only instantiated if used,
even though as per the standard they should be nonstatic and always
instantiated) but if they're used or extern, the assembly gets used and
the assembler screams.

IDK what the files are for or how they should be shared with mingw64 but
from the git history of mingw64 it looks like the tinycc version of the
header was adapted from a pre-2009 version of the mingw64 version; and
those two assembly errors were fixed in 2009.

I have now pushed a fix that replicates those fixes in tinycc.
Additionally I have also changed __CRT_INLINE from `extern __inline__`
to `static __inline__` (inline means the same thing as `inline` in both
gcc and tinycc). From scanning the tree, the macro is used exclusively
in header files and, as per the standard, `extern inline` would create
instatiations upon inclusion, and it just doesn't make sense for header
files to behave like that.

Thanks to Christian Julien for finding the problem!

Cheers,
Petr S.


On 6/12/19 12:00 PM, Christian Jullien wrote:

> Hi Petr,
>
> I prefer to let __CRT_INLINE as is. TinyCC shares Windows header with mingw64. I don't think it's a good idea to start to patch them.
>
> Please note that TinyCC reports a syntax error " invalid operand reference after %" which, to me, is not related to extern/static linkage.
>
> C.
>
> -----Original Message-----
> From: Petr Skočík [mailto:[hidden email]]
> Sent: Wednesday, June 12, 2019 11:49
> To: Christian Jullien; [hidden email]
> Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions
>
> Hi, Christian Jullien.  Thanks for the feedback.
>
> I don't have a Windows setup for tinycc to test it on right now, but
> from a cursory glance, __CRT_INLINE is defined as `extern __inline__` in
> ./win32/include/_mingw.h. Before the patch, extern __inline__ would
> create static functions (and only if the function was later referenced).
> After the patch, it'll unconditionally instantiate the function (as an
> extern). I think redefining it to `__CRT_INLINE` `static __inline__`
> might fix the problem.
>
> I'll try and get a tinycc build working on windows and see if it helps.
>
> Cheers,
> Petr S.
>
> On 6/12/19 11:10 AM, Christian Jullien wrote:
>> More specifically this one: "standard conformant inline functions"
>>
>> -----Original Message-----
>> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Christian Jullien
>> Sent: Wednesday, June 12, 2019 07:20
>> To: [hidden email]; [hidden email]
>> Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions
>>
>> Ooops, trying to compile tcc (after tcc has been compiled a first time) on Windows with your recent patch (and w/o uchar.h), I now get:
>>
>> Building lib/libtcc1-32.a with tcc -m32
>> ./include/winapi/winnt.h:1478: error: invalid operand reference after %
>>
>> Here:
>> #if(defined(_X86_) && !defined(__x86_64))
>>   __CRT_INLINE VOID MemoryBarrier(VOID) {
>>     LONG Barrier;
>>     __asm__ __volatile__("xchgl %eax,%0 "
>>       :"=r" (Barrier));
>>   }
>>
>>
>> Here is the final version of uchar.h I'll push if nobody complains
>>
>> win32/include/uchar.h:
>>
>> /**
>>  * This file has no copyright assigned and is placed in the Public Domain.
>>  * This file is part of the TinyCC package.
>>  * No warranty is given; refer to the file DISCLAIMER within this package.
>>  */
>>
>> #ifndef _INC_UCHAR
>> #define _INC_UCHAR
>>
>> /*
>>  * The following defines are only valid when C11 (-std=c11) is used.
>>  */
>>
>> #if __STDC_VERSION__ >= 201112L
>> /**
>>  * __STDC_UTF_16__ The integer constant 1, intended to indicate that
>>  * values of type char16_t are UTF-16 encoded.
>>  */
>> #define __STDC_UTF_16__ 1
>> /**
>>  * __STDC_UTF_32__ The integer constant 1, intended to indicate that
>>  * values of type char32_t are UTF-32 encoded.
>>  */
>> #define __STDC_UTF_32__ 1
>>
>> typedef unsigned short char16_t;
>> typedef unsigned int char32_t;
>> #endif /* __STDC_VERSION__ */
>> #endif /* _INC_UCHAR */
>>
>> -----Original Message-----
>> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Christian Jullien
>> Sent: Wednesday, June 12, 2019 06:49
>> To: [hidden email]
>> Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions
>>
>> Thanks for your patch,
>> FYI, for Windows compatibility:
>>
>> turn -fdollars-in-identifiers on by default is Ol as it also applies to cl on Windows (the old VMS days :o)
>> Also ok to remove __STDC_ISO_10646__ as is not defined on Windows too.
>>
>> Please note that a conforming C11 implementation should have <uchar.h> which is missing on Windows includes. Among others, on Windows it defines both:
>>
>> __STDC_UTF_16_ _ The integer constant 1, intended to indicate that values of type char16_t are UTF−16 encoded. If some other encoding is used, the macro shall not be defined and the actual encoding used is implementation defined.
>>
>> __STDC_UTF_32_ _ The integer constant 1, intended to indicate that values of type char32_t are UTF−32 encoded. If some other encoding is used, the macro shall not be defined and the actual encoding used is implementation defined.
>>
>> To make tcc more C11 compatible on Windows, I propose to add to the win32 directory this file:
>>
>> win32/include/uchar.h:
>>
>> /**
>>  * This file has no copyright assigned and is placed in the Public Domain.
>>  * This file is part of the TinyCC package.
>>  * No warranty is given; refer to the file DISCLAIMER within this package.
>>  */
>>
>> /**
>>   * __STDC_UTF_16__ The integer constant 1, intended to indicate that values of type char16_t are UTF−16 encoded.
>>  */
>> #define __STDC_UTF_16__ 1
>> /**
>>  * __STDC_UTF_32__ The integer constant 1, intended to indicate that values of type char32_t are UTF−32 encoded.
>>  */
>> #define __STDC_UTF_32__ 1
>>
>>  typedef unsigned short char16_t;
>>  typedef unsigned int char32_t;
>>
>>
>>
>> -----Original Message-----
>> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Petr Skocík
>> Sent: Tuesday, June 11, 2019 16:41
>> To: [hidden email]
>> Subject: [Tinycc-devel] minor patches + standard compliant inline functions
>>
>> Hi,
>>
>> I've pushed a bunch of patches to tinycc.
>>
>>
>> The first three:
>>
>> - turn -fdollars-in-identifiers on by default (gcc/clang do it too)
>> - in c11 mode, skip __STDC_ISO_10646__ (was causing a redefinition
>> warning in simple hello world programs compiled on linux with -std=c11)
>> - make -h|-hh succeed if the output is successfully written
>>
>> are small and should be noncontroversial.
>>
>> The last one is largish and I welcome any input on it.
>>
>> The issue was that tinycc's implementation of non-static inline
>> functions was very much nonconforming in terms of when
>> visible symbols would or would not be created. By looking at the at the
>> mailing list archive, it looks like it was discussed in 2013 but nothing
>> was done about it.
>>
>> The supplied patch should be fixing it.
>>
>> Best regards,
>>
>> Petr Skocik
>>
>> _______________________________________________
>> Tinycc-devel mailing list
>> [hidden email]
>> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>>
>>
>> _______________________________________________
>> Tinycc-devel mailing list
>> [hidden email]
>> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>>
>>
>> _______________________________________________
>> Tinycc-devel mailing list
>> [hidden email]
>> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>>
>>
>> _______________________________________________
>> Tinycc-devel mailing list
>> [hidden email]
>> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>>
>


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: minor patches + standard compliant inline functions

Christian Jullien-3
Thank you Petr,
As far as I see, your patch allows me to compile tcc with bootstrapped tcc on Windows (aka reproducible build) and then compiling my BIG OpenLisp project and its regression test suite on Windows works as before.

As said, I'm still annoyed you changed the definition of __CRT_INLINE which comes from mingw64. The next time someone will get the latest version of Windows headers, it will break tcc on Windows.
I let other TinyCC developper give advices.

Christian

-----Original Message-----
From: Petr Skočík [mailto:[hidden email]]
Sent: Wednesday, June 12, 2019 15:50
To: [hidden email]; [hidden email]
Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions

After much struggle on an unfamiliar system, I figured out how to use
the lib-build.bat method to build tinycc on win.

Indeed, redefining __CRT_INLINE from `extern __inline__`  to `static
__inline__` does fix the problem, but it goes deeper.

It turns out the patch uncovers two assembly errors in
win32/include/winapi/winnt.h.
First:

    1477:     __asm__ __volatile__("xchgl %eax,%0 "

which should be
    1477:     __asm__ __volatile__("xchgl %%eax,%0 "

and second
    1489:     __asm__ __volatile__("int 0x2c ");
which should be
    1489:     __asm__ __volatile__("int $0x2c ");

The errors don't come up if the enclosing functions are static and
unused (the made them incorrectly static and only instantiated if used,
even though as per the standard they should be nonstatic and always
instantiated) but if they're used or extern, the assembly gets used and
the assembler screams.

IDK what the files are for or how they should be shared with mingw64 but
from the git history of mingw64 it looks like the tinycc version of the
header was adapted from a pre-2009 version of the mingw64 version; and
those two assembly errors were fixed in 2009.

I have now pushed a fix that replicates those fixes in tinycc.
Additionally I have also changed __CRT_INLINE from `extern __inline__`
to `static __inline__` (inline means the same thing as `inline` in both
gcc and tinycc). From scanning the tree, the macro is used exclusively
in header files and, as per the standard, `extern inline` would create
instatiations upon inclusion, and it just doesn't make sense for header
files to behave like that.

Thanks to Christian Julien for finding the problem!

Cheers,
Petr S.


On 6/12/19 12:00 PM, Christian Jullien wrote:

> Hi Petr,
>
> I prefer to let __CRT_INLINE as is. TinyCC shares Windows header with mingw64. I don't think it's a good idea to start to patch them.
>
> Please note that TinyCC reports a syntax error " invalid operand reference after %" which, to me, is not related to extern/static linkage.
>
> C.
>
> -----Original Message-----
> From: Petr Skočík [mailto:[hidden email]]
> Sent: Wednesday, June 12, 2019 11:49
> To: Christian Jullien; [hidden email]
> Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions
>
> Hi, Christian Jullien.  Thanks for the feedback.
>
> I don't have a Windows setup for tinycc to test it on right now, but
> from a cursory glance, __CRT_INLINE is defined as `extern __inline__` in
> ./win32/include/_mingw.h. Before the patch, extern __inline__ would
> create static functions (and only if the function was later referenced).
> After the patch, it'll unconditionally instantiate the function (as an
> extern). I think redefining it to `__CRT_INLINE` `static __inline__`
> might fix the problem.
>
> I'll try and get a tinycc build working on windows and see if it helps.
>
> Cheers,
> Petr S.
>
> On 6/12/19 11:10 AM, Christian Jullien wrote:
>> More specifically this one: "standard conformant inline functions"
>>
>> -----Original Message-----
>> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Christian Jullien
>> Sent: Wednesday, June 12, 2019 07:20
>> To: [hidden email]; [hidden email]
>> Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions
>>
>> Ooops, trying to compile tcc (after tcc has been compiled a first time) on Windows with your recent patch (and w/o uchar.h), I now get:
>>
>> Building lib/libtcc1-32.a with tcc -m32
>> ./include/winapi/winnt.h:1478: error: invalid operand reference after %
>>
>> Here:
>> #if(defined(_X86_) && !defined(__x86_64))
>>   __CRT_INLINE VOID MemoryBarrier(VOID) {
>>     LONG Barrier;
>>     __asm__ __volatile__("xchgl %eax,%0 "
>>       :"=r" (Barrier));
>>   }
>>
>>
>> Here is the final version of uchar.h I'll push if nobody complains
>>
>> win32/include/uchar.h:
>>
>> /**
>>  * This file has no copyright assigned and is placed in the Public Domain.
>>  * This file is part of the TinyCC package.
>>  * No warranty is given; refer to the file DISCLAIMER within this package.
>>  */
>>
>> #ifndef _INC_UCHAR
>> #define _INC_UCHAR
>>
>> /*
>>  * The following defines are only valid when C11 (-std=c11) is used.
>>  */
>>
>> #if __STDC_VERSION__ >= 201112L
>> /**
>>  * __STDC_UTF_16__ The integer constant 1, intended to indicate that
>>  * values of type char16_t are UTF-16 encoded.
>>  */
>> #define __STDC_UTF_16__ 1
>> /**
>>  * __STDC_UTF_32__ The integer constant 1, intended to indicate that
>>  * values of type char32_t are UTF-32 encoded.
>>  */
>> #define __STDC_UTF_32__ 1
>>
>> typedef unsigned short char16_t;
>> typedef unsigned int char32_t;
>> #endif /* __STDC_VERSION__ */
>> #endif /* _INC_UCHAR */
>>
>> -----Original Message-----
>> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Christian Jullien
>> Sent: Wednesday, June 12, 2019 06:49
>> To: [hidden email]
>> Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions
>>
>> Thanks for your patch,
>> FYI, for Windows compatibility:
>>
>> turn -fdollars-in-identifiers on by default is Ol as it also applies to cl on Windows (the old VMS days :o)
>> Also ok to remove __STDC_ISO_10646__ as is not defined on Windows too.
>>
>> Please note that a conforming C11 implementation should have <uchar.h> which is missing on Windows includes. Among others, on Windows it defines both:
>>
>> __STDC_UTF_16_ _ The integer constant 1, intended to indicate that values of type char16_t are UTF−16 encoded. If some other encoding is used, the macro shall not be defined and the actual encoding used is implementation defined.
>>
>> __STDC_UTF_32_ _ The integer constant 1, intended to indicate that values of type char32_t are UTF−32 encoded. If some other encoding is used, the macro shall not be defined and the actual encoding used is implementation defined.
>>
>> To make tcc more C11 compatible on Windows, I propose to add to the win32 directory this file:
>>
>> win32/include/uchar.h:
>>
>> /**
>>  * This file has no copyright assigned and is placed in the Public Domain.
>>  * This file is part of the TinyCC package.
>>  * No warranty is given; refer to the file DISCLAIMER within this package.
>>  */
>>
>> /**
>>   * __STDC_UTF_16__ The integer constant 1, intended to indicate that values of type char16_t are UTF−16 encoded.
>>  */
>> #define __STDC_UTF_16__ 1
>> /**
>>  * __STDC_UTF_32__ The integer constant 1, intended to indicate that values of type char32_t are UTF−32 encoded.
>>  */
>> #define __STDC_UTF_32__ 1
>>
>>  typedef unsigned short char16_t;
>>  typedef unsigned int char32_t;
>>
>>
>>
>> -----Original Message-----
>> From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Petr Skocík
>> Sent: Tuesday, June 11, 2019 16:41
>> To: [hidden email]
>> Subject: [Tinycc-devel] minor patches + standard compliant inline functions
>>
>> Hi,
>>
>> I've pushed a bunch of patches to tinycc.
>>
>>
>> The first three:
>>
>> - turn -fdollars-in-identifiers on by default (gcc/clang do it too)
>> - in c11 mode, skip __STDC_ISO_10646__ (was causing a redefinition
>> warning in simple hello world programs compiled on linux with -std=c11)
>> - make -h|-hh succeed if the output is successfully written
>>
>> are small and should be noncontroversial.
>>
>> The last one is largish and I welcome any input on it.
>>
>> The issue was that tinycc's implementation of non-static inline
>> functions was very much nonconforming in terms of when
>> visible symbols would or would not be created. By looking at the at the
>> mailing list archive, it looks like it was discussed in 2013 but nothing
>> was done about it.
>>
>> The supplied patch should be fixing it.
>>
>> Best regards,
>>
>> Petr Skocik
>>
>> _______________________________________________
>> Tinycc-devel mailing list
>> [hidden email]
>> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>>
>>
>> _______________________________________________
>> Tinycc-devel mailing list
>> [hidden email]
>> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>>
>>
>> _______________________________________________
>> Tinycc-devel mailing list
>> [hidden email]
>> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>>
>>
>> _______________________________________________
>> Tinycc-devel mailing list
>> [hidden email]
>> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>>
>


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: minor patches + standard compliant inline functions

Michael Matz-4
In reply to this post by Petr Skočík
Hello Petr,

On Tue, 11 Jun 2019, Petr Skočík wrote:

> - turn -fdollars-in-identifiers on by default (gcc/clang do it too)
> - in c11 mode, skip __STDC_ISO_10646__ (was causing a redefinition
> warning in simple hello world programs compiled on linux with -std=c11)
> - make -h|-hh succeed if the output is successfully written
>
> are small and should be noncontroversial.

Nice.

> The issue was that tinycc's implementation of non-static inline
> functions was very much nonconforming in terms of when visible symbols
> would or would not be created.

Well, it was conforming (roughly), just not to ISO-C99, but rather to GNU
C, which had inline long before ISO C ;-)

> By looking at the at the mailing list archive, it looks like it was
> discussed in 2013 but nothing was done about it.
>
> The supplied patch should be fixing it.

Thanks for that, hopefully meanwhile most code in the wild will not rely
on gnu-inline behaviour anymore, but rather on c99 inline behaviour.  I've
taken up your remark in the patch about needing two new flags in
type.t and have rewritten that part.

FWIW, mingw still requires gnu-inline behaviour, which is why their use of
"extern inline" in __CRT_INLINE is correct for them (they force this
behaviour via an attribute), but with this TCC change 'static inline' is
more correct, though in reality it's even more complicated: it should be
"inline" only (without extern/static) and then some C file within mingw
would declare all these inlines as 'extern' as well, to ensure an external
definition exists.  Of course we can't influence mingw in this way, so
"static inline" is the correct equivalent to gnu-inline "extern inline".

And Christian: we shouldn't worry about changes in _mingw.h: that header
explicitely does _not_ come from Mingw32 as is but is private to TCC, so
differences are expected (and already exist).


Ciao,
Michael.
_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: minor patches + standard compliant inline functions

Christian Jullien-3

Hello Michael,

Your patch gives many new warnings when I do a reproducible tcc build on Windows (i.e. tcc is first compiled by Cygwin/gcc then it is used to produce a native Windows tcc binary – see https://sourceforge.net/projects/wintcc/).

 

Bootstrapping 32bits and 64bits tools with gcc -m64

Building lib/libtcc1-32.a with tcc -m32

In file included from lib/crt1.c:7:

In file included from ./include/winapi/windows.h:66:

In file included from ./include/winapi/windef.h:122:

./include/winapi/winnt.h:1493: warning: static storage ignored for redefinition of 'GetCurrentFiber'

In file included from lib/crt1.c:7:

In file included from ./include/winapi/windows.h:66:

In file included from ./include/winapi/windef.h:122:

./include/winapi/winnt.h:1501: warning: static storage ignored for redefinition of 'GetFiberData'

In file included from lib/crt1.c:8:

./include/stdio.h:259: warning: static storage ignored for redefinition of 'vsnprintf'

In file included from lib/crt1.c:9:

./include/stdlib.h:309: warning: static storage ignored for redefinition of '_Exit'

In file included from lib/crt1.c:9:

./include/stdlib.h:561: warning: static storage ignored for redefinition of 'atoll'

In file included from lib/crt1.c:9:

./include/stdlib.h:562: warning: static storage ignored for redefinition of 'lltoa'

In file included from lib/crt1.c:9:

./include/stdlib.h:563: warning: static storage ignored for redefinition of 'ulltoa'

In file included from lib/crt1.c:9:

./include/stdlib.h:564: warning: static storage ignored for redefinition of 'wtoll'

In file included from lib/crt1.c:9:

 

... and many more!

 

But, more annoying it now terminates with:

 

./include/winapi/winnt.h:1141: error: 'ExChange' undeclared

make: *** [Makefile:90: lib/libtcc1-64.a] Error 1

 

-----Original Message-----
From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=[hidden email]] On Behalf Of Michael Matz
Sent: Monday, June 17, 2019 05:46
To: [hidden email]
Subject: Re: [Tinycc-devel] minor patches + standard compliant inline functions

 

Hello Petr,

 

On Tue, 11 Jun 2019, Petr Skočík wrote:

 

> - turn -fdollars-in-identifiers on by default        (gcc/clang do it too)

> - in c11 mode, skip __STDC_ISO_10646__         (was causing a redefinition

> warning in simple hello world programs compiled on linux with

> -std=c11)

> - make -h|-hh succeed if the output is successfully written

> 

> are small and should be noncontroversial.

 

Nice.

 

> The issue was that tinycc's implementation of non-static inline

> functions was very much nonconforming in terms of when visible symbols

> would or would not be created.

 

Well, it was conforming (roughly), just not to ISO-C99, but rather to GNU C, which had inline long before ISO C ;-)

 

> By looking at the at the mailing list archive, it looks like it was

> discussed in 2013 but nothing was done about it.

> 

> The supplied patch should be fixing it.

 

Thanks for that, hopefully meanwhile most code in the wild will not rely on gnu-inline behaviour anymore, but rather on c99 inline behaviour.  I've taken up your remark in the patch about needing two new flags in type.t and have rewritten that part.

 

FWIW, mingw still requires gnu-inline behaviour, which is why their use of "extern inline" in __CRT_INLINE is correct for them (they force this behaviour via an attribute), but with this TCC change 'static inline' is more correct, though in reality it's even more complicated: it should be "inline" only (without extern/static) and then some C file within mingw would declare all these inlines as 'extern' as well, to ensure an external definition exists.  Of course we can't influence mingw in this way, so "static inline" is the correct equivalent to gnu-inline "extern inline".

 

And Christian: we shouldn't worry about changes in _mingw.h: that header explicitely does _not_ come from Mingw32 as is but is private to TCC, so differences are expected (and already exist).

 

 

Ciao,

Michael.


_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Reply | Threaded
Open this post in threaded view
|

Re: minor patches + standard compliant inline functions

Michael Matz-4
Hi,

On Mon, 17 Jun 2019, Christian Jullien wrote:

> Your patch gives many new warnings when I do a reproducible tcc build on

Aha!  That is the reason why that warning was conditional on !VT_INLINE
(which in the abstract doesn't make sense and I removed that).  Gnah, so
this is all a bit between a rock and a hard place.  The mingw headers do
this:

  PVOID GetFiberData(void);
  __CRT_INLINE PVOID GetFiberData(void) {}

The mingw headers are (and _mingw.h before the patch was) written with
gnu-inline behaviour in mind, so __CRT_INLINE is "extern inline
__attribute__((gnu-inline))", and that's then okay.

Now with C99 inline behaviour __CRT_INLINE has to be "static inline", but
can't be, and there are actually no valid choices for it anymore:
* it can't be "extern inline", because that emits a global instantiation
  of all these inlines, creating multiple def errors when e.g. linking
  together two .c files that include windows.h
* it can't be "inline" (without extern or static), because in C99 inline
  semantics there _must_ be an external definition somewhere in a program,
  when the respective function is used (and the definition in the header
  would not be one); that could potentially be visible when taking the
  address of such function.  But mingw isn't written in a way to provide
  such external definition, and we can't change this with only header
  hackery.
* it can't be "static inline", because that's simply not allowed given
  the above declaration (actually this shouldn't be just a warning but a
  hard error).

So, ..., hmmm.  Gnah!  But I said that already.

I don't see another way than to add back an implementation for the
gnu-inline behaviour and activate it via an attribute.  If noone has an
better idea I'm going to work on that :-/

> But, more annoying it now terminates with:
>
> ./include/winapi/winnt.h:1141: error: 'ExChange' undeclared

Uhh, that's a nice one.  There are two decls for the function in question:

__CRT_INLINE PVOID InterlockedCompareExchangePointer(
     PVOID volatile *Destination,PVOID ExChange,PVOID Comperand) {}

(the definition) and then later from winbase.h:

PVOID _InterlockedCompareExchangePointer(
     PVOID volatile *Destination,PVOID Exchange,PVOID Comperand);

Spot the difference! ;-)  It's wrong of TCC to take the names from the
non-definition, I've fixed this in mob.  I've also added back the hack of
ignoring the warning when inline is given until gnu-inline is implemented
again.


Ciao,
Michael.

_______________________________________________
Tinycc-devel mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel