From 44a38047bb92f25d3123581432631547031a4e70 Mon Sep 17 00:00:00 2001 From: Erhan Kurubas Date: Thu, 20 Aug 2026 13:25:31 +0200 Subject: [PATCH] change(esp_trace): compile hot path at -O2 regardless of project optimization Every event record runs through this component, so -Og on the rest of the project should not set the per-event tracing overhead. --- components/esp_trace/CMakeLists.txt | 4 ++++ components/esp_trace/Kconfig | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/components/esp_trace/CMakeLists.txt b/components/esp_trace/CMakeLists.txt index 9b3e3ac5ae7..871f1e715ad 100644 --- a/components/esp_trace/CMakeLists.txt +++ b/components/esp_trace/CMakeLists.txt @@ -46,3 +46,7 @@ idf_component_register(SRCS ${srcs} REQUIRES ${requires} WHOLE_ARCHIVE TRUE LDFRAGMENTS linker.lf) + +if(CONFIG_ESP_TRACE_OPTIMIZE_SPEED) + target_compile_options(${COMPONENT_LIB} PRIVATE -O2) +endif() diff --git a/components/esp_trace/Kconfig b/components/esp_trace/Kconfig index 7a0d8e3c2c8..21b95c66917 100644 --- a/components/esp_trace/Kconfig +++ b/components/esp_trace/Kconfig @@ -159,4 +159,14 @@ menu "ESP Trace Configuration" endchoice + config ESP_TRACE_OPTIMIZE_SPEED + bool "Compile trace hot path for speed (-O2)" + depends on ESP_TRACE_ENABLE + default y + help + Compile this component with -O2 regardless of the project-wide + optimization level. The per-event trace path (locking, timestamps) + runs through this code, so its speed directly contributes to the + per-event tracing overhead. + endmenu