blob: e2ff425f4c7ea6958beddb3571ed9ac72a3b9ea8 [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Emese Revfy6b90bd42016-05-24 00:09:38 +02002GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
3
4ifeq ($(PLUGINCC),$(HOSTCC))
5 HOSTLIBS := hostlibs
6 HOST_EXTRACFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu99 -ggdb
7 export HOST_EXTRACFLAGS
8else
9 HOSTLIBS := hostcxxlibs
10 HOST_EXTRACXXFLAGS += -I$(GCC_PLUGINS_DIR)/include -I$(src) -std=gnu++98 -fno-rtti
11 HOST_EXTRACXXFLAGS += -fno-exceptions -fasynchronous-unwind-tables -ggdb
12 HOST_EXTRACXXFLAGS += -Wno-narrowing -Wno-unused-variable
13 export HOST_EXTRACXXFLAGS
14endif
15
Emese Revfy543c37c2016-05-24 00:11:37 +020016ifneq ($(CFLAGS_KCOV), $(SANCOV_PLUGIN))
17 GCC_PLUGIN := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGIN))
18endif
19
Emese Revfycaefd8c2016-06-26 17:38:20 +020020export HOSTLIBS
21
Kees Cook313dd1b62017-05-05 23:37:45 -070022$(obj)/randomize_layout_plugin.o: $(objtree)/$(obj)/randomize_layout_seed.h
23quiet_cmd_create_randomize_layout_seed = GENSEED $@
24cmd_create_randomize_layout_seed = \
25 $(CONFIG_SHELL) $(srctree)/$(src)/gen-random-seed.sh $@ $(objtree)/include/generated/randomize_layout_hash.h
26$(objtree)/$(obj)/randomize_layout_seed.h: FORCE
27 $(call if_changed,create_randomize_layout_seed)
28targets = randomize_layout_seed.h randomize_layout_hash.h
29
Emese Revfycaefd8c2016-06-26 17:38:20 +020030$(HOSTLIBS)-y := $(foreach p,$(GCC_PLUGIN),$(if $(findstring /,$(p)),,$(p)))
Emese Revfy6b90bd42016-05-24 00:09:38 +020031always := $($(HOSTLIBS)-y)
32
Emese Revfy7040c832016-06-26 17:36:43 +020033$(foreach p,$($(HOSTLIBS)-y:%.so=%),$(eval $(p)-objs := $(p).o))
Emese Revfy543c37c2016-05-24 00:11:37 +020034
Emese Revfycaefd8c2016-06-26 17:38:20 +020035subdir-y := $(GCC_PLUGIN_SUBDIR)
36subdir- += $(GCC_PLUGIN_SUBDIR)
37
Emese Revfy6b90bd42016-05-24 00:09:38 +020038clean-files += *.so