Re: [PATCH v6 15/24] tools: objtool: Append extra host cflags

From: Ian Rogers

Date: Mon Mar 23 2026 - 17:55:29 EST


On Mon, Mar 23, 2026 at 8:15 AM Leo Yan <leo.yan@xxxxxxx> wrote:
>
> Append HOST_EXTRACFLAGS to HOSTCFLAGS so that additional flags can be
> applied to the host compiler.
>
> Acked-by: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
> Signed-off-by: Leo Yan <leo.yan@xxxxxxx>
> ---
> tools/objtool/Makefile | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/objtool/Makefile b/tools/objtool/Makefile
> index b71d1886022e9b3d9fde52bf73bd502aa20d173e..a41fb2a46217bb14fcd8d0941c99d102945c3f2d 100644
> --- a/tools/objtool/Makefile
> +++ b/tools/objtool/Makefile
> @@ -60,6 +60,8 @@ INCLUDES := -I$(srctree)/tools/include \
> -I$(srctree)/tools/objtool/arch/$(SRCARCH)/include \
> -I$(LIBSUBCMD_OUTPUT)/include
>
> +HOSTCFLAGS += $(HOST_EXTRACFLAGS)

Sashiko noted here (sharing just for common information, not because I
feel this is necessarily making thigs worse) that:
https://sashiko.dev/#/patchset/20260323-tools_build_fix_zero_init-v6-0-235858c51af9%40arm.com

Will this late addition of HOST_EXTRACFLAGS cause a regression by missing the
feature detection checks that run earlier in the Makefile?

The HAVE_XXHASH feature check uses HOSTCFLAGS inside a shell command:

ifeq ($(ARCH_HAS_KLP),y)
HAVE_XXHASH = $(shell printf "$(pound)include
<xxhash.h>\nXXH3_state_t *state;int main() {}" | \
$(HOSTCC) $(HOSTCFLAGS) -xc - -o /dev/null -lxxhash 2> /dev/null
&& echo y || echo n)
ifeq ($(HAVE_XXHASH),y)

Because this check is evaluated immediately by the ifeq ($(HAVE_XXHASH),y)
conditional, the shell command executes during the Makefile parsing phase.

Since HOST_EXTRACFLAGS is appended here after the feature checks, the earlier
tests will run without these extra flags. If a user provides necessary include
paths via HOST_EXTRACFLAGS to locate xxhash.h, the feature test will fail and
silently disable Kernel Live Patching (BUILD_KLP) support.

Could HOSTCFLAGS be updated earlier in the Makefile, before the feature checks
are evaluated?

Thanks,
Ian

> +
> OBJTOOL_CFLAGS := -std=gnu11 -fomit-frame-pointer -O2 -g $(WARNINGS) \
> $(INCLUDES) $(LIBELF_FLAGS) $(LIBXXHASH_CFLAGS) $(HOSTCFLAGS)
>
>
> --
> 2.34.1
>