Patchwork ARM: mx51: Fix build error due to missing include of <linux/bug.h>

login
register
mail settings
Submitter Fabio Estevam
Date Feb. 28, 2012, 12:11 p.m.
Message ID <1330431110-22020-1-git-send-email-fabio.estevam@freescale.com>
Download mbox | patch
Permalink /patch/143440/
State New
Headers show

Comments

Fabio Estevam - Feb. 28, 2012, 12:11 p.m.
Fix the following build error:

arch/arm/mach-imx/cpu_op-mx51.c: In function 'mx51_get_cpu_op':
arch/arm/mach-imx/cpu_op-mx51.c:27: error: implicit declaration of function 'BUILD_BUG_ON_ZERO'

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
---
This applies against linux-next

 arch/arm/mach-imx/cpu_op-mx51.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Russell King - ARM Linux - Feb. 28, 2012, 12:53 p.m.
On Tue, Feb 28, 2012 at 09:11:50AM -0300, Fabio Estevam wrote:
> Fix the following build error:
> 
> arch/arm/mach-imx/cpu_op-mx51.c: In function 'mx51_get_cpu_op':
> arch/arm/mach-imx/cpu_op-mx51.c:27: error: implicit declaration of function 'BUILD_BUG_ON_ZERO'

I think having the asm/bug.h replaced with linux/bug.h in linux/kernel.h
would be a better solution.

