nfs4state.c fails to compile with gcc 4.5.4
Just letting you know that this commit:
fcd8843c406 ('NFSv4: Replace closed stateids with the "invalid special stateid"') causes gcc 4.5.4 to fail the build with this error:
CC [M] fs/nfs/nfs4state.o
/work/git/linux-trace.git/fs/nfs/nfs4state.c:75:4: error: field name not in record or union initializer /work/git/linux-trace.git/fs/nfs/nfs4state.c:75:4: error: (near initialization for 'invalid_stateid.<anonymous>.data') /work/git/linux-trace.git/fs/nfs/nfs4state.c:75:4: warning: overflow in implicit constant conversion /work/git/linux-trace.git/fs/nfs/nfs4state.c:76:4: error: field name not in record or union initializer /work/git/linux-trace.git/fs/nfs/nfs4state.c:76:4: error: (near initialization for 'invalid_stateid.<anonymous>.data') /work/git/linux-trace.git/fs/nfs/nfs4state.c:76:4: warning: braces around scalar initializer /work/git/linux-trace.git/fs/nfs/nfs4state.c:76:4: warning: (near initialization for 'invalid_stateid.<anonymous>.data[1]') make[3]: *** [/work/git/linux-trace.git/scripts/Makefile.build:310: fs/nfs/nfs4state.o] Error 1 make[2]: *** [/work/git/linux-trace.git/scripts/Makefile.build:569: fs/nfs] Error 2
make[1]: *** [/work/git/linux-trace.git/Makefile:1012: fs] Error 2
make[1]: Leaving directory '/work/git/nobackup/bxtest/trace'
Seems it can't handle the initialization of an anonymous struct within an anonymous union.
I switched to gcc 4.6.3 and it compiles fine.
-- Steve
Quoted 3 lines · Steven Rostedt
Seems it can't handle the initialization of an anonymous struct within an anonymous union.
I think we've seen this before, and I think there was some trick to make it work with older gcc versions.
Maybe the unnamed entry that gets initialized had to be declared first, and the initializer needed an extra set of braces?
Something like that.
But maybe the answer is just to say "4.5.4 is really old".
Doing some log digging gives me
ee9d3429c0e4 ("net/sched/sch_red.c: work around gcc-4.4.4 anon
union initializer issue")
aa4bf44dc851 ("userns: use union in {g,u}idmap struct")
6c09ffd02725 ("irqchip/gic-v4: Fix building with ancient gcc")
c848c49a62b3 ("drivers/media/cec/cec-adap.c: fix build with gcc-4.4.4")but they aren't necessarily _exactly_ the same issue.
Linus
Quoted 17 lines · On Wed, 29 Nov 2017 19:27:45 -0800 Linus Torvalds…
Quoted 3 lines · Steven Rostedt
Seems it can't handle the initialization of an anonymous struct within an anonymous union.
I think we've seen this before, and I think there was some trick to make it work with older gcc versions.
Maybe the unnamed entry that gets initialized had to be declared first, and the initializer needed an extra set of braces?
Something like that.
But maybe the answer is just to say "4.5.4 is really old".
Doing some log digging gives me
Quoted 7 lines
ee9d3429c0e4 ("net/sched/sch_red.c: work around gcc-4.4.4 anon union initializer issue") aa4bf44dc851 ("userns: use union in {g,u}idmap struct") 6c09ffd02725 ("irqchip/gic-v4: Fix building with ancient gcc") c848c49a62b3 ("drivers/media/cec/cec-adap.c: fix build with gcc-4.4.4")but they aren't necessarily _exactly_ the same issue.
Yeah, I'm the world expert at working around this gcc bug but the nfs4 one had me stumped when I looked at it, so I shelved it for revisiting later.
It would be nice to fix it, given that this is the only (known) site in the kernel which rules out these compiler versions.
Quoted 4 lines · Andrew Morton
Yeah, I'm the world expert at working around this gcc bug but the nfs4 one had me stumped when I looked at it, so I shelved it for revisiting later.
Does the attached patch fix it? I don't have old compilers.
Linus
fs/nfs/nfs4state.c | 3 +-- include/linux/nfs4.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)
fs/nfs/nfs4state.c +1 -2
@@ -71,8 +71,7 @@ const nfs4_stateid zero_stateid = { };const nfs4_stateid invalid_stateid = { { - .seqid =cpu_to_be32 (0xffffffffU ), - .other = {0 }, + { .seqid =cpu_to_be32 (0xffffffffU ), .other = {0 }, }, }, .type =NFS4_INVALID_STATEID_TYPE , };
include/linux/nfs4.h +1 -1
@@ -53,11 +53,11 @@ typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier;struct nfs4_stateid_struct {union { -char data[NFS4_STATEID_SIZE ];struct {__be32 seqid;char other[NFS4_STATEID_OTHER_SIZE ]; } __attribute__ ((packed)); +char data[NFS4_STATEID_SIZE ]; };enum {
Quoted 8 lines · On Wed, 29 Nov 2017 19:44:33 -0800 Linus Torvalds…
Quoted 4 lines · Andrew Morton
Yeah, I'm the world expert at working around this gcc bug but the nfs4 one had me stumped when I looked at it, so I shelved it for revisiting later.
Does the attached patch fix it? I don't have old compilers.
yup, thanks.
Steven Rostedt
Tested-byOn Wed, 29 Nov 2017 19:44:33 -0800
Linus Torvalds <[email protected]> wrote:
I keep older compilers around to test ftrace before -mfentry was introduced.
I wonder if I should just add a config to force the use without -mfentry even if the compiler supports it.
Quoted 9 lines
fs/nfs/nfs4state.c | 3 +-- include/linux/nfs4.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)fs/nfs/nfs4state.c +0
-0
fs/nfs/nfs4state.c const nfs4_stateid zero_stateid = { · line 74
Quoted 6 lines
fs/nfs/nfs4state.c +1
-2@@ -71,8 +71,7 @@ const nfs4_stateid zero_stateid = { };const nfs4_stateid invalid_stateid = { { - .seqid =cpu_to_be32 (0xffffffffU ), - .other = {0 }, + { .seqid =cpu_to_be32 (0xffffffffU ), .other = {0 }, },
I tried this and it failed.
Quoted 8 lines
fs/nfs/nfs4state.c +0
-0}, .type = NFS4_INVALID_STATEID_TYPE, };include/linux/nfs4.h +0
-0
include/linux/nfs4.h typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier; · line 60
Quoted 9 lines
include/linux/nfs4.h +1
-1@@ -53,11 +53,11 @@ typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier;struct nfs4_stateid_struct {union { -char data[NFS4_STATEID_SIZE ];struct {__be32 seqid;char other[NFS4_STATEID_OTHER_SIZE ]; } __attribute__ ((packed)); +char data[NFS4_STATEID_SIZE ];
But I didn't try this. This looks to be the key.
This works for me.
-- Steve
Quoted 3 lines
include/linux/nfs4.h +0
-0};enum {
Quoted 49 lines · Steven Rostedt
On Wed, 29 Nov 2017 19:44:33 -0800
Linus Torvalds <[email protected]> wrote:I keep older compilers around to test ftrace before -mfentry was introduced.
I wonder if I should just add a config to force the use without -mfentry even if the compiler supports it.
Quoted 9 lines
fs/nfs/nfs4state.c | 3 +-- include/linux/nfs4.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)fs/nfs/nfs4state.c +0
-0fs/nfs/nfs4state.c const nfs4_stateid zero_stateid = { · line 75
Quoted 7 lines
fs/nfs/nfs4state.c +1
-2@@ -71,8 +71,7 @@ const nfs4_stateid zero_stateid = { };const nfs4_stateid invalid_stateid = { { - .seqid =cpu_to_be32 (0xffffffffU ), - .other = {0 }, + { .seqid =cpu_to_be32 (0xffffffffU ), .other = {0 }, },I tried this and it failed.
Quoted 8 lines
fs/nfs/nfs4state.c +0
-0}, .type = NFS4_INVALID_STATEID_TYPE,};
include/linux/nfs4.h +0
-0include/linux/nfs4.h typedef struct { char data[NFS4_VERIFIER_SIZE]; · line 61
Quoted 10 lines
include/linux/nfs4.h +1
-1@@ -53,11 +53,11 @@ typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier;struct nfs4_stateid_struct {union { -char data[NFS4_STATEID_SIZE ];struct {__be32 seqid;char other[NFS4_STATEID_OTHER_SIZE ]; } __attribute__ ((packed)); +char data[NFS4_STATEID_SIZE ];But I didn't try this. This looks to be the key.
Quoted 11 lines
This works for me.
-- Steve
Quoted 3 lines
include/linux/nfs4.h +0
-0};enum {
We already have a fix queued up for this issue. It was reported and the patch hit linux-nfs+linux-kernel almost 2 weeks ago. Anna?
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, PrimaryData [email protected]
Quoted 56 lines · Trond Myklebust
Quoted 55 lines · Steven Rostedt
On Wed, 29 Nov 2017 19:44:33 -0800
Linus Torvalds <[email protected]> wrote:I keep older compilers around to test ftrace before -mfentry was introduced.
I wonder if I should just add a config to force the use without -mfentry even if the compiler supports it.
Quoted 9 lines
fs/nfs/nfs4state.c | 3 +-- include/linux/nfs4.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-)fs/nfs/nfs4state.c +0
-0fs/nfs/nfs4state.c const nfs4_stateid zero_stateid = { · line 75
Quoted 7 lines
fs/nfs/nfs4state.c +1
-2@@ -71,8 +71,7 @@ const nfs4_stateid zero_stateid = { };const nfs4_stateid invalid_stateid = { { - .seqid =cpu_to_be32 (0xffffffffU ), - .other = {0 }, + { .seqid =cpu_to_be32 (0xffffffffU ), .other = {0 }, },I tried this and it failed.
Quoted 8 lines
fs/nfs/nfs4state.c +0
-0}, .type = NFS4_INVALID_STATEID_TYPE,};
include/linux/nfs4.h +0
-0include/linux/nfs4.h typedef struct { char data[NFS4_VERIFIER_SIZE]; · line 61
Quoted 10 lines
include/linux/nfs4.h +1
-1@@ -53,11 +53,11 @@ typedef struct { char data[NFS4_VERIFIER_SIZE]; } nfs4_verifier;struct nfs4_stateid_struct {union { -char data[NFS4_STATEID_SIZE ];struct {__be32 seqid;char other[NFS4_STATEID_OTHER_SIZE ]; } __attribute__ ((packed)); +char data[NFS4_STATEID_SIZE ];But I didn't try this. This looks to be the key.
This works for me.
-- Steve
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
include/linux/nfs4.h +0
-0};enum {
We already have a fix queued up for this issue. It was reported and the patch hit linux-nfs+linux-kernel almost 2 weeks ago. Anna?
I have it queued up, and I was planning to send it this week with some other fixes.
Anna
Quoted 1 line
Quoted 25 lines · Andrew Morton
Quoted 23 lines · On Wed, 29 Nov 2017 19:27:45 -0800 Linus Torvalds…
Quoted 3 lines · Steven Rostedt
Seems it can't handle the initialization of an anonymous struct within an anonymous union.
I think we've seen this before, and I think there was some trick to make it work with older gcc versions.
Maybe the unnamed entry that gets initialized had to be declared first, and the initializer needed an extra set of braces?
Something like that.
But maybe the answer is just to say "4.5.4 is really old".
Doing some log digging gives me
ee9d3429c0e4 ("net/sched/sch_red.c: work around gcc-4.4.4 anon union initializer issue") aa4bf44dc851 ("userns: use union in {g,u}idmap struct") 6c09ffd02725 ("irqchip/gic-v4: Fix building with ancient gcc") c848c49a62b3 ("drivers/media/cec/cec-adap.c: fix build with gcc-4.4.4")
Quoted 8 lines
Quoted 1 line
but they aren't necessarily _exactly_ the same issue.
Yeah, I'm the world expert at working around this gcc bug but the nfs4 one had me stumped when I looked at it, so I shelved it for revisiting later.
It would be nice to fix it, given that this is the only (known) site in the kernel which rules out these compiler versions.
There are more in drivers/irqchip/irq-gic-v4.c and virt/kvm/arm/vgic/, but they are not built on x86. I've fixed it before, but it seems to be coming back each time a new GIC variant gets added.
If anyone cares, I can find the remaining patches I have for this and send them again.
Arnd
Quoted 36 lines · Arnd Bergmann
Quoted 25 lines · Andrew Morton
Quoted 23 lines · On Wed, 29 Nov 2017 19:27:45 -0800 Linus Torvalds…
Quoted 3 lines · Steven Rostedt
Seems it can't handle the initialization of an anonymous struct within an anonymous union.
I think we've seen this before, and I think there was some trick to make it work with older gcc versions.
Maybe the unnamed entry that gets initialized had to be declared first, and the initializer needed an extra set of braces?
Something like that.
But maybe the answer is just to say "4.5.4 is really old".
Doing some log digging gives me
ee9d3429c0e4 ("net/sched/sch_red.c: work around gcc-4.4.4 anon union initializer issue") aa4bf44dc851 ("userns: use union in {g,u}idmap struct") 6c09ffd02725 ("irqchip/gic-v4: Fix building with ancient gcc") c848c49a62b3 ("drivers/media/cec/cec-adap.c: fix build with gcc-4.4.4")Quoted 8 lines
Quoted 1 line
but they aren't necessarily _exactly_ the same issue.
Yeah, I'm the world expert at working around this gcc bug but the nfs4 one had me stumped when I looked at it, so I shelved it for revisiting later.
It would be nice to fix it, given that this is the only (known) site in the kernel which rules out these compiler versions.
Quoted 6 lines
There are more in
drivers/irqchip/irq-gic-v4.candvirt/kvm/arm/vgic/, but they are not built on x86. I've fixed it before, but it seems to be coming back each time a new GIC variant gets added.If anyone cares, I can find the remaining patches I have for this and send them again.
If you have patches for either GIC or the vgic, I'll happily take them.
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
From: Steven Rostedt
Quoted 2 lines
Sent: 30 November 2017 02:59
Subject: [BUILD FAILURE]nfs4state.cfails to compile with gcc 4.5.4
FWIW I can't build the current kernel with gcc 4.7.3-1ubuntu1 under ubuntu 13.04.
The compiler generates some object files that binutils (objdump/ld) 2.23.2 says are invalid.
I've not looked at the hexdump to look for anything 'funny'.
David