Re: [PATCH] kbuild: quote OBJCOPY var to avoid a pahole call break the build

From: Arnaldo Carvalho de Melo
Date: Wed May 26 2021 - 14:59:20 EST


Em Wed, May 26, 2021 at 09:18:27AM -0700, Andrii Nakryiko escreveu:
> On Tue, May 18, 2021 at 7:23 AM Javier Martinez Canillas
> <javierm@xxxxxxxxxx> wrote:
> >
> > The ccache tool can be used to speed up cross-compilation, by calling the
> > compiler and binutils through ccache. For example, following should work:
> >
> > $ export ARCH=arm64 CROSS_COMPILE="ccache aarch64-linux-gnu-"
> >
> > $ make M=drivers/gpu/drm/rockchip/
> >
> > but pahole fails to extract the BTF info from DWARF, breaking the build:
> >
> > CC [M] drivers/gpu/drm/rockchip//rockchipdrm.mod.o
> > LD [M] drivers/gpu/drm/rockchip//rockchipdrm.ko
> > BTF [M] drivers/gpu/drm/rockchip//rockchipdrm.ko
> > aarch64-linux-gnu-objcopy: invalid option -- 'J'
> > Usage: aarch64-linux-gnu-objcopy [option(s)] in-file [out-file]
> > Copies a binary file, possibly transforming it in the process
> > ...
> > make[1]: *** [scripts/Makefile.modpost:156: __modpost] Error 2
> > make: *** [Makefile:1866: modules] Error 2
> >
> > this fails because OBJCOPY is set to "ccache aarch64-linux-gnu-copy" and
> > later pahole is executed with the following command line:
> >
> > LLVM_OBJCOPY=$(OBJCOPY) $(PAHOLE) -J --btf_base vmlinux $@
> >
> > which gets expanded to:
> >
> > LLVM_OBJCOPY=ccache aarch64-linux-gnu-objcopy pahole -J ...
> >
> > instead of:
> >
> > LLVM_OBJCOPY="ccache aarch64-linux-gnu-objcopy" pahole -J ...
> >
> > Fixes: 5f9ae91f7c0 ("kbuild: Build kernel module BTFs if BTF is enabled and pahole supports it")
> > Signed-off-by: Javier Martinez Canillas <javierm@xxxxxxxxxx>
> > ---
> >
>
> LGTM. Masahiro, would you like us to take this through bpf tree or
> you'll apply this to kbuild one?
>
> Acked-by: Andrii Nakryiko <andrii@xxxxxxxxxx>

LGTM

Acked-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>

- Arnaldo


> > scripts/Makefile.modfinal | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal
> > index dd87cea9fba..a7883e45529 100644
> > --- a/scripts/Makefile.modfinal
> > +++ b/scripts/Makefile.modfinal
> > @@ -59,7 +59,7 @@ quiet_cmd_ld_ko_o = LD [M] $@
> > quiet_cmd_btf_ko = BTF [M] $@
> > cmd_btf_ko = \
> > if [ -f vmlinux ]; then \
> > - LLVM_OBJCOPY=$(OBJCOPY) $(PAHOLE) -J --btf_base vmlinux $@; \
> > + LLVM_OBJCOPY="$(OBJCOPY)" $(PAHOLE) -J --btf_base vmlinux $@; \
> > else \
> > printf "Skipping BTF generation for %s due to unavailability of vmlinux\n" $@ 1>&2; \
> > fi;
> > --
> > 2.31.1
> >

--

- Arnaldo