[api] Only apply -O2 to libsodium, not noise-c

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.
This commit is contained in:
J. Nick Koston
2026-04-12 19:15:06 -10:00
parent 5a250cc74f
commit 63184e95a2

View File

@@ -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"])