Page MenuHomePhabricator

[build] set _FORTIFY_SOURCE=2 for -O* builds only
ClosedPublic

Authored by majcosta on May 23 2020, 00:03.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC0e99f4cdb9bd: [build] set _FORTIFY_SOURCE=2 for -O* builds only
Summary

currently building with -DCMAKE_BUILD_TYPE=Debug floods the cli
with warnings about how _FORTIFY_SOURCE=2 requires optimization.

Our Debug build compiles with -O0 because apparently -Og drops some
symbols, so this flag should only be set for Release, RelWithDebInfo
and RelMinSize

h/t @Fabien for help with the CMake generator expressions

Test Plan
cmake .. -GNinja -DCMAKE_BUILD_TYPE=Debug
ninja

see no warnings that _FORTIFY_SOURCE requires compiling with
optimization

cmake .. -GNinja -DCMAKE_BUILD_TYPE=[the other three]
ninja -nv

see the correct flags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 set
in the dry run output

Diff Detail