nmeum / android-tools

Unoffical CMake-based build system for android command line utilities
Apache License 2.0
176 stars 51 forks source link

Build with -ftrivial-auto-var-init=zero #133

Closed z3ntu closed 5 months ago

z3ntu commented 6 months ago

According to upstream[0] there are several cases of variables or struct members not being initialized, but since they're using -ftrivial-auto-var-init=zero to build the code, those will be zero-initialized by the compiler already.

The CMake files should add this flag also to not hit bugs[1] due to uninitialized variables.

I assume we should be able to add these lines here https://github.com/nmeum/android-tools/blob/master/vendor/CMakeLists.txt#L18

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftrivial-auto-var-init=zero")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftrivial-auto-var-init=zero")

Let me know if I should open a pull request with this or if you have other suggestions.

[0] https://android-review.googlesource.com/c/platform/system/core/+/2963911/comments/233c6468_46a055c5

[1] https://gitlab.archlinux.org/archlinux/packaging/packages/android-tools/-/issues/4

Biswa96 commented 6 months ago

Please wait until the pending pull request is being resolved.

z3ntu commented 6 months ago

I don't see how it could conflict with #132 though, is there some concern there?

anatol commented 5 months ago

@z3ntu could you please send a pull request for this patch? It will help to move changes forward.

z3ntu commented 5 months ago

@anatol #139