locking/qspinlock: Fix build for anonymous union in older gcc compilers
PATCH 1/1 locking/qspinlock: Fix build for anonymous union in older gcc compilers
From: Steven Rostedt (VMware) <[email protected]>
One of my tests compiles the kernel with gcc 4.5.3, and I hit the following build error:
/work/git/linux-trace.git/include/linux/semaphore.h: In function 'sema_init':
/work/git/linux-trace.git/include/linux/semaphore.h:35:17: error: unknown field 'val' specified in initializer /work/git/linux-trace.git/include/linux/semaphore.h:35:17: warning: missing braces around initializer /work/git/linux-trace.git/include/linux/semaphore.h:35:17: warning: (near initialization for '(anonymous).raw_lock.<anonymous>.val') In file included from /work/git/linux-trace.git/include/linux/sched/user.h:7:0,
from /work/git/linux-trace.git/include/linux/cred.h:22,
from /work/git/linux-trace.git/include/linux/seq_file.h:12,
from /work/git/linux-trace.git/include/linux/cgroup.h:18,
from /work/git/linux-trace.git/include/linux/memcontrol.h:22,
from /work/git/linux-trace.git/include/linux/swap.h:9,
from /work/git/linux-trace.git/include/linux/suspend.h:5,
from /work/git/linux-trace.git/arch/x86/kernel/asm-offsets.c:13:I bisected it down to the introduction of the commit that makes qspinlock have an anonymous union, which makes initializing it special for older compilers. By adding strategic brackets, it makes the build happy again.
---
include/asm-generic/qspinlock_types.h +1 -1
@@ -63,7 +63,7 @@ typedef struct qspinlock {/* * Initializier */ -#define __ARCH_SPIN_LOCK_UNLOCKED { .val = ATOMIC_INIT(0) } +#define __ARCH_SPIN_LOCK_UNLOCKED { { .val = ATOMIC_INIT(0) } }/* * Bitfields in the atomic value:
Quoted 32 lines · Steven Rostedt
From: Steven Rostedt (VMware) <[email protected]>
One of my tests compiles the kernel with gcc 4.5.3, and I hit the following build error:
/work/git/linux-trace.git/include/linux/semaphore.h: In function '
sema_init':
/work/git/linux-trace.git/include/linux/semaphore.h:35:17: error: unknown field 'val' specified in initializer /work/git/linux-trace.git/include/linux/semaphore.h:35:17: warning: missing braces around initializer /work/git/linux-trace.git/include/linux/semaphore.h:35:17: warning: (near initialization for '(anonymous).raw_lock.<anonymous>.val') In file included from /work/git/linux-trace.git/include/linux/sched/user.h:7:0,from /work/git/linux-trace.git/include/linux/cred.h:22, from /work/git/linux-trace.git/include/linux/seq_file.h:12, from /work/git/linux-trace.git/include/linux/cgroup.h:18, from /work/git/linux-trace.git/include/linux/memcontrol.h:22, from /work/git/linux-trace.git/include/linux/swap.h:9, from /work/git/linux-trace.git/include/linux/suspend.h:5, from /work/git/linux-trace.git/arch/x86/kernel/asm-offsets.c:13:I bisected it down to the introduction of the commit that makes qspinlock have an anonymous union, which makes initializing it special for older compilers. By adding strategic brackets, it makes the build happy again.
Fixes 625e88be1f41 ("locking/qspinlock: Merge 'struct __qspinlock' into 'struct qspinlock'")Signed-off-by Steven Rostedt (VMware) <[email protected]>---
include/asm-generic/qspinlock_types.h +0
-0
include/asm-generic/qspinlock_types.h typedef struct qspinlock { · line 69
Quoted 8 lines
include/asm-generic/qspinlock_types.h +1
-1@@ -63,7 +63,7 @@ typedef struct qspinlock {/* * Initializier */ -#define __ARCH_SPIN_LOCK_UNLOCKED { .val = ATOMIC_INIT(0) } +#define __ARCH_SPIN_LOCK_UNLOCKED { { .val = ATOMIC_INIT(0) } }/* * Bitfields in the atomic value:
tip-bot for Steven Rostedt (VMware)
merge bot[tip:locking/urgent] locking/qspinlock: Fix build for anonymous union in older GCC compilers
In reply to Steven Rostedtlocking/qspinlock: Fix build for anonymous union in older GCC compilers
Commit-ID: 6cc65be4f6f2a7186af8f3e09900787c7912dad2 Gitweb: https://git.kernel.org/tip/6cc65be4f6f2a7186af8f3e09900787c7912dad2 Author: Steven Rostedt (VMware) <[email protected]> AuthorDate: Thu, 21 Jun 2018 20:35:26 -0400 Committer: Ingo Molnar <[email protected]> CommitDate: Fri, 22 Jun 2018 04:19:16 +0200
locking/qspinlock: Fix build for anonymous union in older GCC compilers
One of my tests compiles the kernel with gcc 4.5.3, and I hit the following build error:
include/linux/semaphore.h: In function 'sema_init':
include/linux/semaphore.h:35:17: error: unknown field 'val' specified in initializer include/linux/semaphore.h:35:17: warning: missing braces around initializer include/linux/semaphore.h:35:17: warning: (near initialization for '(anonymous).raw_lock.<anonymous>.val')
I bisected it down to:
625e88be1f41 ("locking/qspinlock: Merge 'struct __qspinlock' into 'struct qspinlock'")
... which makes qspinlock have an anonymous union, which makes initializing it special for older compilers. By adding strategic brackets, it makes the build happy again.
--- include/asm-generic/qspinlock_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/asm-generic/qspinlock_types.h +1 -1
@@ -63,7 +63,7 @@ typedef struct qspinlock {/* * Initializier */ -#define __ARCH_SPIN_LOCK_UNLOCKED { .val = ATOMIC_INIT(0) } +#define __ARCH_SPIN_LOCK_UNLOCKED { { .val = ATOMIC_INIT(0) } }/* * Bitfields in the atomic value:
Hi Steve,
Quoted 19 lines · Steven Rostedt
From: Steven Rostedt (VMware) <[email protected]>
One of my tests compiles the kernel with gcc 4.5.3, and I hit the following build error:
/work/git/linux-trace.git/include/linux/semaphore.h: In function '
sema_init':
/work/git/linux-trace.git/include/linux/semaphore.h:35:17: error: unknown field 'val' specified in initializer /work/git/linux-trace.git/include/linux/semaphore.h:35:17: warning: missing braces around initializer /work/git/linux-trace.git/include/linux/semaphore.h:35:17: warning: (near initialization for '(anonymous).raw_lock.<anonymous>.val') In file included from /work/git/linux-trace.git/include/linux/sched/user.h:7:0,from /work/git/linux-trace.git/include/linux/cred.h:22, from /work/git/linux-trace.git/include/linux/seq_file.h:12, from /work/git/linux-trace.git/include/linux/cgroup.h:18, from /work/git/linux-trace.git/include/linux/memcontrol.h:22, from /work/git/linux-trace.git/include/linux/swap.h:9, from /work/git/linux-trace.git/include/linux/suspend.h:5, from /work/git/linux-trace.git/arch/x86/kernel/asm-offsets.c:13:
Quoted 8 lines
I bisected it down to the introduction of the commit that makes qspinlock have an anonymous union, which makes initializing it special for older compilers. By adding strategic brackets, it makes the build happy again.
Fixes 625e88be1f41 ("locking/qspinlock: Merge 'struct __qspinlock' into 'struct qspinlock'")Signed-off-by Steven Rostedt (VMware) <[email protected]>---
Cheers for spotting this and fixing it up! I know it's already in -tip, but anyway:
Will