diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-13 11:40:34 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-13 11:40:34 -0400 |
| commit | be779f03d563981c65cc7417cc5e0dbbc5b89d30 (patch) | |
| tree | ce0638b1f449e2fe45419567ee287e2c97847836 /scripts | |
| parent | d290ef9305ebaaac884ae0350bfc243dd01d354d (diff) | |
| parent | 00979ce4fcc90d488c7f27f750097adc6b11bd07 (diff) | |
Merge tag 'kbuild-v4.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull more Kbuild updates from Masahiro Yamada:
- fix some bugs introduced by the recent Kconfig syntax extension
- add some symbols about compiler information in Kconfig, such as
CC_IS_GCC, CC_IS_CLANG, GCC_VERSION, etc.
- test compiler capability for the stack protector in Kconfig, and
clean-up Makefile
- test compiler capability for GCC-plugins in Kconfig, and clean-up
Makefile
- allow to enable GCC-plugins for COMPILE_TEST
- test compiler capability for KCOV in Kconfig and correct dependency
- remove auto-detect mode of the GCOV format, which is now more nicely
handled in Kconfig
- test compiler capability for mprofile-kernel on PowerPC, and clean-up
Makefile
- misc cleanups
* tag 'kbuild-v4.18-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
linux/linkage.h: replace VMLINUX_SYMBOL_STR() with __stringify()
kconfig: fix localmodconfig
sh: remove no-op macro VMLINUX_SYMBOL()
powerpc/kbuild: move -mprofile-kernel check to Kconfig
Documentation: kconfig: add recommended way to describe compiler support
gcc-plugins: disable GCC_PLUGIN_STRUCTLEAK_BYREF_ALL for COMPILE_TEST
gcc-plugins: allow to enable GCC_PLUGINS for COMPILE_TEST
gcc-plugins: test plugin support in Kconfig and clean up Makefile
gcc-plugins: move GCC version check for PowerPC to Kconfig
kcov: test compiler capability in Kconfig and correct dependency
gcov: remove CONFIG_GCOV_FORMAT_AUTODETECT
arm64: move GCC version check for ARCH_SUPPORTS_INT128 to Kconfig
kconfig: add CC_IS_CLANG and CLANG_VERSION
kconfig: add CC_IS_GCC and GCC_VERSION
stack-protector: test compiler capability in Kconfig and drop AUTO mode
kbuild: fix endless syncconfig in case arch Makefile sets CROSS_COMPILE
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/Kconfig.include | 3 | ||||
| -rw-r--r-- | scripts/Makefile.gcc-plugins | 91 | ||||
| -rw-r--r-- | scripts/Makefile.kcov | 10 | ||||
| -rwxr-xr-x | scripts/clang-version.sh | 18 | ||||
| -rw-r--r-- | scripts/gcc-plugins/Makefile | 5 | ||||
| -rwxr-xr-x | scripts/gcc-x86_32-has-stack-protector.sh | 7 | ||||
| -rwxr-xr-x | scripts/gcc-x86_64-has-stack-protector.sh | 5 | ||||
| -rwxr-xr-x | scripts/kconfig/streamline_config.pl | 4 |
8 files changed, 39 insertions, 104 deletions
diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include index bf7c0c9fa3a4..dad5583451af 100644 --- a/scripts/Kconfig.include +++ b/scripts/Kconfig.include | |||
| @@ -25,3 +25,6 @@ cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null) | |||
| 25 | # $(ld-option,<flag>) | 25 | # $(ld-option,<flag>) |
| 26 | # Return y if the linker supports <flag>, n otherwise | 26 | # Return y if the linker supports <flag>, n otherwise |
| 27 | ld-option = $(success,$(LD) -v $(1)) | 27 | ld-option = $(success,$(LD) -v $(1)) |
| 28 | |||
| 29 | # gcc version including patch level | ||
| 30 | gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh -p $(CC) | sed 's/^0*//') | ||
diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins index 7f5c86246138..c961b9a65d11 100644 --- a/scripts/Makefile.gcc-plugins +++ b/scripts/Makefile.gcc-plugins | |||
| @@ -1,84 +1,37 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | ifdef CONFIG_GCC_PLUGINS | 2 | gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so |
| 3 | __PLUGINCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC)) | ||
| 4 | PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)") | ||
| 5 | |||
| 6 | SANCOV_PLUGIN := -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so | ||
| 7 | |||
| 8 | gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so | ||
| 9 | 3 | ||
| 10 | gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += latent_entropy_plugin.so | 4 | gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += latent_entropy_plugin.so |
| 11 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += -DLATENT_ENTROPY_PLUGIN | 5 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += -DLATENT_ENTROPY_PLUGIN |
| 12 | ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY | 6 | ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY |
| 13 | DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable | 7 | DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable |
| 14 | endif | 8 | endif |
| 15 | |||
| 16 | ifdef CONFIG_GCC_PLUGIN_SANCOV | ||
| 17 | ifeq ($(strip $(CFLAGS_KCOV)),) | ||
| 18 | # It is needed because of the gcc-plugin.sh and gcc version checks. | ||
| 19 | gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so | ||
| 20 | |||
| 21 | ifneq ($(PLUGINCC),) | ||
| 22 | CFLAGS_KCOV := $(SANCOV_PLUGIN) | ||
| 23 | else | ||
| 24 | $(warning warning: cannot use CONFIG_KCOV: -fsanitize-coverage=trace-pc is not supported by compiler) | ||
| 25 | endif | ||
| 26 | endif | ||
| 27 | endif | ||
| 28 | |||
| 29 | gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += structleak_plugin.so | ||
| 30 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE) += -fplugin-arg-structleak_plugin-verbose | ||
| 31 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) += -fplugin-arg-structleak_plugin-byref-all | ||
| 32 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += -DSTRUCTLEAK_PLUGIN | ||
| 33 | 9 | ||
| 34 | gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += randomize_layout_plugin.so | 10 | gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so |
| 35 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += -DRANDSTRUCT_PLUGIN | 11 | gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += structleak_plugin.so |
| 36 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE) += -fplugin-arg-randomize_layout_plugin-performance-mode | 12 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE) += -fplugin-arg-structleak_plugin-verbose |
| 13 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) += -fplugin-arg-structleak_plugin-byref-all | ||
| 14 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += -DSTRUCTLEAK_PLUGIN | ||
| 37 | 15 | ||
| 38 | GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y)) | 16 | gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += randomize_layout_plugin.so |
| 17 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += -DRANDSTRUCT_PLUGIN | ||
| 18 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE) += -fplugin-arg-randomize_layout_plugin-performance-mode | ||
| 39 | 19 | ||
| 40 | export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR | 20 | GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y)) |
| 41 | export SANCOV_PLUGIN DISABLE_LATENT_ENTROPY_PLUGIN | ||
| 42 | 21 | ||
| 43 | ifneq ($(PLUGINCC),) | 22 | export GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR |
| 44 | # SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication. | 23 | export DISABLE_LATENT_ENTROPY_PLUGIN |
| 45 | GCC_PLUGINS_CFLAGS := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGINS_CFLAGS)) | ||
| 46 | endif | ||
| 47 | 24 | ||
| 48 | KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) | 25 | # sancov_plugin.so can be only in CFLAGS_KCOV because avoid duplication. |
| 49 | GCC_PLUGIN := $(gcc-plugin-y) | 26 | GCC_PLUGINS_CFLAGS := $(filter-out %/sancov_plugin.so, $(GCC_PLUGINS_CFLAGS)) |
| 50 | GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y) | ||
| 51 | endif | ||
| 52 | 27 | ||
| 53 | # If plugins aren't supported, abort the build before hard-to-read compiler | 28 | KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) |
| 54 | # errors start getting spewed by the main build. | 29 | GCC_PLUGIN := $(gcc-plugin-y) |
| 55 | PHONY += gcc-plugins-check | 30 | GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y) |
| 56 | gcc-plugins-check: FORCE | ||
| 57 | ifdef CONFIG_GCC_PLUGINS | ||
| 58 | ifeq ($(PLUGINCC),) | ||
| 59 | ifneq ($(GCC_PLUGINS_CFLAGS),) | ||
| 60 | # Various gccs between 4.5 and 5.1 have bugs on powerpc due to missing | ||
| 61 | # header files. gcc <= 4.6 doesn't work at all, gccs from 4.8 to 5.1 have | ||
| 62 | # issues with 64-bit targets. | ||
| 63 | ifeq ($(ARCH),powerpc) | ||
| 64 | ifeq ($(call cc-ifversion, -le, 0501, y), y) | ||
| 65 | @echo "Cannot use CONFIG_GCC_PLUGINS: plugin support on gcc <= 5.1 is buggy on powerpc, please upgrade to gcc 5.2 or newer" >&2 && exit 1 | ||
| 66 | endif | ||
| 67 | endif | ||
| 68 | ifeq ($(call cc-ifversion, -ge, 0405, y), y) | ||
| 69 | $(Q)$(srctree)/scripts/gcc-plugin.sh --show-error "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)" || true | ||
| 70 | @echo "Cannot use CONFIG_GCC_PLUGINS: your gcc installation does not support plugins, perhaps the necessary headers are missing?" >&2 && exit 1 | ||
| 71 | else | ||
| 72 | @echo "Cannot use CONFIG_GCC_PLUGINS: your gcc version does not support plugins, you should upgrade it to at least gcc 4.5" >&2 && exit 1 | ||
| 73 | endif | ||
| 74 | endif | ||
| 75 | endif | ||
| 76 | endif | ||
| 77 | @: | ||
| 78 | 31 | ||
| 79 | # Actually do the build, if requested. | 32 | # Actually do the build, if requested. |
| 80 | PHONY += gcc-plugins | 33 | PHONY += gcc-plugins |
| 81 | gcc-plugins: scripts_basic gcc-plugins-check | 34 | gcc-plugins: scripts_basic |
| 82 | ifdef CONFIG_GCC_PLUGINS | 35 | ifdef CONFIG_GCC_PLUGINS |
| 83 | $(Q)$(MAKE) $(build)=scripts/gcc-plugins | 36 | $(Q)$(MAKE) $(build)=scripts/gcc-plugins |
| 84 | endif | 37 | endif |
diff --git a/scripts/Makefile.kcov b/scripts/Makefile.kcov index 5cc72037e423..3d61c4bfcbee 100644 --- a/scripts/Makefile.kcov +++ b/scripts/Makefile.kcov | |||
| @@ -1,7 +1,9 @@ | |||
| 1 | ifdef CONFIG_KCOV | 1 | ifdef CONFIG_KCOV |
| 2 | CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,) | 2 | |
| 3 | ifeq ($(CONFIG_KCOV_ENABLE_COMPARISONS),y) | 3 | kcov-flags-$(CONFIG_CC_HAS_SANCOV_TRACE_PC) += -fsanitize-coverage=trace-pc |
| 4 | CFLAGS_KCOV += $(call cc-option,-fsanitize-coverage=trace-cmp,) | 4 | kcov-flags-$(CONFIG_KCOV_ENABLE_COMPARISONS) += -fsanitize-coverage=trace-cmp |
| 5 | endif | 5 | kcov-flags-$(CONFIG_GCC_PLUGIN_SANCOV) += -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so |
| 6 | |||
| 7 | export CFLAGS_KCOV := $(kcov-flags-y) | ||
| 6 | 8 | ||
| 7 | endif | 9 | endif |
diff --git a/scripts/clang-version.sh b/scripts/clang-version.sh index 9780efa56980..dbf0a31eb111 100755 --- a/scripts/clang-version.sh +++ b/scripts/clang-version.sh | |||
| @@ -10,24 +10,14 @@ | |||
| 10 | # clang-5.0.1 etc. | 10 | # clang-5.0.1 etc. |
| 11 | # | 11 | # |
| 12 | 12 | ||
| 13 | if [ "$1" = "-p" ] ; then | ||
| 14 | with_patchlevel=1; | ||
| 15 | shift; | ||
| 16 | fi | ||
| 17 | |||
| 18 | compiler="$*" | 13 | compiler="$*" |
| 19 | 14 | ||
| 20 | if [ ${#compiler} -eq 0 ]; then | 15 | if !( $compiler --version | grep -q clang) ; then |
| 21 | echo "Error: No compiler specified." | 16 | echo 0 |
| 22 | printf "Usage:\n\t$0 <clang-command>\n" | ||
| 23 | exit 1 | 17 | exit 1 |
| 24 | fi | 18 | fi |
| 25 | 19 | ||
| 26 | MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1) | 20 | MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1) |
| 27 | MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1) | 21 | MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1) |
| 28 | if [ "x$with_patchlevel" != "x" ] ; then | 22 | PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1) |
| 29 | PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1) | 23 | printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL |
| 30 | printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL | ||
| 31 | else | ||
| 32 | printf "%02d%02d\\n" $MAJOR $MINOR | ||
| 33 | fi | ||
diff --git a/scripts/gcc-plugins/Makefile b/scripts/gcc-plugins/Makefile index e2ff425f4c7e..326254653bd0 100644 --- a/scripts/gcc-plugins/Makefile +++ b/scripts/gcc-plugins/Makefile | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | # SPDX-License-Identifier: GPL-2.0 | 1 | # SPDX-License-Identifier: GPL-2.0 |
| 2 | PLUGINCC := $(CONFIG_PLUGIN_HOSTCC:"%"=%) | ||
| 2 | GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin) | 3 | GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin) |
| 3 | 4 | ||
| 4 | ifeq ($(PLUGINCC),$(HOSTCC)) | 5 | ifeq ($(PLUGINCC),$(HOSTCC)) |
| @@ -13,10 +14,6 @@ else | |||
| 13 | export HOST_EXTRACXXFLAGS | 14 | export HOST_EXTRACXXFLAGS |
| 14 | endif | 15 | endif |
| 15 | 16 | ||
| 16 | ifneq ($(CFLAGS_KCOV), $(SANCOV_PLUGIN)) | ||
| 17 | GCC_PLUGIN := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGIN)) | ||
| 18 | endif | ||
| 19 | |||
| 20 | export HOSTLIBS | 17 | export HOSTLIBS |
| 21 | 18 | ||
| 22 | $(obj)/randomize_layout_plugin.o: $(objtree)/$(obj)/randomize_layout_seed.h | 19 | $(obj)/randomize_layout_plugin.o: $(objtree)/$(obj)/randomize_layout_seed.h |
diff --git a/scripts/gcc-x86_32-has-stack-protector.sh b/scripts/gcc-x86_32-has-stack-protector.sh index 6b2aeefb9cd3..f5c119495254 100755 --- a/scripts/gcc-x86_32-has-stack-protector.sh +++ b/scripts/gcc-x86_32-has-stack-protector.sh | |||
| @@ -1,9 +1,4 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
| 3 | 3 | ||
| 4 | echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs" | 4 | echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -m32 -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs" |
| 5 | if [ "$?" -eq "0" ] ; then | ||
| 6 | echo y | ||
| 7 | else | ||
| 8 | echo n | ||
| 9 | fi | ||
diff --git a/scripts/gcc-x86_64-has-stack-protector.sh b/scripts/gcc-x86_64-has-stack-protector.sh index 4a48bdcd4d6b..3755af0cd9f7 100755 --- a/scripts/gcc-x86_64-has-stack-protector.sh +++ b/scripts/gcc-x86_64-has-stack-protector.sh | |||
| @@ -2,8 +2,3 @@ | |||
| 2 | # SPDX-License-Identifier: GPL-2.0 | 2 | # SPDX-License-Identifier: GPL-2.0 |
| 3 | 3 | ||
| 4 | echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs" | 4 | echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs" |
| 5 | if [ "$?" -eq "0" ] ; then | ||
| 6 | echo y | ||
| 7 | else | ||
| 8 | echo n | ||
| 9 | fi | ||
diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index a2e83ab17de3..4686531e2f8c 100755 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl | |||
| @@ -165,10 +165,10 @@ sub read_kconfig { | |||
| 165 | my $last_source = ""; | 165 | my $last_source = ""; |
| 166 | 166 | ||
| 167 | # Check for any environment variables used | 167 | # Check for any environment variables used |
| 168 | while ($source =~ /\$(\w+)/ && $last_source ne $source) { | 168 | while ($source =~ /\$\((\w+)\)/ && $last_source ne $source) { |
| 169 | my $env = $1; | 169 | my $env = $1; |
| 170 | $last_source = $source; | 170 | $last_source = $source; |
| 171 | $source =~ s/\$$env/$ENV{$env}/; | 171 | $source =~ s/\$\($env\)/$ENV{$env}/; |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | open(my $kinfile, '<', $source) || die "Can't open $kconfig"; | 174 | open(my $kinfile, '<', $source) || die "Can't open $kconfig"; |
