kbuild: do not add srctree to sysroot relative includes
PATCH 1/1 kbuild: do not add srctree to sysroot relative includes
We need to filter out also -I=/path to allow sysroot relative include paths in the makefiles of external modules.
--- scripts/Kbuild.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/Kbuild.include +1 -1
@@ -206,7 +206,7 @@ hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj # Prefix -I with $(srctree) if it is not an absolute path. # skip if -I has no parameter addtree = $(if $(patsubst -I%,%,$(1)), \ -$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1))) +$(if $(filter-out -I/% -I./% -I../% -I=%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1))) # Find all -I options and call addtree flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
Signature · 1 line
2.1.4
Quoted 13 lines · Lars Persson
We need to filter out also -I=/path to allow sysroot relative include paths in the makefiles of external modules.
Signed-off-by Lars Persson <[email protected]>--- scripts/Kbuild.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/Kbuild.include +0
-0
scripts/Kbuild.include hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj · line 209
Quoted 5 lines
scripts/Kbuild.include +1
-1@@ -206,7 +206,7 @@ hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj # Prefix -I with $(srctree) if it is not an absolute path. # skip if -I has no parameter addtree = $(if $(patsubst -I%,%,$(1)), \ -$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1))) +$(if $(filter-out -I/% -I./% -I../% -I=%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)))
Hi Lars,
Two questions: 1) Where is the -I=/... syntax documented? I could not find it gcc docs. 2) Why do these Makefiles use --sysroot at all? The kernel does not use any system libraries and the host programs are compiled for the host architecture.
Michal
Quoted 22 lines · Michal Marek
Quoted 13 lines · Lars Persson
We need to filter out also -I=/path to allow sysroot relative include paths in the makefiles of external modules.
Signed-off-by Lars Persson <[email protected]>--- scripts/Kbuild.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)scripts/Kbuild.include +0
-0scripts/Kbuild.include hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj · line 209
Quoted 5 lines
scripts/Kbuild.include +1
-1@@ -206,7 +206,7 @@ hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj # Prefix -I with $(srctree) if it is not an absolute path. # skip if -I has no parameter addtree = $(if $(patsubst -I%,%,$(1)), \ -$(if $(filter-out -I/% -I./% -I../%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1))) +$(if $(filter-out -I/% -I./% -I../% -I=%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1)),$(1)))Hi Lars,
Quoted 2 lines
Two questions: 1) Where is the -I=/... syntax documented? I could not find it gcc docs.
You should find this in your gcc manual:
If dir begins with "=", then the "=" will be replaced by the sysroot prefix; see --sysroot and -isysroot.
2) Why do these Makefiles use --sysroot at all? The
Quoted 2 lines
kernel does not use any system libraries and the host programs are compiled for the host architecture.
One use-case is with the yocto build system. Suppose we have two kernel modules A and B. A installs header files into the sysroot that B will include.
- Lars