xref: /linux/scripts/Makefile.gcc-plugins (revision 7ccb95e8fe9131b8fa14b947c60dfb30044fa002)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
2*7ccb95e8SKees Cook
30dae776cSEmese Revfygcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY)	+= cyc_complexity_plugin.so
4543c37cbSEmese Revfy
538addce8SEmese Revfygcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY)	+= latent_entropy_plugin.so
6*7ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY)		\
7*7ccb95e8SKees Cook		+= -DLATENT_ENTROPY_PLUGIN
87b4010edSAndrew Donnellanifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY
938addce8SEmese Revfy    DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable
1038addce8SEmese Revfyendif
115aadfdebSMasahiro Yamadaexport DISABLE_LATENT_ENTROPY_PLUGIN
126b90bd4bSEmese Revfy
13*7ccb95e8SKees Cookgcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV)		+= sancov_plugin.so
146b90bd4bSEmese Revfy
15*7ccb95e8SKees Cookgcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK)	+= structleak_plugin.so
16*7ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE)	\
17*7ccb95e8SKees Cook		+= -fplugin-arg-structleak_plugin-verbose
18*7ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL)	\
19*7ccb95e8SKees Cook		+= -fplugin-arg-structleak_plugin-byref-all
20*7ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK)		\
21*7ccb95e8SKees Cook		+= -DSTRUCTLEAK_PLUGIN
22*7ccb95e8SKees Cook
23*7ccb95e8SKees Cookgcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT)	+= randomize_layout_plugin.so
24*7ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT)		\
25*7ccb95e8SKees Cook		+= -DRANDSTRUCT_PLUGIN
26*7ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE)	\
27*7ccb95e8SKees Cook		+= -fplugin-arg-randomize_layout_plugin-performance-mode
28*7ccb95e8SKees Cook
29*7ccb95e8SKees Cook# All the plugin CFLAGS are collected here in case a build target needs to
30*7ccb95e8SKees Cook# filter them out of the KBUILD_CFLAGS.
31*7ccb95e8SKees CookGCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y))
32*7ccb95e8SKees Cook# The sancov_plugin.so is included via CFLAGS_KCOV, so it is removed here.
33*7ccb95e8SKees CookGCC_PLUGINS_CFLAGS := $(filter-out %/sancov_plugin.so, $(GCC_PLUGINS_CFLAGS))
34*7ccb95e8SKees Cookexport GCC_PLUGINS_CFLAGS
35*7ccb95e8SKees Cook
36*7ccb95e8SKees Cook# Add the flags to the build!
376b90bd4bSEmese RevfyKBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
38*7ccb95e8SKees Cook
39*7ccb95e8SKees Cook# All enabled GCC plugins are collected here for building below.
406b90bd4bSEmese RevfyGCC_PLUGIN := $(gcc-plugin-y)
41*7ccb95e8SKees Cookexport GCC_PLUGIN
42ed58c0e9SKees Cook
43ed58c0e9SKees Cook# Actually do the build, if requested.
44ed58c0e9SKees CookPHONY += gcc-plugins
4559f53855SMasahiro Yamadagcc-plugins: scripts_basic
46ed58c0e9SKees Cookifdef CONFIG_GCC_PLUGINS
47ed58c0e9SKees Cook	$(Q)$(MAKE) $(build)=scripts/gcc-plugins
48ed58c0e9SKees Cookendif
49ed58c0e9SKees Cook	@:
50