Re: [PATCH 2/2] kbuild: add -I$(srctree)/$(src) automatically for hostprogs with O=

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 17, 2019 at 1:18 AM Masahiro Yamada
<yamada.masahiro@xxxxxxxxxxxxx> 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@xxxxxxxxxxxxx>
> ---


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




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux