From b6cfb7ecf605c4cae3db2067b99067e01a80b00f Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Wed, 7 May 2025 00:26:46 +0700 Subject: [PATCH] fix(build): ensure zero-init of padding bits with GCC 15+ GCC 15 introduces a regression in guaranteed zero-initialization of padding bits. The suggested solution is to add the -fzero-init-padding-bits=unions compile option. To prevent similar issues in the future, this change adds the -fzero-init-padding-bits=all build option. It ensures that padding bits in unions and structs are properly zeroed, avoiding regressions. --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c27ab870d..13151b9001 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -169,6 +169,10 @@ if(CONFIG_COMPILER_DUMP_RTL_FILES) list(APPEND compile_options "-fdump-rtl-expand") endif() +if(CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 15.0) + list(APPEND c_compile_options "-fzero-init-padding-bits=all") +endif() + __generate_prefix_map(prefix_map_compile_options) list(APPEND compile_options ${prefix_map_compile_options})