aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-06-13 11:40:34 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-06-13 11:40:34 -0400
commitbe779f03d563981c65cc7417cc5e0dbbc5b89d30 (patch)
treece0638b1f449e2fe45419567ee287e2c97847836 /scripts
parentd290ef9305ebaaac884ae0350bfc243dd01d354d (diff)
parent00979ce4fcc90d488c7f27f750097adc6b11bd07 (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.include3
-rw-r--r--scripts/Makefile.gcc-plugins91
-rw-r--r--scripts/Makefile.kcov10
-rwxr-xr-xscripts/clang-version.sh18
-rw-r--r--scripts/gcc-plugins/Makefile5
-rwxr-xr-xscripts/gcc-x86_32-has-stack-protector.sh7
-rwxr-xr-xscripts/gcc-x86_64-has-stack-protector.sh5
-rwxr-xr-xscripts/kconfig/streamline_config.pl4
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
27ld-option = $(success,$(LD) -v $(1)) 27ld-option = $(success,$(LD) -v $(1))
28
29# gcc version including patch level
30gcc-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
2ifdef CONFIG_GCC_PLUGINS 2gcc-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 4gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += latent_entropy_plugin.so
11 gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += -DLATENT_ENTROPY_PLUGIN 5gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += -DLATENT_ENTROPY_PLUGIN
12 ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY 6ifdef 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 8endif
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 10gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so
35 gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += -DRANDSTRUCT_PLUGIN 11gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += structleak_plugin.so
36 gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE) += -fplugin-arg-randomize_layout_plugin-performance-mode 12gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE) += -fplugin-arg-structleak_plugin-verbose
13gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) += -fplugin-arg-structleak_plugin-byref-all
14gcc-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)) 16gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += randomize_layout_plugin.so
17gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += -DRANDSTRUCT_PLUGIN
18gcc-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 20GCC_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),) 22export GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR
44 # SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication. 23export 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) 26GCC_PLUGINS_CFLAGS := $(filter-out %/sancov_plugin.so, $(GCC_PLUGINS_CFLAGS))
50 GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y)
51endif
52 27
53# If plugins aren't supported, abort the build before hard-to-read compiler 28KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
54# errors start getting spewed by the main build. 29GCC_PLUGIN := $(gcc-plugin-y)
55PHONY += gcc-plugins-check 30GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y)
56gcc-plugins-check: FORCE
57ifdef 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
76endif
77 @:
78 31
79# Actually do the build, if requested. 32# Actually do the build, if requested.
80PHONY += gcc-plugins 33PHONY += gcc-plugins
81gcc-plugins: scripts_basic gcc-plugins-check 34gcc-plugins: scripts_basic
82ifdef CONFIG_GCC_PLUGINS 35ifdef CONFIG_GCC_PLUGINS
83 $(Q)$(MAKE) $(build)=scripts/gcc-plugins 36 $(Q)$(MAKE) $(build)=scripts/gcc-plugins
84endif 37endif
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 @@
1ifdef CONFIG_KCOV 1ifdef CONFIG_KCOV
2CFLAGS_KCOV := $(call cc-option,-fsanitize-coverage=trace-pc,) 2
3ifeq ($(CONFIG_KCOV_ENABLE_COMPARISONS),y) 3kcov-flags-$(CONFIG_CC_HAS_SANCOV_TRACE_PC) += -fsanitize-coverage=trace-pc
4CFLAGS_KCOV += $(call cc-option,-fsanitize-coverage=trace-cmp,) 4kcov-flags-$(CONFIG_KCOV_ENABLE_COMPARISONS) += -fsanitize-coverage=trace-cmp
5endif 5kcov-flags-$(CONFIG_GCC_PLUGIN_SANCOV) += -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so
6
7export CFLAGS_KCOV := $(kcov-flags-y)
6 8
7endif 9endif
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
13if [ "$1" = "-p" ] ; then
14 with_patchlevel=1;
15 shift;
16fi
17
18compiler="$*" 13compiler="$*"
19 14
20if [ ${#compiler} -eq 0 ]; then 15if !( $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
24fi 18fi
25 19
26MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1) 20MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1)
27MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1) 21MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1)
28if [ "x$with_patchlevel" != "x" ] ; then 22PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1)
29 PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1) 23printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
30 printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
31else
32 printf "%02d%02d\\n" $MAJOR $MINOR
33fi
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
2PLUGINCC := $(CONFIG_PLUGIN_HOSTCC:"%"=%)
2GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin) 3GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
3 4
4ifeq ($(PLUGINCC),$(HOSTCC)) 5ifeq ($(PLUGINCC),$(HOSTCC))
@@ -13,10 +14,6 @@ else
13 export HOST_EXTRACXXFLAGS 14 export HOST_EXTRACXXFLAGS
14endif 15endif
15 16
16ifneq ($(CFLAGS_KCOV), $(SANCOV_PLUGIN))
17 GCC_PLUGIN := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGIN))
18endif
19
20export HOSTLIBS 17export 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
4echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs" 4echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -m32 -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
5if [ "$?" -eq "0" ] ; then
6 echo y
7else
8 echo n
9fi
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
4echo "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" 4echo "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"
5if [ "$?" -eq "0" ] ; then
6 echo y
7else
8 echo n
9fi
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";