Re: [PATCH v3 11/58] objtool: Forward toolchain variables to the klp test runner
From: Song Liu <song@kernel.org>
Date: 2026-09-15 21:04:48
Also in:
sashiko-reviews
On Mon, Sep 14, 2026 at 4:45 PM [off-list ref] wrote:
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] objtool: tests target silently falls back to GNU objcopy under LLVM=1 -- commit 11c79ea0e223d9512f0e164886cfdec6a0e5e3b2 Author: Joe Lawrence [off-list ref] objtool: Forward toolchain variables to the klp test runner The tests target passes toolchain variables like CC, LD, READELF, and OBJCOPY into the test scripts so that fixtures are built and inspected with the selected toolchain. [ ... ]quoted
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile index ed5cf146ef2e2..a3d09a5af7a20 100644 --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile@@ -153,6 +153,8 @@ mrproper: clean tests: $(OBJTOOL) $(Q)OBJTOOL=$(abspath $(OBJTOOL)) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) \ + CC='$(CC) $(CLANG_CROSS_FLAGS)' LD='$(LD)' \ + READELF='$(READELF)' OBJCOPY='$(OBJCOPY)' \[Severity: Medium] Will the tests target silently fall back to GNU objcopy when building with LLVM=1? It appears that tools/scripts/Makefile.include defines LLVM_OBJCOPY but leaves OBJCOPY unset for LLVM builds. As a result, $(OBJCOPY) evaluates to an empty string here in the tests recipe. When this empty variable is passed to tools/objtool/tests/lib.sh, the fallback logic: OBJCOPY="${OBJCOPY:-${CROSS_COMPILE}objcopy}" treats the empty OBJCOPY as null due to the :- operator. This substitutes the default GNU objcopy instead of the intended llvm-objcopy, which defeats the goal of using the selected LLVM toolchain.
OK, added the following to v4: OBJCOPY ?= $(if $(LLVM),$(LLVM_OBJCOPY),$(CROSS_COMPILE)objcopy) Thanks, Song