> 
> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
> ---
> This applies against linux-next
> 
>  arch/arm/mach-imx/cpu_op-mx51.c |    1 +
>  1 files changed, 1 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/cpu_op-mx51.c b/arch/arm/mach-imx/cpu_op-mx51.c
> index 9d34c3d..9a4f77a 100644
> --- a/arch/arm/mach-imx/cpu_op-mx51.c
> +++ b/arch/arm/mach-imx/cpu_op-mx51.c
> @@ -14,6 +14,7 @@
>  #include <linux/types.h>
>  #include <mach/hardware.h>
>  #include <linux/kernel.h>
> +#include <linux/bug.h>
>  
>  static struct cpu_op mx51_cpu_op[] = {
>  	{
> -- 
> 1.7.1
> 
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Fabio Estevam - Feb. 28, 2012, 1:03 p.m.
On Tue, Feb 28, 2012 at 9:53 AM, Russell King - ARM Linux
<linux@arm.linux.org.uk> wrote:

> I think having the asm/bug.h replaced with linux/bug.h in linux/kernel.h
> would be a better solution.

commit 6f863554 (kernel.h: doesn't explicitly use bug.h, so don't
include it. ), which appears in linux-next, has removed asm/debug.h
from linux/kernel.h.

I should have pointed this commit ID in my commit log.

Regards,

Fabio Estevam
Russell King - ARM Linux - Feb. 28, 2012, 1:21 p.m.
On Tue, Feb 28, 2012 at 10:03:33AM -0300, Fabio Estevam wrote:
> On Tue, Feb 28, 2012 at 9:53 AM, Russell King - ARM Linux
> <linux@arm.linux.org.uk> wrote:
> 
> > I think having the asm/bug.h replaced with linux/bug.h in linux/kernel.h
> > would be a better solution.
> 
> commit 6f863554 (kernel.h: doesn't explicitly use bug.h, so don't
> include it. ), which appears in linux-next, has removed asm/debug.h
> from linux/kernel.h.
> 
> I should have pointed this commit ID in my commit log.

No, this is not a fix, and it probably makes things worse.

linux/kernel.h _does_ use bug stuff - in ARRAY_SIZE().

ARRAY_SIZE() uses __must_be_array(), which is defined in linux/compiler-gcc.h,
which is obtained via linux/compiler.h and linux/linkage.h.

linux/compiler-gcc.h defines __must_be_array() to be:
#define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))

and BUILD_BUG_ON_ZERO used to be in linux/kernel.h but got moved to
linux/bug.h.

Hence why people are seeing build breakage with ARRAY_SIZE().

The answer is not to start scattering lots of .c files with linux/bug.h
includes, but to fix linux/kernel.h.
Fabio Estevam - Feb. 28, 2012, 1:25 p.m.
On 2/28/12, Russell King - ARM Linux <linux@arm.linux.org.uk> wrote:
> On Tue, Feb 28, 2012 at 10:03:33AM -0300, Fabio Estevam wrote:
>> On Tue, Feb 28, 2012 at 9:53 AM, Russell King - ARM Linux
>> <linux@arm.linux.org.uk> wrote:
>>
>> > I think having the asm/bug.h replaced with linux/bug.h in linux/kernel.h
>> > would be a better solution.
>>
>> commit 6f863554 (kernel.h: doesn't explicitly use bug.h, so don't
>> include it. ), which appears in linux-next, has removed asm/debug.h
>> from linux/kernel.h.
>>
>> I should have pointed this commit ID in my commit log.
>
> No, this is not a fix, and it probably makes things worse.
>
> linux/kernel.h _does_ use bug stuff - in ARRAY_SIZE().
>
> ARRAY_SIZE() uses __must_be_array(), which is defined in
> linux/compiler-gcc.h,
> which is obtained via linux/compiler.h and linux/linkage.h.
>
> linux/compiler-gcc.h defines __must_be_array() to be:
> #define __must_be_array(a) BUILD_BUG_ON_ZERO(__same_type((a), &(a)[0]))
>
> and BUILD_BUG_ON_ZERO used to be in linux/kernel.h but got moved to
> linux/bug.h.
>
> Hence why people are seeing build breakage with ARRAY_SIZE().
>
> The answer is not to start scattering lots of .c files with linux/bug.h
> includes, but to fix linux/kernel.h.

This makes sense, thanks.

Will submit a patch for lkml shortly.
Paul Gortmaker - Feb. 28, 2012, 11:52 p.m.
[Re: [PATCH] ARM: mx51: Fix build error due to missing include of <linux/bug.h>] On 28/02/2012 (Tue 13:21) Russell King - ARM Linux wrote:

[...]

> The answer is not to start scattering lots of .c files with linux/bug.h
> includes, but to fix linux/kernel.h.

Hi Russell,

I understand your concerns, and had I found myself "buggering" lots
of .c files, I would have backed away and said to myself, "OK, this
really isn't going to work - we really can't do this."

But to put some metrics to it, after building for about 10 different
arch and all their defconfigs, I only had to change about twenty[1] of
the approximately sixteen thousand .c files in the kernel.  That is
about 0.125% -- which is one of the things that made me think "Hey, we
can really do this cleanup!"   Including this file, there were only
two .c files in all of arch/arm that were using bug somehow.

So I think having kernel.h not require bug.h is completely do-able.
But in the end, I'm not welded to the idea.  I think it is a win, but
I'm not going to kick up a big stink if Linus or Andrew say they don't
think it is of value, and would rather not rock the boat.

Thanks,
Paul.
--

[1] https://lkml.org/lkml/2012/1/26/521
Russell King - ARM Linux - Feb. 29, 2012, 12:06 a.m.
On Tue, Feb 28, 2012 at 06:52:45PM -0500, Paul Gortmaker wrote:
> [Re: [PATCH] ARM: mx51: Fix build error due to missing include of <linux/bug.h>] On 28/02/2012 (Tue 13:21) Russell King - ARM Linux wrote:
> 
> [...]
> 
> > The answer is not to start scattering lots of .c files with linux/bug.h
> > includes, but to fix linux/kernel.h.
> 
> Hi Russell,
> 
> I understand your concerns, and had I found myself "buggering" lots
> of .c files, I would have backed away and said to myself, "OK, this
> really isn't going to work - we really can't do this."
> 
> But to put some metrics to it, after building for about 10 different
> arch and all their defconfigs, I only had to change about twenty[1] of
> the approximately sixteen thousand .c files in the kernel.

I think there's more than that - I've seen two reports for other
files which have needed fixing so far, and I wouldn't be surprised if
there's more.

I guess we'll see in coming weeks how it pans out, but my gut feeling
is that this is going to cause a fair number of build problems.

Patch

diff --git a/arch/arm/mach-imx/cpu_op-mx51.c b/arch/arm/mach-imx/cpu_op-mx51.c
index 9d34c3d..9a4f77a 100644
--- a/arch/arm/mach-imx/cpu_op-mx51.c
+++ b/arch/arm/mach-imx/cpu_op-mx51.c
@@ -14,6 +14,7 @@ 
 #include <linux/types.h>
 #include <mach/hardware.h>
 #include <linux/kernel.h>
+#include <linux/bug.h>
 
 static struct cpu_op mx51_cpu_op[] = {
 	{