Skip to content

Commit 77342a0

Browse files
committed
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 <[email protected]> Acked-by: Kees Cook <[email protected]>
1 parent afe956c commit 77342a0

File tree

7 files changed

+14
-103
lines changed

7 files changed

+14
-103
lines changed

scripts/Kconfig.include

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ $(error-if,$(failure,command -v $(LD)),linker '$(LD)' not found)
4848
# Fail if the linker is gold as it's not capable of linking the kernel proper
4949
$(error-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not supported)
5050

51-
# gcc version including patch level
52-
gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC))
53-
5451
# machine bit flags
5552
# $(m32-flag): -m32 if the compiler supports it, or an empty string otherwise.
5653
# $(m64-flag): -m64 if the compiler supports it, or an empty string otherwise.

scripts/Makefile.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ include $(kbuild-file)
4646
include scripts/Makefile.lib
4747

4848
# 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),)
5050
include scripts/Makefile.host
5151
endif
5252

scripts/Makefile.clean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
3030
__clean-files := $(extra-y) $(extra-m) $(extra-) \
3131
$(always) $(always-y) $(always-m) $(always-) $(targets) $(clean-files) \
3232
$(hostprogs) $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
33-
$(hostlibs-y) $(hostlibs-m) $(hostlibs-) \
3433
$(hostcxxlibs-y) $(hostcxxlibs-m)
3534

3635
__clean-files := $(filter-out $(no-clean-files), $(__clean-files))

scripts/Makefile.host

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ $(obj)/%.tab.c $(obj)/%.tab.h: $(src)/%.y FORCE
3939
# They are linked as C++ code to the executable qconf
4040

4141
__hostprogs := $(sort $(hostprogs))
42-
host-cshlib := $(sort $(hostlibs-y) $(hostlibs-m))
4342
host-cxxshlib := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
4443

4544
# C code
@@ -63,17 +62,14 @@ host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m)))
6362
host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
6463

6564
# Object (.o) files used by the shared libaries
66-
host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
6765
host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
6866

6967
host-csingle := $(addprefix $(obj)/,$(host-csingle))
7068
host-cmulti := $(addprefix $(obj)/,$(host-cmulti))
7169
host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
7270
host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
7371
host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
74-
host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
7572
host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
76-
host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
7773
host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
7874

7975
#####
@@ -140,13 +136,6 @@ quiet_cmd_host-cxxobjs = HOSTCXX $@
140136
$(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE
141137
$(call if_changed_dep,host-cxxobjs)
142138

143-
# Compile .c file, create position independent .o file
144-
# host-cshobjs -> .o
145-
quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
146-
cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $<
147-
$(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
148-
$(call if_changed_dep,host-cshobjs)
149-
150139
# Compile .c file, create position independent .o file
151140
# Note that plugin capable gcc versions can be either C or C++ based
152141
# therefore plugin source files have to be compilable in both C and C++ mode.
@@ -157,16 +146,6 @@ quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
157146
$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
158147
$(call if_changed_dep,host-cxxshobjs)
159148

160-
# Link a shared library, based on position independent .o files
161-
# *.o -> .so shared library (host-cshlib)
162-
quiet_cmd_host-cshlib = HOSTLLD -shared $@
163-
cmd_host-cshlib = $(HOSTCC) $(KBUILD_HOSTLDFLAGS) -shared -o $@ \
164-
$(addprefix $(obj)/, $($(target-stem)-objs)) \
165-
$(KBUILD_HOSTLDLIBS) $(HOSTLDLIBS_$(target-stem).so)
166-
$(host-cshlib): FORCE
167-
$(call if_changed,host-cshlib)
168-
$(call multi_depend, $(host-cshlib), .so, -objs)
169-
170149
# Link a shared library, based on position independent .o files
171150
# *.o -> .so shared library (host-cxxshlib)
172151
quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
@@ -178,4 +157,4 @@ $(host-cxxshlib): FORCE
178157
$(call multi_depend, $(host-cxxshlib), .so, -objs)
179158

180159
targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
181-
$(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
160+
$(host-cxxmulti) $(host-cxxobjs) $(host-cxxshlib) $(host-cxxshobjs)

scripts/gcc-plugin.sh

Lines changed: 4 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,14 @@
11
#!/bin/sh
22
# SPDX-License-Identifier: GPL-2.0
3-
srctree=$(dirname "$0")
4-
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-
)
213

22-
if [ $? -ne 0 ]
23-
then
24-
if [ -n "$SHOW_ERROR" ] ; then
25-
echo "${plugincc}" >&2
26-
fi
27-
exit 1
28-
fi
4+
set -e
295

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-
;;
6+
srctree=$(dirname "$0")
397

40-
*)
41-
exit 1
42-
;;
43-
esac
8+
gccplugins_dir=$($* -print-file-name=plugin)
449

4510
# 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
4712
#include "gcc-common.h"
4813
class test {
4914
public:
@@ -52,15 +17,3 @@ public:
5217
.test = 1
5318
};
5419
EOF
55-
)
56-
57-
if [ $? -eq 0 ]
58-
then
59-
echo "$2"
60-
exit 0
61-
fi
62-
63-
if [ -n "$SHOW_ERROR" ] ; then
64-
echo "${plugincc}" >&2
65-
fi
66-
exit 1

scripts/gcc-plugins/Kconfig

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
11
# 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-
112
config HAVE_GCC_PLUGINS
123
bool
134
help
@@ -17,7 +8,8 @@ config HAVE_GCC_PLUGINS
178
menuconfig GCC_PLUGINS
189
bool "GCC plugins"
1910
depends on HAVE_GCC_PLUGINS
20-
depends on PLUGIN_HOSTCC != ""
11+
depends on CC_IS_GCC && GCC_VERSION >= 40800
12+
depends on $(success,$(srctree)/scripts/gcc-plugin.sh $(CC))
2113
default y
2214
help
2315
GCC plugins are loadable modules that provide extra features to the

scripts/gcc-plugins/Makefile

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,9 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
PLUGINCC := $(CONFIG_PLUGIN_HOSTCC:"%"=%)
32
GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
43

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
167

178
$(obj)/randomize_layout_plugin.o: $(objtree)/$(obj)/randomize_layout_seed.h
189
quiet_cmd_create_randomize_layout_seed = GENSEED $@
@@ -22,9 +13,9 @@ $(objtree)/$(obj)/randomize_layout_seed.h: FORCE
2213
$(call if_changed,create_randomize_layout_seed)
2314
targets = randomize_layout_seed.h randomize_layout_hash.h
2415

25-
$(HOSTLIBS)-y := $(foreach p,$(GCC_PLUGIN),$(if $(findstring /,$(p)),,$(p)))
26-
always-y := $($(HOSTLIBS)-y)
16+
hostcxxlibs-y := $(foreach p,$(GCC_PLUGIN),$(if $(findstring /,$(p)),,$(p)))
17+
always-y := $(hostcxxlibs-y)
2718

28-
$(foreach p,$($(HOSTLIBS)-y:%.so=%),$(eval $(p)-objs := $(p).o))
19+
$(foreach p,$(hostcxxlibs-y:%.so=%),$(eval $(p)-objs := $(p).o))
2920

3021
clean-files += *.so

0 commit comments

Comments
 (0)