Skip to content

Commit

Permalink
gcc-plugins: Add support for plugin subdirectories
Browse files Browse the repository at this point in the history
This adds support for building more complex gcc plugins that live in a
subdirectory instead of just in a single source file.

Reported-by: PaX Team <[email protected]>
Signed-off-by: Emese Revfy <[email protected]>
[kees: clarified commit message]
Signed-off-by: Kees Cook <[email protected]>
  • Loading branch information
ephox-gcc-plugins authored and kees committed Aug 9, 2016
1 parent 7040c83 commit caefd8c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion scripts/Makefile.gcc-plugins
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ifdef CONFIG_GCC_PLUGINS

GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y))

export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN SANCOV_PLUGIN
export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR SANCOV_PLUGIN

ifneq ($(PLUGINCC),)
# SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication.
Expand All @@ -30,6 +30,7 @@ ifdef CONFIG_GCC_PLUGINS

KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
GCC_PLUGIN := $(gcc-plugin-y)
GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y)
endif

# If plugins aren't supported, abort the build before hard-to-read compiler
Expand Down
9 changes: 6 additions & 3 deletions scripts/gcc-plugins/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ else
export HOST_EXTRACXXFLAGS
endif

export GCCPLUGINS_DIR HOSTLIBS

ifneq ($(CFLAGS_KCOV), $(SANCOV_PLUGIN))
GCC_PLUGIN := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGIN))
endif

$(HOSTLIBS)-y := $(GCC_PLUGIN)
export HOSTLIBS

$(HOSTLIBS)-y := $(foreach p,$(GCC_PLUGIN),$(if $(findstring /,$(p)),,$(p)))
always := $($(HOSTLIBS)-y)

$(foreach p,$($(HOSTLIBS)-y:%.so=%),$(eval $(p)-objs := $(p).o))

subdir-y := $(GCC_PLUGIN_SUBDIR)
subdir- += $(GCC_PLUGIN_SUBDIR)

clean-files += *.so

0 comments on commit caefd8c

Please sign in to comment.