diff mbox series

[3/3] kbuild: check the presence of lzo and lz4 tools when necessary

Message ID 1539681053-24388-4-git-send-email-yamada.masahiro@socionext.com (mailing list archive)
State New, archived
Headers show
Series kbuild: add scripts/Makefile.toolcheck to check necessary host tools | expand

Commit Message

Masahiro Yamada Oct. 16, 2018, 9:10 a.m. UTC
If CONFIG_KERNEL_LZ4 is enabled without lz4 tool installed on the
system, the build fails at the very last stage (reported by
Borislav Petkov [1]).

  LZO     arch/x86/boot/compressed/vmlinux.bin.lzo
/bin/sh: 1: lzop: not found
arch/x86/boot/compressed/Makefile:141: recipe for target 'arch/x86/boot/compressed/vmlinux.bin.lzo' failed
make[2]: *** [arch/x86/boot/compressed/vmlinux.bin.lzo] Error 1
arch/x86/boot/Makefile:112: recipe for target 'arch/x86/boot/compressed/vmlinux' failed
make[1]: *** [arch/x86/boot/compressed/vmlinux] Error 2
arch/x86/Makefile:284: recipe for target 'bzImage' failed
make: *** [bzImage] Error 2

Check the tools in scripts/Makefile.toolcheck to fail the build
earlier with a more readable message.

[1] https://patchwork.kernel.org/patch/10635381/

Suggested-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 scripts/Makefile.toolcheck | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Masahiro Yamada Oct. 17, 2018, 8:59 a.m. UTC | #1
On Wed, Oct 17, 2018 at 4:56 AM Borislav Petkov <bp@suse.de> wrote:
>
> On Tue, Oct 16, 2018 at 06:10:53PM +0900, Masahiro Yamada wrote:
> > If CONFIG_KERNEL_LZ4 is enabled without lz4 tool installed on the
> > system, the build fails at the very last stage (reported by
> > Borislav Petkov [1]).
> >
> >   LZO     arch/x86/boot/compressed/vmlinux.bin.lzo
> > /bin/sh: 1: lzop: not found
> > arch/x86/boot/compressed/Makefile:141: recipe for target 'arch/x86/boot/compressed/vmlinux.bin.lzo' failed
> > make[2]: *** [arch/x86/boot/compressed/vmlinux.bin.lzo] Error 1
> > arch/x86/boot/Makefile:112: recipe for target 'arch/x86/boot/compressed/vmlinux' failed
> > make[1]: *** [arch/x86/boot/compressed/vmlinux] Error 2
> > arch/x86/Makefile:284: recipe for target 'bzImage' failed
> > make: *** [bzImage] Error 2
> >
> > Check the tools in scripts/Makefile.toolcheck to fail the build
> > earlier with a more readable message.
> >
> > [1] https://patchwork.kernel.org/patch/10635381/
> >
> > Suggested-by: Borislav Petkov <bp@suse.de>
> > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> > ---
> >
> >  scripts/Makefile.toolcheck | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/scripts/Makefile.toolcheck b/scripts/Makefile.toolcheck
> > index bc26fc0..5e336e4 100644
> > --- a/scripts/Makefile.toolcheck
> > +++ b/scripts/Makefile.toolcheck
> > @@ -17,6 +17,14 @@ msg_stack_validation = "libelf is necessary for building the objtool." \
> >                      "Please install libelf-dev, libelf-devel or elfutils-libelf-devel."
> >  toolcheck-$(CONFIG_STACK_VALIDATION) += stack_validation
> >
> > +chk_lzo = command -v lzop
> > +msg_lzo = "lzo tool not found. Please install it."
> > +toolcheck-$(CONFIG_KERNEL_LZO) += lzo
> > +
> > +chk_lz4 = command -v lz4c
> > +msg_lz4 = "lz4 tool not found. Please install it."
> > +toolcheck-$(CONFIG_KERNEL_LZ4) += lz4
> > +
> >  PHONY += $(toolcheck-y)
> >  __toolcheck: $(toolcheck-y)
> >
> > --
>
> Cool, thanks for doing that!
>
> However, I applied all three, cleaned up the tree properly:
>
> $ git clean -dqfx
>
> and then used my .config (attached) which selects CONFIG_KERNEL_LZ4.
>
> And I built it twice just to make sure I'm seeing correctly but the
> error still happens at the end:
>
>   DESCEND  objtool
>   CALL    scripts/checksyscalls.sh
>   CHK     include/generated/compile.h
>   Building modules, stage 2.
>   CC      arch/x86/boot/compressed/misc.o
>   LZ4     arch/x86/boot/compressed/vmlinux.bin.lz4
> /bin/sh: 1: lz4c: not found
> make[2]: *** [arch/x86/boot/compressed/Makefile:143: arch/x86/boot/compressed/vmlinux.bin.lz4] Error 1
> make[2]: *** Waiting for unfinished jobs....
> make[1]: *** [arch/x86/boot/Makefile:112: arch/x86/boot/compressed/vmlinux] Error 2
> make: *** [arch/x86/Makefile:290: bzImage] Error 2
> make: *** Waiting for unfinished jobs....
>   MODPOST 956 modules
>
> What am I missing?


