From c6509a24d6ba0f8560a81c032c30d169ba467b0a Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Jun 2019 19:13:58 +0900 Subject: kbuild: fix Kconfig prompt of CONFIG_HEADERS_CHECK Prior to commit 257edce66d31 ("kbuild: exploit parallel building for CONFIG_HEADERS_CHECK"), the sanity check of exported headers was done as a side-effect of build rule of vmlinux. That commit is good, but I missed to update the prompt of the Kconfig entry. For the sake of preciseness, lets' say "when building 'all'". Signed-off-by: Masahiro Yamada --- lib/Kconfig.debug | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/Kconfig.debug') diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index cbdfae379896..7cdcb962358c 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -306,11 +306,11 @@ config DEBUG_FS If unsure, say N. config HEADERS_CHECK - bool "Run 'make headers_check' when building vmlinux" + bool "Run sanity checks on uapi headers when building 'all'" depends on !UML help - This option will extract the user-visible kernel headers whenever - building the kernel, and will run basic sanity checks on them to + This option will extract the user-visible kernel headers when + building the 'all' target, and will run basic sanity checks on them to ensure that exported files do not attempt to include files which were not exported, etc. -- cgit From e949f4c2d6a3df2b7fd00e56c0f081b15284906f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Jun 2019 19:13:59 +0900 Subject: kbuild: add CONFIG_HEADERS_INSTALL and loosen the dependency of samples Commit 5318321d367c ("samples: disable CONFIG_SAMPLES for UML") used a big hammer to fix the build errors under the samples/ directory. Only some samples actually include uapi headers from usr/include. Introduce CONFIG_HEADERS_INSTALL since 'depends on HEADERS_INSTALL' is clearer than 'depends on !UML'. If this option is enabled, uapi headers are installed before starting directory descending. I added 'depends on HEADERS_INSTALL' to per-sample CONFIG options. This allows UML to compile some samples. $ make ARCH=um allmodconfig samples/ [ snip ] CC [M] samples/configfs/configfs_sample.o CC [M] samples/kfifo/bytestream-example.o CC [M] samples/kfifo/dma-example.o CC [M] samples/kfifo/inttype-example.o CC [M] samples/kfifo/record-example.o CC [M] samples/kobject/kobject-example.o CC [M] samples/kobject/kset-example.o CC [M] samples/trace_events/trace-events-sample.o CC [M] samples/trace_printk/trace-printk.o AR samples/vfio-mdev/built-in.a AR samples/built-in.a Signed-off-by: Masahiro Yamada --- lib/Kconfig.debug | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'lib/Kconfig.debug') diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 7cdcb962358c..6a6ea4219d1e 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -305,14 +305,23 @@ config DEBUG_FS If unsure, say N. +config HEADERS_INSTALL + bool "Install uapi headers to usr/include" + depends on !UML + help + This option will install uapi headers (headers exported to user-space) + into the usr/include directory for use during the kernel build. + This is unneeded for building the kernel itself, but needed for some + user-space program samples. It is also needed by some features such + as uapi header sanity checks. + config HEADERS_CHECK bool "Run sanity checks on uapi headers when building 'all'" - depends on !UML + depends on HEADERS_INSTALL help - This option will extract the user-visible kernel headers when - building the 'all' target, and will run basic sanity checks on them to - ensure that exported files do not attempt to include files which - were not exported, etc. + This option will run basic sanity checks on uapi headers when + building the 'all' target, for example, ensure that they do not + attempt to include files which were not exported, etc. If you're making modifications to header files which are relevant for userspace, say 'Y', and check the headers -- cgit From 59b2bd05f5f4dc62979c2e82ddd384f07e8f10bc Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 4 Jun 2019 19:14:02 +0900 Subject: kbuild: add 'headers' target to build up uapi headers in usr/include In Linux build system, build targets and installation targets are separated. Examples are: - 'make vmlinux' -> 'make install' - 'make modules' -> 'make modules_install' - 'make dtbs' -> 'make dtbs_install' - 'make vdso' -> 'make vdso_install' The intention is to run the build targets under the normal privilege, then the installation targets under the root privilege since we need the write permission to the system directories. We have 'make headers_install' but the corresponding 'make headers' stage does not exist. The purpose of headers_install is to provide the kernel interface to C library. So, nobody would try to install headers to /usr/include directly. If 'sudo make INSTALL_HDR_PATH=/usr/include headers_install' were run, some build artifacts in the kernel tree would be owned by root because some of uapi headers are generated by 'uapi-asm-generic', 'archheaders' targets. Anyway, I believe it makes sense to split the header installation into two stages. [1] 'make headers' Process headers in uapi directories by scripts/headers_install.sh and copy them to usr/include [2] 'make headers_install' Copy '*.h' verbatim from usr/include to $(INSTALL_HDR_PATH)/include For the backward compatibility, 'headers_install' depends on 'headers'. Some samples expect uapi headers in usr/include. So, the 'headers' target is useful to build up them in the fixed location usr/include irrespective of INSTALL_HDR_PATH. Another benefit is to stop polluting the final destination with the time-stamp files '.install' and '.check'. Maybe you can see them in your toolchains. Lastly, my main motivation is to prepare for compile-testing uapi headers. To build something, we have to save an object and .*.cmd somewhere. The usr/include/ will be the work directory for that. Signed-off-by: Masahiro Yamada --- lib/Kconfig.debug | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/Kconfig.debug') diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 6a6ea4219d1e..0031a31d98c2 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -324,9 +324,7 @@ config HEADERS_CHECK attempt to include files which were not exported, etc. If you're making modifications to header files which are - relevant for userspace, say 'Y', and check the headers - exported to $(INSTALL_HDR_PATH) (usually 'usr/include' in - your build tree), to make sure they're suitable. + relevant for userspace, say 'Y'. config OPTIMIZE_INLINING bool "Allow compiler to uninline functions marked 'inline'" -- cgit