Skip to content

Commit caefd8c

Browse files
ephox-gcc-pluginskees
authored andcommitted
gcc-plugins: Add support for plugin subdirectories
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 <pageexec@freemail.hu> Signed-off-by: Emese Revfy <re.emese@gmail.com> [kees: clarified commit message] Signed-off-by: Kees Cook <keescook@chromium.org>
1 parent 7040c83 commit caefd8c

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

scripts/Makefile.gcc-plugins

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ifdef CONFIG_GCC_PLUGINS
2121

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

24-
export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN SANCOV_PLUGIN
24+
export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR SANCOV_PLUGIN
2525

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

3131
KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
3232
GCC_PLUGIN := $(gcc-plugin-y)
33+
GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y)
3334
endif
3435

3536
# If plugins aren't supported, abort the build before hard-to-read compiler

scripts/gcc-plugins/Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,18 @@ else
1212
export HOST_EXTRACXXFLAGS
1313
endif
1414

15-
export GCCPLUGINS_DIR HOSTLIBS
16-
1715
ifneq ($(CFLAGS_KCOV), $(SANCOV_PLUGIN))
1816
GCC_PLUGIN := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGIN))
1917
endif
2018

21-
$(HOSTLIBS)-y := $(GCC_PLUGIN)
19+
export HOSTLIBS
20+
21+
$(HOSTLIBS)-y := $(foreach p,$(GCC_PLUGIN),$(if $(findstring /,$(p)),,$(p)))
2222
always := $($(HOSTLIBS)-y)
2323

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

26+
subdir-y := $(GCC_PLUGIN_SUBDIR)
27+
subdir- += $(GCC_PLUGIN_SUBDIR)
28+
2629
clean-files += *.so

0 commit comments

Comments
 (0)