I have no idea.

With liblz4-tool package installed on my machine,
I can build x86 kernel with CONFIG_KERNEL_LZ4.
Borislav Petkov Oct. 17, 2018, 9:10 a.m. UTC | #2
On Wed, Oct 17, 2018 at 05:59:02PM +0900, Masahiro Yamada wrote:
> >   DESCEND  objtool
> >   CALL    scripts/checksyscalls.sh
> >   CHK     include/generated/compile.h
> >   Building modules, stage 2.
> >   CC      arch/x86/boot/compressed/misc.o
> >   LZ4     arch/x86/boot/compressed/vmlinux.bin.lz4
> > /bin/sh: 1: lz4c: not found
> > make[2]: *** [arch/x86/boot/compressed/Makefile:143: arch/x86/boot/compressed/vmlinux.bin.lz4] Error 1
> > make[2]: *** Waiting for unfinished jobs....
> > make[1]: *** [arch/x86/boot/Makefile:112: arch/x86/boot/compressed/vmlinux] Error 2
> > make: *** [arch/x86/Makefile:290: bzImage] Error 2
> > make: *** Waiting for unfinished jobs....
> >   MODPOST 956 modules
> >
> > What am I missing?
> 
> 
> I have no idea.
> 
> With liblz4-tool package installed on my machine,
> I can build x86 kernel with CONFIG_KERNEL_LZ4.

What happens if you remove the lz4c executable? Do you see the ugly
error above or the "lz4 tool not found. Please install it." message with
my config?
Masahiro Yamada Oct. 17, 2018, 9:25 a.m. UTC | #3
On Wed, Oct 17, 2018 at 6:12 PM Borislav Petkov <bp@suse.de> wrote:
>
> On Wed, Oct 17, 2018 at 05:59:02PM +0900, Masahiro Yamada wrote:
> > >   DESCEND  objtool
> > >   CALL    scripts/checksyscalls.sh
> > >   CHK     include/generated/compile.h
> > >   Building modules, stage 2.
> > >   CC      arch/x86/boot/compressed/misc.o
> > >   LZ4     arch/x86/boot/compressed/vmlinux.bin.lz4
> > > /bin/sh: 1: lz4c: not found
> > > make[2]: *** [arch/x86/boot/compressed/Makefile:143: arch/x86/boot/compressed/vmlinux.bin.lz4] Error 1
> > > make[2]: *** Waiting for unfinished jobs....
> > > make[1]: *** [arch/x86/boot/Makefile:112: arch/x86/boot/compressed/vmlinux] Error 2
> > > make: *** [arch/x86/Makefile:290: bzImage] Error 2
> > > make: *** Waiting for unfinished jobs....
> > >   MODPOST 956 modules
> > >
> > > What am I missing?
> >
> >
> > I have no idea.
> >
> > With liblz4-tool package installed on my machine,
> > I can build x86 kernel with CONFIG_KERNEL_LZ4.
>
> What happens if you remove the lz4c executable? Do you see the ugly
> error above or the "lz4 tool not found. Please install it." message with
> my config?
>

I tried that.
I can see the expected error message.



masahiro@pug:~/ref/linux$ git log  --oneline  | head -n 4
6cd6271 kbuild: check the presence of lzo and lz4 tools when necessary
b72cfb7 objtool: move libelf check out of top Makefile
e3061d8 kbuild: provide a new place to check necessary host tools
b955a91 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
masahiro@pug:~/ref/linux$ git clean -dqfx
masahiro@pug:~/ref/linux$ cp ~/Downloads/config.lz4  .config
masahiro@pug:~/ref/linux$ sudo mv /usr/bin/lz4c /usr/bin/lz4c.backup
[sudo] password for masahiro:
masahiro@pug:~/ref/linux$ make
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  YACC    scripts/kconfig/zconf.tab.c
  LEX     scripts/kconfig/zconf.lex.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf  --syncconfig Kconfig
