From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC6D533F365; Sun, 8 Mar 2026 16:46:39 +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=1772988403; cv=none; b=jb99BPas1OjJWk1Tl9tEWG5emmHELzsm/tHxF0WEQW3yzy9fJoN3F/A5SvANA3QPn21pamQtUuoefo7m4ugh5dLDaROcgrNIu5P4TRMCYY4XJ4GzeunvErvLxsQ73xXIQV5iJ4qj6Ze5Ec7VXuYc4wWY5rtdyiTepP6xz1LdJEs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772988403; c=relaxed/simple; bh=Tc0lndhA3qp3WkqrTPnPBNSk6pyPwX6QhyRxTEiuDnY=; h=From:Subject:Date:Message-Id:MIME-Version:Content-Type:To:Cc; b=FosQ8wCT7wwtrY3PpCbs489LROsLsiL7cJqFYjQ96PbzVszPZqmoCTKy68FC47lh7Jm/fqW3fy8nu0dm3ZoAohyr68XZInpovAiakcUCJKyOyCwVgXU1a5sKWNmoKE2d8MY1Ds3ozu7V5M3x/gPAGoYazNva6kaXHKP8bQVG5aU= 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; 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 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 B651D1758; Sun, 8 Mar 2026 09:46: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 D8B843F694; Sun, 8 Mar 2026 09:46:24 -0700 (PDT) From: Leo Yan Subject: [PATCH v3 00/30] tools build: Append -fzero-init-padding-bits=all option Date: Sun, 08 Mar 2026 16:46:05 +0000 Message-Id: <20260308-tools_build_fix_zero_init-v3-0-6477808123b7@arm.com> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-B4-Tracking: v=1; b=H4sIAM2nrWkC/42NXQ6CMBCEr0L22Rq6KjY+eQ9Dmv6ssgm0pEWiE u5u5QQ+fpOZbxbIlJgyXKoFEs2cOYYCh10FrjPhQYJ9YcAamxrxKKYY+6ztk3uv7/zSH0pRc+B JeHfCRlqvrLJQ9mOiUtjct7Zwx3mK6b1dzfhL/7HOKKSw0jin5NnUkq4mDXsXB2jXdf0CBGiwx cAAAAA= X-Change-ID: 20260224-tools_build_fix_zero_init-dc5261bd8b8b To: Arnaldo Carvalho de Melo , Ian Rogers , Namhyung Kim , James Clark , Kees Cook , Quentin Monnet , Nathan Chancellor , Nicolas Schier , Nick Desaulniers , Bill Wendling , Justin Stitt , 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 , "Rafael J. Wysocki" , Daniel Lezcano , Zhang Rui , Lukasz Luba , Peter Zijlstra , Ingo Molnar , Mark Rutland , Alexander Shishkin , Adrian Hunter , Masami Hiramatsu , William Breathitt Gray , Barry Song , Qinxin Xia , Bartosz Golaszewski , Kent Gibson , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Jonathan Cameron , David Lechner , =?utf-8?q?Nuno_S=C3=A1?= , Andy Shevchenko , Andrew Morton , Willy Tarreau , =?utf-8?q?Thomas_Wei=C3=9Fschuh?= , Josh Poimboeuf , Robert Moore , Len Brown , Srinivas Pandruvada , Tejun Heo , David Vernet , Andrea Righi , Changwoo Min , Mark Brown , Steven Rostedt , Gabriele Monaco , Shuah Khan , Jiri Kosina , Benjamin Tissoires Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, llvm@lists.linux.dev, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1772988384; l=5429; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=Tc0lndhA3qp3WkqrTPnPBNSk6pyPwX6QhyRxTEiuDnY=; b=/7RyLMM/efjUgseU6DFkghtJCkFtN/T0ka5j+jiiuEp7Td6vOngRngWVLncOqQAI8NGl1uWn0 sttzYZ4XOv0DoeW3cBuiqE34X3ALthVmG/knEHLBCH7w5mvdla4NVBx X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= GCC-15 doesn't guarantee that a {0} initializer clears the whole union [1]. This may cause bugs if data is not intialized properly. The kernel enabld the -fzero-init-padding-bits=all option to tackle the issue, which was merged in commit dce4aab8441d ("kbuild: Use -fzero-init-padding-bits=all"). This series propagates the same flag to the tools build. It uses tools/scripts/Makefile.include as the central place to add the option to EXTRA_CFLAGS and HOST_EXTRACFLAGS for the CC and HOSTCC compilers. Each project under tools/ appends the variables as needed. The variable name HOST_EXTRACFLAGS comes from kbuild conventions (see Documentation/kbuild/makefiles.rst). This series is divided into three parts: Patches 01 – 04: Preparation before adding the new compiler option. These patches adjust Makefiles to ensure the newly introduced option does not cause regressions. Patch 05: Propagate -fzero-init-padding-bits=all to EXTRA_CFLAGS and HOST_EXTRACFLAGS for the CC and HOSTCC compilers, respectively. Patches 06 – 30: Apply EXTRA_CFLAGS and HOST_EXTRACFLAGS in project Makefiles. The change has been verified: Test 1: cross compiling perf with aarch64 GCC-15.2 [2]: ARCH=arm64 CROSS_COMPILE=aarch64-none-linux-gnu- \ make LDFLAGS="-static" -C tools/perf VF=1 NO_JEVENTS=1 \ DEBUG=1 V=1 NO_LIBELF=1 NO_LIBTRACEEVENT=1 Test 2: native selftest build on Arm64 machine: make -C tools/testing/selftests TARGETS=hid SKIP_TARGETS="" V=1 [1] https://gcc.gnu.org/gcc-15/changes.html [2] https://developer.arm.com/-/media/Files/downloads/gnu/15.2.rel1/binrel/arm-gnu-toolchain-15.2.rel1-x86_64-aarch64-none-linux-gnu.tar.xz Signed-off-by: Leo Yan --- Changes in v3: - Extended to support cross compilation (Quentin). - Link to v2: https://lore.kernel.org/r/20260224-tools_build_fix_zero_init-v2-1-b1acc817a01e@arm.com --- Leo Yan (30): bpftool: Avoid adding EXTRA_CFLAGS to HOST_CFLAGS libbpf: Initialize CFLAGS before including Makefile.include tools: lib: thermal: Initialize CFLAGS before including Makefile.include tools/thermal: Initialize CFLAGS before including Makefile.include tools build: Append -fzero-init-padding-bits=all to extra cflags bpftool: Append extra host flags perf build: Append extra host flags tools/bpf: build: Append extra cflags tools build: Append extra host cflags tools build: Append extra cflags for feature tools: bootconfig: Append extra cflags tools: counter: Append extra cflags tools: dma: Append extra cflags tools: gpio: Append extra cflags tools: hv: Append extra cflags tools: iio: Append extra cflags tools: mm: Append extra cflags tools: nolibc: Append extra cflags tools: objtool: Append extra host cflags tools: power: acpi: Append extra cflags tools: power: x86/intel-speed-select: Append extra cflags tools: sched_ext: Append extra cflags tools: spi: Append extra cflags tools: tracing: Append extra cflags tools: usb: Append extra cflags tools: verification: Append extra cflags selftests/bpf: Append extra cflags selftests/hid: Append extra cflags selftests/nolibc: Append extra cflags selftests/sched_ext: Append extra cflags tools/bootconfig/Makefile | 1 + tools/bpf/Makefile | 1 + tools/bpf/bpftool/Makefile | 9 +++++++-- tools/build/Makefile | 6 ++++-- tools/build/feature/Makefile | 2 ++ tools/counter/Makefile | 1 + tools/dma/Makefile | 1 + tools/gpio/Makefile | 1 + tools/hv/Makefile | 1 + tools/iio/Makefile | 1 + tools/include/nolibc/Makefile | 2 +- tools/lib/bpf/Makefile | 16 ++++++++------- tools/lib/thermal/Makefile | 16 ++++++++------- tools/mm/Makefile | 1 + tools/objtool/Makefile | 2 ++ tools/perf/Makefile.config | 2 +- tools/power/acpi/Makefile.config | 1 + tools/power/x86/intel-speed-select/Makefile | 1 + tools/sched_ext/Makefile | 1 + tools/scripts/Makefile.include | 28 ++++++++++++++++++++++++++ tools/spi/Makefile | 1 + tools/testing/selftests/bpf/Makefile | 1 + tools/testing/selftests/hid/Makefile | 1 + tools/testing/selftests/nolibc/Makefile.nolibc | 3 +++ tools/testing/selftests/sched_ext/Makefile | 1 + tools/thermal/lib/Makefile | 16 ++++++++------- tools/tracing/latency/Makefile | 1 + tools/usb/Makefile | 1 + tools/verification/rv/Makefile | 1 + 29 files changed, 93 insertions(+), 27 deletions(-) --- base-commit: 4ae12d8bd9a830799db335ee661d6cbc6597f838 change-id: 20260224-tools_build_fix_zero_init-dc5261bd8b8b Best regards, -- Leo Yan