Makefile.gcc-plugins 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. ifdef CONFIG_GCC_PLUGINS
  2. __PLUGINCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC))
  3. PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)")
  4. SANCOV_PLUGIN := -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so
  5. gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so
  6. ifdef CONFIG_GCC_PLUGIN_SANCOV
  7. ifeq ($(CFLAGS_KCOV),)
  8. # It is needed because of the gcc-plugin.sh and gcc version checks.
  9. gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so
  10. ifneq ($(PLUGINCC),)
  11. CFLAGS_KCOV := $(SANCOV_PLUGIN)
  12. else
  13. $(warning warning: cannot use CONFIG_KCOV: -fsanitize-coverage=trace-pc is not supported by compiler)
  14. endif
  15. endif
  16. endif
  17. GCC_PLUGINS_CFLAGS := $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y))
  18. export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN SANCOV_PLUGIN
  19. ifeq ($(PLUGINCC),)
  20. ifneq ($(GCC_PLUGINS_CFLAGS),)
  21. ifeq ($(call cc-ifversion, -ge, 0405, y), y)
  22. PLUGINCC := $(shell $(CONFIG_SHELL) -x $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)")
  23. $(warning warning: your gcc installation does not support plugins, perhaps the necessary headers are missing?)
  24. else
  25. $(warning warning: your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least)
  26. endif
  27. endif
  28. else
  29. # SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication.
  30. GCC_PLUGINS_CFLAGS := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGINS_CFLAGS))
  31. endif
  32. KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
  33. GCC_PLUGIN := $(gcc-plugin-y)
  34. endif