From: sashiko-bot@kernel.org
To: "Leo Yan" <leo.yan@arm.com>
Cc: linux-perf-users@vger.kernel.org
Subject: Re: [PATCH v7 06/23] tools build: Append -fzero-init-padding-bits=all to extra cflags
Date: Tue, 02 Jun 2026 15:04:01 +0000 [thread overview]
Message-ID: <20260602150401.CE0CA1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260602-tools_build_fix_zero_init-v7-6-631baf679fe7@arm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The `try-run` macro attempts to create a temporary directory in the source tree, breaking out-of-tree builds on read-only filesystems.
- [High] Unconditionally appending to `EXTRA_CFLAGS` in `Makefile.include` breaks `libbpf`'s default compilation flags, causing it to be built without debug info and optimizations.
--
commit e8ede2fdc1b643da62469cb30003522715558696
Author: Leo Yan <leo.yan@arm.com>
Subject: tools build: Append -fzero-init-padding-bits=all to extra cflags
The kernel has enabled -fzero-init-padding-bits=all to zero padding bits
in unions and structures. This commit applies the same option for tools
building by adding cc-option and host-cc-option to dynamically detect and
append it to EXTRA_CFLAGS and HOST_EXTRACFLAGS.
Link: https://gcc.gnu.org/gcc-15/changes.html
> diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
> index 41971a68972dd..17d24cf84051a 100644
> --- a/tools/scripts/Makefile.include
> +++ b/tools/scripts/Makefile.include
[ ... ]
> @@ -139,6 +139,36 @@ else
> EXTRA_WARNINGS += -Wshadow
> endif
>
> +# output directory for tests below
> +TMPOUT = .tmp_$$$$
> +
> +# try-run
> +# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
> +# Exit code chooses option. "$$TMP" serves as a temporary file and is
> +# automatically cleaned up.
> +try-run = $(shell set -e; \
> + TMP=$(TMPOUT)/tmp; \
> + trap "rm -rf $(TMPOUT)" EXIT; \
> + mkdir -p $(TMPOUT); \
[Severity: High]
Does this break out-of-tree builds on read-only filesystems?
Because TMPOUT is hardcoded as .tmp_$$$$ without an $(OUTPUT) prefix,
the mkdir -p command will attempt to write directly to the source directory.
When performing out-of-tree builds (like make O=/path/to/build) on read-only
source trees, this fails with a read-only file system error. Since the
compiler flag uses immediate assignment (:=), this failure might spam the
console and silently drop the option during parsing.
> + if ($(1)) >/dev/null 2>&1; \
> + then echo "$(2)"; \
> + else echo "$(3)"; \
> + fi)
> +
[ ... ]
> +host-cc-option = $(call try-run, \
> + $(HOSTCC) -Werror $(1) -c -x c /dev/null -o "$$TMP",$(1),$(2))
> +
> +# Explicitly clear padding bits with the initializer '{ 0 }'
> +FLAG_ZERO_INIT := $(call cc-option,-fzero-init-padding-bits=all)
> +override EXTRA_CFLAGS += $(FLAG_ZERO_INIT)
[Severity: High]
Will this cause libbpf to lose its default debug and optimization flags?
In tools/lib/bpf/Makefile, there is a conditional block:
ifdef EXTRA_CFLAGS
CFLAGS := $(EXTRA_CFLAGS)
else
CFLAGS := -g -O2
endif
Because tools/scripts/Makefile.include is included prior to this check,
EXTRA_CFLAGS will unconditionally contain -fzero-init-padding-bits=all
if supported by the compiler.
This means EXTRA_CFLAGS is always defined, causing libbpf to completely drop
its default -g -O2 flags and compile with only the padding bits flag.
It appears libthermal was fixed to avoid this issue, but is a corresponding
fix needed for libbpf in this patch series?
> +HOST_FLAG_ZERO_INIT := $(call host-cc-option,-fzero-init-padding-bits=all)
> +override HOST_EXTRACFLAGS += $(HOST_FLAG_ZERO_INIT)
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260602-tools_build_fix_zero_init-v7-0-631baf679fe7@arm.com?part=6
next prev parent reply other threads:[~2026-06-02 15:04 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-02 14:40 [PATCH v7 00/23] tools build: Append -fzero-init-padding-bits=all option Leo Yan
2026-06-02 14:40 ` [PATCH v7 01/23] tools: lib: thermal: Fix typo Leo Yan
2026-06-02 14:54 ` sashiko-bot
2026-06-02 14:40 ` [PATCH v7 02/23] tools/thermal: " Leo Yan
2026-06-02 14:52 ` sashiko-bot
2026-06-02 14:40 ` [PATCH v7 03/23] tools: lib: thermal: Initialize CFLAGS before including Makefile.include Leo Yan
2026-06-02 14:56 ` sashiko-bot
2026-06-02 14:40 ` [PATCH v7 04/23] tools/thermal: " Leo Yan
2026-06-02 14:40 ` [PATCH v7 05/23] selftests/nolibc: Use a dedicated cross cc-option helper Leo Yan
2026-06-02 15:02 ` sashiko-bot
2026-06-02 14:40 ` [PATCH v7 06/23] tools build: Append -fzero-init-padding-bits=all to extra cflags Leo Yan
2026-06-02 15:04 ` sashiko-bot [this message]
2026-06-02 14:40 ` [PATCH v7 07/23] perf build: Append extra host flags Leo Yan
2026-06-02 14:40 ` [PATCH v7 08/23] tools build: Append extra host CFLAGS for fixdep Leo Yan
2026-06-02 15:00 ` sashiko-bot
2026-06-02 14:40 ` [PATCH v7 09/23] tools: bootconfig: Append extra cflags Leo Yan
2026-06-02 14:40 ` [PATCH v7 10/23] tools: counter: " Leo Yan
2026-06-02 14:40 ` [PATCH v7 11/23] tools: dma: " Leo Yan
2026-06-02 14:40 ` [PATCH v7 12/23] tools: gpio: " Leo Yan
2026-06-02 14:40 ` [PATCH v7 13/23] tools: hv: " Leo Yan
2026-06-02 14:40 ` [PATCH v7 14/23] tools: iio: " Leo Yan
2026-06-02 14:40 ` [PATCH v7 15/23] tools: mm: " Leo Yan
2026-06-02 14:40 ` [PATCH v7 16/23] tools: objtool: Append extra host cflags Leo Yan
2026-06-02 14:40 ` [PATCH v7 17/23] tools: power: acpi: Append extra cflags Leo Yan
2026-06-02 15:07 ` sashiko-bot
2026-06-02 14:40 ` [PATCH v7 18/23] tools: power: x86/intel-speed-select: " Leo Yan
2026-06-02 14:40 ` [PATCH v7 19/23] tools: sched_ext: " Leo Yan
2026-06-02 21:27 ` Tejun Heo
2026-06-02 14:40 ` [PATCH v7 20/23] tools: spi: " Leo Yan
2026-06-02 14:40 ` [PATCH v7 21/23] tools: tracing: " Leo Yan
2026-06-02 14:40 ` [PATCH v7 22/23] tools: usb: " Leo Yan
2026-06-02 14:40 ` [PATCH v7 23/23] selftests: Include tools Makefile.include Leo Yan
2026-06-02 15:15 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260602150401.CE0CA1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=leo.yan@arm.com \
--cc=linux-perf-users@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox