Skip to content

Commit db547ef

Browse files
arndbMichal Marek
authored andcommitted
Kbuild: don't add obj tree in additional includes
When building with separate object directories and driver specific Makefiles that add additional header include paths, Kbuild adjusts the gcc flags so that we include both the directory in the source tree and in the object tree. However, due to another bug I fixed earlier, this did not actually include the correct directory in the object tree, so we know that we only really need the source tree here. Also, including the object tree sometimes causes warnings about nonexisting directories when the include path only exists in the source. This changes the logic to only emit the -I argument for the srctree, not for objects. We still need both $(srctree)/$(src) and $(obj) though, so I'm adding them manually. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Michal Marek <mmarek@suse.com>
1 parent 58ab5e0 commit db547ef

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

scripts/Kbuild.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
202202
# Prefix -I with $(srctree) if it is not an absolute path.
203203
# skip if -I has no parameter
204204
addtree = $(if $(patsubst -I%,%,$(1)), \
205-
$(if $(filter-out -I/% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1))
205+
$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)))
206206

207207
# Find all -I options and call addtree
208208
flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))

scripts/Makefile.lib

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,10 @@ else
155155
# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
156156
# and locates generated .h files
157157
# FIXME: Replace both with specific CFLAGS* statements in the makefiles
158-
__c_flags = $(call addtree,-I$(obj)) $(call flags,_c_flags)
159-
__a_flags = $(call flags,_a_flags)
160-
__cpp_flags = $(call flags,_cpp_flags)
158+
__c_flags = $(if $(obj),-I$(srctree)/$(src) -I$(obj)) \
159+
$(call flags,_c_flags)
160+
__a_flags = $(call flags,_a_flags)
161+
__cpp_flags = $(call flags,_cpp_flags)
161162
endif
162163

163164
c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \

0 commit comments

Comments
 (0)