From nobody Thu Dec 18 22:35:12 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E710E2080D9; Thu, 20 Mar 2025 10:52:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742467975; cv=none; b=r+BzltwubOS0vxF6Ho0UhaAwbVoz6iKCXxapDbhdDohgJGJKkLx+O1CwzDZ3KKFpj84yPZs3EoHoJHE02mGyCyihJZcThZKwHcq1Un8AD9lTgH2wDogHozC0QHdgsR7JuJEYlopJoANFoq29cuUO/Kn9SdC3g7Xr6KgED5dJtQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742467975; c=relaxed/simple; bh=PYDOmSl2p1Fip80TqRIZOF7AApAkcengg2Yk1qVLQFQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=J4J9n/fhBmx61R+ibjBwzJFuQVXMqRoiRnMpNpmuo04dfLuIn+kDjILGglDajElrLi+EPYCyFmDkWZ9viSvYTqThsTBDN7ir51jk6fUb9IH6YIq25TGGaMPDIxOgjbI3JF5H3aUdPDMZqsP9HgsoryIuvra0EHaAdQREEQkkFBo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C7F4F1424; Thu, 20 Mar 2025 03:52:53 -0700 (PDT) Received: from e132581.cambridge.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 386D03F694; Thu, 20 Mar 2025 03:52:44 -0700 (PDT) From: Leo Yan To: Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , "Liang, Kan" , James Clark , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Leo Yan Subject: [PATCH v2] perf build: Use -fzero-init-padding-bits=all Date: Thu, 20 Mar 2025 10:52:35 +0000 Message-Id: <20250320105235.3498106-1-leo.yan@arm.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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=3Dunions option to restore old GCC behavior. This new behaviour might cause unexpected data when we define a union with using the '{ 0 }' initializer. Currently, the perf tool has ruled out these cases with the sanitizer "-fsanitize=3Dundefined". But the sanitizer is not enabled by default, we need to manually enable it with EXTRA_CFLAGS=3D'-fsanitize=3Dundefined'. This means developers might encounter issues caused by the initializer with new compilers. Enable -fzero-init-padding-bits=3Dall to zero padding bits in unions and structures that might otherwise be left uninitialized. [1] https://gcc.gnu.org/gcc-15/changes.html Signed-off-by: Leo Yan --- Changes from v1: - Changed to use '-fzero-init-padding-bits=3Dall' to replace '-fzero-init-padding-bits=3Dunions'. (Namhyung) - Updated commit log for a bit background info. (Ian) tools/perf/Makefile.config | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config index a148ca9efca9..b4f6d656c729 100644 --- a/tools/perf/Makefile.config +++ b/tools/perf/Makefile.config @@ -323,6 +323,8 @@ FEATURE_CHECK_LDFLAGS-libaio =3D -lrt FEATURE_CHECK_LDFLAGS-disassembler-four-args =3D -lbfd -lopcodes -ldl FEATURE_CHECK_LDFLAGS-disassembler-init-styled =3D -lbfd -lopcodes -ldl =20 +# Explicitly clear padding bits with the initializer '{ 0 }' +CORE_CFLAGS +=3D $(call cc-option,-fzero-init-padding-bits=3Dall) CORE_CFLAGS +=3D -fno-omit-frame-pointer CORE_CFLAGS +=3D -Wall CORE_CFLAGS +=3D -Wextra --=20 2.34.1