Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Kees Cook | 7ccb95e | 2018-07-11 17:38:52 -0700 | [diff] [blame^] | 2 | |
Masahiro Yamada | 59f5385 | 2018-05-28 18:22:06 +0900 | [diff] [blame] | 3 | gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so |
Emese Revfy | 6b90bd4 | 2016-05-24 00:09:38 +0200 | [diff] [blame] | 4 | |
Masahiro Yamada | 59f5385 | 2018-05-28 18:22:06 +0900 | [diff] [blame] | 5 | gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += latent_entropy_plugin.so |
Kees Cook | 7ccb95e | 2018-07-11 17:38:52 -0700 | [diff] [blame^] | 6 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) \ |
| 7 | += -DLATENT_ENTROPY_PLUGIN |
Masahiro Yamada | 59f5385 | 2018-05-28 18:22:06 +0900 | [diff] [blame] | 8 | ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY |
Kees Cook | 7ccb95e | 2018-07-11 17:38:52 -0700 | [diff] [blame^] | 9 | DISABLE_LATENT_ENTROPY_PLUGIN += -fplugin-arg-latent_entropy_plugin-disable |
Emese Revfy | 6b90bd4 | 2016-05-24 00:09:38 +0200 | [diff] [blame] | 10 | endif |
Masahiro Yamada | 59f5385 | 2018-05-28 18:22:06 +0900 | [diff] [blame] | 11 | export DISABLE_LATENT_ENTROPY_PLUGIN |
| 12 | |
Kees Cook | 7ccb95e | 2018-07-11 17:38:52 -0700 | [diff] [blame^] | 13 | gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so |
Masahiro Yamada | 59f5385 | 2018-05-28 18:22:06 +0900 | [diff] [blame] | 14 | |
Kees Cook | 7ccb95e | 2018-07-11 17:38:52 -0700 | [diff] [blame^] | 15 | gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) += structleak_plugin.so |
| 16 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE) \ |
| 17 | += -fplugin-arg-structleak_plugin-verbose |
| 18 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL) \ |
| 19 | += -fplugin-arg-structleak_plugin-byref-all |
| 20 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK) \ |
| 21 | += -DSTRUCTLEAK_PLUGIN |
| 22 | |
| 23 | gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) += randomize_layout_plugin.so |
| 24 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT) \ |
| 25 | += -DRANDSTRUCT_PLUGIN |
| 26 | gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE) \ |
| 27 | += -fplugin-arg-randomize_layout_plugin-performance-mode |
| 28 | |
| 29 | # All the plugin CFLAGS are collected here in case a build target needs to |
| 30 | # filter them out of the KBUILD_CFLAGS. |
| 31 | GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y)) |
| 32 | # The sancov_plugin.so is included via CFLAGS_KCOV, so it is removed here. |
| 33 | GCC_PLUGINS_CFLAGS := $(filter-out %/sancov_plugin.so, $(GCC_PLUGINS_CFLAGS)) |
| 34 | export GCC_PLUGINS_CFLAGS |
| 35 | |
| 36 | # Add the flags to the build! |
Masahiro Yamada | 59f5385 | 2018-05-28 18:22:06 +0900 | [diff] [blame] | 37 | KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS) |
Kees Cook | 7ccb95e | 2018-07-11 17:38:52 -0700 | [diff] [blame^] | 38 | |
| 39 | # All enabled GCC plugins are collected here for building below. |
Masahiro Yamada | 59f5385 | 2018-05-28 18:22:06 +0900 | [diff] [blame] | 40 | GCC_PLUGIN := $(gcc-plugin-y) |
Kees Cook | 7ccb95e | 2018-07-11 17:38:52 -0700 | [diff] [blame^] | 41 | export GCC_PLUGIN |
Kees Cook | ed58c0e | 2016-06-17 23:11:12 -0700 | [diff] [blame] | 42 | |
| 43 | # Actually do the build, if requested. |
| 44 | PHONY += gcc-plugins |
Masahiro Yamada | 59f5385 | 2018-05-28 18:22:06 +0900 | [diff] [blame] | 45 | gcc-plugins: scripts_basic |
Kees Cook | ed58c0e | 2016-06-17 23:11:12 -0700 | [diff] [blame] | 46 | ifdef CONFIG_GCC_PLUGINS |
| 47 | $(Q)$(MAKE) $(build)=scripts/gcc-plugins |
| 48 | endif |
| 49 | @: |