Re: [PATCH] kbuild: fix false positive warning/error about missing libelf

From: Qian Cai
Date: Tue Dec 18 2018 - 09:34:14 EST


On Tue, 2018-12-18 at 14:25 +0900, Masahiro Yamada wrote:
> For the same reason as commit 25896d073d8a ("x86/build: Fix compiler
> support check for CONFIG_RETPOLINE"), you cannot put this $(error ...)
> into the parse stage of the top Makefile.
>
> Perhaps I'd propose a more sophisticated solution later, but this is
> the best I can do for now.
>
> Link: https://lkml.org/lkml/2017/12/25/211
> Reported-by: Paul Gortmaker <paul.gortmaker@xxxxxxxxxxxxx>
> Reported-by: Bernd Edlinger <bernd.edlinger@xxxxxxxxxx>
> Reported-by: Qian Cai <cai@xxxxxx>
> Cc: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> Signed-off-by: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx>
> ---
>

Tested-by: Qian Cai <cai@xxxxxx>

> ÂMakefile | 13 ++++++++-----
> Â1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 56d5270..d45856f 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -962,11 +962,6 @@ ifdef CONFIG_STACK_VALIDATION
> ÂÂÂifeq ($(has_libelf),1)
> ÂÂÂÂÂobjtool_target := tools/objtool FORCE
> ÂÂÂelse
> -ÂÂÂÂifdef CONFIG_UNWINDER_ORC
> -ÂÂÂÂÂÂ$(error "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please
> install libelf-dev, libelf-devel or elfutils-libelf-devel")
> -ÂÂÂÂelse
> -ÂÂÂÂÂÂ$(warning "Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-
> dev, libelf-devel or elfutils-libelf-devel")
> -ÂÂÂÂendif
> ÂÂÂÂÂSKIP_STACK_VALIDATION := 1
> ÂÂÂÂÂexport SKIP_STACK_VALIDATION
> ÂÂÂendif
> @@ -1125,6 +1120,14 @@ uapi-asm-generic:
> Â
> ÂPHONY += prepare-objtool
> Âprepare-objtool: $(objtool_target)
> +ifeq ($(SKIP_STACK_VALIDATION),1)
> +ifdef CONFIG_UNWINDER_ORC
> + @echo "error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y,
> please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
> + @false
> +else
> + @echo "warning: Cannot use CONFIG_STACK_VALIDATION=y, please install
> libelf-dev, libelf-devel or elfutils-libelf-devel" >&2
> +endif
> +endif
> Â
> Â# Generate some files
> Â# ---------------------------------------------------------------------------