Re: [PATCH v2 11/58] objtool: Forward toolchain variables to the klp test runner
From: Song Liu <song@kernel.org>
Date: 2026-09-14 20:48:35
Also in:
sashiko-reviews
On Sun, Sep 13, 2026 at 11:39 PM [off-list ref] wrote:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [Medium] Forwarding CC='$(CC)' breaks LLVM cross-compilation because Clang target flags are omitted. - [Medium] Forwarding READELF forces the use of llvm-readelf under LLVM=1, which explicitly violates test suite assertions. -- commit be049d84a50dfed10ff53ea94f5daa93c75008b3 Author: Joe Lawrence [off-list ref] Subject: objtool: Forward toolchain variables to the klp test runner This commit forwards toolchain variables from the objtool Makefile to the klp test runner script. This ensures that the tests use the intended compiler and tools, especially when specific toolchains are selected via environment variables like LLVM=1.quoted
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile --- a/tools/objtool/Makefile +++ b/tools/objtool/Makefile@@ -153,6 +153,7 @@ mrproper: clean tests: $(OBJTOOL) $(Q)OBJTOOL=$(abspath $(OBJTOOL)) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) \ + CC='$(CC)' LD='$(LD)' READELF='$(READELF)' OBJCOPY='$(OBJCOPY)' \[Severity: Medium] When cross-compiling with LLVM=1, does forwarding CC like this drop the Clang target flags (such as --target=aarch64-linux-gnu) normally passed via CLANG_CROSS_FLAGS? The top-level build sets CC to clang and passes target flags separately. Because only CC is forwarded here, the test script runs clang without any target flags and builds test fixtures for the host architecture instead. This mismatch is then caught in tools/objtool/tests/lib.sh during klp_preflight(), which bails out when it detects that the objects target a different architecture: tools/objtool/tests/lib.sh:klp_preflight() "$OBJTOOL" klp checksum "$tmp/probe.o" >/dev/null 2>&1 || { rm -rf "$tmp" bail "objtool rejects an object built by '$CC'; they target" \ "different architectures (set CROSS_COMPILE, or" \ "--target= for clang)"; } [Severity: Medium] Will forwarding READELF break the test suite parsing when LLVM=1 is used? The script tools/objtool/tests/lib.sh explicitly documents that it requires GNU readelf because llvm-readelf spaces columns differently, which breaks the test assertions: tools/objtool/tests/lib.sh: # readelf reads any target, so it rarely needs overriding -- and it must stay # GNU readelf, whose column layout the assertions parse; llvm-readelf spaces # them differently. Forwarding READELF forces llvm-readelf into the script environment under LLVM=1, which appears to violate this documented test framework constraint.quoted
KEEP=$(KEEP) $(srctree)/tools/objtool/tests/run-tests.sh FORCE:
Fixed both in v3. Thanks, Song