@@ -48,7 +48,7 @@ subdir-ym := $(sort $(subdir-y) $(subdir-m))
4848
4949# if $(foo-objs) exists, foo.o is a composite object
5050multi-used-y := $(sort $(foreach m,$(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
51- multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))), $(m))))
51+ multi-used-m := $(sort $(foreach m,$(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) ), $(m))))
5252multi-used := $(multi-used-y) $(multi-used-m)
5353single-used-m := $(sort $(filter-out $(multi-used-m),$(obj-m)))
5454
@@ -67,7 +67,7 @@ obj-dirs := $(dir $(multi-objs) $(obj-y))
6767
6868# Replace multi-part objects by their individual parts, look at local dir only
6969real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
70- real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))) ,$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
70+ real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m))) ,$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m )),$(m)))
7171
7272# Add subdir path
7373
@@ -96,16 +96,17 @@ obj-dirs := $(addprefix $(obj)/,$(obj-dirs))
9696# Note: Files that end up in two or more modules are compiled without the
9797# KBUILD_MODNAME definition. The reason is that any made-up name would
9898# differ in different configs.
99- name-fix = $(subst $(comma),_,$(subst -,_,$1))
100- basename_flags = -D"KBUILD_BASENAME=KBUILD_STR( $(call name-fix,$(basetarget)))"
99+ name-fix = $(squote)$(quote)$( subst $(comma),_,$(subst -,_,$1))$(quote)$(squote )
100+ basename_flags = -DKBUILD_BASENAME= $(call name-fix,$(basetarget))
101101modname_flags = $(if $(filter 1,$(words $(modname))),\
102- -D"KBUILD_MODNAME=KBUILD_STR( $(call name-fix,$(modname)))" )
102+ -DKBUILD_MODNAME= $(call name-fix,$(modname)))
103103
104104orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) $(KBUILD_SUBDIR_CCFLAGS) \
105105 $(ccflags-y) $(CFLAGS_$(basetarget).o)
106106_c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
107- _a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \
107+ orig_a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) $(KBUILD_SUBDIR_ASFLAGS) \
108108 $(asflags-y) $(AFLAGS_$(basetarget).o)
109+ _a_flags = $(filter-out $(AFLAGS_REMOVE_$(basetarget).o), $(orig_a_flags))
109110_cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
110111
111112#
@@ -129,6 +130,18 @@ _c_flags += $(if $(patsubst n%,, \
129130 $(CFLAGS_KASAN))
130131endif
131132
133+ ifeq ($(CONFIG_UBSAN),y)
134+ _c_flags += $(if $(patsubst n%,, \
135+ $(UBSAN_SANITIZE_$(basetarget).o)$(UBSAN_SANITIZE)$(CONFIG_UBSAN_SANITIZE_ALL)), \
136+ $(CFLAGS_UBSAN))
137+ endif
138+
139+ ifeq ($(CONFIG_KCOV),y)
140+ _c_flags += $(if $(patsubst n%,, \
141+ $(KCOV_INSTRUMENT_$(basetarget).o)$(KCOV_INSTRUMENT)$(CONFIG_KCOV_INSTRUMENT_ALL)), \
142+ $(CFLAGS_KCOV))
143+ endif
144+
132145# If building the kernel in a separate objtree expand all occurrences
133146# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
134147
@@ -142,14 +155,15 @@ else
142155# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
143156# and locates generated .h files
144157# FIXME: Replace both with specific CFLAGS* statements in the makefiles
145- __c_flags = $(call addtree,-I$(obj)) $(call flags,_c_flags)
158+ __c_flags = $(if $(obj),-I$(srctree)/$(src) -I$(obj)) \
159+ $(call flags,_c_flags)
146160__a_flags = $(call flags,_a_flags)
147161__cpp_flags = $(call flags,_cpp_flags)
148162endif
149163
150164c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
151165 $(__c_flags) $(modkern_cflags) \
152- -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
166+ $(basename_flags) $(modname_flags)
153167
154168a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
155169 $(__a_flags) $(modkern_aflags)
@@ -262,6 +276,12 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
262276
263277# DTC
264278# ---------------------------------------------------------------------------
279+ DTC ?= $(objtree)/scripts/dtc/dtc
280+
281+ # Disable noisy checks by default
282+ ifeq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
283+ DTC_FLAGS += -Wno-unit_address_vs_reg
284+ endif
265285
266286# Generate an assembly file to wrap the output of the device tree compiler
267287quiet_cmd_dt_S_dtb= DTB $@
@@ -284,21 +304,26 @@ $(obj)/%.dtb.S: $(obj)/%.dtb
284304quiet_cmd_dtc = DTC $@
285305cmd_dtc = mkdir -p $(dir ${dtc-tmp}) ; \
286306 $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
287- $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \
307+ $(DTC) -O dtb -o $@ -b 0 \
288308 -i $(dir $<) $(DTC_FLAGS) \
289309 -d $(depfile).dtc.tmp $(dtc-tmp) ; \
290310 cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
291311
292312$(obj)/%.dtb: $(src)/%.dts FORCE
293313 $(call if_changed_dep,dtc)
294314
295- dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
315+ quiet_cmd_dtco = DTCO $@
316+ cmd_dtco = mkdir -p $(dir ${dtc-tmp}) ; \
317+ $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
318+ $(DTC) -@ -H epapr -O dtb -o $@ -b 0 \
319+ -i $(dir $<) $(DTC_FLAGS) \
320+ -d $(depfile).dtc.tmp $(dtc-tmp) ; \
321+ cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
296322
297- # cat
298- # ---------------------------------------------------------------------------
299- # Concatentate multiple files together
300- quiet_cmd_cat = CAT $@
301- cmd_cat = (cat $(filter-out FORCE,$^) > $@) || (rm -f $@; false)
323+ $(obj)/%.dtbo: $(src)/%-overlay.dts FORCE
324+ $(call if_changed_dep,dtco)
325+
326+ dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
302327
303328# Bzip2
304329# ---------------------------------------------------------------------------
0 commit comments