summaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2019-06-30 20:58:40 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2019-07-08 10:13:57 -0400
commitd6fc9fcbaa655cff2d2be05e16867d1918f78b85 (patch)
tree963ee9a8fa175e10b832aa6a5d724ae5acb1f5bd /init
parent1a927fd347ebb3c02046150ee489d4fe4e6b9e81 (diff)
kbuild: compile-test exported headers to ensure they are self-contained
Multiple people have suggested compile-testing UAPI headers to ensure they can be really included from user-space. "make headers_check" is obviously not enough to catch bugs, and we often leak unresolved references to user-space. Use the new header-test-y syntax to implement it. Please note exported headers are compile-tested with a completely different set of compiler flags. The header search path is set to $(objtree)/usr/include since exported headers should not include unexported ones. We use -std=gnu89 for the kernel space since the kernel code highly depends on GNU extensions. On the other hand, UAPI headers should be written in more standardized C, so they are compiled with -std=c90. This will emit errors if C++ style comments, the keyword 'inline', etc. are used. Please use C style comments (/* ... */), '__inline__', etc. in UAPI headers. There is additional compiler requirement to enable this test because many of UAPI headers include <stdlib.h>, <sys/ioctl.h>, <sys/time.h>, etc. directly or indirectly. You cannot use kernel.org pre-built toolchains [1] since they lack <stdlib.h>. I reused CONFIG_CC_CAN_LINK to check the system header availability. The intention is slightly different, but a compiler that can link userspace programs provide system headers. For now, a lot of headers need to be excluded because they cannot be compiled standalone, but this is a good start point. [1] https://mirrors.edge.kernel.org/pub/tools/crosstool/index.html Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'init')
-rw-r--r--init/Kconfig10
1 files changed, 10 insertions, 0 deletions
diff --git a/init/Kconfig b/init/Kconfig
index 2e9813daa2c1..74192de8ada6 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -108,6 +108,16 @@ config HEADER_TEST
108 If you are a developer or tester and want to ensure the requested 108 If you are a developer or tester and want to ensure the requested
109 headers are self-contained, say Y here. Otherwise, choose N. 109 headers are self-contained, say Y here. Otherwise, choose N.
110 110
111config UAPI_HEADER_TEST
112 bool "Compile test UAPI headers"
113 depends on HEADER_TEST && HEADERS_INSTALL && CC_CAN_LINK
114 help
115 Compile test headers exported to user-space to ensure they are
116 self-contained, i.e. compilable as standalone units.
117
118 If you are a developer or tester and want to ensure the exported
119 headers are self-contained, say Y here. Otherwise, choose N.
120
111config LOCALVERSION 121config LOCALVERSION
112 string "Local version - append to kernel release" 122 string "Local version - append to kernel release"
113 help 123 help