All of lore.kernel.org
 help / color / mirror / Atom feed
* Redefinition of typedefs (C11 feature)
@ 2020-09-11 18:49 Eduardo Habkost
  2020-09-11 19:06 ` Peter Maydell
  0 siblings, 1 reply; 13+ messages in thread
From: Eduardo Habkost @ 2020-09-11 18:49 UTC (permalink / raw)
  To: qemu-devel
  Cc: Peter Maydell, Daniel P. Berrange, Markus Armbruster, Paolo Bonzini

I'm wondering: do our supported build host platforms all include
compilers that are new enough to let us redefine typedefs?

The ability to redefine typedefs is a C11 feature which would be
very useful for simplifying our QOM boilerplate code.  The
feature is supported by GCC since 2011 (v4.6.0)[1], and by clang
since 2012 (v3.1)[2].

[1] https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=ce3765bf44e49ef0568a1ad4a0b7f807591d6412
    https://gcc.gnu.org/gcc-4.6/changes.html
[2] https://github.com/llvm-mirror/clang/commit/c0004df84fca9225b66a50adc66cf21c34298227

-- 
Eduardo



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Redefinition of typedefs (C11 feature)
  2020-09-11 18:49 Redefinition of typedefs (C11 feature) Eduardo Habkost
@ 2020-09-11 19:06 ` Peter Maydell
  2020-09-11 20:06   ` Moving to C11? (was Re: Redefinition of typedefs (C11 feature)) Eduardo Habkost
  0 siblings, 1 reply; 13+ messages in thread
From: Peter Maydell @ 2020-09-11 19:06 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Paolo Bonzini, Daniel P. Berrange, QEMU Developers, Markus Armbruster

On Fri, 11 Sep 2020 at 19:49, Eduardo Habkost <ehabkost@redhat.com> wrote:
>
> I'm wondering: do our supported build host platforms all include
> compilers that are new enough to let us redefine typedefs?
>
> The ability to redefine typedefs is a C11 feature which would be
> very useful for simplifying our QOM boilerplate code.  The
> feature is supported by GCC since 2011 (v4.6.0)[1], and by clang
> since 2012 (v3.1)[2].

In configure we mandate either GCC v4.8 or better, or
clang v3.4 or better, or XCode Clang v5.1 or better
(Apple uses a different version numbering setup to upstream).
So you should probably double-check that that xcode clang has
what you want, but it looks like we're good to go otherwise.

thanks
-- PMM


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Moving to C11? (was Re: Redefinition of typedefs (C11 feature))
  2020-09-11 19:06 ` Peter Maydell
@ 2020-09-11 20:06   ` Eduardo Habkost
  2020-09-11 20:10     ` Warner Losh
  2020-09-12  6:45     ` Thomas Huth
  0 siblings, 2 replies; 13+ messages in thread
From: Eduardo Habkost @ 2020-09-11 20:06 UTC (permalink / raw)
  To: Peter Maydell
  Cc: Paolo Bonzini, Daniel P. Berrange, QEMU Developers, Markus Armbruster

On Fri, Sep 11, 2020 at 08:06:10PM +0100, Peter Maydell wrote:
> On Fri, 11 Sep 2020 at 19:49, Eduardo Habkost <ehabkost@redhat.com> wrote:
> >
> > I'm wondering: do our supported build host platforms all include
> > compilers that are new enough to let us redefine typedefs?
> >
> > The ability to redefine typedefs is a C11 feature which would be
> > very useful for simplifying our QOM boilerplate code.  The
> > feature is supported by GCC since 2011 (v4.6.0)[1], and by clang
> > since 2012 (v3.1)[2].
> 
> In configure we mandate either GCC v4.8 or better, or
> clang v3.4 or better, or XCode Clang v5.1 or better
> (Apple uses a different version numbering setup to upstream).
> So you should probably double-check that that xcode clang has
> what you want, but it looks like we're good to go otherwise.

Can anybody confirm if the following is accurate?

https://gist.github.com/yamaya/2924292#file-xcode-clang-vers-L67
# Xcode 5.1 (5B130a)
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix

If we know we have GCC 4.8+ or clang 3.4+, can we move to C11 and
start using -std=gnu11?

-- 
Eduardo



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Moving to C11? (was Re: Redefinition of typedefs (C11 feature))
  2020-09-11 20:06   ` Moving to C11? (was Re: Redefinition of typedefs (C11 feature)) Eduardo Habkost
