xref: /linux/scripts/Makefile.gcc-plugins (revision 4f2c0a4acffbec01079c28f839422e64ddeff004)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
27ccb95e8SKees Cook
338addce8SEmese Revfygcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY)	+= latent_entropy_plugin.so
47ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY)		\
57ccb95e8SKees Cook		+= -DLATENT_ENTROPY_PLUGIN
67b4010edSAndrew Donnellanifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY
7*012e8d20SAndrew Donnellan    DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable -ULATENT_ENTROPY_PLUGIN
838addce8SEmese Revfyendif
95aadfdebSMasahiro Yamadaexport DISABLE_LATENT_ENTROPY_PLUGIN
106b90bd4bSEmese Revfy
117ccb95e8SKees Cookgcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK)	+= structleak_plugin.so
127ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE)	\
137ccb95e8SKees Cook		+= -fplugin-arg-structleak_plugin-verbose
1481a56f6dSKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF)		\
1581a56f6dSKees Cook		+= -fplugin-arg-structleak_plugin-byref
167ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL)	\
177ccb95e8SKees Cook		+= -fplugin-arg-structleak_plugin-byref-all
18554afc3bSBrendan Higginsifdef CONFIG_GCC_PLUGIN_STRUCTLEAK
19554afc3bSBrendan Higgins    DISABLE_STRUCTLEAK_PLUGIN += -fplugin-arg-structleak_plugin-disable
20554afc3bSBrendan Higginsendif
21554afc3bSBrendan Higginsexport DISABLE_STRUCTLEAK_PLUGIN
227ccb95e8SKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK)		\
237ccb95e8SKees Cook		+= -DSTRUCTLEAK_PLUGIN
247ccb95e8SKees Cook
2510e9ae9fSAlexander Popovgcc-plugin-$(CONFIG_GCC_PLUGIN_STACKLEAK)	+= stackleak_plugin.so
2610e9ae9fSAlexander Popovgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STACKLEAK)		\
2710e9ae9fSAlexander Popov		+= -DSTACKLEAK_PLUGIN
2810e9ae9fSAlexander Popovgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STACKLEAK)		\
2910e9ae9fSAlexander Popov		+= -fplugin-arg-stackleak_plugin-track-min-size=$(CONFIG_STACKLEAK_TRACK_MIN_SIZE)
30feee1b8cSAlexander Popovgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STACKLEAK)		\
31feee1b8cSAlexander Popov		+= -fplugin-arg-stackleak_plugin-arch=$(SRCARCH)
32f154066bSKees Cookgcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STACKLEAK_VERBOSE)	\
33f154066bSKees Cook		+= -fplugin-arg-stackleak_plugin-verbose
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
39189af465SArd Biesheuvelgcc-plugin-$(CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK) += arm_ssp_per_task_plugin.so
40189af465SArd Biesheuvelifdef CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK
41189af465SArd Biesheuvel    DISABLE_ARM_SSP_PER_TASK_PLUGIN += -fplugin-arg-arm_ssp_per_task_plugin-disable
42189af465SArd Biesheuvelendif
43189af465SArd Biesheuvelexport DISABLE_ARM_SSP_PER_TASK_PLUGIN
44189af465SArd 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 Cookexport GCC_PLUGINS_CFLAGS
497ccb95e8SKees Cook
507ccb95e8SKees Cook# Add the flags to the build!
516b90bd4bSEmese RevfyKBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
527ccb95e8SKees Cook
53d3646589SKees Cook# Some plugins are enabled outside of this Makefile, but they still need to
54d3646589SKees Cook# be included in GCC_PLUGIN so they can get built.
55d3646589SKees Cookgcc-plugin-external-$(CONFIG_GCC_PLUGIN_SANCOV)			\
56d3646589SKees Cook	+= sancov_plugin.so
57613f4b3eSKees Cookgcc-plugin-external-$(CONFIG_GCC_PLUGIN_RANDSTRUCT)		\
58613f4b3eSKees Cook	+= randomize_layout_plugin.so
59d3646589SKees Cook
60d3646589SKees Cook# All enabled GCC plugins are collected here for building in
61d3646589SKees Cook# scripts/gcc-scripts/Makefile.
62d3646589SKees CookGCC_PLUGIN := $(gcc-plugin-y) $(gcc-plugin-external-y)
637ccb95e8SKees Cookexport GCC_PLUGIN
64