From 63184e95a2d8ba53bceae10b57e39cd4b47a2b27 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 12 Apr 2026 19:15:06 -1000 Subject: [PATCH] [api] Only apply -O2 to libsodium, not noise-c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CodSpeed results show only Noise benchmarks improved with -O2 — the speedup comes from libsodium's crypto primitives (Curve25519, ChaCha20, Poly1305), not noise-c's protocol layer. Narrow the optimization to libsodium only. --- esphome/components/api/crypto_optimize.py.script | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/esphome/components/api/crypto_optimize.py.script b/esphome/components/api/crypto_optimize.py.script index fe693d1911..1093a09bf6 100644 --- a/esphome/components/api/crypto_optimize.py.script +++ b/esphome/components/api/crypto_optimize.py.script @@ -1,9 +1,9 @@ -# Compile crypto libraries with -O2 for speed instead of the default -Os. -# Crypto is CPU-bound and benefits significantly from speed optimization. -# GCC uses the last -O flag, so appending -O2 overrides the global -Os -# for these libraries only. +# Compile libsodium with -O2 for speed instead of the default -Os. +# libsodium provides the crypto primitives (Curve25519, ChaCha20, Poly1305) +# used by the Noise protocol and benefits significantly from speed optimization. +# GCC uses the last -O flag, so appending -O2 overrides the global -Os. Import("env") for lb in env.GetLibBuilders(): - if lb.name in ("noise-c", "libsodium"): + if lb.name == "libsodium": lb.env.Append(CCFLAGS=["-O2"])