From: Leo Yan <leo.yan@arm.com>
To: James Clark <james.clark@linaro.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
"Liang, Kan" <kan.liang@linux.intel.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] perf build: Use -fzero-init-padding-bits=all
Date: Thu, 20 Mar 2025 15:06:45 +0000 [thread overview]
Message-ID: <20250320150645.GD3249206@e132581.arm.com> (raw)
In-Reply-To: <06233fa3-0663-4861-8fd0-ca30806d38a3@linaro.org>
On Thu, Mar 20, 2025 at 11:46:03AM +0000, James Clark wrote:
[...]
> > --- a/tools/perf/Makefile.config
> > +++ b/tools/perf/Makefile.config
> > @@ -323,6 +323,8 @@ FEATURE_CHECK_LDFLAGS-libaio = -lrt
> > FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
> > FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl
> > +# Explicitly clear padding bits with the initializer '{ 0 }'
> > +CORE_CFLAGS += $(call cc-option,-fzero-init-padding-bits=all)
> > CORE_CFLAGS += -fno-omit-frame-pointer
> > CORE_CFLAGS += -Wall
> > CORE_CFLAGS += -Wextra
>
> I don't think this makes its way to libperf. I don't have a compiler that
> supports it, but "-std=gnu11" is in CORE_CFLAGS and that's not there on any
> libperf compile commands so I'm assuming CORE_CFLAGS is only local to Perf.
Indeed. Thanks for pointing out.
Since the commit 91009a3a9913 ("perf build: Install libperf locally when
building"), though the CORE_CFLAGS is appended to LIBPERF_CFLAGS, the
later is never populated to libperf.
I can add the compiler option into tools/lib/perf as well, and remove
the unused LIBPERF_CFLAGS variable. This can allow the libperf to be
built independently from the perf tool.
To be honest, I am a bit concerned this is still insufficient as Perf
also links other libs (e.g. libbpf). Another option is to place the
compiler option into tools/scripts/Makefile.include, something like:
diff --git a/tools/scripts/Makefile.include b/tools/scripts/Makefile.include
index 0aa4005017c7..86d1a318a9f6 100644
--- a/tools/scripts/Makefile.include
+++ b/tools/scripts/Makefile.include
@@ -40,6 +40,18 @@ EXTRA_WARNINGS += -Wwrite-strings
EXTRA_WARNINGS += -Wformat
EXTRA_WARNINGS += -Wno-type-limits
+try-run = $(shell set -e; \
+ if ($(1)) >/dev/null 2>&1; \
+ then echo "$(2)"; \
+ else echo "$(3)"; \
+ fi)
+
+__cc-option = $(call try-run,\
+ $(1) -Werror $(2) -c -x c /dev/null -o /dev/null,$(2),)
+cc-option = $(call __cc-option, $(CC),$(1))
+
+CFLAGS += $(call cc-option,-fzero-init-padding-bits=all)
+
Thanks,
Leo
prev parent reply other threads:[~2025-03-20 15:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 10:52 Leo Yan
2025-03-20 11:46 ` James Clark
2025-03-20 15:06 ` Leo Yan [this message]
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=20250320150645.GD3249206@e132581.arm.com \
--to=leo.yan@arm.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=namhyung@kernel.org \
/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
all inboxes | Powered by JetHome®