[PATCH, v2] bug.h: Fix up x86 build regression

From: Ingo Molnar
Date: Mon Jun 25 2012 - 06:51:10 EST



* Ingo Molnar <mingo@xxxxxxxxxx> wrote:

>
> * Paul Mundt <lethal@xxxxxxxxxxxx> wrote:
>
> > The asm-generic/bug.h __ASSEMBLY__ guarding is completely bogus, which
> > tripped up the powerpc build when the kernel.h include was added:
> >
> > In file included from include/asm-generic/bug.h:5:0,
> > from arch/powerpc/include/asm/bug.h:127,
> > from arch/powerpc/kernel/head_64.S:31:
> > include/linux/kernel.h:44:0: warning: "ALIGN" redefined [enabled by default]
> > include/linux/linkage.h:57:0: note: this is the location of the previous definition
> > include/linux/sysinfo.h: Assembler messages:
> > include/linux/sysinfo.h:7: Error: Unrecognized opcode: `struct'
> > include/linux/sysinfo.h:8: Error: Unrecognized opcode: `__kernel_long_t'
> >
> > Moving the __ASSEMBLY__ guard up and stashing the kernel.h include under
> > it fixes this up, as well as covering the case the original fix was
> > attempting to handle.
> >
> > Tested-by: Stephen Rothwell <sfr@xxxxxxxxxxxxxxxx>
> > Acked-by: Arnd Bergmann <arnd@xxxxxxxx>
> > Signed-off-by: Paul Mundt <lethal@xxxxxxxxxxxx>
>
> This commit broke most x86 !CONFIG_BUG builds in -rc4:
>
> In file included from /home/mingo/tip/arch/x86/include/asm/cpumask.h:4:0,
> from /home/mingo/tip/arch/x86/include/asm/msr.h:18,
> from /home/mingo/tip/arch/x86/include/asm/processor.h:20,
> from /home/mingo/tip/arch/x86/include/asm/atomic.h:6,
> from include/linux/atomic.h:4,
> from include/linux/crypto.h:20,
> from arch/x86/kernel/asm-offsets.c:8:
> include/linux/cpumask.h: In function âcpumask_checkâ:
> include/linux/cpumask.h:108:2: error: implicit declaration of function âWARN_ON_ONCEâ [-Werror=implicit-function-declaration]
> In file included from include/linux/thread_info.h:54:0,
> from include/linux/preempt.h:9,
> from include/linux/spinlock.h:50,
> from include/linux/mmzone.h:7,
> from include/linux/gfp.h:4,
> from include/linux/slab.h:12,
> from include/linux/crypto.h:24,
> from arch/x86/kernel/asm-offsets.c:8:
> /home/mingo/tip/arch/x86/include/asm/thread_info.h: In function âset_restore_sigmaskâ:
> /home/mingo/tip/arch/x86/include/asm/thread_info.h:251:2: error: implicit declaration of function âWARN_ONâ [-Werror=implicit-function-declaration]
> In file included from /home/mingo/tip/arch/x86/include/asm/apic.h:12:0,
> from /home/mingo/tip/arch/x86/include/asm/smp.h:13,
> from include/linux/smp.h:38,
> from include/linux/topology.h:33,
> from include/linux/gfp.h:7,
> from include/linux/slab.h:12,
> from include/linux/crypto.h:24,
> from arch/x86/kernel/asm-offsets.c:8:
> /home/mingo/tip/arch/x86/include/asm/fixmap.h: In function âvirt_to_fixâ:
> /home/mingo/tip/arch/x86/include/asm/fixmap.h:219:2: error: implicit declaration of function âBUG_ONâ [-Werror=implicit-function-declaration]
> In file included from include/linux/slab.h:185:0,
> from include/linux/crypto.h:24,
> from arch/x86/kernel/asm-offsets.c:8:
> include/linux/slub_def.h: In function âkmalloc_indexâ:
> include/linux/slub_def.h:192:2: error: implicit declaration of function âBUGâ [-Werror=implicit-function-declaration]
> cc1: some warnings being treated as errors
>
> The commit mis-placed the !ASSEMBLY block, mixing it with the
> CONFIG_BUG section.
>
> Hiding an #include <kernel.h> deep inside a generic header is in
> pretty bad taste anyway, it creates kconfig dependent breakages
> and makes it harder to untangle header files.
>
> The patch below fixes most of the bad effects for me on x86, but
> I have not tested the PowerPC cross-build yet.

I did a PowerPC cross-build and it was not quite there yet, but
the second version below does the trick and fixes x86 and
powerpc as well.

Linus, if there are no objections to the patch then I can push
this fix to you via tip:core/urgent (where it's queued up
currently), or you could apply it via email as well.

Thanks,

Ingo

------------->