Back to home page

LXR

 
 

    


0001 ifdef CONFIG_GCC_PLUGINS
0002   __PLUGINCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC))
0003   PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)")
0004 
0005   SANCOV_PLUGIN := -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so
0006 
0007   gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY)        += cyc_complexity_plugin.so
0008 
0009   gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY)        += latent_entropy_plugin.so
0010   gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += -DLATENT_ENTROPY_PLUGIN
0011   ifdef CONFIG_PAX_LATENT_ENTROPY
0012     DISABLE_LATENT_ENTROPY_PLUGIN                       += -fplugin-arg-latent_entropy_plugin-disable
0013   endif
0014 
0015   ifdef CONFIG_GCC_PLUGIN_SANCOV
0016     ifeq ($(CFLAGS_KCOV),)
0017       # It is needed because of the gcc-plugin.sh and gcc version checks.
0018       gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV)           += sancov_plugin.so
0019 
0020       ifneq ($(PLUGINCC),)
0021         CFLAGS_KCOV := $(SANCOV_PLUGIN)
0022       else
0023         $(warning warning: cannot use CONFIG_KCOV: -fsanitize-coverage=trace-pc is not supported by compiler)
0024       endif
0025     endif
0026   endif
0027 
0028   GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y))
0029 
0030   export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR
0031   export SANCOV_PLUGIN DISABLE_LATENT_ENTROPY_PLUGIN
0032 
0033   ifneq ($(PLUGINCC),)
0034     # SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication.
0035     GCC_PLUGINS_CFLAGS := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGINS_CFLAGS))
0036   endif
0037 
0038   KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
0039   GCC_PLUGIN := $(gcc-plugin-y)
0040   GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y)
0041 endif
0042 
0043 # If plugins aren't supported, abort the build before hard-to-read compiler
0044 # errors start getting spewed by the main build.
0045 PHONY += gcc-plugins-check
0046 gcc-plugins-check: FORCE
0047 ifdef CONFIG_GCC_PLUGINS
0048   ifeq ($(PLUGINCC),)
0049     ifneq ($(GCC_PLUGINS_CFLAGS),)
0050       ifeq ($(call cc-ifversion, -ge, 0405, y), y)
0051         $(Q)$(srctree)/scripts/gcc-plugin.sh --show-error "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)" || true
0052         @echo "Cannot use CONFIG_GCC_PLUGINS: your gcc installation does not support plugins, perhaps the necessary headers are missing?" >&2 && exit 1
0053       else
0054         @echo "Cannot use CONFIG_GCC_PLUGINS: your gcc version does not support plugins, you should upgrade it to at least gcc 4.5" >&2 && exit 1
0055       endif
0056     endif
0057   endif
0058 endif
0059         @:
0060 
0061 # Actually do the build, if requested.
0062 PHONY += gcc-plugins
0063 gcc-plugins: scripts_basic gcc-plugins-check
0064 ifdef CONFIG_GCC_PLUGINS
0065         $(Q)$(MAKE) $(build)=scripts/gcc-plugins
0066 endif
0067         @: