From 02f828fcbf425d921023c1405b0528c78366a2fc Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 12 Apr 2026 18:37:50 -1000 Subject: [PATCH] [benchmark] Use -Os to match firmware optimization level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CodSpeed benchmarks were building with -O2, while all firmware targets (ESP8266, ESP32, LibreTiny) use -Os. This mismatch means the benchmarks cannot detect inlining regressions that affect real devices — GCC under -O2 inlines functions that -Os outlines due to its size-conscious cost model. Switch to -Os with -ffunction-sections/-fdata-sections for proper dead-code stripping (needed because -Os preserves references that -O2 optimizes away at compile time). --- script/cpp_benchmark.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/script/cpp_benchmark.py b/script/cpp_benchmark.py index c09c4dee90..5080a9fec7 100755 --- a/script/cpp_benchmark.py +++ b/script/cpp_benchmark.py @@ -27,7 +27,10 @@ STUBS_DIR: Path = Path(root_path) / "tests" / "benchmarks" / "stubs" PLATFORMIO_OPTIONS = { "build_flags": [ + "-Os", # match firmware optimization level (detects inlining regressions) "-g", # debug symbols for profiling + "-ffunction-sections", # required for dead-code stripping with -Os + "-fdata-sections", # required for dead-code stripping with -Os "-DUSE_BENCHMARK", # disable WarnIfComponentBlockingGuard in finish() f"-I{STUBS_DIR}", # stub headers for ESP32-only components ],