@ 2020-09-11 20:10     ` Warner Losh
  2020-09-12  8:16       ` Philippe Mathieu-Daudé
  2020-09-12  6:45     ` Thomas Huth
  1 sibling, 1 reply; 13+ messages in thread
From: Warner Losh @ 2020-09-11 20:10 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, Daniel P. Berrange, QEMU Developers,
	Markus Armbruster, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 1565 bytes --]

On Fri, Sep 11, 2020 at 2:07 PM Eduardo Habkost <ehabkost@redhat.com> wrote:

> On Fri, Sep 11, 2020 at 08:06:10PM +0100, Peter Maydell wrote:
> > On Fri, 11 Sep 2020 at 19:49, Eduardo Habkost <ehabkost@redhat.com>
> wrote:
> > >
> > > I'm wondering: do our supported build host platforms all include
> > > compilers that are new enough to let us redefine typedefs?
> > >
> > > The ability to redefine typedefs is a C11 feature which would be
> > > very useful for simplifying our QOM boilerplate code.  The
> > > feature is supported by GCC since 2011 (v4.6.0)[1], and by clang
> > > since 2012 (v3.1)[2].
> >
> > In configure we mandate either GCC v4.8 or better, or
> > clang v3.4 or better, or XCode Clang v5.1 or better
> > (Apple uses a different version numbering setup to upstream).
> > So you should probably double-check that that xcode clang has
> > what you want, but it looks like we're good to go otherwise.
>
> Can anybody confirm if the following is accurate?
>
> https://gist.github.com/yamaya/2924292#file-xcode-clang-vers-L67
> # Xcode 5.1 (5B130a)
> Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
> Target: x86_64-apple-darwin13.1.0
> Thread model: posix
>
> If we know we have GCC 4.8+ or clang 3.4+, can we move to C11 and
> start using -std=gnu11?
>

All supported branches of FreeBSD tier 1 platforms would be fine since they
all use clang. Most of the tier 2 ones do too, but the ports/pkg system we
have will install a newer compiler if need be (the ones that don't are
still stuck at gcc 4.2.1 for GPLv3 reasons).

Warner

[-- Attachment #2: Type: text/html, Size: 2255 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Moving to C11? (was Re: Redefinition of typedefs (C11 feature))
  2020-09-11 20:06   ` Moving to C11? (was Re: Redefinition of typedefs (C11 feature)) Eduardo Habkost
  2020-09-11 20:10     ` Warner Losh
@ 2020-09-12  6:45     ` Thomas Huth
  2020-09-13  2:51       ` Eduardo Habkost
  1 sibling, 1 reply; 13+ messages in thread
From: Thomas Huth @ 2020-09-12  6:45 UTC (permalink / raw)
  To: Eduardo Habkost, Peter Maydell
  Cc: Paolo Bonzini, Daniel P. Berrange, QEMU Developers, Markus Armbruster

On 11/09/2020 22.06, Eduardo Habkost wrote:
> On Fri, Sep 11, 2020 at 08:06:10PM +0100, Peter Maydell wrote:
>> On Fri, 11 Sep 2020 at 19:49, Eduardo Habkost <ehabkost@redhat.com> wrote:
>>>
>>> I'm wondering: do our supported build host platforms all include
>>> compilers that are new enough to let us redefine typedefs?
>>>
>>> The ability to redefine typedefs is a C11 feature which would be
>>> very useful for simplifying our QOM boilerplate code.  The
>>> feature is supported by GCC since 2011 (v4.6.0)[1], and by clang
>>> since 2012 (v3.1)[2].
>>
>> In configure we mandate either GCC v4.8 or better, or
>> clang v3.4 or better, or XCode Clang v5.1 or better
>> (Apple uses a different version numbering setup to upstream).
>> So you should probably double-check that that xcode clang has
>> what you want, but it looks like we're good to go otherwise.
> 
> Can anybody confirm if the following is accurate?
> 
> https://gist.github.com/yamaya/2924292#file-xcode-clang-vers-L67
> # Xcode 5.1 (5B130a)
> Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
> Target: x86_64-apple-darwin13.1.0
> Thread model: posix
> 
> If we know we have GCC 4.8+ or clang 3.4+, can we move to C11 and
> start using -std=gnu11?

You don't have to switch to gnu11, redefintions of typedefs are already
fine in gnu99, they are a gnu extension there to the c99 standard.

See also:
https://git.qemu.org/?p=qemu.git;a=commitdiff;h=7be41675f7cb16b

https://www.mail-archive.com/qemu-devel@nongnu.org/msg585581.html

 HTH,
  Thomas



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Moving to C11? (was Re: Redefinition of typedefs (C11 feature))
  2020-09-11 20:10     ` Warner Losh
@ 2020-09-12  8:16       ` Philippe Mathieu-Daudé
  2020-09-12 15:04         ` Warner Losh
  0 siblings, 1 reply; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-09-12  8:16 UTC (permalink / raw)
  To: Warner Losh, Eduardo Habkost
  Cc: Peter Maydell, Paolo Bonzini, Daniel P. Berrange,
	QEMU Developers, Markus Armbruster