*
* Restart config...
*
*
* GCC plugins
*
GCC plugins (GCC_PLUGINS) [N/y/?] (NEW)
*
* lz4 tool not found. Please install it.
*
make[1]: *** [scripts/Makefile.toolcheck;46: check_lz4] Error 1
Makefile:595: include/config/auto.conf: No such file or directory
make: *** [Makefile;636: include/config/auto.conf] Error 2
make: *** Deleting file 'include/config/auto.conf'
Borislav Petkov Oct. 17, 2018, 9:47 a.m. UTC | #4
On Wed, Oct 17, 2018 at 06:25:23PM +0900, Masahiro Yamada wrote:
> masahiro@pug:~/ref/linux$ git log  --oneline  | head -n 4
> 6cd6271 kbuild: check the presence of lzo and lz4 tools when necessary
> b72cfb7 objtool: move libelf check out of top Makefile
> e3061d8 kbuild: provide a new place to check necessary host tools
> b955a91 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc
> masahiro@pug:~/ref/linux$ git clean -dqfx
> masahiro@pug:~/ref/linux$ cp ~/Downloads/config.lz4  .config
> masahiro@pug:~/ref/linux$ sudo mv /usr/bin/lz4c /usr/bin/lz4c.backup
> [sudo] password for masahiro:
> masahiro@pug:~/ref/linux$ make
>   HOSTCC  scripts/basic/fixdep
>   HOSTCC  scripts/kconfig/conf.o
>   YACC    scripts/kconfig/zconf.tab.c
>   LEX     scripts/kconfig/zconf.lex.c
>   HOSTCC  scripts/kconfig/zconf.tab.o
>   HOSTLD  scripts/kconfig/conf
> scripts/kconfig/conf  --syncconfig Kconfig
> *
> * Restart config...
> *
> *
> * GCC plugins
> *
> GCC plugins (GCC_PLUGINS) [N/y/?] (NEW)
> *
> * lz4 tool not found. Please install it.
> *
> make[1]: *** [scripts/Makefile.toolcheck;46: check_lz4] Error 1
> Makefile:595: include/config/auto.conf: No such file or directory
> make: *** [Makefile;636: include/config/auto.conf] Error 2
> make: *** Deleting file 'include/config/auto.conf'

Ok, gotcha. The difference is the "make oldconfig" I do.

[boris@zn: ~/kernel/linux> git log  --oneline  | head -n 3
57ac85467970 kbuild: check the presence of lzo and lz4 tools when necessary
92a3b44ab988 objtool: move libelf check out of top Makefile
23b142c064a7 kbuild: provide a new place to check necessary host tools
[boris@zn: ~/kernel/linux> git clean -dqfx
[boris@zn: ~/kernel/linux> cp ~/tmp/config.lz4 .config
[boris@zn: ~/kernel/linux> make oldconfig
  HOSTCC  scripts/basic/fixdep
  HOSTCC  scripts/kconfig/conf.o
  YACC    scripts/kconfig/zconf.tab.c
  LEX     scripts/kconfig/zconf.lex.c
  HOSTCC  scripts/kconfig/zconf.tab.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf  --oldconfig Kconfig
#
# configuration written to .config
#
[boris@zn: ~/kernel/linux> make
  SYSTBL  arch/x86/include/generated/asm/syscalls_32.h
  SYSHDR  arch/x86/include/generated/asm/unistd_32_ia32.h
  SYSHDR  arch/x86/include/generated/asm/unistd_64_x32.h
  SYSTBL  arch/x86/include/generated/asm/syscalls_64.h
  HYPERCALLS arch/x86/include/generated/asm/xen-hypercalls.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_32.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_64.h
  SYSHDR  arch/x86/include/generated/uapi/asm/unistd_x32.h
  HOSTCC  arch/x86/tools/relocs_32.o
  HOSTCC  arch/x86/tools/relocs_64.o
  HOSTCC  arch/x86/tools/relocs_common.o
  HOSTLD  arch/x86/tools/relocs
...
diff mbox series

Patch

diff --git a/scripts/Makefile.toolcheck b/scripts/Makefile.toolcheck
index bc26fc0..5e336e4 100644
--- a/scripts/Makefile.toolcheck
+++ b/scripts/Makefile.toolcheck
@@ -17,6 +17,14 @@  msg_stack_validation = "libelf is necessary for building the objtool." \
 		       "Please install libelf-dev, libelf-devel or elfutils-libelf-devel."
 toolcheck-$(CONFIG_STACK_VALIDATION) += stack_validation
 
+chk_lzo = command -v lzop
+msg_lzo = "lzo tool not found. Please install it."
+toolcheck-$(CONFIG_KERNEL_LZO) += lzo
+
+chk_lz4 = command -v lz4c
+msg_lz4 = "lz4 tool not found. Please install it."
+toolcheck-$(CONFIG_KERNEL_LZ4) += lz4
+
 PHONY += $(toolcheck-y)
 __toolcheck: $(toolcheck-y)