xref: /linux/scripts/Makefile.gcc-plugins (revision 189af4657186da08a2e79fb8e906cfd82b2ccddc)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
27ccb95e8SKees 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
67ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY)		\
77ccb95e8SKees 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
137ccb95e8SKees Cookgcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV)		+= sancov_plugin.so
146b90bd4bSEmese Revfy
157ccb95e8SKees Cookgcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK)	+= structleak_plugin.so
167ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE)	\
177ccb95e8SKees Cook		+= -fplugin-arg-structleak_plugin-verbose
187ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL)	\
197ccb95e8SKees Cook		+= -fplugin-arg-structleak_plugin-byref-all
207ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK)		\
217ccb95e8SKees Cook		+= -DSTRUCTLEAK_PLUGIN
227ccb95e8SKees Cook
237ccb95e8SKees Cookgcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT)	+= randomize_layout_plugin.so
247ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT)		\
257ccb95e8SKees Cook		+= -DRANDSTRUCT_PLUGIN
267ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE)	\
277ccb95e8SKees Cook		+= -fplugin-arg-randomize_layout_plugin-performance-mode
287ccb95e8SKees Cook
2910e9ae9fSAlexander Popovgcc-plugin-$(CONFIG_GCC_PLUGIN_STACKLEAK)	+= stackleak_plugin.so
3010e9ae9fSAlexander Popovgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STACKLEAK)		\
3110e9ae9fSAlexander Popov		+= -DSTACKLEAK_PLUGIN
3210e9ae9fSAlexander Popovgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STACKLEAK)		\
3310e9ae9fSAlexander Popov		+= -fplugin-arg-stackleak_plugin-track-min-size=$(CONFIG_STACKLEAK_TRACK_MIN_SIZE)
3410e9ae9fSAlexander Popovifdef CONFIG_GCC_PLUGIN_STACKLEAK
3510e9ae9fSAlexander Popov    DISABLE_STACKLEAK_PLUGIN += -fplugin-arg-stackleak_plugin-disable
3610e9ae9fSAlexander Popovendif
3710e9ae9fSAlexander Popovexport DISABLE_STACKLEAK_PLUGIN
3810e9ae9fSAlexander Popov
39*189af465SArd Biesheuvelgcc-plugin-$(CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK) += arm_ssp_per_task_plugin.so
40*189af465SArd Biesheuvelifdef CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK
41*189af465SArd Biesheuvel    DISABLE_ARM_SSP_PER_TASK_PLUGIN += -fplugin-arg-arm_ssp_per_task_plugin-disable
42*189af465SArd Biesheuvelendif
43*189af465SArd Biesheuvelexport DISABLE_ARM_SSP_PER_TASK_PLUGIN
44*189af465SArd Biesheuvel
457ccb95e8SKees Cook# All the plugin CFLAGS are collected here in case a build target needs to
467ccb95e8SKees Cook# filter them out of the KBUILD_CFLAGS.
477ccb95e8SKees CookGCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y))
487ccb95e8SKees Cook# The sancov_plugin.so is included via CFLAGS_KCOV, so it is removed here.
497ccb95e8SKees CookGCC_PLUGINS_CFLAGS := $(filter-out %/sancov_plugin.so, $(GCC_PLUGINS_CFLAGS))
507ccb95e8SKees Cookexport GCC_PLUGINS_CFLAGS
517ccb95e8SKees Cook
527ccb95e8SKees Cook# Add the flags to the build!
536b90bd4bSEmese RevfyKBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
547ccb95e8SKees Cook
557ccb95e8SKees Cook# All enabled GCC plugins are collected here for building below.
566b90bd4bSEmese RevfyGCC_PLUGIN := $(gcc-plugin-y)
577ccb95e8SKees Cookexport GCC_PLUGIN
58ed58c0e9SKees Cook
59ed58c0e9SKees Cook# Actually do the build, if requested.
60ed58c0e9SKees CookPHONY += gcc-plugins
6159f53855SMasahiro Yamadagcc-plugins: scripts_basic
62ed58c0e9SKees Cookifdef CONFIG_GCC_PLUGINS
63ed58c0e9SKees Cook	$(Q)$(MAKE) $(build)=scripts/gcc-plugins
64ed58c0e9SKees Cookendif
65ed58c0e9SKees Cook	@:
66