summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2019-06-30 20:58:41 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2019-07-08 21:10:27 -0400
commitc93a0368aaa2962e6c89da20f79b8789b42e3387 (patch)
treecc7a41af7bc845ee6336f16dfd49326d56ea252c
parentd6fc9fcbaa655cff2d2be05e16867d1918f78b85 (diff)
kbuild: do not create wrappers for header-test-y
header-test-y does not work with headers in sub-directories. For example, you may want to write a Makefile, like this: include/linux/Kbuild: header-test-y += mtd/nand.h This entry will create a wrapper include/linux/mtd/nand.hdrtest.c with the following content: #include "mtd/nand.h" To make this work, we need to add $(srctree)/include/linux to the header search path. It would be tedious to add ccflags-y. Instead, we could change the *.hdrtest.c rule to wrap: #include "nand.h" This works for in-tree build since #include "..." searches in the relative path from the header with this directive. For O=... build, we need to add $(srctree)/include/linux/mtd to the header search path, which will be even more tedious. After all, I thought it would be handier to compile headers directly without creating wrappers. I added a new build rule to compile %.h into %.h.s The target is %.h.s instead of %.h.o because it is slightly faster. Also, as for GCC, an empty assembly is smaller than an empty object. I wrote the build rule: $(CC) $(c_flags) -S -o $@ -x c /dev/null -include $< instead of: $(CC) $(c_flags) -S -o $@ -x c $< Both work fine with GCC, but the latter is bad for Clang. This comes down to the difference in the -Wunused-function policy. GCC does not warn about unused 'static inline' functions at all. Clang does not warn about the ones in included headers, but does about the ones in the source. So, we should handle headers as headers, not as source files. In fact, this has been hidden since commit abb2ea7dfd82 ("compiler, clang: suppress warning for unused static inline functions"), but we should not rely on that. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Acked-by: Jani Nikula <jani.nikula@intel.com> Tested-by: Jani Nikula <jani.nikula@intel.com>
-rw-r--r--.gitignore1
-rw-r--r--Documentation/dontdiff1
-rw-r--r--Documentation/kbuild/makefiles.txt3
-rw-r--r--Makefile1
-rw-r--r--scripts/Makefile.build10
-rw-r--r--scripts/Makefile.lib2
-rwxr-xr-xscripts/package/mkspec2
7 files changed, 8 insertions, 12 deletions
diff --git a/.gitignore b/.gitignore
index 4bb60f0fa23b..7587ef56b92d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,7 +22,6 @@
22*.elf 22*.elf
23*.gcno 23*.gcno
24*.gz 24*.gz
25*.hdrtest.c
26*.i 25*.i
27*.ko 26*.ko
28*.lex.c 27*.lex.c
diff --git a/Documentation/dontdiff b/Documentation/dontdiff
index 554dfe4883d2..5eba889ea84d 100644
--- a/Documentation/dontdiff
+++ b/Documentation/dontdiff
@@ -19,7 +19,6 @@
19*.grep 19*.grep
20*.grp 20*.grp
21*.gz 21*.gz
22*.hdrtest.c
23*.html 22*.html
24*.i 23*.i
25*.jpeg 24*.jpeg
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index ca4b24ec0399..5080fec34609 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -1023,8 +1023,7 @@ When kbuild executes, the following steps are followed (roughly):
1023 header-test-y specifies headers (*.h) in the current directory that 1023 header-test-y specifies headers (*.h) in the current directory that
1024 should be compile tested to ensure they are self-contained, 1024 should be compile tested to ensure they are self-contained,
1025 i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled, 1025 i.e. compilable as standalone units. If CONFIG_HEADER_TEST is enabled,
1026 this autogenerates dummy sources to include the headers, and builds them 1026 this builds them as part of extra-y.
1027 as part of extra-y.
1028 1027
1029--- 6.7 Commands useful for building a boot image 1028--- 6.7 Commands useful for building a boot image
1030 1029
diff --git a/Makefile b/Makefile
index fca827bc3f77..82fccd37a1ad 100644
--- a/Makefile
+++ b/Makefile
@@ -1663,7 +1663,6 @@ clean: $(clean-dirs)
1663 -o -name '*.dwo' -o -name '*.lst' \ 1663 -o -name '*.dwo' -o -name '*.lst' \
1664 -o -name '*.su' \ 1664 -o -name '*.su' \
1665 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ 1665 -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
1666 -o -name '*.hdrtest.c' \
1667 -o -name '*.lex.c' -o -name '*.tab.[ch]' \ 1666 -o -name '*.lex.c' -o -name '*.tab.[ch]' \
1668 -o -name '*.asn1.[ch]' \ 1667 -o -name '*.asn1.[ch]' \
1669 -o -name '*.symtypes' -o -name 'modules.order' \ 1668 -o -name '*.symtypes' -o -name 'modules.order' \
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index ee0319560513..776842b7e6a3 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -294,14 +294,14 @@ quiet_cmd_cc_lst_c = MKLST $@
294$(obj)/%.lst: $(src)/%.c FORCE 294$(obj)/%.lst: $(src)/%.c FORCE
295 $(call if_changed_dep,cc_lst_c) 295 $(call if_changed_dep,cc_lst_c)
296 296
297# Dummy C sources for header test (header-test-y target) 297# header test (header-test-y target)
298# --------------------------------------------------------------------------- 298# ---------------------------------------------------------------------------
299 299
300quiet_cmd_header_test = HDRTEST $@ 300quiet_cmd_cc_s_h = CC $@
301 cmd_header_test = echo "\#include \"$*.h\"" > $@ 301 cmd_cc_s_h = $(CC) $(c_flags) -S -o $@ -x c /dev/null -include $<
302 302
303$(obj)/%.hdrtest.c: 303$(obj)/%.h.s: $(src)/%.h FORCE
304 $(call cmd,header_test) 304 $(call if_changed_dep,cc_s_h)
305 305
306# Compile assembler sources (.S) 306# Compile assembler sources (.S)
307# --------------------------------------------------------------------------- 307# ---------------------------------------------------------------------------
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 3e630fcaffd1..55ae1ec65342 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -67,7 +67,7 @@ extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-))
67endif 67endif
68 68
69# Test self-contained headers 69# Test self-contained headers
70extra-$(CONFIG_HEADER_TEST) += $(patsubst %.h,%.hdrtest.o,$(header-test-y)) 70extra-$(CONFIG_HEADER_TEST) += $(addsuffix .s, $(header-test-y))
71 71
72# Add subdir path 72# Add subdir path
73 73
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index 009147d4718e..2d29df4a0a53 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -31,7 +31,7 @@ PROVIDES="$PROVIDES kernel-$KERNELRELEASE"
31__KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g") 31__KERNELRELEASE=$(echo $KERNELRELEASE | sed -e "s/-/_/g")
32EXCLUDES="$RCS_TAR_IGNORE --exclude=.tmp_versions --exclude=*vmlinux* \ 32EXCLUDES="$RCS_TAR_IGNORE --exclude=.tmp_versions --exclude=*vmlinux* \
33--exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \ 33--exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation \
34--exclude=.config.old --exclude=.missing-syscalls.d" 34--exclude=.config.old --exclude=.missing-syscalls.d --exclude=*.s"
35 35
36# We can label the here-doc lines for conditional output to the spec file 36# We can label the here-doc lines for conditional output to the spec file
37# 37#