Re: [PATCH v5 3/5] Add Cyclomatic complexity GCC plugin

From: Emese Revfy
Date: Mon Mar 14 2016 - 17:04:58 EST


On Fri, 11 Mar 2016 15:26:39 +0900
Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx> wrote:

> > diff --git a/scripts/Makefile.gcc-plugins b/scripts/Makefile.gcc-plugins
> > index 7c85bf2..dd7b56d 100644
> > --- a/scripts/Makefile.gcc-plugins
> > +++ b/scripts/Makefile.gcc-plugins
> > @@ -5,7 +5,11 @@ else
> > PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
> > endif
> > ifneq ($(PLUGINCC),)
> > -export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS
> > +ifdef CONFIG_GCC_PLUGIN_CYC_COMPLEXITY
> > +GCC_PLUGIN_CYC_COMPLEXITY_CFLAGS := -fplugin=$(objtree)/tools/gcc/cyc_complexity_plugin.so
> > +endif
> > +GCC_PLUGINS_CFLAGS := $(GCC_PLUGIN_CYC_COMPLEXITY_CFLAGS)
> > +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS GCC_PLUGIN_CYC_COMPLEXITY
>
>
> Do you need to export "GCC_PLUGIN_CYC_COMPLEXITY"?
> I do not see any reference to it.

This is a demo plugin. I just want to demonstrate how to use this infrastructure but I can remove it.
In my project there would be other plugins which use the export.

> If we expect more and more plugins in the future,
> is it better to do like this?
>
> gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so
> gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV) += sancov_plugin.so
> gcc-plugin-$(CONFIG_GCC_PLUGIN_FOO) += foo_plugin.so
>
>
> GCC_PLUGINS_CFLAGS := $(addprefix -fplugin=$(objtree)/tools/gcc/,
> $(gcc-plugin-y))

Yes, it is better, I will do it.

--
Emese