mirror of
https://github.com/esphome/esphome.git
synced 2026-09-21 20:18:43 +00:00
ESP-IDF SDK components reference fprintf(), printf(), and vprintf() which pull in newlib's _vfprintf_r (~11 KB). This is a separate implementation from _svfprintf_r (used by snprintf/vsnprintf) that handles FILE* stream I/O with buffering and locking. ESPHome replaces the ESP-IDF log handler via esp_log_set_vprintf_(), so the SDK's vprintf() path is dead code at runtime. The fprintf() and printf() calls in SDK components are only in debug/assert paths that are either GC'd or never called. These linker --wrap stubs redirect through vsnprintf() + fwrite(), allowing the linker to dead-code eliminate _vfprintf_r. An escape hatch is provided via enable_full_printf: true in the esp32 advanced config section for external components that need full FILE*-based fprintf.