1*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593Smuzhiyungcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY)	+= cyc_complexity_plugin.so
4*4882a593Smuzhiyun
5*4882a593Smuzhiyungcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY)	+= latent_entropy_plugin.so
6*4882a593Smuzhiyungcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY)		\
7*4882a593Smuzhiyun		+= -DLATENT_ENTROPY_PLUGIN
8*4882a593Smuzhiyunifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY
9*4882a593Smuzhiyun    DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable
10*4882a593Smuzhiyunendif
11*4882a593Smuzhiyunexport DISABLE_LATENT_ENTROPY_PLUGIN
12*4882a593Smuzhiyun
13*4882a593Smuzhiyungcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV)		+= sancov_plugin.so
14*4882a593Smuzhiyun
15*4882a593Smuzhiyungcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK)	+= structleak_plugin.so
16*4882a593Smuzhiyungcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE)	\
17*4882a593Smuzhiyun		+= -fplugin-arg-structleak_plugin-verbose
18*4882a593Smuzhiyungcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL)	\
19*4882a593Smuzhiyun		+= -fplugin-arg-structleak_plugin-byref-all
20*4882a593Smuzhiyunifdef CONFIG_GCC_PLUGIN_STRUCTLEAK
21*4882a593Smuzhiyun    DISABLE_STRUCTLEAK_PLUGIN += -fplugin-arg-structleak_plugin-disable
22*4882a593Smuzhiyunendif
23*4882a593Smuzhiyunexport DISABLE_STRUCTLEAK_PLUGIN
24*4882a593Smuzhiyungcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK)		\
25*4882a593Smuzhiyun		+= -DSTRUCTLEAK_PLUGIN
26*4882a593Smuzhiyun
27*4882a593Smuzhiyungcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT)	+= randomize_layout_plugin.so
28*4882a593Smuzhiyungcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT)		\
29*4882a593Smuzhiyun		+= -DRANDSTRUCT_PLUGIN
30*4882a593Smuzhiyungcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE)	\
31*4882a593Smuzhiyun		+= -fplugin-arg-randomize_layout_plugin-performance-mode
32*4882a593Smuzhiyun
33*4882a593Smuzhiyun# All the plugin CFLAGS are collected here in case a build target needs to
34*4882a593Smuzhiyun# filter them out of the KBUILD_CFLAGS.
35*4882a593SmuzhiyunGCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y))
36*4882a593Smuzhiyun# The sancov_plugin.so is included via CFLAGS_KCOV, so it is removed here.
37*4882a593SmuzhiyunGCC_PLUGINS_CFLAGS := $(filter-out %/sancov_plugin.so, $(GCC_PLUGINS_CFLAGS))
38*4882a593Smuzhiyunexport GCC_PLUGINS_CFLAGS
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun# Add the flags to the build!
41*4882a593SmuzhiyunKBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun# All enabled GCC plugins are collected here for building below.
44*4882a593SmuzhiyunGCC_PLUGIN := $(gcc-plugin-y)
45*4882a593Smuzhiyunexport GCC_PLUGIN
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun# Actually do the build, if requested.
48*4882a593SmuzhiyunPHONY += gcc-plugins
49*4882a593Smuzhiyungcc-plugins: scripts_basic
50*4882a593Smuzhiyunifdef CONFIG_GCC_PLUGINS
51*4882a593Smuzhiyun	$(Q)$(MAKE) $(build)=scripts/gcc-plugins
52*4882a593Smuzhiyunendif
53*4882a593Smuzhiyun	@:
54