public inbox for linux-perf-users@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/30] tools build: Append -fzero-init-padding-bits=all option
@ 2026-03-08 16:46 Leo Yan
  2026-03-08 16:46 ` [PATCH v3 01/30] bpftool: Avoid adding EXTRA_CFLAGS to HOST_CFLAGS Leo Yan
                   ` (29 more replies)
  0 siblings, 30 replies; 77+ messages in thread
From: Leo Yan @ 2026-03-08 16:46 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, llvm, bpf, linux-perf-users, Leo Yan

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 <leo.yan@arm.com>
---
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 <leo.yan@arm.com>


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

end of thread, other threads:[~2026-03-10 17:50 UTC | newest]

Thread overview: 77+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-08 16:46 [PATCH v3 00/30] tools build: Append -fzero-init-padding-bits=all option Leo Yan
2026-03-08 16:46 ` [PATCH v3 01/30] bpftool: Avoid adding EXTRA_CFLAGS to HOST_CFLAGS Leo Yan
2026-03-09 10:17   ` Quentin Monnet
2026-03-09 17:40   ` Ian Rogers
2026-03-09 17:51     ` Quentin Monnet
2026-03-08 16:46 ` [PATCH v3 02/30] libbpf: Initialize CFLAGS before including Makefile.include Leo Yan
2026-03-09 17:03   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 03/30] tools: lib: thermal: " Leo Yan
2026-03-09 15:10   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 04/30] tools/thermal: " Leo Yan
2026-03-09  8:41   ` Daniel Lezcano
2026-03-09 10:07     ` Leo Yan
2026-03-10 12:00       ` Daniel Lezcano
2026-03-08 16:46 ` [PATCH v3 05/30] tools build: Append -fzero-init-padding-bits=all to extra cflags Leo Yan
2026-03-09 10:17   ` Quentin Monnet
2026-03-09 17:17   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 06/30] bpftool: Append extra host flags Leo Yan
2026-03-09 10:17   ` Quentin Monnet
2026-03-08 16:46 ` [PATCH v3 07/30] perf build: " Leo Yan
2026-03-08 16:46 ` [PATCH v3 08/30] tools/bpf: build: Append extra cflags Leo Yan
2026-03-09 17:42   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 09/30] tools build: Append extra host cflags Leo Yan
2026-03-08 16:46 ` [PATCH v3 10/30] tools build: Append extra cflags for feature Leo Yan
2026-03-09 17:51   ` Ian Rogers
2026-03-10 14:25     ` Leo Yan
2026-03-08 16:46 ` [PATCH v3 11/30] tools: bootconfig: Append extra cflags Leo Yan
2026-03-09 12:22   ` Masami Hiramatsu
2026-03-09 17:53   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 12/30] tools: counter: " Leo Yan
2026-03-09 17:55   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 13/30] tools: dma: " Leo Yan
2026-03-09 12:08   ` Qinxin Xia
2026-03-09 17:56   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 14/30] tools: gpio: " Leo Yan
2026-03-09  8:54   ` Bartosz Golaszewski
2026-03-09 17:57   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 15/30] tools: hv: " Leo Yan
2026-03-08 20:28   ` [EXTERNAL] " Haiyang Zhang
2026-03-09 17:58   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 16/30] tools: iio: " Leo Yan
2026-03-09 17:58   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 17/30] tools: mm: " Leo Yan
2026-03-09 17:59   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 18/30] tools: nolibc: " Leo Yan
2026-03-09 22:20   ` Thomas Weißschuh
2026-03-08 16:46 ` [PATCH v3 19/30] tools: objtool: Append extra host cflags Leo Yan
2026-03-09 20:19   ` Josh Poimboeuf
2026-03-08 16:46 ` [PATCH v3 20/30] tools: power: acpi: Append extra cflags Leo Yan
2026-03-09 18:01   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 21/30] tools: power: x86/intel-speed-select: " Leo Yan
2026-03-09 15:59   ` srinivas pandruvada
2026-03-09 18:02   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 22/30] tools: sched_ext: " Leo Yan
2026-03-09 18:07   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 23/30] tools: spi: " Leo Yan
2026-03-08 23:21   ` Mark Brown
2026-03-09 18:03   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 24/30] tools: tracing: " Leo Yan
2026-03-09 15:44   ` Steven Rostedt
2026-03-09 16:37     ` Ian Rogers
2026-03-10 11:48       ` Leo Yan
2026-03-08 16:46 ` [PATCH v3 25/30] tools: usb: " Leo Yan
2026-03-09 18:04   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 26/30] tools: verification: " Leo Yan
2026-03-09  6:26   ` Gabriele Monaco
2026-03-10 15:58     ` Leo Yan
2026-03-08 16:46 ` [PATCH v3 27/30] selftests/bpf: " Leo Yan
2026-03-09 18:05   ` Ian Rogers
2026-03-10 17:50   ` Leo Yan
2026-03-08 16:46 ` [PATCH v3 28/30] selftests/hid: " Leo Yan
2026-03-09 18:06   ` Ian Rogers
2026-03-08 16:46 ` [PATCH v3 29/30] selftests/nolibc: " Leo Yan
2026-03-09 22:24   ` Thomas Weißschuh
2026-03-10 16:06     ` Leo Yan
2026-03-08 16:46 ` [PATCH v3 30/30] selftests/sched_ext: " Leo Yan
2026-03-09 12:45   ` Andrea Righi
2026-03-09 18:02   ` Ian Rogers

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