Re: [PATCH v4 05/30] bpftool: Avoid adding EXTRA_CFLAGS to HOST_CFLAGS

From: Leo Yan

Date: Fri Mar 13 2026 - 12:30:07 EST


On Fri, Mar 13, 2026 at 04:07:27PM +0000, Quentin Monnet wrote:

[...]

> >>> +
> >>> +# This must be done before appending EXTRA_CFLAGS to CFLAGS to avoid
> >>> +# including flags that are not applicable to the host compiler.
> >>> +HOST_CFLAGS := $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE),\
> >>> + $(subst $(CLANG_CROSS_FLAGS),,$(CFLAGS)))
> >>> +
> >>> ifneq ($(EXTRA_CFLAGS),)
> >>> CFLAGS += $(EXTRA_CFLAGS)
> >>> endif
> >>> @@ -88,8 +94,6 @@ ifneq ($(EXTRA_LDFLAGS),)
> >>> LDFLAGS += $(EXTRA_LDFLAGS)
> >>> endif
> >>>
> >>> -HOST_CFLAGS := $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE),\
> >>> - $(subst $(CLANG_CROSS_FLAGS),,$(CFLAGS)))
> >>> HOST_LDFLAGS := $(LDFLAGS)
> >>
> >> Should HOST_LDFLAGS be similarly moved? Otherwise, it seems target
> >> flags in EXTRA_LDFLAGS will be added for the host.
> >
> > Though this series is irrelevant to LDFLAGS, I am fine to move
> > HOST_LDFLAGS together.
>
>
> If we move the HOST_LDFLAGS earlier so that they no longer receive the
> EXTRA_LDFLAGS, then we lose the possibility to use any EXTRA variable to
> pass additional flags to HOST_LDFLAGS. So OK to move, but maybe add a
> "HOST_LDFLAGS += $(HOST_EXTRALDFLAGS)" to it for consistency with the
> processing of HOST_CFLAGS?

Adding HOST_EXTRALDFLAGS seems a bit over designed to me, as there is
no use case for it currently. To avoid complexity, let's keep this
patch as it is, we can add HOST_EXTRALDFLAGS if later have requirement.

P.s. I saw that you already replied the same comment in the previous
version. I should have confirmed at that time, sorry for the duplicate
discussion.