* [PATCH 1/2] kbuild: skip 'addtree' and 'flags' magic for external module build
@ 2019-01-16 2:56 Masahiro Yamada
2019-01-16 2:56 ` [PATCH 2/2] kbuild: add -I$(srctree)/$(src) automatically for hostprogs with O= Masahiro Yamada
2019-01-24 4:28 ` [PATCH 1/2] kbuild: skip 'addtree' and 'flags' magic for external module build Masahiro Yamada
0 siblings, 2 replies; 4+ messages in thread
From: Masahiro Yamada @ 2019-01-16 2:56 UTC (permalink / raw)
To: linux-kbuild; +Cc: devicetree, Masahiro Yamada, Michal Marek, linux-kernel
When building an external module, $(obj) is the absolute path to it.
The header search paths from ccflags-y etc. should not be tweaked.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
scripts/Makefile.host | 6 ++++--
scripts/Makefile.lib | 11 ++++++-----
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index 0393f75..a115259 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -67,13 +67,15 @@ _hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
_hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
$(HOSTCXXFLAGS_$(basetarget).o)
-ifeq ($(KBUILD_SRC),)
__hostc_flags = $(_hostc_flags)
__hostcxx_flags = $(_hostcxx_flags)
-else
+
+ifeq ($(KBUILD_EXTMOD),)
+ifneq ($(KBUILD_SRC),)
__hostc_flags = -I$(obj) $(call flags,_hostc_flags)
__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags)
endif
+endif
hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags)
hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 12b88d0..ecad15b 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -137,14 +137,14 @@ _c_flags += $(if $(patsubst n%,, \
$(CFLAGS_KCOV))
endif
-# If building the kernel in a separate objtree expand all occurrences
-# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
-
-ifeq ($(KBUILD_SRC),)
__c_flags = $(_c_flags)
__a_flags = $(_a_flags)
__cpp_flags = $(_cpp_flags)
-else
+
+# If building the kernel in a separate objtree expand all occurrences
+# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
+ifeq ($(KBUILD_EXTMOD),)
+ifneq ($(KBUILD_SRC),)
# -I$(obj) locates generated .h files
# $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
@@ -155,6 +155,7 @@ __c_flags = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \
__a_flags = $(call flags,_a_flags)
__cpp_flags = $(call flags,_cpp_flags)
endif
+endif
c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
-include $(srctree)/include/linux/compiler_types.h \
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] kbuild: add -I$(srctree)/$(src) automatically for hostprogs with O=
2019-01-16 2:56 [PATCH 1/2] kbuild: skip 'addtree' and 'flags' magic for external module build Masahiro Yamada
@ 2019-01-16 2:56 ` Masahiro Yamada
2019-01-17 12:09 ` Masahiro Yamada
2019-01-24 4:28 ` [PATCH 1/2] kbuild: skip 'addtree' and 'flags' magic for external module build Masahiro Yamada
1 sibling, 1 reply; 4+ messages in thread
From: Masahiro Yamada @ 2019-01-16 2:56 UTC (permalink / raw)
To: linux-kbuild
Cc: devicetree, Masahiro Yamada, linux-kernel, Michal Marek,
Mauro Rossi, Rob Herring, Frank Rowand
When building kernel objects with the O= option, scripts/Makefile.lib
automatically adds both -I$(srctree)/$(src) and -I$(obj) so each
Makefile does not need to add them explicitly.
In contrast, scripts/Makefile.host adds only -I$(obj) when building
host programs with the O= option. As a result, each Makefile must add
the extra option to include checkin headers from generated C files.
Let's cater to this in the build system for consistency, and drop
extra options from the kconfig, dtc, genksyms Makefiles.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---
scripts/Makefile.host | 4 ++--
scripts/dtc/Makefile | 4 ----
scripts/genksyms/Makefile | 4 ----
scripts/kconfig/Makefile | 2 --
4 files changed, 2 insertions(+), 12 deletions(-)
diff --git a/scripts/Makefile.host b/scripts/Makefile.host
index a115259..c41d5a1d 100644
--- a/scripts/Makefile.host
+++ b/scripts/Makefile.host
@@ -72,8 +72,8 @@ __hostcxx_flags = $(_hostcxx_flags)
ifeq ($(KBUILD_EXTMOD),)
ifneq ($(KBUILD_SRC),)
-__hostc_flags = -I$(obj) $(call flags,_hostc_flags)
-__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags)
+__hostc_flags = -I $(srctree)/$(src) -I $(obj) $(call flags,_hostc_flags)
+__hostcxx_flags = -I $(srctree)/$(src) -I $(obj) $(call flags,_hostcxx_flags)
endif
endif
diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
index 5f227d8..72d3fa4 100644
--- a/scripts/dtc/Makefile
+++ b/scripts/dtc/Makefile
@@ -22,9 +22,5 @@ dtc-objs += yamltree.o
HOSTLDLIBS_dtc := -lyaml
endif
-# Generated files need one more search path to include headers in source tree
-HOSTCFLAGS_dtc-lexer.lex.o := -I$(src)
-HOSTCFLAGS_dtc-parser.tab.o := -I$(src)
-
# dependencies on generated files need to be listed explicitly
$(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h
diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
index 03b7ce9..ae5953d 100644
--- a/scripts/genksyms/Makefile
+++ b/scripts/genksyms/Makefile
@@ -30,9 +30,5 @@ $(obj)/parse.tab.h: $(src)/parse.y FORCE
endif
-# -I needed for generated C source (shipped source)
-HOSTCFLAGS_parse.tab.o := -I$(src)
-HOSTCFLAGS_lex.lex.o := -I$(src)
-
# dependencies on generated files need to be listed explicitly
$(obj)/lex.lex.o: $(obj)/parse.tab.h
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 1819735..12cb5eb 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -146,8 +146,6 @@ help:
common-objs := confdata.o expr.o symbol.o preprocess.o zconf.lex.o zconf.tab.o
$(obj)/zconf.lex.o: $(obj)/zconf.tab.h
-HOSTCFLAGS_zconf.lex.o := -I$(src)
-HOSTCFLAGS_zconf.tab.o := -I$(src)
# conf: Used for defconfig, oldconfig and related targets
hostprogs-y += conf
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] kbuild: add -I$(srctree)/$(src) automatically for hostprogs with O=
2019-01-16 2:56 ` [PATCH 2/2] kbuild: add -I$(srctree)/$(src) automatically for hostprogs with O= Masahiro Yamada
@ 2019-01-17 12:09 ` Masahiro Yamada
0 siblings, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2019-01-17 12:09 UTC (permalink / raw)
To: Linux Kbuild mailing list
Cc: DTML, Linux Kernel Mailing List, Michal Marek, Mauro Rossi,
Rob Herring, Frank Rowand, Michael Ellerman
On Thu, Jan 17, 2019 at 1:18 AM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> When building kernel objects with the O= option, scripts/Makefile.lib
> automatically adds both -I$(srctree)/$(src) and -I$(obj) so each
> Makefile does not need to add them explicitly.
>
> In contrast, scripts/Makefile.host adds only -I$(obj) when building
> host programs with the O= option. As a result, each Makefile must add
> the extra option to include checkin headers from generated C files.
>
> Let's cater to this in the build system for consistency, and drop
> extra options from the kconfig, dtc, genksyms Makefiles.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
I take back this patch.
I noticed this would break out-of-tree build of PowerPC.
I attached the error log below.
The error summary is, the host program
arch/powerpc/mktree.c is including arch/powerpc/types.h
via a system header.
In arch/powerpc/boot, there are lots of headers
whose name is the same as the system header,
such as types.h, string.h, stdint.h, etc.
HOSTCC arch/powerpc/boot/mktree
In file included from /usr/include/x86_64-linux-gnu/sys/uio.h:23:0,
from /usr/include/x86_64-linux-gnu/sys/socket.h:26,
from /usr/include/netinet/in.h:23,
from ../arch/powerpc/boot/mktree.c:18:
/usr/include/x86_64-linux-gnu/sys/types.h:197:1: error: conflicting
types for ‘int64_t’
__intN_t (64, __DI__);
^
In file included from ../arch/powerpc/boot/stdint.h:13:0,
from /usr/include/netinet/in.h:22,
from ../arch/powerpc/boot/mktree.c:18:
../arch/powerpc/boot/types.h:26:13: note: previous declaration of
‘int64_t’ was here
typedef s64 int64_t;
^
../arch/powerpc/boot/mktree.c: In function ‘main’:
../arch/powerpc/boot/mktree.c:52:3: warning: implicit declaration of
function ‘exit’ [-Wimplicit-function-declaration]
exit(1);
^
../arch/powerpc/boot/mktree.c:52:3: warning: incompatible implicit
declaration of built-in function ‘exit’
../arch/powerpc/boot/mktree.c:52:3: note: include ‘<stdlib.h>’ or
provide a declaration of ‘exit’
../arch/powerpc/boot/mktree.c:56:3: warning: implicit declaration of
function ‘perror’ [-Wimplicit-function-declaration]
perror("stat");
^
../arch/powerpc/boot/mktree.c:57:3: warning: incompatible implicit
declaration of built-in function ‘exit’
exit(2);
^
../arch/powerpc/boot/mktree.c:57:3: note: include ‘<stdlib.h>’ or
provide a declaration of ‘exit’
In file included from ../arch/powerpc/boot/mktree.c:18:0:
../arch/powerpc/boot/mktree.c:65:21: warning: implicit declaration of
function ‘strtoul’ [-Wimplicit-function-declaration]
bt.bb_dest = htonl(strtoul(argv[3], NULL, 0));
^
../arch/powerpc/boot/mktree.c:84:3: warning: incompatible implicit
declaration of built-in function ‘exit’
exit(3);
^
../arch/powerpc/boot/mktree.c:84:3: note: include ‘<stdlib.h>’ or
provide a declaration of ‘exit’
../arch/powerpc/boot/mktree.c:89:3: warning: incompatible implicit
declaration of built-in function ‘exit’
exit(3);
^
../arch/powerpc/boot/mktree.c:89:3: note: include ‘<stdlib.h>’ or
provide a declaration of ‘exit’
../arch/powerpc/boot/mktree.c:102:3: warning: incompatible implicit
declaration of built-in function ‘exit’
exit(4);
^
../arch/powerpc/boot/mktree.c:102:3: note: include ‘<stdlib.h>’ or
provide a declaration of ‘exit’
../arch/powerpc/boot/mktree.c:107:3: warning: incompatible implicit
declaration of built-in function ‘exit’
exit(4);
^
../arch/powerpc/boot/mktree.c:107:3: note: include ‘<stdlib.h>’ or
provide a declaration of ‘exit’
../arch/powerpc/boot/mktree.c:112:3: warning: incompatible implicit
declaration of built-in function ‘exit’
exit(4);
^
../arch/powerpc/boot/mktree.c:112:3: note: include ‘<stdlib.h>’ or
provide a declaration of ‘exit’
../arch/powerpc/boot/mktree.c:121:3: warning: incompatible implicit
declaration of built-in function ‘exit’
exit(5);
^
../arch/powerpc/boot/mktree.c:121:3: note: include ‘<stdlib.h>’ or
provide a declaration of ‘exit’
../arch/powerpc/boot/mktree.c:127:4: warning: incompatible implicit
declaration of built-in function ‘exit’
exit(5);
^
../arch/powerpc/boot/mktree.c:127:4: note: include ‘<stdlib.h>’ or
provide a declaration of ‘exit’
../arch/powerpc/boot/mktree.c:134:4: warning: incompatible implicit
declaration of built-in function ‘exit’
exit(5);
^
../arch/powerpc/boot/mktree.c:134:4: note: include ‘<stdlib.h>’ or
provide a declaration of ‘exit’
../arch/powerpc/boot/mktree.c:143:3: warning: incompatible implicit
declaration of built-in function ‘exit’
exit(1);
^
../arch/powerpc/boot/mktree.c:143:3: note: include ‘<stdlib.h>’ or
provide a declaration of ‘exit’
../arch/powerpc/boot/mktree.c:147:3: warning: incompatible implicit
declaration of built-in function ‘exit’
exit(1);
^
../arch/powerpc/boot/mktree.c:147:3: note: include ‘<stdlib.h>’ or
provide a declaration of ‘exit’
../arch/powerpc/boot/mktree.c:150:2: warning: incompatible implicit
declaration of built-in function ‘exit’
exit(0);
^
../arch/powerpc/boot/mktree.c:150:2: note: include ‘<stdlib.h>’ or
provide a declaration of ‘exit’
>
> scripts/Makefile.host | 4 ++--
> scripts/dtc/Makefile | 4 ----
> scripts/genksyms/Makefile | 4 ----
> scripts/kconfig/Makefile | 2 --
> 4 files changed, 2 insertions(+), 12 deletions(-)
>
> diff --git a/scripts/Makefile.host b/scripts/Makefile.host
> index a115259..c41d5a1d 100644
> --- a/scripts/Makefile.host
> +++ b/scripts/Makefile.host
> @@ -72,8 +72,8 @@ __hostcxx_flags = $(_hostcxx_flags)
>
> ifeq ($(KBUILD_EXTMOD),)
> ifneq ($(KBUILD_SRC),)
> -__hostc_flags = -I$(obj) $(call flags,_hostc_flags)
> -__hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags)
> +__hostc_flags = -I $(srctree)/$(src) -I $(obj) $(call flags,_hostc_flags)
> +__hostcxx_flags = -I $(srctree)/$(src) -I $(obj) $(call flags,_hostcxx_flags)
> endif
> endif
>
> diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile
> index 5f227d8..72d3fa4 100644
> --- a/scripts/dtc/Makefile
> +++ b/scripts/dtc/Makefile
> @@ -22,9 +22,5 @@ dtc-objs += yamltree.o
> HOSTLDLIBS_dtc := -lyaml
> endif
>
> -# Generated files need one more search path to include headers in source tree
> -HOSTCFLAGS_dtc-lexer.lex.o := -I$(src)
> -HOSTCFLAGS_dtc-parser.tab.o := -I$(src)
> -
> # dependencies on generated files need to be listed explicitly
> $(obj)/dtc-lexer.lex.o: $(obj)/dtc-parser.tab.h
> diff --git a/scripts/genksyms/Makefile b/scripts/genksyms/Makefile
> index 03b7ce9..ae5953d 100644
> --- a/scripts/genksyms/Makefile
> +++ b/scripts/genksyms/Makefile
> @@ -30,9 +30,5 @@ $(obj)/parse.tab.h: $(src)/parse.y FORCE
>
> endif
>
> -# -I needed for generated C source (shipped source)
> -HOSTCFLAGS_parse.tab.o := -I$(src)
> -HOSTCFLAGS_lex.lex.o := -I$(src)
> -
> # dependencies on generated files need to be listed explicitly
> $(obj)/lex.lex.o: $(obj)/parse.tab.h
> diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
> index 1819735..12cb5eb 100644
> --- a/scripts/kconfig/Makefile
> +++ b/scripts/kconfig/Makefile
> @@ -146,8 +146,6 @@ help:
> common-objs := confdata.o expr.o symbol.o preprocess.o zconf.lex.o zconf.tab.o
>
> $(obj)/zconf.lex.o: $(obj)/zconf.tab.h
> -HOSTCFLAGS_zconf.lex.o := -I$(src)
> -HOSTCFLAGS_zconf.tab.o := -I$(src)
>
> # conf: Used for defconfig, oldconfig and related targets
> hostprogs-y += conf
> --
> 2.7.4
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] kbuild: skip 'addtree' and 'flags' magic for external module build
2019-01-16 2:56 [PATCH 1/2] kbuild: skip 'addtree' and 'flags' magic for external module build Masahiro Yamada
2019-01-16 2:56 ` [PATCH 2/2] kbuild: add -I$(srctree)/$(src) automatically for hostprogs with O= Masahiro Yamada
@ 2019-01-24 4:28 ` Masahiro Yamada
1 sibling, 0 replies; 4+ messages in thread
From: Masahiro Yamada @ 2019-01-24 4:28 UTC (permalink / raw)
To: Linux Kbuild mailing list; +Cc: DTML, Michal Marek, Linux Kernel Mailing List
On Thu, Jan 17, 2019 at 1:18 AM Masahiro Yamada
<yamada.masahiro@socionext.com> wrote:
>
> When building an external module, $(obj) is the absolute path to it.
>
> The header search paths from ccflags-y etc. should not be tweaked.
>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
Applied to linux-kbuild.
(2/2 was discarded.)
> scripts/Makefile.host | 6 ++++--
> scripts/Makefile.lib | 11 ++++++-----
> 2 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/scripts/Makefile.host b/scripts/Makefile.host
> index 0393f75..a115259 100644
> --- a/scripts/Makefile.host
> +++ b/scripts/Makefile.host
> @@ -67,13 +67,15 @@ _hostc_flags = $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS) \
> _hostcxx_flags = $(KBUILD_HOSTCXXFLAGS) $(HOST_EXTRACXXFLAGS) \
> $(HOSTCXXFLAGS_$(basetarget).o)
>
> -ifeq ($(KBUILD_SRC),)
> __hostc_flags = $(_hostc_flags)
> __hostcxx_flags = $(_hostcxx_flags)
> -else
> +
> +ifeq ($(KBUILD_EXTMOD),)
> +ifneq ($(KBUILD_SRC),)
> __hostc_flags = -I$(obj) $(call flags,_hostc_flags)
> __hostcxx_flags = -I$(obj) $(call flags,_hostcxx_flags)
> endif
> +endif
>
> hostc_flags = -Wp,-MD,$(depfile) $(__hostc_flags)
> hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags)
> diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
> index 12b88d0..ecad15b 100644
> --- a/scripts/Makefile.lib
> +++ b/scripts/Makefile.lib
> @@ -137,14 +137,14 @@ _c_flags += $(if $(patsubst n%,, \
> $(CFLAGS_KCOV))
> endif
>
> -# If building the kernel in a separate objtree expand all occurrences
> -# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
> -
> -ifeq ($(KBUILD_SRC),)
> __c_flags = $(_c_flags)
> __a_flags = $(_a_flags)
> __cpp_flags = $(_cpp_flags)
> -else
> +
> +# If building the kernel in a separate objtree expand all occurrences
> +# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
> +ifeq ($(KBUILD_EXTMOD),)
> +ifneq ($(KBUILD_SRC),)
>
> # -I$(obj) locates generated .h files
> # $(call addtree,-I$(obj)) locates .h files in srctree, from generated .c files
> @@ -155,6 +155,7 @@ __c_flags = $(if $(obj),$(call addtree,-I$(src)) -I$(obj)) \
> __a_flags = $(call flags,_a_flags)
> __cpp_flags = $(call flags,_cpp_flags)
> endif
> +endif
>
> c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
> -include $(srctree)/include/linux/compiler_types.h \
> --
> 2.7.4
>
--
Best Regards
Masahiro Yamada
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-24 4:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-16 2:56 [PATCH 1/2] kbuild: skip 'addtree' and 'flags' magic for external module build Masahiro Yamada
2019-01-16 2:56 ` [PATCH 2/2] kbuild: add -I$(srctree)/$(src) automatically for hostprogs with O= Masahiro Yamada
2019-01-17 12:09 ` Masahiro Yamada
2019-01-24 4:28 ` [PATCH 1/2] kbuild: skip 'addtree' and 'flags' magic for external module build Masahiro Yamada
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).