From nobody Mon Jun 8 04:27:30 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 533973EB7FF; Tue, 2 Jun 2026 14:47:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411649; cv=none; b=SAZOV/krCNYg/xynYd6A37lIl016x5x7zKdZbQsKEQk1nUFZO1s1T0EL2cEM5tSGWKmTrv4lkb8bpwXULfCmLLE6i+ECNRNgUYC+Qan8S9hYfSc62gLWxfisiI0ntRHvmDUIT2bBFcI+pOayUWmjhXMEFNP/GnTkSl2mi96sh/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411649; c=relaxed/simple; bh=+bPMqBjWhP4el8DDzLN3UmoeC6gA35HpOFjMwmSxEuo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JJJ/Ckv09/wzXTNmHIGSyFt3QYM8bQtrjnXpPMmKBI607yX8oqGBa370aqlfzTCvDWv4dWDLJ3neFfg7VXMHUkfwlCKxz6SBqgp7K7fbM9jzgopL/MyO2PTNNB5bzTsBGdXgclRCOz0qOGheEBTk3DFWC0KZc1ewSzGpWWDdRFI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=AKR3BxFk; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="AKR3BxFk" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E4B1C356D; Tue, 2 Jun 2026 07:47:21 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 706EF3F632; Tue, 2 Jun 2026 07:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1780411646; bh=+bPMqBjWhP4el8DDzLN3UmoeC6gA35HpOFjMwmSxEuo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=AKR3BxFk7xb0YlmAfRzyNzx2sm6EcZVrNNd+zeQEImE7ip8DGl6VYQN+XVxORJ7X1 6yrkrxgQat9ymy1JMFLi2KauKj6Bq0MXtqr85RAva/mL62yNrIRUN7KXzQEu2JXob9 eISO8Nfmr2XK6Ge0BXTtMkxMXiFIYHzm5giFsBO4= From: Leo Yan Date: Tue, 02 Jun 2026 15:47:10 +0100 Subject: [PATCH bpf-next v2 1/8] bpftool: Pass host flags to bootstrap libbpf Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260602-tools_build_fix_zero_init_bpf_only-v2-1-c76e5250ea1c@arm.com> References: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> In-Reply-To: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Lorenz Bauer , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Kees Cook , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780411637; l=1945; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=+bPMqBjWhP4el8DDzLN3UmoeC6gA35HpOFjMwmSxEuo=; b=PEHBmgSuakarM8vWBq6KZrpVfK7rlR0JRdLE08nDVmieBHCg2ve2luSMU7W7N0CObN7GkLSey KR+SGo+dTg5BjY3ifzGxSseD3C/yheTKKdiKxLyXqk/O3CXaR5lv4kq X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= 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 Acked-by: Quentin Monnet --- 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..1f033e578f90a2d6b93168ab413= 99de758bdf659 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -47,7 +47,8 @@ $(LIBBPF_INTERNAL_HDRS): $(LIBBPF_HDRS_DIR)/%.h: $(BPF_DI= R)/%.h | $(LIBBPF_HDRS_ $(LIBBPF_BOOTSTRAP): $(wildcard $(BPF_DIR)/*.[ch] $(BPF_DIR)/Makefile) | $= (LIBBPF_BOOTSTRAP_OUTPUT) $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=3D$(LIBBPF_BOOTSTRAP_OUTPUT) \ DESTDIR=3D$(LIBBPF_BOOTSTRAP_DESTDIR:/=3D) prefix=3D \ - ARCH=3D CROSS_COMPILE=3D CC=3D"$(HOSTCC)" LD=3D"$(HOSTLD)" AR=3D"$(HOSTA= R)" $@ install_headers + ARCH=3D CROSS_COMPILE=3D CC=3D"$(HOSTCC)" LD=3D"$(HOSTLD)" AR=3D"$(HOSTA= R)" \ + CFLAGS=3D"$(LIBBPF_BOOTSTRAP_CFLAGS)" EXTRA_CFLAGS=3D $@ install_headers =20 $(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 :=3D $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_B= OOTSTRAP_INCLUDE),\ $(subst $(CLANG_CROSS_FLAGS),,$(CFLAGS))) HOST_LDFLAGS :=3D $(LDFLAGS) =20 +# Remove warnings for libbpf bootstrap build +LIBBPF_BOOTSTRAP_CFLAGS :=3D $(filter-out -W -Wall -Wextra -Wformat -Wform= at-signedness,$(HOST_CFLAGS)) + INSTALL ?=3D install RM ?=3D rm -f =20 --=20 2.34.1 From nobody Mon Jun 8 04:27:30 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 287CB3EDADF; Tue, 2 Jun 2026 14:47:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411654; cv=none; b=Ie5ZAoQkDTUrzk8/RrecWObkVkCXIyQyVPHDadMfp48mDJWCi+u0sxgfIGP+dHbDwXJLlr4KEie9Ct1e4shL+orIYH92ULf/uESo4PDMpONR9LaMsyo3cnmMJNLSFBgotT1YACcFBnBNvmvawISXN/sEaxX+6TChfV1/445P12k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411654; c=relaxed/simple; bh=ftrGfPlCpSuFDSQHacVgFrG56NXWBlICsaIhKhYspOQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fQMtoHGzF9FfgrjDWrNdNxJylhH0UH3w/J5yuSkXdKZfbUroL24bR6dw7g1p1mOpSbEuFpe2WSCIMC17E7fBWoESNDsaH1rhmeUND9xj+zLh+SxbLWfbC7zBe/5bmG0UsPG0i0/4h/GUlLgpyTiKaOOhZ7JhOInr4Z+Nnn2hf7s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=kz7C7LPY; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="kz7C7LPY" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id ABCDF3576; Tue, 2 Jun 2026 07:47:26 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 36AED3F632; Tue, 2 Jun 2026 07:47:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1780411651; bh=ftrGfPlCpSuFDSQHacVgFrG56NXWBlICsaIhKhYspOQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kz7C7LPYODIKIqfd5uOjRjmm0FSiTgiFxsD5SnXCq+NC1it0enSnZ9PsDlfY5C/8N 5JOdu0idcRRgVsGvaPVEwbQ1cKoOLvy8sb2LvH4eaDu5q8OoqvMG8UIMN/FdngYmMU 0orJR0UTs9pJei071XKoO5kF68kXPw5koHvpCvYM= From: Leo Yan Date: Tue, 02 Jun 2026 15:47:11 +0100 Subject: [PATCH bpf-next v2 2/8] bpftool: Avoid adding EXTRA_CFLAGS to HOST_CFLAGS Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260602-tools_build_fix_zero_init_bpf_only-v2-2-c76e5250ea1c@arm.com> References: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> In-Reply-To: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Lorenz Bauer , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Kees Cook , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780411637; l=1462; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=ftrGfPlCpSuFDSQHacVgFrG56NXWBlICsaIhKhYspOQ=; b=Ltv4m0kswXfh6oi4eVR3XrM95ptbINRZyDvGwqzaj/PJqOAH4qarP3lCKMgP/1QlhwTJhuFIG 5EiCMNrc6cYDHFCAVI7DyWAHbg07JYw6y20D+okGlWMb2jL8HSLjAjU X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= Prepare for future changes where EXTRA_CFLAGS may include flags not applicable to the host compiler. Move the HOST_CFLAGS assignment before appending EXTRA_CFLAGS to CFLAGS so that HOST_CFLAGS does not inherit flags from EXTRA_CFLAGS. Acked-by: Quentin Monnet Signed-off-by: Leo Yan --- tools/bpf/bpftool/Makefile | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 1f033e578f90a2d6b93168ab41399de758bdf659..616c14247e4bb690e16ae4ff8c1= 992e6d4fc863e 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -82,6 +82,12 @@ CFLAGS +=3D -DPACKAGE=3D'"bpftool"' -D__EXPORTED_HEADERS= __ \ ifneq ($(BPFTOOL_VERSION),) CFLAGS +=3D -DBPFTOOL_VERSION=3D'"$(BPFTOOL_VERSION)"' endif + +# This must be done before appending EXTRA_CFLAGS to CFLAGS to avoid +# including flags that are not applicable to the host compiler. +HOST_CFLAGS :=3D $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE)= ,\ + $(subst $(CLANG_CROSS_FLAGS),,$(CFLAGS))) + ifneq ($(EXTRA_CFLAGS),) CFLAGS +=3D $(EXTRA_CFLAGS) endif @@ -89,8 +95,6 @@ ifneq ($(EXTRA_LDFLAGS),) LDFLAGS +=3D $(EXTRA_LDFLAGS) endif =20 -HOST_CFLAGS :=3D $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE)= ,\ - $(subst $(CLANG_CROSS_FLAGS),,$(CFLAGS))) HOST_LDFLAGS :=3D $(LDFLAGS) =20 # Remove warnings for libbpf bootstrap build --=20 2.34.1 From nobody Mon Jun 8 04:27:30 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2AA6A3EF658; Tue, 2 Jun 2026 14:47:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411658; cv=none; b=LHkEnpNK0SSUus0dTYcbcRQxMPGzYr0+LCjv1N8jK8HkljTBDMcMKLPkf9fxpJEZ2X7/gqmuZxjwlbo8cwlv6/ihPLRG8O7uC0dgyCk8oaJ6Q+2EcDdKIwEvdSOskTz1AtCvkxNaDSGzOdmXgazVUTR2A6BE0mlMrNhhJ2e8UME= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411658; c=relaxed/simple; bh=x7cZMt2bdvciDxx6hGzYMUYeiKiePmRdhY+wP37FvBo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pSjdM1EshduqfEOX4ZL3mdJ+f6ihKDjeqAdkTLy61g/9RoDxqLnFxnbJeoFsCUa2HL7Mw5Pj7LbYDQrPE+u0jn/LS89LFB3geMXAoPqv6QDm4eBzRMVDBwGqUax0sDe9PFi7zG9l0NNQkMIB0RKXwoq2ioONtQWL2/mqWwrpCos= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=bAWV5RQX; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="bAWV5RQX" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 899C02B; Tue, 2 Jun 2026 07:47:31 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F32463F632; Tue, 2 Jun 2026 07:47:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1780411656; bh=x7cZMt2bdvciDxx6hGzYMUYeiKiePmRdhY+wP37FvBo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bAWV5RQXAxIvK4CZtbqhPng8ge68XfgTYs8SRPm8Dop3NkYMC9P5tt5puKEvK/AJN TX4E95jKFrpMa+pEYTb1Wwz58ipqocBxnjeXv8C8H5EkcQuAtMJbq3zrX9wXdH+yjU JXjEtlT2OfBK8zECm+8TYrxJNeVKjmboydgyF2wE= From: Leo Yan Date: Tue, 02 Jun 2026 15:47:12 +0100 Subject: [PATCH bpf-next v2 3/8] bpftool: Append extra host flags Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260602-tools_build_fix_zero_init_bpf_only-v2-3-c76e5250ea1c@arm.com> References: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> In-Reply-To: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Lorenz Bauer , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Kees Cook , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780411637; l=824; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=x7cZMt2bdvciDxx6hGzYMUYeiKiePmRdhY+wP37FvBo=; b=7LNfWhRMlyI7VhOkEtDSekJ3ixPBft1J6UrrC+T/O+LuO713EeVH9Z5m9SBp3vviYH2zg6utx eP//X95OUEJDOQaTBV++DsA86oAhG8tHe3Wah3Liy4G1+BxCVqh5rbU X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= Append HOST_EXTRACFLAGS to HOST_CFLAGS so that additional flags can be applied to the host compiler. Acked-by: Quentin Monnet Signed-off-by: Leo Yan --- tools/bpf/bpftool/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 616c14247e4bb690e16ae4ff8c1992e6d4fc863e..96be5647f0e1370247025d65e81= 3db376b146e52 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -87,6 +87,7 @@ endif # including flags that are not applicable to the host compiler. HOST_CFLAGS :=3D $(subst -I$(LIBBPF_INCLUDE),-I$(LIBBPF_BOOTSTRAP_INCLUDE)= ,\ $(subst $(CLANG_CROSS_FLAGS),,$(CFLAGS))) +HOST_CFLAGS +=3D $(HOST_EXTRACFLAGS) =20 ifneq ($(EXTRA_CFLAGS),) CFLAGS +=3D $(EXTRA_CFLAGS) --=20 2.34.1 From nobody Mon Jun 8 04:27:30 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C272C3F0755; Tue, 2 Jun 2026 14:47:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411663; cv=none; b=grK8v8EhtTUaCi7GsUQZPhQE+/0jHe43tI6LPcHP8i6g+Qkqj4avUxSPdQKyUIsHGPoii6LHDIhIV2sUMBN4V26g4YSfXiK7F37IlaWRC9ornql76JGxN7JdGzVrgvyeK4SZi1JKNd7wmy2+Fh+nNy74ZvWHpXzVmTA+wxI7ijA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411663; c=relaxed/simple; bh=IWbL8s6kDVXxb7irKM9RRyKWD+H39SbNVArY0xlKstw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=soPeyP9AL2YYvDQZbQK0srbgg4/ZsGdhP9KaC9+hFIlArGPSF6+w5ns7CuEgwSx0PUduz/dX+x8sJTaJInlEcMb0ZfZdGgQb4mB7AZheXOSDWjZpqdSg/Phu/Q01CIIBjTliC1CrG4fYvzX43BjtHUpHIe3jbX6xz+jP7fVWu9M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=swGmSUO2; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="swGmSUO2" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 65C13497; Tue, 2 Jun 2026 07:47:36 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BF49F3F632; Tue, 2 Jun 2026 07:47:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1780411661; bh=IWbL8s6kDVXxb7irKM9RRyKWD+H39SbNVArY0xlKstw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=swGmSUO20NIisccu2dXjhTuNBjmK8mt/g0D4vcSM8Wy43i0eksdVQv/WidZXWyrcP ulpECny9XHIjjwnRpNaRfZxvOga6V31dA81smNlxx1EaYak3FANgVHM81Ky4THPD3v TUHxa9ygFscjIMlEMVWPyPGaApKzWIr/vpNEzaHw= From: Leo Yan Date: Tue, 02 Jun 2026 15:47:13 +0100 Subject: [PATCH bpf-next v2 4/8] libbpf: Initialize CFLAGS before including Makefile.include Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260602-tools_build_fix_zero_init_bpf_only-v2-4-c76e5250ea1c@arm.com> References: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> In-Reply-To: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Lorenz Bauer , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Kees Cook , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Leo Yan , Ihor Solodrai X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780411637; l=2272; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=IWbL8s6kDVXxb7irKM9RRyKWD+H39SbNVArY0xlKstw=; b=vNpyYO6ES8PZJyibEbEj9YTGBHPGfwezz/gUbInMy3sGfNdwzrbxn8DJgkYusI0tD/7AjF9pw GRMgEJcWoH1BbK1P76l+UnWMMoUxdzdVInNi+OQP3Tob1iacv8Al3cv X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= tools/scripts/Makefile.include may expand EXTRA_CFLAGS in a future change. This could alter the initialization of CFLAGS, as the default options "-g -O2" would never be set once EXTRA_CFLAGS is expanded. Prepare for this by moving the CFLAGS initialization before including tools/scripts/Makefile.include, so it is not affected by the extended EXTRA_CFLAGS. Append EXTRA_CFLAGS to CFLAGS only after including Makefile.include and place it last so that the extra flags propagate properly and can override the default options. tools/scripts/Makefile.include already appends $(CLANG_CROSS_FLAGS) to CFLAGS, the Makefile appends $(CLANG_CROSS_FLAGS) again, remove the redundant append. Signed-off-by: Leo Yan Acked-by: Ihor Solodrai --- tools/lib/bpf/Makefile | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index 168140f8e6461bd06db40e23d21a3fb8847ccbf4..eca584fb061e16013e76827e420= 3f6be0477a73e 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -49,6 +49,14 @@ man_dir_SQ =3D '$(subst ','\'',$(man_dir))' export man_dir man_dir_SQ INSTALL export DESTDIR DESTDIR_SQ =20 +# Defer assigning EXTRA_CFLAGS to CFLAGS until after including +# tools/scripts/Makefile.include, as it may add flags to EXTRA_CFLAGS. +ifdef EXTRA_CFLAGS + CFLAGS :=3D +else + CFLAGS :=3D -g -O2 +endif + include $(srctree)/tools/scripts/Makefile.include =20 # copy a bit from Linux kbuild @@ -70,13 +78,6 @@ LIB_TARGET =3D libbpf.a libbpf.so.$(LIBBPF_VERSION) LIB_FILE =3D libbpf.a libbpf.so* PC_FILE =3D libbpf.pc =20 -# Set compile option CFLAGS -ifdef EXTRA_CFLAGS - CFLAGS :=3D $(EXTRA_CFLAGS) -else - CFLAGS :=3D -g -O2 -endif - # Append required CFLAGS override CFLAGS +=3D -std=3Dgnu89 override CFLAGS +=3D $(EXTRA_WARNINGS) -Wno-switch-enum @@ -84,7 +85,7 @@ override CFLAGS +=3D -Werror -Wall override CFLAGS +=3D $(INCLUDES) override CFLAGS +=3D -fvisibility=3Dhidden override CFLAGS +=3D -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=3D64 -override CFLAGS +=3D $(CLANG_CROSS_FLAGS) +override CFLAGS +=3D $(EXTRA_CFLAGS) =20 # flags specific for shared library SHLIB_FLAGS :=3D -DSHARED -fPIC --=20 2.34.1 From nobody Mon Jun 8 04:27:30 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88EB73F1676; Tue, 2 Jun 2026 14:47:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411667; cv=none; b=i8zDeVCXEFDfTUNEG02N6a0R1iDNLOXn2hX5LE6i1v3DLzz8bquMLwx7JNL65jlSsdw/QoG0q+96sw+5X3WxqOXFshFLif10aqkITUUeChGUv78sv5N3ylpgiWmn5bUYqNbVYHOSt9BNSowoc4hYtsTde8q1CQSphSHCogpbI1k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411667; c=relaxed/simple; bh=QVECXhBfSn3HTksxV9ctf7sdfgmuzFaQvCXjb24QcOs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SqeJnZ842wNRQZwmTAyt1pu2o+bQZbTa20VpNAH3H7jxQFytbsOxsIcCUgg+wO5sZoMYl8LJlCH9LaGo9UDNSlKaYJ2cDa0vFa2ziA9Q93bpFhRHZaenMNXSsCNoLdbU+3CpTcuP12C/uM5wg8j2x0Ei/dSr5JmWRCsRoMR06ss= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=TvVe6zyk; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="TvVe6zyk" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2CA302B; Tue, 2 Jun 2026 07:47:41 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AA5EC3F632; Tue, 2 Jun 2026 07:47:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1780411666; bh=QVECXhBfSn3HTksxV9ctf7sdfgmuzFaQvCXjb24QcOs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=TvVe6zykEq2a46xyCn9ktAwfarF4GDmXwb+qFv9nlLzrMo70u5jPq+wXvWbMHTt+v /ETTIuRDmzNWUXCEfK0ebMCPcsLXIJV+QRRnel7nQpIzK0QWSl1zxlKwqb1I447dDm D6X609R8iO7OclJzPKeo5PkLvzP1oOu41hFNJ+GM= From: Leo Yan Date: Tue, 02 Jun 2026 15:47:14 +0100 Subject: [PATCH bpf-next v2 5/8] tools/bpf: build: Append extra cflags Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260602-tools_build_fix_zero_init_bpf_only-v2-5-c76e5250ea1c@arm.com> References: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> In-Reply-To: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Lorenz Bauer , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Kees Cook , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780411637; l=742; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=QVECXhBfSn3HTksxV9ctf7sdfgmuzFaQvCXjb24QcOs=; b=iMNmxLU7KuObiTWa6YHCONwQwKj+iQbXWIc5qUCcQ4QDokEUQ/rzrc9x8rgcW2wgS4TlVSvDB SLI8yxghZcyBhgqjSxEnsU96bGX3x5gro+hU0e1UxXsBZFQqzea9vUA X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= Append EXTRA_CFLAGS to CFLAGS so that additional flags can be applied to the compiler. Signed-off-by: Leo Yan --- tools/bpf/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/bpf/Makefile b/tools/bpf/Makefile index fd2585af1252669c59228af3a77320e449e1a1ab..9c19e81f3c274767c3b9b94c907= cbbe3ce9fe78c 100644 --- a/tools/bpf/Makefile +++ b/tools/bpf/Makefile @@ -11,6 +11,7 @@ INSTALL ?=3D install CFLAGS +=3D -Wall -O2 CFLAGS +=3D -D__EXPORTED_HEADERS__ -I$(srctree)/tools/include/uapi \ -I$(srctree)/tools/include +CFLAGS +=3D $(EXTRA_CFLAGS) =20 # This will work when bpf is built in tools env. where srctree # isn't set and when invoked from selftests build, where srctree --=20 2.34.1 From nobody Mon Jun 8 04:27:30 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 487363F2115; Tue, 2 Jun 2026 14:47:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411672; cv=none; b=t8ffYfKOq01TwWkvTAZ42VkuQEjiJeviZBfyVU7xdkjBtZCl2Hsb1PIuyRPqggfkjAnWdHEXPJozSFE9tn3Cmqs8pb7mwUgoi73nbsejhWF090Clk74mxGSV50PCEzgnZytVv3ODwCKgrc1uJ9h+opIWxJiBb0GVKeclImAqr4I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411672; c=relaxed/simple; bh=GLUFbbIEHS0K9sAkY65AIMIBJlV7lJXIB46SducMo/c=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LN+VvlvX+9HhE0K/yw5nmDVKS1wCkp5q1PvP35QXvmZbL7SEZZmWSHaZKxcFPRpxXS0GOpsndNdxNYwx6/E2SjfoayRnc+FE3mSC5Czb75xZXR25pswoZHZCIO1KYODfJgt/ABfFIc8wl0o5wzIFxlBJD4pOVn14Jy/ycHC40JI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=D02CeUF/; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="D02CeUF/" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EA7E03560; Tue, 2 Jun 2026 07:47:45 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7269A3F632; Tue, 2 Jun 2026 07:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1780411670; bh=GLUFbbIEHS0K9sAkY65AIMIBJlV7lJXIB46SducMo/c=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=D02CeUF/kZjFaBUr2nqAaink6RjHRSFLEhkOHVwT7nZmeYkPJCkEACzeMoV79AyU5 4FMx2kamJbQDZkvaQfBoZC6OtNcfphmb3HlvT+GgcKG/CdtC1BD1FPITCXAZNvFeUo 9VPXVKaMz/a8A4QGJLc28Auh0Ytr3HjlCmvlgJI4= From: Leo Yan Date: Tue, 02 Jun 2026 15:47:15 +0100 Subject: [PATCH bpf-next v2 6/8] selftests/bpf: Initialize operation name before use Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260602-tools_build_fix_zero_init_bpf_only-v2-6-c76e5250ea1c@arm.com> References: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> In-Reply-To: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Lorenz Bauer , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Kees Cook , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780411637; l=1077; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=GLUFbbIEHS0K9sAkY65AIMIBJlV7lJXIB46SducMo/c=; b=63cu9sDDg2Uz0Wc5e/+QysEkWtM1JbgeG8xJVPiOdWZ8bRfEo1F7xW3cTb/FEeWG5oWNMfs19 qrfEQ+WzW7UBJwEEFH7HkCgTVsvwvacSMBbB0QJmlyodoAa9uj3JJ53 X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= ASAN reports stack-buffer-overflow due to the uninitialized op_name. Initialize it to fix the issue. Fixes: 054b6c7866c7 ("selftests/bpf: Add verifier log tests for BPF_BTF_LOA= D command") Signed-off-by: Leo Yan --- tools/testing/selftests/bpf/prog_tests/verifier_log.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/bpf/prog_tests/verifier_log.c b/tools/= testing/selftests/bpf/prog_tests/verifier_log.c index c01c0114af1b7476d27885ce380d90400a4bdc89..4542bb586d723b8fda2faf82610= 66f16102c60c0 100644 --- a/tools/testing/selftests/bpf/prog_tests/verifier_log.c +++ b/tools/testing/selftests/bpf/prog_tests/verifier_log.c @@ -317,6 +317,7 @@ static void verif_btf_log_subtest(bool bad_btf) res =3D load_btf(&opts, true); ASSERT_EQ(res, -ENOSPC, "half_log_fd"); ASSERT_EQ(strlen(logs.buf), 24, "log_fixed_25"); + strscpy(op_name, "log_fixed", sizeof(op_name)); ASSERT_STRNEQ(logs.buf, logs.reference, 24, op_name); =20 /* validate rolling verifier log logic: try all variations of log buf --=20 2.34.1 From nobody Mon Jun 8 04:27:30 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 22D6F364043; Tue, 2 Jun 2026 14:47:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411678; cv=none; b=EzIgXeWF13rhajxVRCv6V7s7MHgxjUIZD4lg3fdVpAvTzQzr0iSIeHP73Y+tGh9vIeMAIZm8bAPU2Zno5TfOUlrLy1oWqYp278fj+OQfWuvZn6a/UCIx9bzphC/q2bNET37mYh6ZUId4+EXZngFt0I6bVzRKng4KPgfN59tJc5U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411678; c=relaxed/simple; bh=bMN9gphLJ0WpQVf2p7gRQo/4Ma444n+6RwFR/oCCDds=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FSEeJuSKC674z7UOtTefFKKMT2V+4FxPj73NyNjkTOrz5+PorjOftqAQLaZCKnUGRgDRxiB/2GOjEf2GHxOeg1OgzxVwKN0suOJvbCgjgfl6UGdyPXKKRwevqu7koAwjEE6y/lLxTpkZ3MXJOAIOxswH+PDNYZYkfzhBpAePLpE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=uywKaYA4; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="uywKaYA4" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B018A2B; Tue, 2 Jun 2026 07:47:50 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3CB573F632; Tue, 2 Jun 2026 07:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1780411675; bh=bMN9gphLJ0WpQVf2p7gRQo/4Ma444n+6RwFR/oCCDds=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uywKaYA4ak3RTQezJyAobLlxIRE501WokpNfyShftwbwxg4zrYCbzAHWnG1NO1+Vh oRHz8HvyAMdQWm89pu+z8xcR+Dpolarcg7kMdlYxKogL75oe3+c2j+utiSXvjCcu7N +BUvq8BmNH4XERm52V7gS/bmu67G1+bU1x+MywiQ= From: Leo Yan Date: Tue, 02 Jun 2026 15:47:16 +0100 Subject: [PATCH bpf-next v2 7/8] selftests/bpf: Use common CFLAGS for urandom_read Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260602-tools_build_fix_zero_init_bpf_only-v2-7-c76e5250ea1c@arm.com> References: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> In-Reply-To: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Lorenz Bauer , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Kees Cook , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780411637; l=2847; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=bMN9gphLJ0WpQVf2p7gRQo/4Ma444n+6RwFR/oCCDds=; b=emrjfJPI9VdzcKeIN1ZDHuyaKSs8VnFdstQhCXZeZpQLKrr4TDaRvRiw1vOikCxNLP+JWsEuc oiYidFuvAKbA3KRz/aVYu4ly4pxS6Nw1dcKf+ny1PHsL5sX39aenybk X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= The urandom_read helper and its shared library are built with $(CLANG) directly rather than through the normal selftest $(CC) rules. The CFLAGS variable can contain specific flags only for $(CC) but might be imcompatible for $(CLANG) and those flags are not necessarily valid for the clang-only urandom_read build. Split the BPF selftest local flags into COMMON_CFLAGS and append them to CFLAGS for the normal build path. Use COMMON_CFLAGS directly for urandom_read and liburandom_read.so, while still filtering out -static as before. Signed-off-by: Leo Yan --- tools/testing/selftests/bpf/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests= /bpf/Makefile index bc049620c7745ce35976f5e0922eb680e38def13..1e47e29ba4214925c62afc0595a= 7edb859ace944 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -51,7 +51,7 @@ srctree :=3D $(patsubst %/,%,$(dir $(srctree))) srctree :=3D $(patsubst %/,%,$(dir $(srctree))) endif =20 -CFLAGS +=3D -g $(OPT_FLAGS) -rdynamic -std=3Dgnu11 \ +COMMON_CFLAGS =3D -g $(OPT_FLAGS) -rdynamic -std=3Dgnu11 \ -Wall -Werror -fno-omit-frame-pointer \ -Wno-unused-but-set-variable \ $(GENFLAGS) $(SAN_CFLAGS) $(LIBELF_CFLAGS) \ @@ -64,7 +64,7 @@ LDLIBS +=3D $(LIBELF_LIBS) -lz -lrt -lpthread PCAP_CFLAGS :=3D $(shell $(PKG_CONFIG) --cflags libpcap 2>/dev/null && ech= o "-DTRAFFIC_MONITOR=3D1") PCAP_LIBS :=3D $(shell $(PKG_CONFIG) --libs libpcap 2>/dev/null) LDLIBS +=3D $(PCAP_LIBS) -CFLAGS +=3D $(PCAP_CFLAGS) +CFLAGS +=3D $(COMMON_CFLAGS) $(PCAP_CFLAGS) =20 # Some utility functions use LLVM libraries jit_disasm_helpers.c-CFLAGS =3D $(LLVM_CFLAGS) @@ -261,7 +261,7 @@ endif $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urandom_read_lib2.c libu= random_read.map $(call msg,LIB,,$@) $(Q)$(CLANG) $(CLANG_TARGET_ARCH) \ - $(filter-out -static,$(CFLAGS) $(LDFLAGS)) \ + $(filter-out -static,$(COMMON_CFLAGS) $(LDFLAGS)) \ $(filter %.c,$^) $(filter-out -static,$(LDLIBS)) \ -Wno-unused-command-line-argument \ -fuse-ld=3D$(LLD) -Wl,-znoseparate-code -Wl,--build-id=3Dsha1 \ @@ -271,7 +271,7 @@ $(OUTPUT)/liburandom_read.so: urandom_read_lib1.c urand= om_read_lib2.c liburandom $(OUTPUT)/urandom_read: urandom_read.c urandom_read_aux.c $(OUTPUT)/libura= ndom_read.so $(call msg,BINARY,,$@) $(Q)$(CLANG) $(CLANG_TARGET_ARCH) \ - $(filter-out -static,$(CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \ + $(filter-out -static,$(COMMON_CFLAGS) $(LDFLAGS)) $(filter %.c,$^) \ -Wno-unused-command-line-argument \ -lurandom_read $(filter-out -static,$(LDLIBS)) -L$(OUTPUT) \ -fuse-ld=3D$(LLD) -Wl,-znoseparate-code -Wl,--build-id=3Dsha1 \ --=20 2.34.1 From nobody Mon Jun 8 04:27:30 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D9DEF364043; Tue, 2 Jun 2026 14:48:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411682; cv=none; b=eFWKvFO6IW2ZOuV6ZxUz5wgxXlP0x1P40v1U55/EtHopWchqMNs6+M64pW0kUaIRvFMPMz2x/vU97gT91ot+zOnJ2miZM++tPx3dy12oQvNHjG+JTZAxlNs9Z+oI5C/dSzGttic2RFaeWn/HWuBbKCMwJnr8jAKo928wQ3qFr7Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780411682; c=relaxed/simple; bh=tBWghxOoy760LznhjWPLMsorMOUF8XUjgk8TeUz6l1M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ozzcfLEJRGcu4iTT6Ve49s1aek3Ddk6uxbBe3IBw6sqeuwiMv1Gc8ts7O07e/gm90az7GuE2TRfK5towT4U3Mcvb3SdAYiT+kP41pFF6Vkd93WC/0gTylIo3PpMTbg/nYkWF6pdGKbJCyfLfLh6O0WvWi7aY9hCNBwxjV3C7zCM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=LOg5ZGmu; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="LOg5ZGmu" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 76E9619F6; Tue, 2 Jun 2026 07:47:55 -0700 (PDT) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 03F273F632; Tue, 2 Jun 2026 07:47:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1780411680; bh=tBWghxOoy760LznhjWPLMsorMOUF8XUjgk8TeUz6l1M=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LOg5ZGmu518ZkCsJLcqgYjJEUXyDouXNrnEbyTHw/haPfaoHe64obu0/YOWYA8W+8 xc/xRRhHAZFpQav0uV0r+tDCDQenff7W2P4XvbWwGCdQCtDwxsr5+ZN5OT32fj7+91 vbXs4/X1lAFXNFiwitWoMf4jHWlHMWGqH6SxlSLo= From: Leo Yan Date: Tue, 02 Jun 2026 15:47:17 +0100 Subject: [PATCH bpf-next v2 8/8] selftests/bpf: Avoid static LLVM linking for cross builds Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260602-tools_build_fix_zero_init_bpf_only-v2-8-c76e5250ea1c@arm.com> References: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> In-Reply-To: <20260602-tools_build_fix_zero_init_bpf_only-v2-0-c76e5250ea1c@arm.com> To: Quentin Monnet , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Lorenz Bauer , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt Cc: Arnaldo Carvalho de Melo , Namhyung Kim , Ian Rogers , James Clark , Kees Cook , bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, llvm@lists.linux.dev, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1780411637; l=1910; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=tBWghxOoy760LznhjWPLMsorMOUF8XUjgk8TeUz6l1M=; b=8ZY/PbHwZHO5k6Px7eSBt/bi2qfBHGuFSVLXyyi2bdr148mAam2GORwMsLTFSpZLDVHHlAZR4 Ugv4muZoC5RAUElMAjnjNqYVa77OdmyxxJx2z8RvY9ys173jQJS2LUR X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= The BPF selftests prefer static LLVM linking, which works for native builds but can break cross builds. Its --link-static output may include host-only libraries that are unavailable for the cross compilation, causing link failures. Avoid static LLVM linking for cross builds and use shared LLVM libraries instead. Native builds keep the existing behavior. Signed-off-by: Leo Yan --- tools/testing/selftests/bpf/Makefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests= /bpf/Makefile index 1e47e29ba4214925c62afc0595a7edb859ace944..ffa90674e86f639d3a9cadb833e= 57f3693d77bdc 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -188,8 +188,15 @@ ifeq ($(feature-llvm),1) LLVM_CONFIG_LIB_COMPONENTS :=3D mcdisassembler all-targets # both llvm-config and lib.mk add -D_GNU_SOURCE, which ends up as confli= ct LLVM_CFLAGS +=3D $(filter-out -D_GNU_SOURCE,$(shell $(LLVM_CONFIG) --cf= lags)) - # Prefer linking statically if it's available, otherwise fallback to sha= red - ifeq ($(shell $(LLVM_CONFIG) --link-static --libs >/dev/null 2>&1 && ech= o static),static) + # Cross compilation must use dynamic linking to avoid unresolved library + # dependencies. For native build, prefer linking statically if it's + # available, otherwise fallback to shared. + ifneq ($(ARCH), $(HOSTARCH)) + LLVM_LINK_STATIC :=3D + else + LLVM_LINK_STATIC :=3D $(shell $(LLVM_CONFIG) --link-static --libs >/de= v/null 2>&1 && echo y) + endif + ifeq ($(LLVM_LINK_STATIC),y) LLVM_LDLIBS +=3D $(shell $(LLVM_CONFIG) --link-static --libs $(LLVM_C= ONFIG_LIB_COMPONENTS)) LLVM_LDLIBS +=3D $(filter-out -lxml2,$(shell $(LLVM_CONFIG) --link-st= atic --system-libs $(LLVM_CONFIG_LIB_COMPONENTS))) LLVM_LDLIBS +=3D -lstdc++ --=20 2.34.1