xref: /linux/scripts/Makefile.gcc-plugins (revision 543c37cb165049c3be24a0d4733e67caa2b33eef)
16b90bd4bSEmese Revfyifdef CONFIG_GCC_PLUGINS
26b90bd4bSEmese Revfy  __PLUGINCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC))
36b90bd4bSEmese Revfy  PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)")
46b90bd4bSEmese Revfy
5*543c37cbSEmese Revfy  SANCOV_PLUGIN := -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so
6*543c37cbSEmese Revfy
70dae776cSEmese Revfy  gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY)	+= cyc_complexity_plugin.so
8*543c37cbSEmese Revfy
9*543c37cbSEmese Revfy  ifdef CONFIG_GCC_PLUGIN_SANCOV
10*543c37cbSEmese Revfy    ifeq ($(CFLAGS_KCOV),)
11*543c37cbSEmese Revfy      # It is needed because of the gcc-plugin.sh and gcc version checks.
12*543c37cbSEmese Revfy      gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV)           += sancov_plugin.so
13*543c37cbSEmese Revfy
14*543c37cbSEmese Revfy      ifneq ($(PLUGINCC),)
15*543c37cbSEmese Revfy        CFLAGS_KCOV := $(SANCOV_PLUGIN)
16*543c37cbSEmese Revfy      else
17*543c37cbSEmese Revfy        $(warning warning: cannot use CONFIG_KCOV: -fsanitize-coverage=trace-pc is not supported by compiler)
18*543c37cbSEmese Revfy      endif
19*543c37cbSEmese Revfy    endif
20*543c37cbSEmese Revfy  endif
21*543c37cbSEmese Revfy
226b90bd4bSEmese Revfy  GCC_PLUGINS_CFLAGS := $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y))
236b90bd4bSEmese Revfy
24*543c37cbSEmese Revfy  export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN SANCOV_PLUGIN
256b90bd4bSEmese Revfy
266b90bd4bSEmese Revfy  ifeq ($(PLUGINCC),)
276b90bd4bSEmese Revfy    ifneq ($(GCC_PLUGINS_CFLAGS),)
286b90bd4bSEmese Revfy      ifeq ($(call cc-ifversion, -ge, 0405, y), y)
296b90bd4bSEmese Revfy        PLUGINCC := $(shell $(CONFIG_SHELL) -x $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)")
306b90bd4bSEmese Revfy        $(warning warning: your gcc installation does not support plugins, perhaps the necessary headers are missing?)
316b90bd4bSEmese Revfy      else
326b90bd4bSEmese Revfy        $(warning warning: your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least)
336b90bd4bSEmese Revfy      endif
346b90bd4bSEmese Revfy    endif
35*543c37cbSEmese Revfy  else
36*543c37cbSEmese Revfy    # SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication.
37*543c37cbSEmese Revfy    GCC_PLUGINS_CFLAGS := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGINS_CFLAGS))
386b90bd4bSEmese Revfy  endif
396b90bd4bSEmese Revfy
406b90bd4bSEmese Revfy  KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
416b90bd4bSEmese Revfy  GCC_PLUGIN := $(gcc-plugin-y)
426b90bd4bSEmese Revfy
436b90bd4bSEmese Revfyendif
44