Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

gcc-plugins: drop support for GCC <= 4.7

Nobody was opposed to raising minimum GCC version to 4.8 [1]
So, we will drop GCC <= 4.7 support sooner or later.

We always use C++ compiler for building plugins for GCC >= 4.8.

This commit drops the plugin support for GCC <= 4.7 a bit earlier,
which allows us to dump lots of code.

[1] https://lkml.org/lkml/2020/1/23/545

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Acked-by: Kees Cook <keescook@chromium.org>

+15 -104
-3
scripts/Kconfig.include
··· 48 48 # Fail if the linker is gold as it's not capable of linking the kernel proper 49 49 $(error-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not supported) 50 50 51 - # gcc version including patch level 52 - gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) 53 - 54 51 # machine bit flags 55 52 # $(m32-flag): -m32 if the compiler supports it, or an empty string otherwise. 56 53 # $(m64-flag): -m64 if the compiler supports it, or an empty string otherwise.
+1 -1
scripts/Makefile.build
··· 46 46 include scripts/Makefile.lib 47 47 48 48 # Do not include host rules unless needed 49 - ifneq ($(hostprogs)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),) 49 + ifneq ($(hostprogs)$(hostcxxlibs-y)$(hostcxxlibs-m),) 50 50 include scripts/Makefile.host 51 51 endif 52 52
-1
scripts/Makefile.clean
··· 30 30 __clean-files := $(extra-y) $(extra-m) $(extra-) \ 31 31 $(always) $(always-y) $(always-m) $(always-) $(targets) $(clean-files) \ 32 32 $(hostprogs) $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \ 33 - $(hostlibs-y) $(hostlibs-m) $(hostlibs-) \ 34 33 $(hostcxxlibs-y) $(hostcxxlibs-m) 35 34 36 35 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
+1 -22
scripts/Makefile.host
··· 39 39 # They are linked as C++ code to the executable qconf 40 40 41 41 __hostprogs := $(sort $(hostprogs)) 42 - host-cshlib := $(sort $(hostlibs-y) $(hostlibs-m)) 43 42 host-cxxshlib := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m)) 44 43 45 44 # C code ··· 62 63 host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) 63 64 64 65 # Object (.o) files used by the shared libaries 65 - host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) 66 66 host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs)))) 67 67 68 68 host-csingle := $(addprefix $(obj)/,$(host-csingle)) ··· 69 71 host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) 70 72 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti)) 71 73 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs)) 72 - host-cshlib := $(addprefix $(obj)/,$(host-cshlib)) 73 74 host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib)) 74 - host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs)) 75 75 host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs)) 76 76 77 77 ##### ··· 137 141 $(call if_changed_dep,host-cxxobjs) 138 142 139 143 # Compile .c file, create position independent .o file 140 - # host-cshobjs -> .o 141 - quiet_cmd_host-cshobjs = HOSTCC -fPIC $@ 142 - cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $< 143 - $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE 144 - $(call if_changed_dep,host-cshobjs) 145 - 146 - # Compile .c file, create position independent .o file 147 144 # Note that plugin capable gcc versions can be either C or C++ based 148 145 # therefore plugin source files have to be compilable in both C and C++ mode. 149 146 # This is why a C++ compiler is invoked on a .c file. ··· 145 156 cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $< 146 157 $(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE 147 158 $(call if_changed_dep,host-cxxshobjs) 148 - 149 - # Link a shared library, based on position independent .o files 150 - # *.o -> .so shared library (host-cshlib) 151 - quiet_cmd_host-cshlib = HOSTLLD -shared $@ 152 - cmd_host-cshlib = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \ 153 - $(addprefix $(obj)/, $($(target-stem)-objs)) \ 154 - $(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem).so) 155 - $(host-cshlib): FORCE 156 - $(call if_changed,host-cshlib) 157 - $(call multi_depend, $(host-cshlib), .so, -objs) 158 159 159 160 # Link a shared library, based on position independent .o files 160 161 # *.o -> .so shared library (host-cxxshlib) ··· 157 178 $(call multi_depend, $(host-cxxshlib), .so, -objs) 158 179 159 180 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\ 160 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs) 181 + $(host-cxxmulti) $(host-cxxobjs) $(host-cxxshlib) $(host-cxxshobjs)
+5 -52
scripts/gcc-plugin.sh
··· 1 1 #!/bin/sh 2 2 # SPDX-License-Identifier: GPL-2.0 3 + 4 + set -e 5 + 3 6 srctree=$(dirname "$0") 4 7 5 - SHOW_ERROR= 6 - if [ "$1" = "--show-error" ] ; then 7 - SHOW_ERROR=1 8 - shift || true 9 - fi 10 - 11 - gccplugins_dir=$($3 -print-file-name=plugin) 12 - plugincc=$($1 -E -x c++ - -o /dev/null -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1 <<EOF 13 - #include "gcc-common.h" 14 - #if BUILDING_GCC_VERSION >= 4008 || defined(ENABLE_BUILD_WITH_CXX) 15 - #warning $2 CXX 16 - #else 17 - #warning $1 CC 18 - #endif 19 - EOF 20 - ) 21 - 22 - if [ $? -ne 0 ] 23 - then 24 - if [ -n "$SHOW_ERROR" ] ; then 25 - echo "${plugincc}" >&2 26 - fi 27 - exit 1 28 - fi 29 - 30 - case "$plugincc" in 31 - *"$1 CC"*) 32 - echo "$1" 33 - exit 0 34 - ;; 35 - 36 - *"$2 CXX"*) 37 - # the c++ compiler needs another test, see below 38 - ;; 39 - 40 - *) 41 - exit 1 42 - ;; 43 - esac 8 + gccplugins_dir=$($* -print-file-name=plugin) 44 9 45 10 # we need a c++ compiler that supports the designated initializer GNU extension 46 - plugincc=$($2 -c -x c++ -std=gnu++98 - -fsyntax-only -I"${srctree}"/gcc-plugins -I"${gccplugins_dir}"/include 2>&1 <<EOF 11 + $HOSTCC -c -x c++ -std=gnu++98 - -fsyntax-only -I $srctree/gcc-plugins -I $gccplugins_dir/include 2>/dev/null <<EOF 47 12 #include "gcc-common.h" 48 13 class test { 49 14 public: ··· 17 52 .test = 1 18 53 }; 19 54 EOF 20 - ) 21 - 22 - if [ $? -eq 0 ] 23 - then 24 - echo "$2" 25 - exit 0 26 - fi 27 - 28 - if [ -n "$SHOW_ERROR" ] ; then 29 - echo "${plugincc}" >&2 30 - fi 31 - exit 1
+2 -10
scripts/gcc-plugins/Kconfig
··· 1 1 # SPDX-License-Identifier: GPL-2.0-only 2 - preferred-plugin-hostcc := $(if-success,[ $(gcc-version) -ge 40800 ],$(HOSTCXX),$(HOSTCC)) 3 - 4 - config PLUGIN_HOSTCC 5 - string 6 - default "$(shell,$(srctree)/scripts/gcc-plugin.sh "$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")" if CC_IS_GCC 7 - help 8 - Host compiler used to build GCC plugins. This can be $(HOSTCXX), 9 - $(HOSTCC), or a null string if GCC plugin is unsupported. 10 - 11 2 config HAVE_GCC_PLUGINS 12 3 bool 13 4 help ··· 8 17 menuconfig GCC_PLUGINS 9 18 bool "GCC plugins" 10 19 depends on HAVE_GCC_PLUGINS 11 - depends on PLUGIN_HOSTCC != "" 20 + depends on CC_IS_GCC && GCC_VERSION >= 40800 21 + depends on $(success,$(srctree)/scripts/gcc-plugin.sh $(CC)) 12 22 default y 13 23 help 14 24 GCC plugins are loadable modules that provide extra features to the
+6 -15
scripts/gcc-plugins/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 - PLUGINCC := $(CONFIG_PLUGIN_HOSTCC:"%"=%) 3 2 GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin) 4 3 5 - ifeq ($(PLUGINCC),$(HOSTCC)) 6 - HOSTLIBS := hostlibs 7 - HOST_EXTRACFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu99 -ggdb 8 - export HOST_EXTRACFLAGS 9 - else 10 - HOSTLIBS := hostcxxlibs 11 - HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu++98 -fno-rtti 12 - HOST_EXTRACXXFLAGS += -fno-exceptions -fasynchronous-unwind-tables -ggdb 13 - HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable -Wno-c++11-compat 14 - export HOST_EXTRACXXFLAGS 15 - endif 4 + HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu++98 -fno-rtti 5 + HOST_EXTRACXXFLAGS += -fno-exceptions -fasynchronous-unwind-tables -ggdb 6 + HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable -Wno-c++11-compat 16 7 17 8 $(obj)/randomize_layout_plugin.o: $(objtree)/$(obj)/randomize_layout_seed.h 18 9 quiet_cmd_create_randomize_layout_seed = GENSEED $@ ··· 13 22 $(call if_changed,create_randomize_layout_seed) 14 23 targets = randomize_layout_seed.h randomize_layout_hash.h 15 24 16 - $(HOSTLIBS)-y := $(foreach p,$(GCC_PLUGIN),$(if $(findstring /,$(p)),,$(p))) 17 - always-y := $($(HOSTLIBS)-y) 25 + hostcxxlibs-y := $(foreach p,$(GCC_PLUGIN),$(if $(findstring /,$(p)),,$(p))) 26 + always-y := $(hostcxxlibs-y) 18 27 19 - $(foreach p,$($(HOSTLIBS)-y:%.so=%),$(eval $(p)-objs := $(p).o)) 28 + $(foreach p,$(hostcxxlibs-y:%.so=%),$(eval $(p)-objs := $(p).o)) 20 29 21 30 clean-files += *.so