linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] locking/qspinlock: Fix build for anonymous union in older gcc compilers
@ 2018-06-22  0:35 Steven Rostedt
  2018-06-22  2:05 ` Waiman Long
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Steven Rostedt @ 2018-06-22  0:35 UTC (permalink / raw)
  To: LKML
  Cc: Linus Torvalds, Will Deacon, Peter Zijlstra (Intel),
	Waiman Long, Boqun Feng, Ingo Molnar, linux-arm-kernel,
	Andrew Morton

From: Steven Rostedt (VMware) <rostedt@goodmis.org>

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) <rostedt@goodmis.org>
---
diff --git a/include/asm-generic/qspinlock_types.h b/include/asm-generic/qspinlock_types.h
index 0763f065b975..d10f1e7d6ba8 100644
--- a/include/asm-generic/qspinlock_types.h
+++ b/include/asm-generic/qspinlock_types.h
@@ -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:

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

* Re: [PATCH] locking/qspinlock: Fix build for anonymous union in older gcc compilers
  2018-06-22  0:35 [PATCH] locking/qspinlock: Fix build for anonymous union in older gcc compilers Steven Rostedt
@ 2018-06-22  2:05 ` Waiman Long
  2018-06-22  2:24 ` [tip:locking/urgent] locking/qspinlock: Fix build for anonymous union in older GCC compilers tip-bot for Steven Rostedt (VMware)
  2018-06-22  7:49 ` [PATCH] locking/qspinlock: Fix build for anonymous union in older gcc compilers Will Deacon
  2 siblings, 0 replies; 4+ messages in thread
From: Waiman Long @ 2018-06-22  2:05 UTC (permalink / raw)
  To: Steven Rostedt, LKML
  Cc: Linus Torvalds, Will Deacon, Peter Zijlstra (Intel),
	Boqun Feng, Ingo Molnar, linux-arm-kernel, Andrew Morton

On 06/22/2018 08:35 AM, Steven Rostedt wrote:
> From: Steven Rostedt (VMware) <rostedt@goodmis.org>
>
> 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) <rostedt@goodmis.org>
> ---
> diff --git a/include/asm-generic/qspinlock_types.h b/include/asm-generic/qspinlock_types.h
> index 0763f065b975..d10f1e7d6ba8 100644
> --- a/include/asm-generic/qspinlock_types.h
> +++ b/include/asm-generic/qspinlock_types.h
> @@ -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:

Acked-by: Waiman Long <longman@redhat.com>


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

* [tip:locking/urgent] locking/qspinlock: Fix build for anonymous union in older GCC compilers
  2018-06-22  0:35 [PATCH] locking/qspinlock: Fix build for anonymous union in older gcc compilers Steven Rostedt
  2018-06-22  2:05 ` Waiman Long
@ 2018-06-22  2:24 ` tip-bot for Steven Rostedt (VMware)
  2018-06-22  7:49 ` [PATCH] locking/qspinlock: Fix build for anonymous union in older gcc compilers Will Deacon
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot for Steven Rostedt (VMware) @ 2018-06-22  2:24 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: tglx, will.deacon, rostedt, akpm, longman, linux-kernel,
	boqun.feng, peterz, torvalds, mingo, hpa

Commit-ID:  6cc65be4f6f2a7186af8f3e09900787c7912dad2
Gitweb:     https://git.kernel.org/tip/6cc65be4f6f2a7186af8f3e09900787c7912dad2
Author:     Steven Rostedt (VMware) <rostedt@goodmis.org>
AuthorDate: Thu, 21 Jun 2018 20:35:26 -0400
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: Waiman Long <longman@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arm-kernel@lists.infradead.org
Fixes: 625e88be1f41 ("locking/qspinlock: Merge 'struct __qspinlock' into 'struct qspinlock'")
Link: http://lkml.kernel.org/r/20180621203526.172ab5c4@vmware.local.home
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/asm-generic/qspinlock_types.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/asm-generic/qspinlock_types.h b/include/asm-generic/qspinlock_types.h
index 0763f065b975..d10f1e7d6ba8 100644
--- a/include/asm-generic/qspinlock_types.h
+++ b/include/asm-generic/qspinlock_types.h
@@ -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:

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

* Re: [PATCH] locking/qspinlock: Fix build for anonymous union in older gcc compilers
  2018-06-22  0:35 [PATCH] locking/qspinlock: Fix build for anonymous union in older gcc compilers Steven Rostedt
  2018-06-22  2:05 ` Waiman Long
  2018-06-22  2:24 ` [tip:locking/urgent] locking/qspinlock: Fix build for anonymous union in older GCC compilers tip-bot for Steven Rostedt (VMware)
@ 2018-06-22  7:49 ` Will Deacon
  2 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2018-06-22  7:49 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: LKML, Linus Torvalds, Peter Zijlstra (Intel),
	Waiman Long, Boqun Feng, Ingo Molnar, linux-arm-kernel,
	Andrew Morton

Hi Steve,

On Thu, Jun 21, 2018 at 08:35:26PM -0400, Steven Rostedt wrote:
> From: Steven Rostedt (VMware) <rostedt@goodmis.org>
> 
> 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) <rostedt@goodmis.org>
> ---

Cheers for spotting this and fixing it up! I know it's already in -tip, but
anyway:

Acked-by: Will Deacon <will.deacon@arm.com>

Will

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

end of thread, other threads:[~2018-06-22  7:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-22  0:35 [PATCH] locking/qspinlock: Fix build for anonymous union in older gcc compilers Steven Rostedt
2018-06-22  2:05 ` Waiman Long
2018-06-22  2:24 ` [tip:locking/urgent] locking/qspinlock: Fix build for anonymous union in older GCC compilers tip-bot for Steven Rostedt (VMware)
2018-06-22  7:49 ` [PATCH] locking/qspinlock: Fix build for anonymous union in older gcc compilers Will Deacon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).