Skip to content

Commit

Permalink
[build] set -fno-omit-frame-pointer
Browse files Browse the repository at this point in the history
This patch sets the `-fno-omit-frame-pointer` for non release builds.
This is useful for a few things:
- makes stack traces more reliable and complete
- enables better profiling with tools like perf
- better visibility into call chains during performance analysis

It has a small impact on performance as an extra register needs to be
used, e.g., the `rbp` register on x86_64 to store the frame pointer. It
also incurs a small of setup and teardown of stack frames. Because of
these reasons, this is currently only set for non release builds.
  • Loading branch information
philipportner committed Oct 25, 2024
1 parent 649b2da commit 0a11e1b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_OPTIMIZE_DEPENDENCIES 1)

set(CMAKE_CXX_FLAGS_DEBUG="${CMAKE_CXX_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_DEBUG="${CMAKE_CXX_FLAGS_DEBUG} -g -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g -O3")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -g -O3 -fno-omit-frame-pointer")

# silence a warning about DEPFILE path transformations (used in LLVM)
cmake_policy(SET CMP0116 OLD)
Expand Down

0 comments on commit 0a11e1b

Please sign in to comment.