On Thu, 2014-08-28 at 11:00 -0700, Ben Hutchings wrote: > On Thu, 2014-08-28 at 09:38 -0300, Mauricio Faria de Oliveira wrote: > > Package: src:linux > > > > Hi Ben, > > > > On 08/26/2014 05:05 AM, Ben Hutchings wrote: > > > The first build failure (requiring __SANE_USERSPACE_TYPES__) appears to > > > be fixed upstream in 3.16. [...] > > > > I'm still hitting that w/ 3.16 (linux-tools from trunk, plus .orig > > from 3.16~rc7~exp1 or upstream 3.16.1 -- not usual, but I believe > > it was supposed to work). > > > > May you please point where/commit/excerpt you see this fixed? I could > > only find a related commit for MIPS [1], but nothing for powerpc. > > I thought this would do it: > > commit d944c4eebcf4c0d5e5d9728fec110cbf0047ad7f > Author: Borislav Petkov <bp@suse.de> > Date: Fri Apr 25 21:31:02 2014 +0200 > > tools: Consolidate types.h OK, I forgot to apply this fix for 3.16-1. So coming back to this, I tried to understand what __SANE_USERSPACE_TYPES__ has to do with defining 'u32' (which the kernel headers should never define for userland), and why we would include include/linux/types.h (rather than the corresponding UAPI header) at all. The answer is that devicetable-offsets.c is supposed to be built like kernel code, but we're fudging it - we're also trying to make modpost support cross-builds and not depend on any kernel configuration. As we don't want it to depend on the host architecture, our search path is just: include So the chain of included headers is: <linux/types.h> => include/linux/types.h <asm/types.h> => /usr/include/.../asm/types.h either: <asm-generic/int-ll64.h> => include/asm-generic/int-ll64.h or: <asm-generic/int-l64.h> => /usr/include/asm-generic/int-l64.h Since there is no include/asm-generic/int-l64.h, whether or not we define __SANE_USERSPACE_TYPES__ determines whether we include a kernel or userland header. So that's why your fix works, but we really shouldn't be including any userland headers at all. I think we should avoid <linux/types.h> altogether, and make sure we don't accidentally include UAPI headers: Index: linux-tools/debian/build/scripts/mod/Makefile.real =================================================================== --- linux-tools/debian/build/scripts/mod/Makefile.real (revision 21797) +++ linux-tools/debian/build/scripts/mod/Makefile.real (working copy) @@ -2,8 +2,6 @@ top_srcdir = ../.. -CFLAGS += -I$(top_srcdir)/include - include $(top_srcdir)/debian/build/Makefile.inc modpost.real-$(TYPE): file2alias.real-$(TYPE).o modpost.real-$(TYPE).o sumversion.real-$(TYPE).o @@ -13,7 +11,7 @@ $(CC) -I real-$(TYPE) $(CFLAGS) -c -o $@ $< real-$(TYPE)/devicetable-offsets.s: $(SOURCEDIR)/devicetable-offsets.c - $(CC) -include real-$(TYPE)/types.h $(CFLAGS) -S -o $@ $< + $(CC) -include real-$(TYPE)/types.h $(CFLAGS) -nostdinc -I$(top_srcdir)/include -S -o $@ $< real-$(TYPE)/devicetable-offsets.h: real-$(TYPE)/devicetable-offsets.s echo >$@ "#define __DEVICEVTABLE_OFFSETS_H__" Index: linux-tools/debian/build/scripts/mod/real-lsb-32/types.h =================================================================== --- linux-tools/debian/build/scripts/mod/real-lsb-32/types.h (revision 21797) +++ linux-tools/debian/build/scripts/mod/real-lsb-32/types.h (working copy) @@ -1,2 +1,3 @@ -#include <linux/types.h> +#include "../types.h" typedef __u32 kernel_ulong_t; +#define BITS_PER_LONG 32 Index: linux-tools/debian/build/scripts/mod/real-lsb-64/types.h =================================================================== --- linux-tools/debian/build/scripts/mod/real-lsb-64/types.h (revision 21797) +++ linux-tools/debian/build/scripts/mod/real-lsb-64/types.h (working copy) @@ -1,2 +1,3 @@ -#include <linux/types.h> +#include "../types.h" typedef __u64 __attribute__((aligned(8))) kernel_ulong_t; +#define BITS_PER_LONG 64 Index: linux-tools/debian/build/scripts/mod/real-msb-32/types.h =================================================================== --- linux-tools/debian/build/scripts/mod/real-msb-32/types.h (revision 21797) +++ linux-tools/debian/build/scripts/mod/real-msb-32/types.h (working copy) @@ -1,2 +1,3 @@ -#include <linux/types.h> +#include "../types.h" typedef __u32 kernel_ulong_t; +#define BITS_PER_LONG 32 Index: linux-tools/debian/build/scripts/mod/real-msb-64/types.h =================================================================== --- linux-tools/debian/build/scripts/mod/real-msb-64/types.h (revision 21797) +++ linux-tools/debian/build/scripts/mod/real-msb-64/types.h (working copy) @@ -1,2 +1,3 @@ -#include <linux/types.h> +#include "../types.h" typedef __u64 __attribute__((aligned(8))) kernel_ulong_t; +#define BITS_PER_LONG 64 Index: linux-tools/debian/build/scripts/mod/types.h =================================================================== --- linux-tools/debian/build/scripts/mod/types.h (revision 0) +++ linux-tools/debian/build/scripts/mod/types.h (working copy) @@ -0,0 +1,6 @@ +/* Minimal definitions for mod_devicetable.h and devicetable-offsets.c */ +typedef unsigned char __u8; +typedef unsigned short __u16; +typedef unsigned int __u32; +typedef unsigned long long __u64; +#define offsetof(a,b) __builtin_offsetof(a,b) Index: linux-tools/debian/changelog =================================================================== --- linux-tools/debian/changelog (revision 21797) +++ linux-tools/debian/changelog (working copy) @@ -1,3 +1,13 @@ +linux-tools (3.16-2) UNRELEASED; urgency=medium + + [ Ben Hutchings ] + * linux-kbuild: Change the type headers used for devicetable-offsets.c + to avoid depending on UAPI headers or <linux/types.h>. This really + closes: #754213. It also fixes modpost handling of input device IDs + when host and target have differing word size. + + -- Ben Hutchings <ben@decadent.org.uk> Tue, 09 Sep 2014 12:18:29 +0100 + linux-tools (3.16-1) unstable; urgency=medium * New upstream release --- END --- Avoiding <linux/types.h> forced me to define BITS_PER_LONG, which resulted in the second fix mentioned above. However, a cross-modpost still doesn't correctly handle various other device ID types where the structure is defined to have pointer fields (not kernel_ulong_t). Ben. -- Ben Hutchings If God had intended Man to program, we'd have been born with serial I/O ports.
Attachment:
signature.asc
Description: This is a digitally signed message part