On 9/11/20 10:10 PM, Warner Losh wrote:
> 
> 
> On Fri, Sep 11, 2020 at 2:07 PM Eduardo Habkost <ehabkost@redhat.com
> <mailto:ehabkost@redhat.com>> wrote:
> 
>     On Fri, Sep 11, 2020 at 08:06:10PM +0100, Peter Maydell wrote:
>     > On Fri, 11 Sep 2020 at 19:49, Eduardo Habkost <ehabkost@redhat.com
>     <mailto:ehabkost@redhat.com>> wrote:
>     > >
>     > > I'm wondering: do our supported build host platforms all include
>     > > compilers that are new enough to let us redefine typedefs?
>     > >
>     > > The ability to redefine typedefs is a C11 feature which would be
>     > > very useful for simplifying our QOM boilerplate code.  The
>     > > feature is supported by GCC since 2011 (v4.6.0)[1], and by clang
>     > > since 2012 (v3.1)[2].
>     >
>     > In configure we mandate either GCC v4.8 or better, or
>     > clang v3.4 or better, or XCode Clang v5.1 or better
>     > (Apple uses a different version numbering setup to upstream).
>     > So you should probably double-check that that xcode clang has
>     > what you want, but it looks like we're good to go otherwise.
> 
>     Can anybody confirm if the following is accurate?
> 
>     https://gist.github.com/yamaya/2924292#file-xcode-clang-vers-L67
>     # Xcode 5.1 (5B130a)
>     Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
>     Target: x86_64-apple-darwin13.1.0
>     Thread model: posix
> 
>     If we know we have GCC 4.8+ or clang 3.4+, can we move to C11 and
>     start using -std=gnu11?
> 
> 
> All supported branches of FreeBSD tier 1 platforms would be fine since
> they all use clang. Most of the tier 2 ones do too, but the ports/pkg
> system we have will install a newer compiler if need be (the ones that
> don't are still stuck at gcc 4.2.1 for GPLv3 reasons).

See the quoted message from Peter: "In configure we mandate either
GCC v4.8 or better"... You shouldn't be able to build QEMU in ports/pkg.

Regards,

Phil.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Moving to C11? (was Re: Redefinition of typedefs (C11 feature))
  2020-09-12  8:16       ` Philippe Mathieu-Daudé
@ 2020-09-12 15:04         ` Warner Losh
  0 siblings, 0 replies; 13+ messages in thread
From: Warner Losh @ 2020-09-12 15:04 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Peter Maydell, Daniel P. Berrange, Eduardo Habkost,
	Markus Armbruster, QEMU Developers, Paolo Bonzini

[-- Attachment #1: Type: text/plain, Size: 2364 bytes --]

On Sat, Sep 12, 2020, 2:16 AM Philippe Mathieu-Daudé <f4bug@amsat.org>
wrote:

> On 9/11/20 10:10 PM, Warner Losh wrote:
> >
> >
> > On Fri, Sep 11, 2020 at 2:07 PM Eduardo Habkost <ehabkost@redhat.com
> > <mailto:ehabkost@redhat.com>> wrote:
> >
> >     On Fri, Sep 11, 2020 at 08:06:10PM +0100, Peter Maydell wrote:
> >     > On Fri, 11 Sep 2020 at 19:49, Eduardo Habkost <ehabkost@redhat.com
> >     <mailto:ehabkost@redhat.com>> wrote:
> >     > >
> >     > > I'm wondering: do our supported build host platforms all include
> >     > > compilers that are new enough to let us redefine typedefs?
> >     > >
> >     > > The ability to redefine typedefs is a C11 feature which would be
> >     > > very useful for simplifying our QOM boilerplate code.  The
> >     > > feature is supported by GCC since 2011 (v4.6.0)[1], and by clang
> >     > > since 2012 (v3.1)[2].
> >     >
> >     > In configure we mandate either GCC v4.8 or better, or
> >     > clang v3.4 or better, or XCode Clang v5.1 or better
> >     > (Apple uses a different version numbering setup to upstream).
> >     > So you should probably double-check that that xcode clang has
> >     > what you want, but it looks like we're good to go otherwise.
> >
> >     Can anybody confirm if the following is accurate?
> >
> >     https://gist.github.com/yamaya/2924292#file-xcode-clang-vers-L67
> >     # Xcode 5.1 (5B130a)
> >     Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
> >     Target: x86_64-apple-darwin13.1.0
> >     Thread model: posix
> >
> >     If we know we have GCC 4.8+ or clang 3.4+, can we move to C11 and
> >     start using -std=gnu11?
> >
> >
> > All supported branches of FreeBSD tier 1 platforms would be fine since
> > they all use clang. Most of the tier 2 ones do too, but the ports/pkg
> > system we have will install a newer compiler if need be (the ones that
> > don't are still stuck at gcc 4.2.1 for GPLv3 reasons).
>
> See the quoted message from Peter: "In configure we mandate either
> GCC v4.8 or better"... You shouldn't be able to build QEMU in ports/pkg.
>

Ah, I was grepping for gcc/clang. It specifies compiler:c11 so I missed
that it already brings in a better compiler on those weird, old platforms.

In any event, FreeBSD won't be a problem....

Warner

Regards,
>
> Phil.
>

[-- Attachment #2: Type: text/html, Size: 3793 bytes --]

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Moving to C11? (was Re: Redefinition of typedefs (C11 feature))
  2020-09-12  6:45     ` Thomas Huth
@ 2020-09-13  2:51       ` Eduardo Habkost
  2020-09-14  5:39         ` Thomas Huth
  0 siblings, 1 reply; 13+ messages in thread
From: Eduardo Habkost @ 2020-09-13  2:51 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Peter Maydell, Daniel P. Berrange, QEMU Developers,
	Markus Armbruster, Paolo Bonzini

On Sat, Sep 12, 2020 at 08:45:19AM +0200, Thomas Huth wrote:
> On 11/09/2020 22.06, Eduardo Habkost wrote:
> > On Fri, Sep 11, 2020 at 08:06:10PM +0100, Peter Maydell wrote:
> >> On Fri, 11 Sep 2020 at 19:49, Eduardo Habkost <ehabkost@redhat.com> wrote:
> >>>
> >>> I'm wondering: do our supported build host platforms all include
> >>> compilers that are new enough to let us redefine typedefs?
> >>>
> >>> The ability to redefine typedefs is a C11 feature which would be
> >>> very useful for simplifying our QOM boilerplate code.  The
> >>> feature is supported by GCC since 2011 (v4.6.0)[1], and by clang
> >>> since 2012 (v3.1)[2].
> >>
> >> In configure we mandate either GCC v4.8 or better, or
> >> clang v3.4 or better, or XCode Clang v5.1 or better
> >> (Apple uses a different version numbering setup to upstream).
> >> So you should probably double-check that that xcode clang has
> >> what you want, but it looks like we're good to go otherwise.
> > 
> > Can anybody confirm if the following is accurate?
> > 
> > https://gist.github.com/yamaya/2924292#file-xcode-clang-vers-L67
> > # Xcode 5.1 (5B130a)
> > Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
> > Target: x86_64-apple-darwin13.1.0
> > Thread model: posix
> > 
> > If we know we have GCC 4.8+ or clang 3.4+, can we move to C11 and
> > start using -std=gnu11?
> 
> You don't have to switch to gnu11, redefintions of typedefs are already
> fine in gnu99, they are a gnu extension there to the c99 standard.
> 
> See also:
> https://git.qemu.org/?p=qemu.git;a=commitdiff;h=7be41675f7cb16b
> 
> https://www.mail-archive.com/qemu-devel@nongnu.org/msg585581.html

They still trigger a warning with gnu99 on clang:

$ clang --version
clang version 10.0.0 (Fedora 10.0.0-2.fc32)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ cat test.c
typedef struct A A;
typedef struct A A;
$ clang -std=gnu11 -c test.c
$ clang -std=gnu99 -c test.c
test.c:2:18: warning: redefinition of typedef 'A' is a C11 feature [-Wtypedef-redefinition]
typedef struct A A;
                 ^
test.c:1:18: note: previous definition is here
typedef struct A A;
                 ^
1 warning generated.
$ 

-- 
Eduardo



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Moving to C11? (was Re: Redefinition of typedefs (C11 feature))
  2020-09-13  2:51       ` Eduardo Habkost
@ 2020-09-14  5:39         ` Thomas Huth
  2020-09-14 13:46           ` Eduardo Habkost
  0 siblings, 1 reply; 13+ messages in thread
From: Thomas Huth @ 2020-09-14  5:39 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, Daniel P. Berrange, QEMU Developers,
	Markus Armbruster, Paolo Bonzini

On 13/09/2020 04.51, Eduardo Habkost wrote:
> On Sat, Sep 12, 2020 at 08:45:19AM +0200, Thomas Huth wrote:
>> On 11/09/2020 22.06, Eduardo Habkost wrote:
>>> On Fri, Sep 11, 2020 at 08:06:10PM +0100, Peter Maydell wrote:
>>>> On Fri, 11 Sep 2020 at 19:49, Eduardo Habkost <ehabkost@redhat.com> wrote:
>>>>>
>>>>> I'm wondering: do our supported build host platforms all include
>>>>> compilers that are new enough to let us redefine typedefs?
>>>>>
>>>>> The ability to redefine typedefs is a C11 feature which would be
>>>>> very useful for simplifying our QOM boilerplate code.  The
>>>>> feature is supported by GCC since 2011 (v4.6.0)[1], and by clang
>>>>> since 2012 (v3.1)[2].
>>>>
>>>> In configure we mandate either GCC v4.8 or better, or
>>>> clang v3.4 or better, or XCode Clang v5.1 or better
>>>> (Apple uses a different version numbering setup to upstream).
>>>> So you should probably double-check that that xcode clang has
>>>> what you want, but it looks like we're good to go otherwise.
>>>
>>> Can anybody confirm if the following is accurate?
>>>
>>> https://gist.github.com/yamaya/2924292#file-xcode-clang-vers-L67
>>> # Xcode 5.1 (5B130a)
>>> Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
>>> Target: x86_64-apple-darwin13.1.0
>>> Thread model: posix
>>>
>>> If we know we have GCC 4.8+ or clang 3.4+, can we move to C11 and
>>> start using -std=gnu11?
>>
>> You don't have to switch to gnu11, redefintions of typedefs are already
>> fine in gnu99, they are a gnu extension there to the c99 standard.
>>
>> See also:
>> https://git.qemu.org/?p=qemu.git;a=commitdiff;h=7be41675f7cb16b
>>
>> https://www.mail-archive.com/qemu-devel@nongnu.org/msg585581.html
> 
> They still trigger a warning with gnu99 on clang:
> 
> $ clang --version
> clang version 10.0.0 (Fedora 10.0.0-2.fc32)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
> InstalledDir: /usr/bin
> $ cat test.c
> typedef struct A A;
> typedef struct A A;
> $ clang -std=gnu11 -c test.c
> $ clang -std=gnu99 -c test.c
> test.c:2:18: warning: redefinition of typedef 'A' is a C11 feature [-Wtypedef-redefinition]
> typedef struct A A;

Ah, right, I forgot about that ... so for clang, we silence that warning
via CFLAGS in the configure script. See commit e6e90feedb706b1.

 Thomas



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Moving to C11? (was Re: Redefinition of typedefs (C11 feature))
  2020-09-14  5:39         ` Thomas Huth
@ 2020-09-14 13:46           ` Eduardo Habkost
  2020-09-14 13:50             ` Daniel P. Berrangé
  2020-09-14 15:36             ` Thomas Huth
  0 siblings, 2 replies; 13+ messages in thread
From: Eduardo Habkost @ 2020-09-14 13:46 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Peter Maydell, Daniel P. Berrange, QEMU Developers,
	Markus Armbruster, Paolo Bonzini

On Mon, Sep 14, 2020 at 07:39:09AM +0200, Thomas Huth wrote:
> On 13/09/2020 04.51, Eduardo Habkost wrote:
> > On Sat, Sep 12, 2020 at 08:45:19AM +0200, Thomas Huth wrote:
> >> On 11/09/2020 22.06, Eduardo Habkost wrote:
> >>> On Fri, Sep 11, 2020 at 08:06:10PM +0100, Peter Maydell wrote:
> >>>> On Fri, 11 Sep 2020 at 19:49, Eduardo Habkost <ehabkost@redhat.com> wrote:
> >>>>>
> >>>>> I'm wondering: do our supported build host platforms all include
> >>>>> compilers that are new enough to let us redefine typedefs?
> >>>>>
> >>>>> The ability to redefine typedefs is a C11 feature which would be
> >>>>> very useful for simplifying our QOM boilerplate code.  The
> >>>>> feature is supported by GCC since 2011 (v4.6.0)[1], and by clang
> >>>>> since 2012 (v3.1)[2].
> >>>>
> >>>> In configure we mandate either GCC v4.8 or better, or
> >>>> clang v3.4 or better, or XCode Clang v5.1 or better
> >>>> (Apple uses a different version numbering setup to upstream).
> >>>> So you should probably double-check that that xcode clang has
> >>>> what you want, but it looks like we're good to go otherwise.
> >>>
> >>> Can anybody confirm if the following is accurate?
> >>>
> >>> https://gist.github.com/yamaya/2924292#file-xcode-clang-vers-L67
> >>> # Xcode 5.1 (5B130a)
> >>> Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
> >>> Target: x86_64-apple-darwin13.1.0
> >>> Thread model: posix
> >>>
> >>> If we know we have GCC 4.8+ or clang 3.4+, can we move to C11 and
> >>> start using -std=gnu11?
> >>
> >> You don't have to switch to gnu11, redefintions of typedefs are already
> >> fine in gnu99, they are a gnu extension there to the c99 standard.
> >>
> >> See also:
> >> https://git.qemu.org/?p=qemu.git;a=commitdiff;h=7be41675f7cb16b
> >>
> >> https://www.mail-archive.com/qemu-devel@nongnu.org/msg585581.html
> > 
> > They still trigger a warning with gnu99 on clang:
> > 
> > $ clang --version
> > clang version 10.0.0 (Fedora 10.0.0-2.fc32)
> > Target: x86_64-unknown-linux-gnu
> > Thread model: posix
> > InstalledDir: /usr/bin
> > $ cat test.c
> > typedef struct A A;
> > typedef struct A A;
> > $ clang -std=gnu11 -c test.c
> > $ clang -std=gnu99 -c test.c
> > test.c:2:18: warning: redefinition of typedef 'A' is a C11 feature [-Wtypedef-redefinition]
> > typedef struct A A;
> 
> Ah, right, I forgot about that ... so for clang, we silence that warning
> via CFLAGS in the configure script. See commit e6e90feedb706b1.

Nice, I hadn't seen that.  This means we don't need C11 for
supporting redefinition of typedefs.

Now, do we have other reasons for not moving to C11?  It would be
nice to make QEMU_GENERIC unnecessary and just use _Generic, for
example.

-- 
Eduardo



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Moving to C11? (was Re: Redefinition of typedefs (C11 feature))
  2020-09-14 13:46           ` Eduardo Habkost
@ 2020-09-14 13:50             ` Daniel P. Berrangé
  2020-09-14 15:36             ` Thomas Huth
  1 sibling, 0 replies; 13+ messages in thread
From: Daniel P. Berrangé @ 2020-09-14 13:50 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, Thomas Huth, QEMU Developers, Markus Armbruster,
	Paolo Bonzini

On Mon, Sep 14, 2020 at 09:46:36AM -0400, Eduardo Habkost wrote:
> On Mon, Sep 14, 2020 at 07:39:09AM +0200, Thomas Huth wrote:
> > On 13/09/2020 04.51, Eduardo Habkost wrote:
> > > On Sat, Sep 12, 2020 at 08:45:19AM +0200, Thomas Huth wrote:
> > >> On 11/09/2020 22.06, Eduardo Habkost wrote:
> > >>> On Fri, Sep 11, 2020 at 08:06:10PM +0100, Peter Maydell wrote:
> > >>>> On Fri, 11 Sep 2020 at 19:49, Eduardo Habkost <ehabkost@redhat.com> wrote:
> > >>>>>
> > >>>>> I'm wondering: do our supported build host platforms all include
> > >>>>> compilers that are new enough to let us redefine typedefs?
> > >>>>>
> > >>>>> The ability to redefine typedefs is a C11 feature which would be
> > >>>>> very useful for simplifying our QOM boilerplate code.  The
> > >>>>> feature is supported by GCC since 2011 (v4.6.0)[1], and by clang
> > >>>>> since 2012 (v3.1)[2].
> > >>>>
> > >>>> In configure we mandate either GCC v4.8 or better, or
> > >>>> clang v3.4 or better, or XCode Clang v5.1 or better
> > >>>> (Apple uses a different version numbering setup to upstream).
> > >>>> So you should probably double-check that that xcode clang has
> > >>>> what you want, but it looks like we're good to go otherwise.
> > >>>
> > >>> Can anybody confirm if the following is accurate?
> > >>>
> > >>> https://gist.github.com/yamaya/2924292#file-xcode-clang-vers-L67
> > >>> # Xcode 5.1 (5B130a)
> > >>> Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
> > >>> Target: x86_64-apple-darwin13.1.0
> > >>> Thread model: posix
> > >>>
> > >>> If we know we have GCC 4.8+ or clang 3.4+, can we move to C11 and
> > >>> start using -std=gnu11?
> > >>
> > >> You don't have to switch to gnu11, redefintions of typedefs are already
> > >> fine in gnu99, they are a gnu extension there to the c99 standard.
> > >>
> > >> See also:
> > >> https://git.qemu.org/?p=qemu.git;a=commitdiff;h=7be41675f7cb16b
> > >>
> > >> https://www.mail-archive.com/qemu-devel@nongnu.org/msg585581.html
> > > 
> > > They still trigger a warning with gnu99 on clang:
> > > 
> > > $ clang --version
> > > clang version 10.0.0 (Fedora 10.0.0-2.fc32)
> > > Target: x86_64-unknown-linux-gnu
> > > Thread model: posix
> > > InstalledDir: /usr/bin
> > > $ cat test.c
> > > typedef struct A A;
> > > typedef struct A A;
> > > $ clang -std=gnu11 -c test.c
> > > $ clang -std=gnu99 -c test.c
> > > test.c:2:18: warning: redefinition of typedef 'A' is a C11 feature [-Wtypedef-redefinition]
> > > typedef struct A A;
> > 
> > Ah, right, I forgot about that ... so for clang, we silence that warning
> > via CFLAGS in the configure script. See commit e6e90feedb706b1.
> 
> Nice, I hadn't seen that.  This means we don't need C11 for
> supporting redefinition of typedefs.
> 
> Now, do we have other reasons for not moving to C11?  It would be
> nice to make QEMU_GENERIC unnecessary and just use _Generic, for
> example.

When we set std=gnu99 in:


  commit 7be41675f7cb16be7c8d2554add7a63fa43781a8
  Author: Thomas Huth <thuth@redhat.com>
  Date:   Mon Jan 7 11:25:22 2019 +0100

    configure: Force the C standard to gnu99

we chose to not use gnu11, because this standard level is marked as
experimental in GCC 4.8 and thus we felt it wasn't a good idea to
rely on.


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Moving to C11? (was Re: Redefinition of typedefs (C11 feature))
  2020-09-14 13:46           ` Eduardo Habkost
  2020-09-14 13:50             ` Daniel P. Berrangé
@ 2020-09-14 15:36             ` Thomas Huth
  2020-09-14 16:53               ` Eduardo Habkost
  1 sibling, 1 reply; 13+ messages in thread
From: Thomas Huth @ 2020-09-14 15:36 UTC (permalink / raw)
  To: Eduardo Habkost
  Cc: Peter Maydell, Daniel P. Berrange, QEMU Developers,
	Markus Armbruster, Paolo Bonzini

On 14/09/2020 15.46, Eduardo Habkost wrote:
> On Mon, Sep 14, 2020 at 07:39:09AM +0200, Thomas Huth wrote:
>> On 13/09/2020 04.51, Eduardo Habkost wrote:
>>> On Sat, Sep 12, 2020 at 08:45:19AM +0200, Thomas Huth wrote:
>>>> On 11/09/2020 22.06, Eduardo Habkost wrote:
>>>>> On Fri, Sep 11, 2020 at 08:06:10PM +0100, Peter Maydell wrote:
>>>>>> On Fri, 11 Sep 2020 at 19:49, Eduardo Habkost <ehabkost@redhat.com> wrote:
>>>>>>>
>>>>>>> I'm wondering: do our supported build host platforms all include
>>>>>>> compilers that are new enough to let us redefine typedefs?
>>>>>>>
>>>>>>> The ability to redefine typedefs is a C11 feature which would be
>>>>>>> very useful for simplifying our QOM boilerplate code.  The
>>>>>>> feature is supported by GCC since 2011 (v4.6.0)[1], and by clang
>>>>>>> since 2012 (v3.1)[2].
>>>>>>
>>>>>> In configure we mandate either GCC v4.8 or better, or
>>>>>> clang v3.4 or better, or XCode Clang v5.1 or better
>>>>>> (Apple uses a different version numbering setup to upstream).
>>>>>> So you should probably double-check that that xcode clang has
>>>>>> what you want, but it looks like we're good to go otherwise.
>>>>>
>>>>> Can anybody confirm if the following is accurate?
>>>>>
>>>>> https://gist.github.com/yamaya/2924292#file-xcode-clang-vers-L67
>>>>> # Xcode 5.1 (5B130a)
>>>>> Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
>>>>> Target: x86_64-apple-darwin13.1.0
>>>>> Thread model: posix
>>>>>
>>>>> If we know we have GCC 4.8+ or clang 3.4+, can we move to C11 and
>>>>> start using -std=gnu11?
>>>>
>>>> You don't have to switch to gnu11, redefintions of typedefs are already
>>>> fine in gnu99, they are a gnu extension there to the c99 standard.
>>>>
>>>> See also:
>>>> https://git.qemu.org/?p=qemu.git;a=commitdiff;h=7be41675f7cb16b
>>>>
>>>> https://www.mail-archive.com/qemu-devel@nongnu.org/msg585581.html
>>>
>>> They still trigger a warning with gnu99 on clang:
>>>
>>> $ clang --version
>>> clang version 10.0.0 (Fedora 10.0.0-2.fc32)
>>> Target: x86_64-unknown-linux-gnu
>>> Thread model: posix
>>> InstalledDir: /usr/bin
>>> $ cat test.c
>>> typedef struct A A;
>>> typedef struct A A;
>>> $ clang -std=gnu11 -c test.c
>>> $ clang -std=gnu99 -c test.c
>>> test.c:2:18: warning: redefinition of typedef 'A' is a C11 feature [-Wtypedef-redefinition]
>>> typedef struct A A;
>>
>> Ah, right, I forgot about that ... so for clang, we silence that warning
>> via CFLAGS in the configure script. See commit e6e90feedb706b1.
> 
> Nice, I hadn't seen that.  This means we don't need C11 for
> supporting redefinition of typedefs.
> 
> Now, do we have other reasons for not moving to C11?  It would be
> nice to make QEMU_GENERIC unnecessary and just use _Generic, for
> example.

See https://www.mail-archive.com/qemu-devel@nongnu.org/msg585581.html
... c11 is still "experimental" in GCC 4.8, so I think we likely have to
wait 'till summer next year - then we do not have to support
RHEL7/CentOS7 anymore according our support policy, and thus we can bump
the minimum required compiler versions.

 Thomas



^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Moving to C11? (was Re: Redefinition of typedefs (C11 feature))
  2020-09-14 15:36             ` Thomas Huth
@ 2020-09-14 16:53               ` Eduardo Habkost
  0 siblings, 0 replies; 13+ messages in thread
From: Eduardo Habkost @ 2020-09-14 16:53 UTC (permalink / raw)
  To: Thomas Huth
  Cc: Peter Maydell, Daniel P. Berrange, QEMU Developers,
	Markus Armbruster, Paolo Bonzini

On Mon, Sep 14, 2020 at 05:36:30PM +0200, Thomas Huth wrote:
> On 14/09/2020 15.46, Eduardo Habkost wrote:
> > On Mon, Sep 14, 2020 at 07:39:09AM +0200, Thomas Huth wrote:
> >> On 13/09/2020 04.51, Eduardo Habkost wrote:
> >>> On Sat, Sep 12, 2020 at 08:45:19AM +0200, Thomas Huth wrote:
> >>>> On 11/09/2020 22.06, Eduardo Habkost wrote:
> >>>>> On Fri, Sep 11, 2020 at 08:06:10PM +0100, Peter Maydell wrote:
> >>>>>> On Fri, 11 Sep 2020 at 19:49, Eduardo Habkost <ehabkost@redhat.com> wrote:
> >>>>>>>
> >>>>>>> I'm wondering: do our supported build host platforms all include
> >>>>>>> compilers that are new enough to let us redefine typedefs?
> >>>>>>>
> >>>>>>> The ability to redefine typedefs is a C11 feature which would be
> >>>>>>> very useful for simplifying our QOM boilerplate code.  The
> >>>>>>> feature is supported by GCC since 2011 (v4.6.0)[1], and by clang
> >>>>>>> since 2012 (v3.1)[2].
> >>>>>>
> >>>>>> In configure we mandate either GCC v4.8 or better, or
> >>>>>> clang v3.4 or better, or XCode Clang v5.1 or better
> >>>>>> (Apple uses a different version numbering setup to upstream).
> >>>>>> So you should probably double-check that that xcode clang has
> >>>>>> what you want, but it looks like we're good to go otherwise.
> >>>>>
> >>>>> Can anybody confirm if the following is accurate?
> >>>>>
> >>>>> https://gist.github.com/yamaya/2924292#file-xcode-clang-vers-L67
> >>>>> # Xcode 5.1 (5B130a)
> >>>>> Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
> >>>>> Target: x86_64-apple-darwin13.1.0
> >>>>> Thread model: posix
> >>>>>
> >>>>> If we know we have GCC 4.8+ or clang 3.4+, can we move to C11 and
> >>>>> start using -std=gnu11?
> >>>>
> >>>> You don't have to switch to gnu11, redefintions of typedefs are already
> >>>> fine in gnu99, they are a gnu extension there to the c99 standard.
> >>>>
> >>>> See also:
> >>>> https://git.qemu.org/?p=qemu.git;a=commitdiff;h=7be41675f7cb16b
> >>>>
> >>>> https://www.mail-archive.com/qemu-devel@nongnu.org/msg585581.html
> >>>
> >>> They still trigger a warning with gnu99 on clang:
> >>>
> >>> $ clang --version
> >>> clang version 10.0.0 (Fedora 10.0.0-2.fc32)
> >>> Target: x86_64-unknown-linux-gnu
> >>> Thread model: posix
> >>> InstalledDir: /usr/bin
> >>> $ cat test.c
> >>> typedef struct A A;
> >>> typedef struct A A;
> >>> $ clang -std=gnu11 -c test.c
> >>> $ clang -std=gnu99 -c test.c
> >>> test.c:2:18: warning: redefinition of typedef 'A' is a C11 feature [-Wtypedef-redefinition]
> >>> typedef struct A A;
> >>
> >> Ah, right, I forgot about that ... so for clang, we silence that warning
> >> via CFLAGS in the configure script. See commit e6e90feedb706b1.
> > 
> > Nice, I hadn't seen that.  This means we don't need C11 for
> > supporting redefinition of typedefs.
> > 
> > Now, do we have other reasons for not moving to C11?  It would be
> > nice to make QEMU_GENERIC unnecessary and just use _Generic, for
> > example.
> 
> See https://www.mail-archive.com/qemu-devel@nongnu.org/msg585581.html
> ... c11 is still "experimental" in GCC 4.8, so I think we likely have to
> wait 'till summer next year - then we do not have to support
> RHEL7/CentOS7 anymore according our support policy, and thus we can bump
> the minimum required compiler versions.

Thanks Thomas and Daniel for the pointers.  Staying with gnu99
for a little longer sounds reasonable, now that we typedef
redefinitions are allowed.

-- 
Eduardo



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-09-14 16:55 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-11 18:49 Redefinition of typedefs (C11 feature) Eduardo Habkost
2020-09-11 19:06 ` Peter Maydell
2020-09-11 20:06   ` Moving to C11? (was Re: Redefinition of typedefs (C11 feature)) Eduardo Habkost
2020-09-11 20:10     ` Warner Losh
2020-09-12  8:16       ` Philippe Mathieu-Daudé
2020-09-12 15:04         ` Warner Losh
2020-09-12  6:45     ` Thomas Huth
2020-09-13  2:51       ` Eduardo Habkost
2020-09-14  5:39         ` Thomas Huth
2020-09-14 13:46           ` Eduardo Habkost
2020-09-14 13:50             ` Daniel P. Berrangé
2020-09-14 15:36             ` Thomas Huth
2020-09-14 16:53               ` Eduardo Habkost

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.