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