Skip to content

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

@z3ntu

Description

@z3ntu

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions