Skip to content

tools build: Append -fzero-init-padding-bits=all option

Leo Yan linux-kbuild linux-perf-users lkml 8 versions – In review

Get series with b4
b4 am [email protected] change-id 20260224-tools_build_fix_zero_init-dc5261bd8b8b

Versions newest first

  1. v7 Latest23 patches 2 repliesIn review
  2. v624 patches 3 repliesSuperseded
  3. v526 patches 6 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v430 patches25 repliesSuperseded
v330 patches46 repliesSuperseded
v2 posting 2/21 patch13 repliesSuperseded inferred link
v2 posting 1/21 patch1 replySuperseded inferred link
v11 patch2 repliesSuperseded

Changes in v7 from the cover letter

- Appended $(EXTRA_CFLAGS) in tracing/rtla/Makefile.
- Refactored testing/selftests/lib.mk to include Makefile.include, as
the $(EXTRA_CFLAGS) can be applied globally for selftest, dropped the
patches for selftests/hid, selftests/nolibc and selftests/sched_ext.
- Link to v6: https://lore.kernel.org/r/[email protected]

Patches in v7 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/23tools: lib: thermal: Fix typotools/lib/thermal/Makefile+2 -20 replies
2/23tools/thermal: Fix typotools/thermal/lib/Makefile+2 -20 replies
3/23tools: lib: thermal: Initialize CFLAGS before including Makefile.includetools/lib/thermal/Makefile+9 -70 replies
4/23tools/thermal: Initialize CFLAGS before including Makefile.includetools/thermal/lib/Makefile+9 -70 replies
5/23selftests/nolibc: Use a dedicated cross cc-option helpertools/testing/selftests/nolibc/Makefile.nolibc+6 -60 replies
6/23tools build: Append -fzero-init-padding-bits=all to extra cflagstools/scripts/Makefile.include+30 -00 replies
7/23perf build: Append extra host flagstools/perf/Makefile.config+1 -10 replies
8/23tools build: Append extra host CFLAGS for fixdeptools/build/Makefile+5 -30 replies
9/23tools: bootconfig: Append extra cflagstools/bootconfig/Makefile+1 -00 replies
10/23tools: counter: Append extra cflagstools/counter/Makefile+1 -01 reply
11/23tools: dma: Append extra cflagstools/dma/Makefile+1 -00 replies
12/23tools: gpio: Append extra cflagstools/gpio/Makefile+1 -00 replies
13/23tools: hv: Append extra cflagstools/hv/Makefile+1 -00 replies
14/23tools: iio: Append extra cflagstools/iio/Makefile+1 -00 replies
15/23tools: mm: Append extra cflagstools/mm/Makefile+1 -00 replies
16/23tools: objtool: Append extra host cflagstools/objtool/Makefile+2 -00 replies
17/23tools: power: acpi: Append extra cflagstools/power/acpi/Makefile.config+1 -00 replies
18/23tools: power: x86/intel-speed-select: Append extra cflagstools/power/x86/intel-speed-select/Makefile+1 -00 replies
19/23tools: sched_ext: Append extra cflagstools/sched_ext/Makefile+1 -01 reply
20/23tools: spi: Append extra cflagstools/spi/Makefile+1 -00 replies
21/23tools: tracing: Append extra cflagstools/tracing/latency/Makefile tools/tracing/rtla/Makefile+2 -00 replies
22/23tools: usb: Append extra cflagstools/usb/Makefile+1 -00 replies
23/23selftests: Include tools Makefile.includetools/testing/selftests/lib.mk+15 -150 replies

Reviews trailers per patch

16 of 23 patches have a Reviewed-by or Acked-by.

PatchDaniel LezcanoQuentin MonnetNamhyung KimMasami Hiramatsu (Google)Qinxin XiaBartosz GolaszewskiHaiyang ZhangJonathan CameronJosh PoimboeufSrinivas PandruvadaMark BrownTejun HeoWilliam Breathitt Gray
1/23A-b
2/23A-b
3/23A-b
4/23A-b
5/23
6/23A-b A-b
7/23A-b
8/23
9/23A-b
10/23A-b
11/23A-b
12/23A-b
13/23R-b
14/23A-b
15/23
16/23A-b
17/23
18/23A-b
19/23A-b
20/23A-b
21/23
22/23
23/23

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 13 reviewers.

Read the v7 thread

Cover letter [PATCH v7 00/23] tools build: Append -fzero-init-padding-bits=all option

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: Rename to cross-cc-option so the function name
cc-option can be reserved for using globally.
Patch 06: Propagate -fzero-init-padding-bits=all to
EXTRA_CFLAGS and HOST_EXTRACFLAGS for the CC and HOSTCC compilers, respectively.
Patches 07 – 23: Apply EXTRA_CFLAGS and HOST_EXTRACFLAGS in
project Makefiles.

The change has been verified:

Test 1: Cross compiling perf (rebased on perf-tools-next)

	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: BPF CI test (BPF patches will be sent separately)

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

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

---
Changes in v7:
- Appended $(EXTRA_CFLAGS) in tracing/rtla/Makefile.
- Refactored testing/selftests/lib.mk to include Makefile.include, as
the $(EXTRA_CFLAGS) can be applied globally for selftest, dropped the
patches for selftests/hid, selftests/nolibc and selftests/sched_ext.
- Link to v6: https://lore.kernel.org/r/[email protected]

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/[email protected]

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/[email protected]

---
Leo Yan (23):
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 selftests/nolibc: Use a dedicated cross cc-option helper tools build: Append -fzero-init-padding-bits=all to extra cflags perf build: Append extra host flags
tools build: Append extra host CFLAGS for fixdep
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: Include tools Makefile.include

 tools/bootconfig/Makefile                      |  1 +
 tools/build/Makefile                           |  8 ++++---
 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/lib.mk                 | 30 +++++++++++++-------------
 tools/testing/selftests/nolibc/Makefile.nolibc | 12 +++++------
 tools/thermal/lib/Makefile                     | 20 +++++++++--------
 tools/tracing/latency/Makefile                 |  1 +
 tools/tracing/rtla/Makefile                    |  1 +
 tools/usb/Makefile                             |  1 +
 22 files changed, 95 insertions(+), 43 deletions(-)

---
base-commit: 6f3ed7fec72fc8979b2a8c7219c0a9fcfc8d07b5
change-id: 20260224-tools_build_fix_zero_init-dc5261bd8b8b

Best regards,

Signature · 1 line
Leo Yan <[email protected]>