BPF List
 help / color / mirror / Atom feed
From: Quentin Monnet <qmo@kernel.org>
To: Leo Yan <leo.yan@arm.com>, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>,
	Lorenz Bauer <lmb@isovalent.com>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <nick.desaulniers+lkml@gmail.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
	Namhyung Kim <namhyung@kernel.org>,
	Ian Rogers <irogers@google.com>,
	James Clark <james.clark@linaro.org>, Kees Cook <kees@kernel.org>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, llvm@lists.linux.dev
Subject: Re: [PATCH bpf-next v2 1/8] bpftool: Pass host flags to bootstrap libbpf
Date: Wed, 3 Jun 2026 10:21:58 +0100	[thread overview]
Message-ID: <2b72da46-bf83-406f-bf5b-022f8e0ac04f@kernel.org> (raw)
In-Reply-To: <20260602-tools_build_fix_zero_init_bpf_only-v2-1-c76e5250ea1c@arm.com>

2026-06-02 15:47 UTC+0100 ~ Leo Yan <leo.yan@arm.com>
> bpftool builds a bootstrap libbpf with HOSTCC, but the libbpf submake can
> still inherit target build flags through CFLAGS. This can break cross
> builds when host objects are compiled with target-only options.
> 
> Since HOST_CFLAGS contains warning options that are not suitable for
> building libbpf, use LIBBPF_BOOTSTRAP_CFLAGS with the warning options
> removed to build the bootstrap libbpf. Clear EXTRA_CFLAGS so target
> extra flags are not mixed into the host bootstrap libbpf build.
> 
> Signed-off-by: Leo Yan <leo.yan@arm.com>
> ---
>  tools/bpf/bpftool/Makefile | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile
> index 0febf60e1b64656035dfe93cd15cba090015587a..1f033e578f90a2d6b93168ab41399de758bdf659 100644
> --- a/tools/bpf/bpftool/Makefile
> +++ b/tools/bpf/bpftool/Makefile
> @@ -47,7 +47,8 @@ $(LIBBPF_INTERNAL_HDRS): $(LIBBPF_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_HDRS_
>  $(LIBBPF_BOOTSTRAP): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $(LIBBPF_BOOTSTRAP_OUTPUT)
>  	$(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_BOOTSTRAP_OUTPUT) \
>  		DESTDIR=$(LIBBPF_BOOTSTRAP_DESTDIR:/=) prefix= \
> -		ARCH= CROSS_COMPILE= CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" $@ install_headers
> +		ARCH= CROSS_COMPILE= CC="$(HOSTCC)" LD="$(HOSTLD)" AR="$(HOSTAR)" \
> +		CFLAGS="$(LIBBPF_BOOTSTRAP_CFLAGS)" EXTRA_CFLAGS= $@ install_headers
>  
>  $(LIBBPF_BOOTSTRAP_INTERNAL_HDRS): $(LIBBPF_BOOTSTRAP_HDRS_DIR)/%.h: $(BPF_DIR)/%.h | $(LIBBPF_BOOTSTRAP_HDRS_DIR)
>  	$(call QUIET_INSTALL, $@)
> @@ -92,6 +93,9 @@ HOST_CFLAGS := $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE),\
>  		$(subst $(CLANG_CROSS_FLAGS),,$(CFLAGS)))
>  HOST_LDFLAGS := $(LDFLAGS)
>  
> +# Remove warnings for libbpf bootstrap build

Nitpick: We could expand this comment to briefly explain why. Not sure
it's worth a respin, though.

> +LIBBPF_BOOTSTRAP_CFLAGS := $(filter-out -W -Wall -Wextra -Wformat -Wformat-signedness,$(HOST_CFLAGS))

Do we need to remove all warnings, or would it be sufficient to take out
-Wformat and -Wformat-signedness? I don't mind removing them all if
necessary, just asking.

Acked-by: Quentin Monnet <qmo@kernel.org>

Thanks!

  reply	other threads:[~2026-06-03  9:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-02 14:47 [PATCH bpf-next v2 0/8] tools build: bpf: Append EXTRA_CFLAGS and HOST_EXTRACFLAGS Leo Yan
2026-06-02 14:47 ` [PATCH bpf-next v2 1/8] bpftool: Pass host flags to bootstrap libbpf Leo Yan
2026-06-03  9:21   ` Quentin Monnet [this message]
2026-06-02 14:47 ` [PATCH bpf-next v2 2/8] bpftool: Avoid adding EXTRA_CFLAGS to HOST_CFLAGS Leo Yan
2026-06-02 14:47 ` [PATCH bpf-next v2 3/8] bpftool: Append extra host flags Leo Yan
2026-06-02 14:47 ` [PATCH bpf-next v2 4/8] libbpf: Initialize CFLAGS before including Makefile.include Leo Yan
2026-06-02 15:11   ` sashiko-bot
2026-06-02 14:47 ` [PATCH bpf-next v2 5/8] tools/bpf: build: Append extra cflags Leo Yan
2026-06-13  1:09   ` Ihor Solodrai
2026-06-02 14:47 ` [PATCH bpf-next v2 6/8] selftests/bpf: Initialize operation name before use Leo Yan
2026-06-13  1:11   ` Ihor Solodrai
2026-06-02 14:47 ` [PATCH bpf-next v2 7/8] selftests/bpf: Use common CFLAGS for urandom_read Leo Yan
2026-06-02 15:32   ` bot+bpf-ci
2026-06-02 17:25   ` sashiko-bot
2026-06-13  1:37     ` Ihor Solodrai
2026-06-02 14:47 ` [PATCH bpf-next v2 8/8] selftests/bpf: Avoid static LLVM linking for cross builds Leo Yan
2026-06-02 17:33   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2b72da46-bf83-406f-bf5b-022f8e0ac04f@kernel.org \
    --to=qmo@kernel.org \
    --cc=acme@kernel.org \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=irogers@google.com \
    --cc=james.clark@linaro.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=justinstitt@google.com \
    --cc=kees@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=leo.yan@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=lmb@isovalent.com \
    --cc=martin.lau@linux.dev \
    --cc=morbo@google.com \
    --cc=namhyung@kernel.org \
    --cc=nathan@kernel.org \
    --cc=nick.desaulniers+lkml@gmail.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=song@kernel.org \
    --cc=yonghong.song@linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox