mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v6 00/24] tools build: Append -fzero-init-padding-bits=all option
@ 2026-03-23 15:13 Leo Yan
  2026-03-23 15:13 ` [PATCH v6 01/24] tools: lib: thermal: Fix typo Leo Yan
                   ` (25 more replies)
  0 siblings, 26 replies; 28+ messages in thread
From: Leo Yan @ 2026-03-23 15:13 UTC (permalink / raw)
  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, Nuno Sá,
	Andy Shevchenko, Andrew Morton, Willy Tarreau,
	Thomas Weißschuh, 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, linux-kernel, linux-perf-users, Leo Yan,
	Bartosz Golaszewski, Jonathan Cameron

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.

BPF/bpftool related patches will be sent separately, as maintainers
prefer them to go via the BPF tree.

The changes are organized into three parts:

  Patches 01 – 04: Fixes for thermal build.
  Patch 05:        Propagate -fzero-init-padding-bits=all to
                   EXTRA_CFLAGS and HOST_EXTRACFLAGS for the
                   CC and HOSTCC compilers, respectively.
  Patches 06 – 24: Apply EXTRA_CFLAGS and HOST_EXTRACFLAGS in
                   project Makefiles.

The change has been verified:

Test 1: Cross compiling perf
	host: gcc 15.2.0 (x86_64), target: aarch64-linux-gnu-gcc

  make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- LDFLAGS="-static" \
	    -C tools/perf VF=1 CORESIGHT=1 NO_JEVENTS=1 DEBUG=1

Test 2: Cross compiling selftest bpf and sched_ext
	host: gcc 15.2.0 (x86_64), target: aarch64-linux-gnu-gcc

  export ARCH=arm64
  export CROSS_COMPILE=aarch64-linux-gnu-
  make -C tools/testing/selftests/ TARGETS="bpf sched_ext" SKIP_TARGETS=""

Test 3: Native compiling selftest bpf and sched_ext
	host: gcc 15.2.0 (x86_64)

  make -C tools/testing/selftests/ TARGETS="bpf sched_ext" SKIP_TARGETS=""

Test 4: BPF CI test (with BPF patches sent separately)

  https://github.com/kernel-patches/bpf/actions/runs/23439834394

[1] https://gcc.gnu.org/gcc-15/changes.html

Signed-off-by: Leo Yan <leo.yan@arm.com>
---
Changes in v6:
- Gathered Acked tags (thanks Jonathan!)
- Left out bpftool patches and will send together with other BPF patches (Quentin)
- Added back complete info in cover (Peter.Z)
- Link to v5: https://lore.kernel.org/r/20260318-tools_build_fix_zero_init-v5-0-bbeffd8da199@arm.com

Changes in v5:
- Gathered Acked tags (thanks Daniel, Namhyung, Benjamin!)
- Appended HOST_EXTRACFLAGS after KBUILD_HOSTCFLAGS (Ian)
- Appended CFLAGS for libc-test (Thomas)
- Left out BPF patches and will send out separately (Alexei)
- Rebase on v7.0.0-rc4
- Link to v4: https://lore.kernel.org/r/20260311-tools_build_fix_zero_init-v4-0-9e35bdb99cb3@arm.com

---
Leo Yan (24):
      tools: lib: thermal: Fix typo
      tools/thermal: Fix typo
      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
      perf build: Append extra host flags
      tools build: Append extra host cflags
      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: 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
      selftests/hid: Append extra cflags
      selftests/nolibc: Append extra cflags
      selftests/sched_ext: Append extra cflags

 tools/bootconfig/Makefile                   |  1 +
 tools/build/Makefile                        |  6 ++++--
 tools/counter/Makefile                      |  1 +
 tools/dma/Makefile                          |  1 +
 tools/gpio/Makefile                         |  1 +
 tools/hv/Makefile                           |  1 +
 tools/iio/Makefile                          |  1 +
 tools/lib/thermal/Makefile                  | 20 ++++++++++---------
 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              | 30 +++++++++++++++++++++++++++++
 tools/spi/Makefile                          |  1 +
 tools/testing/selftests/hid/Makefile        |  1 +
 tools/testing/selftests/nolibc/Makefile     |  7 +++----
 tools/testing/selftests/sched_ext/Makefile  |  1 +
 tools/thermal/lib/Makefile                  | 20 ++++++++++---------
 tools/tracing/latency/Makefile              |  1 +
 tools/usb/Makefile                          |  1 +
 22 files changed, 77 insertions(+), 25 deletions(-)
---
base-commit: bfec8e88ff6022b056615ec71506703e7e54de82
change-id: 20260224-tools_build_fix_zero_init-dc5261bd8b8b

Best regards,
-- 
Leo Yan <leo.yan@arm.com>


^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2026-03-23 22:11 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-23 15:13 [PATCH v6 00/24] tools build: Append -fzero-init-padding-bits=all option Leo Yan
2026-03-23 15:13 ` [PATCH v6 01/24] tools: lib: thermal: Fix typo Leo Yan
2026-03-23 15:13 ` [PATCH v6 02/24] tools/thermal: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 03/24] tools: lib: thermal: Initialize CFLAGS before including Makefile.include Leo Yan
2026-03-23 15:13 ` [PATCH v6 04/24] tools/thermal: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 05/24] tools build: Append -fzero-init-padding-bits=all to extra cflags Leo Yan
2026-03-23 15:13 ` [PATCH v6 06/24] perf build: Append extra host flags Leo Yan
2026-03-23 15:13 ` [PATCH v6 07/24] tools build: Append extra host cflags Leo Yan
2026-03-23 15:13 ` [PATCH v6 08/24] tools: bootconfig: Append extra cflags Leo Yan
2026-03-23 15:13 ` [PATCH v6 09/24] tools: counter: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 10/24] tools: dma: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 11/24] tools: gpio: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 12/24] tools: hv: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 13/24] tools: iio: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 14/24] tools: mm: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 15/24] tools: objtool: Append extra host cflags Leo Yan
2026-03-23 21:52   ` Ian Rogers
2026-03-23 15:13 ` [PATCH v6 16/24] tools: power: acpi: Append extra cflags Leo Yan
2026-03-23 15:13 ` [PATCH v6 17/24] tools: power: x86/intel-speed-select: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 18/24] tools: sched_ext: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 19/24] tools: spi: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 20/24] tools: tracing: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 21/24] tools: usb: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 22/24] selftests/hid: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 23/24] selftests/nolibc: " Leo Yan
2026-03-23 15:13 ` [PATCH v6 24/24] selftests/sched_ext: " Leo Yan
2026-03-23 21:56 ` [PATCH v6 00/24] tools build: Append -fzero-init-padding-bits=all option Ian Rogers
2026-03-23 22:11 ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®