[PATCH AUTOSEL 6.19] objtool: Use HOSTCFLAGS for HAVE_XXHASH test
From: Sasha Levin
Date: Tue Mar 17 2026 - 07:33:22 EST
From: HONG Yifan <elsk@xxxxxxxxxx>
[ Upstream commit 32234049107d012703d50547e815f198f147968b ]
Previously, HAVE_XXHASH is tested by invoking HOSTCC without HOSTCFLAGS.
Consider the following scenario:
- The host machine has libxxhash installed
- We build the kernel with HOSTCFLAGS containing a --sysroot that does
not have xxhash.h (for hermetic builds)
In this case, HAVE_XXHASH is set to y, but when it builds objtool with
HOSTCFLAGS, because the --sysroot does not contain xxhash.h, the
following error is raised:
<...>/common/tools/objtool/include/objtool/checksum_types.h:12:10: fatal error: 'xxhash.h' file not found
12 | #include <xxhash.h>
| ^~~~~~~~~~
To resolve the error, we test HAVE_XXHASH by invoking HOSTCC with
HOSTCFLAGS.
Signed-off-by: HONG Yifan <elsk@xxxxxxxxxx>
Reviewed-by: Carlos Llamas <cmllamas@xxxxxxxxxx>
Link: https://patch.msgid.link/20260303010340.306164-1-elsk@xxxxxxxxxx
Signed-off-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
LLM Generated explanations, may be completely bogus:
### Key Finding: Code Exists Only in v6.19+
The `HAVE_XXHASH` test was introduced in commit `0d83da43b1e1c`
("objtool/klp: Add --checksum option to generate per-function
checksums"), which first appeared in v6.19-rc1. This means:
- The buggy code does **not exist** in any older stable trees (6.12.y,
6.6.y, 6.1.y, 5.15.y, etc.)
- This fix is only relevant for the **6.19.y** stable tree
### Assessment
**Pros:**
- Build fix — explicitly listed as appropriate stable material
- One-line change with zero runtime risk
- Obviously correct: the feature test should use the same flags as the
actual build
- Reviewed by Carlos Llamas, accepted by Josh Poimboeuf (objtool
maintainer)
- Fixes a real `fatal error` that completely blocks compilation
**Cons:**
- Only affects builds using custom `HOSTCFLAGS` with `--sysroot`
(hermetic builds) — a niche scenario
- Only applicable to 6.19.y (the code doesn't exist in older stable
trees)
### Verdict
This is a legitimate build fix: small, obviously correct, zero risk, and
it prevents a real compilation failure for users with custom sysroot
configurations. Build fixes are explicitly called out as appropriate for
stable trees. The only caveat is that it only applies to 6.19.y since
the affected code was introduced in v6.19-rc1.
### Verification
- `git tag --contains 0d83da43b1e1c` confirmed the HAVE_XXHASH code was
introduced in v6.19-rc1, not present in earlier stable trees
- `git log -- tools/objtool/Makefile | grep -i xxhash` confirmed the
history of xxhash-related changes
- The diff is a one-line addition of `$(HOSTCFLAGS)` — verified by
reading the patch
- Reviewed-by: Carlos Llamas and signed-off by Josh Poimboeuf (objtool
maintainer) confirmed in commit message
- The fix logic is self-evident: if the build uses `$(HOSTCC)
$(HOSTCFLAGS)`, the test should too
**YES**
tools/objtool/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
index 76bcd4e85de34..b71d1886022e9 100644
--- a/tools/objtool/Makefile
+++ b/tools/objtool/Makefile
@@ -13,7 +13,7 @@ endif
ifeq ($(ARCH_HAS_KLP),y)
HAVE_XXHASH = $(shell printf "$(pound)include <xxhash.h>\nXXH3_state_t *state;int main() {}" | \
- $(HOSTCC) -xc - -o /dev/null -lxxhash 2> /dev/null && echo y || echo n)
+ $(HOSTCC) $(HOSTCFLAGS) -xc - -o /dev/null -lxxhash 2> /dev/null && echo y || echo n)
ifeq ($(HAVE_XXHASH),y)
BUILD_KLP := y
LIBXXHASH_CFLAGS := $(shell $(HOSTPKG_CONFIG) libxxhash --cflags 2>/dev/null) \
--
2.51.0