linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf build: Restore {0} initializer since GCC-15
@ 2025-03-19 11:04 Leo Yan
  2025-03-19 11:19 ` James Clark
  0 siblings, 1 reply; 8+ messages in thread
From: Leo Yan @ 2025-03-19 11:04 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Ian Rogers, Adrian Hunter,
	Liang, Kan, James Clark, linux-perf-users, linux-kernel
  Cc: Leo Yan

GCC-15 release claims [1]:

 {0} initializer in C or C++ for unions no longer guarantees clearing
 of the whole union (except for static storage duration initialization),
 it just initializes the first union member to zero. If initialization
 of the whole union including padding bits is desirable, use {} (valid
 in C23 or C++) or use -fzero-init-padding-bits=unions option to
 restore old GCC behavior.

This new behaviour might cause stale and unexpected data we defined in
Perf.  Add the -fzero-init-padding-bits=unions option for entirely
zeroing union structures.

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

Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/Makefile.config | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index a148ca9efca9..f767ab634022 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -323,6 +323,14 @@ FEATURE_CHECK_LDFLAGS-libaio = -lrt
 FEATURE_CHECK_LDFLAGS-disassembler-four-args = -lbfd -lopcodes -ldl
 FEATURE_CHECK_LDFLAGS-disassembler-init-styled = -lbfd -lopcodes -ldl
 
+# As described in GCC-15 release: https://gcc.gnu.org/gcc-15/changes.html:
+#   "{0} initializer in C or C++ for unions no longer guarantees clearing
+#    of the whole union (except for static storage duration initialization),
+#    it just initializes the first union member to zero. ... use {} (valid
+#    in C23 or C++) or use -fzero-init-padding-bits=unions option to
+#    restore old GCC behavior."
+CORE_CFLAGS += $(call cc-option,-fzero-init-padding-bits=unions)
+
 CORE_CFLAGS += -fno-omit-frame-pointer
 CORE_CFLAGS += -Wall
 CORE_CFLAGS += -Wextra
-- 
2.34.1


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

end of thread, other threads:[~2025-03-20 11:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-19 11:04 [PATCH] perf build: Restore {0} initializer since GCC-15 Leo Yan
2025-03-19 11:19 ` James Clark
2025-03-19 13:30   ` Leo Yan
2025-03-19 15:26     ` Ian Rogers
2025-03-19 18:28       ` Leo Yan
2025-03-19 21:05         ` Ian Rogers
2025-03-20  1:03           ` Namhyung Kim
2025-03-20 11:36   ` James Clark

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).