headers_install.sh: enhance error handling
Exit with error if using undefined variables or if any sub command fails with error return value. unidef needs special handling since but this can be done without the trap. Enables exaniming intermediate files if some commands failed. Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
scripts/headers_compile_test.sh: compile test script for exported hea…
…ders
Users of kernel header files would be happier if they did not contain
kernel specific parts and would contain #include statements for all
other header files that they depend on, and in general would compile.
For each header file exported to userspace, this script creates
a simple .c file which just includes the header file. Then it
tries to compile it together with minimal header files from GCC
and libc, and reports results.
Default libc and GCC header file locations are parsed from compiler
configuration.
Kernel headers depend on GCC headers so their path is included in
the test compiler command line.
Some gcc and kernel headers depend on libc headers which are made available
by copying from the compiler default location to a temporary location and
removing possibly existing kernel headers from this directory. This is a bit
of a hack but seems to work in multiple environments.
Tested natively on:
Debian unstable, i586-linux-gnu and gcc 4.9.2
Raspbian Wheezy, arm-linux-gnueabihf and gcc 4.6.3
Ubuntu 12.04 LTS, x86_64-linux-gnu and gcc 4.6.3
Tested cross compilation using standard CROSS_COMPILE=/path/to/gcc with:
arm-linux-gnueabihf-gcc (crosstool-NG linaro-1.13.1-4.9-2014.09 - Linaro GCC 4.9-2014.09) 4.9.2 20140904 (prerelease)
Execute the script in the directory where kernel header files are installed.
For example:
$ make headers_install
$ cd usr/include
$ ../../scripts/headers_compile_test.sh
Example statistics from 3.18.4 kernel:
130 files failed the compile test.
609 files passed the compile test.
Example error types from 3.18.4 kernel:
$ ../../scripts/headers_compile_test.sh 2>&1 | \
grep error: | sed -e 's/.*error://g' | sort | uniq -c | sort -rn
352 unknown type name ‘uint32_t’
134 unknown type name ‘uint64_t’
103 unknown type name ‘size_t’
43 unknown type name ‘__kernel_ulong_t’
38 unknown type name ‘uint8_t’
24 unknown type name ‘int32_t’
22 field ‘addr’ has incomplete type
18 field ‘tstamp’ has incomplete type
16 unknown type name ‘__kernel_time_t’
16 field ‘in’ has incomplete type
16 field ‘in6’ has incomplete type
14 unknown type name ‘__be16’
13 ‘IFNAMSIZ’ undeclared here (not in a function)
12 unknown type name ‘uint16_t’
9 field ‘ifru_netmask’ has incomplete type
9 field ‘ifru_hwaddr’ has incomplete type
9 field ‘ifru_dstaddr’ has incomplete type
9 field ‘ifru_broadaddr’ has incomplete type
9 field ‘ifru_addr’ has incomplete type
8 unknown type name ‘__kernel_pid_t’
7 unknown type name ‘u_short’
7 unknown type name ‘pid_t’
6 invalid application of ‘sizeof’ to incomplete type ‘struct timespec’
6 field ‘src’ has incomplete type
6 field ‘audio_tstamp’ has incomplete type
6 array type has incomplete element type
5 unknown type name ‘__kernel_long_t’
5 requested alignment is not an integer constant
5 field ‘smsk’ has incomplete type
4 unknown type name ‘__kernel_uid32_t’
4 unknown type name ‘__kernel_gid32_t’
4 ‘ETH_ALEN’ undeclared here (not in a function)
3 unknown type name ‘int64_t’
3 unknown type name ‘caddr_t’
3 ‘IPSET_ERR_TYPE_SPECIFIC’ undeclared here (not in a function)
3 field ‘trigger_tstamp’ has incomplete type
3 field ‘src_addr’ has incomplete type
3 field ‘sin_addr’ has incomplete type
3 field ‘laddr’ has incomplete type
3 field ‘id’ has incomplete type
3 field ‘dmsk’ has incomplete type
3 field ‘bssid’ has incomplete type
3 expected specifier-qualifier-list before ‘uint64_t’
2 unknown type name ‘u_long’
2 unknown type name ‘stack_t’
2 unknown type name ‘sigset_t’
2 unknown type name ‘sa_family_t’
2 unknown type name ‘__kernel_mode_t’
2 unknown type name ‘__kernel_key_t’
2 unknown type name ‘elf_gregset_t’
2 unknown type name ‘bool’
2 ‘uint64_t’ undeclared here (not in a function)
2 ‘true’ undeclared (first use in this function)
2 ‘NAME_MAX’ undeclared here (not in a function)
2 ‘__kernel_mode_t’ undeclared here (not in a function)
2 invalid application of ‘sizeof’ to incomplete type ‘struct sockaddr’
2 field ‘uc_mcontext’ has incomplete type
2 field ‘tmsk’ has incomplete type
2 field ‘tgt’ has incomplete type
2 field ‘shm_perm’ has incomplete type
2 field ‘sem_perm’ has incomplete type
2 field ‘raddr’ has incomplete type
2 field ‘msg_perm’ has incomplete type
2 field ‘grp’ has incomplete type
2 field ‘dst’ has incomplete type
2 field ‘dst_addr’ has incomplete type
2 field ‘arp_pa’ has incomplete type
2 field ‘arp_netmask’ has incomplete type
2 field ‘arp_ha’ has incomplete type
2 ‘false’ undeclared (first use in this function)
1 xen/interface/xen.h: No such file or directory
1 via_drmclient.h: No such file or directory
1 unknown type name ‘wait_queue_head_t’
1 unknown type name ‘snd_seq_client_type_t’
1 unknown type name ‘int16_t’
1 unknown type name ‘ino_t’
1 unknown type name ‘elf_greg_t’
1 unknown type name ‘elf_fpxregset_t’
1 unknown type name ‘elf_fpregset_t’
1 unknown type name ‘__be32’
1 ‘SIOCDEVPRIVATE’ undeclared here (not in a function)
1 ‘sa_family_t’ undeclared here (not in a function)
1 ‘NULL’ undeclared (first use in this function)
1 ‘MSG_FIN’ undeclared here (not in a function)
1 ‘MAX_IPOPTLEN’ undeclared here (not in a function)
1 ‘MAX_ADDR_LEN’ undeclared here (not in a function)
1 ‘IFHWADDRLEN’ undeclared here (not in a function)
1 field ‘vmask’ has incomplete type
1 field ‘vifc_rmt_addr’ has incomplete type
1 field ‘vifc_lcl_addr’ has incomplete type
1 field ‘vaddr’ has incomplete type
1 field ‘uc_chain’ has incomplete type
1 field ‘tgt_ip’ has incomplete type
1 field ‘tcp’ has incomplete type
1 field ‘sw_reserved’ has incomplete type
1 field ‘sspp_addr’ has incomplete type
1 field ‘ssp_addr’ has incomplete type
1 field ‘src_mask’ has incomplete type
1 field ‘src_ip’ has incomplete type
1 field ‘spt_address’ has incomplete type
1 field ‘spp_address’ has incomplete type
1 field ‘spinfo_address’ has incomplete type
1 field ‘spc_aaddr’ has incomplete type
1 field ‘sas_obs_rto_ipaddr’ has incomplete type
1 field ‘saddr’ has incomplete type
1 field ‘rtmsg_src’ has incomplete type
1 field ‘rtmsg_gateway’ has incomplete type
1 field ‘rtmsg_dst’ has incomplete type
1 field ‘rt_genmask’ has incomplete type
1 field ‘rt_gateway’ has incomplete type
1 field ‘rt_dst’ has incomplete type
1 field ‘real’ has incomplete type
1 field ‘prefix’ has incomplete type
1 field ‘obj_list’ has incomplete type
1 field ‘mfcc_origin’ has incomplete type
1 field ‘mfcc_mcastgrp’ has incomplete type
1 field ‘mf6cc_origin’ has incomplete type
1 field ‘mf6cc_mcastgrp’ has incomplete type
1 field ‘mask’ has incomplete type
1 field ‘ival2’ has incomplete type
1 field ‘ival1’ has incomplete type
1 field ‘iph’ has incomplete type
1 field ‘ip’ has incomplete type
1 field ‘im_src’ has incomplete type
1 field ‘im_dst’ has incomplete type
1 field ‘im6_src’ has incomplete type
1 field ‘im6_dst’ has incomplete type
1 field ‘gw’ has incomplete type
1 field ‘expected’ has incomplete type
1 field ‘dst_mask’ has incomplete type
1 field ‘dest_addr’ has incomplete type
1 field ‘daddr’ has incomplete type
1 field ‘ap_addr’ has incomplete type
1 field ‘a6’ has incomplete type
1 field ‘a4’ has incomplete type
1 expected specifier-qualifier-list before ‘DECLARE_BITMAP’
1 expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘snd_seq_client_type_t’
1 #error "patchkey.h included directly"
1 ‘DLM_RESNAME_MAXLEN’ undeclared here (not in a function)
Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>drm.h: use __kernel_size_t instead of size_t
Fixes userspace compilation error: drm/drm.h:132:2: error: unknown type name ‘size_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
drm_mode.h: use __u32 and __u64 from linux/types.h
Fixes userspace compilation error: drm/drm_mode.h:472:2: error: unknown type name ‘uint32_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
exynos_drm.h: use __u64 from linux/types.h
Fixes userspace compilation error: drm/exynos_drm.h:30:2: error: unknown type name ‘uint64_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
nouveau_drm.h: use __u32 and __u64 from linux/types.h
Fixes userspace compilation errors like: drm/nouveau_drm.h:41:2: error: unknown type name ‘uint32_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
radeon_drm.h: use __u32 and __u64 from linux/types.h
Fixes userspace compiler error: drm/radeon_drm.h:794:2: error: unknown type name ‘uint64_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
Fixes compile error: drm/r128_drm.h:156:23: error: array type has incomplete element type struct drm_clip_rect boxes[R128_NR_SAREA_CLIPRECTS]; Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
via_drm.h: include linux/types.h instead of non-existing via_drmclient.h
Fixes compiler error: drm/via_drm.h:36:27: fatal error: via_drmclient.h: No such file or directory Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
via_drm.h: hide struct via_file_private in userspace
Fixes compiler error since list_head is not exported to userspace headers. Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
savage_drm.h: include <drm/drm.h>
Fixes compiler error: drm/savage_drm.h:50:24: error: array type has incomplete element type struct drm_tex_region texList[SAVAGE_NR_TEX_HEAPS][SAVAGE_NR_TEX_REGIONS + Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
sis_drm.h: hide sis_file_private in userspace
Fixes compiler error: drm/sis_drm.h:68:19: error: field ‘obj_list’ has incomplete type struct list_head obj_list; Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
drm/i810_drm.h: include drm/drm.h
Fixes userspace compilation error: error: array type has incomplete element type struct drm_clip_rect boxes[I810_NR_SAREA_CLIPRECTS]; Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/drm/vmwgfx_drm.h: use __s32, __u32 and __u64 from linux/…
…types.h Fixes userspace compilation errors like: error: unknown type name ‘uint32_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/drm/qxl_drm.h: use __s32, __u32 and __u64 from linux/typ…
…es.h Fixes userspace compilation errors like: error: unknown type name ‘uint32_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/drm/msm_drm.h: use __s32, __s64, __u32 and __u64 from li…
…nux/types.h Fixes userspace compilation errors like: error: unknown type name ‘uint32_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/linux/agpgart.h: include stdlib.h in userspace
Fixes userspace compiler error: error: unknown type name ‘size_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/sound/emu10k1.h: added EMU10K1 version of DECLARE_BITMAP…
… etc macros Fixes userspace compilation error: error: expected specifier-qualifier-list before ‘DECLARE_BITMAP’ DECLARE_BITMAP(gpr_valid, 0x200); /* bitmask of valid initializers */ DECLARE_BITMAP etc macros are not meant for userspace headers and thus added here as private copies for emu10k.h. Fix was suggested by Arnd Bergmann <arnd@arndb.de> in message <2168807.4Yxh5gl11Q@wuerfel> on lkml. Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
dm-log-userspace.h: use __u32, __s32 and __u64 from linux/types.h
Fixes userspace compilation errors like: linux/dm-log-userspace.h:416:2: error: unknown type name ‘uint64_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
hsi_char.h: use __u32 from linux/types.h
Fixes userspace compiler errors like: linux/hsi/hsi_char.h:51:2: error: unknown type name ‘uint32_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/linux/hsi/cs-protocol.h: include linux/time.h
Fixes userspace compilation errors due to missing timespec definition. Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
ebtables.h: use __u64 from linux/types.h
Fixes userspace compilation error: linux/netfilter_bridge/ebtables.h:38:2: error: unknown type name ‘uint64_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
cld.h: use __u8, __u16, __s16, __u32 and __s64 from linux/types.h
Fixes userspace compilation errors like: linux/nfsd/cld.h:40:2: error: unknown type name ‘uint16_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
rds.h: use __u8, __u16, __s16, __u32 and __s64 from linux/types.h
Fixes userspace compilation errors like: linux/rds.h:96:2: error: unknown type name ‘uint8_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
sctp.h: use __u8 and __u32 from linux/types.h
Fixes userspace compilation errors like: linux/sctp.h:652:2: error: unknown type name ‘uint32_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
scsi_bsg_fc.h: use __u8, __u32 and __u64 from linux/types.h
Fixes userspace compilation errors like: scsi/scsi_bsg_fc.h:83:2: error: unknown type name ‘uint8_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
scsi_netlink.h: use __u8, __u16 and __u64 from linux/types.h
Fixes userspace compilation errors like: scsi/scsi_netlink.h:43:2: error: unknown type name ‘uint8_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
scsi_netlink_fc.h: use __u16, __u32 and __u64 from linux/types.h
Fixes userspace compilation errors like: scsi/scsi_netlink_fc.h:60:2: error: expected specifier-qualifier-list before ‘uint64_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
scsi_netlink_fc.h: include stdint.h in userspace
Fixes compilation error: scsi/scsi_netlink_fc.h:60:2: error: expected specifier-qualifier-list before ‘uint64_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
hdspm.h: use __u8, __u32 and __u64 from linux/types.h
Fixes userspace compilation errors like: sound/hdspm.h:43:2: error: unknown type name ‘uint32_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
gntalloc.h: use __u16, __u32 and __u64 from linux/types.h
Fixes userspace compilation errors like: xen/gntalloc.h:22:2: error: unknown type name ‘uint16_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
gntdev.h: use __u32 and __u64 from linux/types.h
Fixes userspace compilation errors like: xen/gntdev.h:38:2: error: unknown type name ‘uint32_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/linux/sysctl.h: use __kernel_size_t instead of size_t
Fixes userspace compilation error: error: unknown type name ‘size_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/asm-generic/ipcbuf.h: include linux/posix_types.h
Fixes userspace compilation error: error: unknown type name ‘__kernel_key_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/asm-generic/msgbuf.h: include asm/ipcbuf.h
Fixes userspace compilation errors like: error: field ‘msg_perm’ has incomplete type struct ipc64_perm msg_perm Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/asm-generic/shmbuf.h: include fixes
Include linux/types.h and asm/msgbuf.h and use __kernel_size_t instead of size_t. Fixes userspace compilation errors like: error: field ‘shm_perm’ has incomplete type struct ipc64_perm shm_perm; /* operation perms */ error: unknown type name ‘size_t’ error: unknown type name ‘__kernel_time_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
asm-generic/sembuf.h: include asm/posix_types.h and asm/ipcbuf.h
Fixes userspace compilation errors like: error: field ‘msg_perm’ has incomplete type struct ipc64_perm msg_perm; error: unknown type name ‘__kernel_ulong_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/asm-generic/signal.h: use __kernel_size_t instead of size_t
Fixes userspace compiler error: error: unknown type name ‘size_t’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/linux/socket.h: include sys/socket.h in userspace
This libc header has sockaddr definition for userspace. Fixes userspace compilation errors like these from kernel headers including only linux/socket.h: error: field ‘ifru_addr’ has incomplete type struct sockaddr ifru_addr; Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/linux/rds.h: include linux/socket.h and linux/types.h
Fixes userspace compilation errors like: error: unknown type name ‘__be32’ error: field ‘dest_addr’ has incomplete type struct sockaddr_storage dest_addr; Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/linux/if_pppox.h: include linux/if.h
Fixes userspace compilation error: error: ‘IFNAMSIZ’ undeclared here (not in a function) Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/linux/if_tunnel.h: include linux/if.h, linux/ip.h and li…
…nux/in6.h Fixes userspace compilation errors like: error: field ‘iph’ has incomplete type error: field ‘prefix’ has incomplete type Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/linux/hdlc/ioctl.h: include linux/if.h
Fixes userspace compiler error: error: ‘IFNAMSIZ’ undeclared here (not in a function) Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
nf_conntrack_tuple_common.h: include linux/types.h and linux/netfilter.h
Fixes userspace compilation errors like: error: unknown type name ‘__be16’ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/linux/ipv6_route.h: include linux/in6.h
Fixes userspace compile errors like: error: field ‘mf6cc_origin’ has incomplete type struct sockaddr_in6 mf6cc_origin; /* Origin of mcast */ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/linux/ipv6_route.h: include linux/in6.h
Fixes userspace compile errors like: error: field ‘rtmsg_dst’ has incomplete type struct in6_addr rtmsg_dst; Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/linux/if_pppol2tp.h: include linux/in.h and linux/in6.h
Fixes userspace compilation errors like:
error: field ‘addr’ has incomplete type
struct sockaddr_in addr; /* IP address and port to send to */
^
error: field ‘addr’ has incomplete type
struct sockaddr_in6 addr; /* IP address and port to send to */
Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>include/uapi/linux/if_pppox.h: include linux/in.h and linux/in6.h
Fixes userspace compilation errors: error: field ‘addr’ has incomplete type struct sockaddr_in addr; /* IP address and port to send to */ error: field ‘addr’ has incomplete type struct sockaddr_in6 addr; /* IP address and port to send to */ Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
Break dependency loop between linux/if.h and linux/hdlc/ioctl.h
This isn't pretty but does the job. I assume including plain linux/hdlc/ioctl.h without linux/if.h is much more rare than the other way round, and that these header file names are part of API, and that creating a new header file just for IFNAMSIZ isn't a good idea either. Fixes userspace compiler error: error: ‘IFNAMSIZ’ undeclared here (not in a function) Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>
include/uapi/linux/packet_diag.h: include linux/netdevice.h
Fixes userspace compilation error: error: ‘MAX_ADDR_LEN’ undeclared here (not in a function) Signed-off-by: Mikko Rapeli <mikko.rapeli@iki.fi>