From 59ff36d3bf7d73cd4efd6f89bbf9c86a09a04d16 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Wed, 20 Mar 2024 08:25:10 +0100 Subject: [PATCH] CMake: Compile with -ftrivial-auto-var-init=zero As per upstream guidance [0] we should compile the sources with this flag in order to not hit issues with using uninitialized variables. [0] https://android-review.googlesource.com/c/platform/system/core/+/2963911/1#message-01ebff378bb51f7815b6ed8b035a57fbce0418ab Fixes #133 --- vendor/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index bcabe7e..9d33219 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -16,6 +16,9 @@ if(APPLE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_DARWIN_C_SOURCE -D__DARWIN_C_LEVEL=__DARWIN_C_FULL") endif() +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftrivial-auto-var-init=zero") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftrivial-auto-var-init=zero") + # Android seems to use various attributes supported by clang but not by # GCC which causes it to emit lots of warnings. Since these attributes # don't seem to effect runtime behaviour simply disable the warnings.