Skip to content

Commit 97dd74d

Browse files
build: add Profile CMAKE_BUILD_TYPE for perf/flamegraph
Adds a Profile build type with -O2 -g -fno-omit-frame-pointer so perf can walk stacks accurately while running optimized code. Use with cmake -DCMAKE_BUILD_TYPE=Profile ..
1 parent 8b4c93e commit 97dd74d

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ cmake --build . --target zmc
132132

133133
| Option | Values | Default | Notes |
134134
|--------|--------|---------|-------|
135-
| `CMAKE_BUILD_TYPE` | Release/Debug/Optimised | Release | |
135+
| `CMAKE_BUILD_TYPE` | Release/Debug/Optimised/Profile | Release | `Profile` = `-O2 -g -fno-omit-frame-pointer` for perf/flamegraph |
136136
| `BUILD_TEST_SUITE` | ON/OFF | OFF | Enables Catch2 tests |
137137
| `ENABLE_WERROR` | ON/OFF | OFF | Warnings as errors (CI uses ON) |
138138
| `ASAN` | ON/OFF | OFF | AddressSanitizer |

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ set(CMAKE_C_FLAGS_DEBUG "-g")
3838
set(CMAKE_CXX_FLAGS_DEBUG "-g")
3939
set(CMAKE_C_FLAGS_OPTIMISED "-O3")
4040
set(CMAKE_CXX_FLAGS_OPTIMISED "-O3")
41+
# Profile: release-level optimization, plus debug symbols and frame pointers
42+
# so perf/flamegraph can walk stacks accurately. Use with:
43+
# cmake -DCMAKE_BUILD_TYPE=Profile ..
44+
set(CMAKE_C_FLAGS_PROFILE "-O2 -g -fno-omit-frame-pointer")
45+
set(CMAKE_CXX_FLAGS_PROFILE "-O2 -g -fno-omit-frame-pointer")
4146
set(CMAKE_INCLUDE_CURRENT_DIR ON)
4247
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
4348
set(CMAKE_CXX_STANDARD 17)

0 commit comments

Comments
 (0)