From 4d7e06da0a47984cecc65c3c9e70121ff866b0a0 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 19 Mar 2026 23:07:17 -1000 Subject: [PATCH] [esp32] Disable PicolibC Newlib compatibility shim on IDF 6.0+ ESP-IDF 6.0 switched from Newlib to PicolibC. The Newlib compatibility shim (CONFIG_LIBC_PICOLIBC_NEWLIB_COMPATIBILITY) provides thread-local stdin/stdout/stderr and getreent() for code compiled against Newlib. ESPHome doesn't link against Newlib-built libraries that use stdio, so the shim is unnecessary overhead. The cost is small (a few dozen bytes of TLS per FreeRTOS task) but there's no reason to carry it. Users linking precompiled Newlib binaries can re-enable via: sdkconfig_options: CONFIG_LIBC_PICOLIBC_NEWLIB_COMPATIBILITY: "y" --- esphome/components/esp32/__init__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/esphome/components/esp32/__init__.py b/esphome/components/esp32/__init__.py index 64e5f44081..31abe6cdf1 100644 --- a/esphome/components/esp32/__init__.py +++ b/esphome/components/esp32/__init__.py @@ -1920,6 +1920,15 @@ async def to_code(config): add_idf_sdkconfig_option("CONFIG_MBEDTLS_SHA384_C", False) add_idf_sdkconfig_option("CONFIG_MBEDTLS_SHA512_C", False) + # Disable PicolibC Newlib compatibility shim on IDF 6.0+ + # IDF 6.0 switched from Newlib to PicolibC. The shim provides thread-local + # stdin/stdout/stderr and getreent() for code compiled against Newlib. + # ESPHome doesn't link against Newlib-built libraries that use stdio. + # If a component needs it (e.g. precompiled Newlib binaries), re-enable via + # sdkconfig_options: CONFIG_LIBC_PICOLIBC_NEWLIB_COMPATIBILITY: "y" + if idf_version() >= cv.Version(6, 0, 0): + add_idf_sdkconfig_option("CONFIG_LIBC_PICOLIBC_NEWLIB_COMPATIBILITY", False) + # Disable regi2c control functions in IRAM # Only needed if using analog peripherals (ADC, DAC, etc.) from ISRs while cache is disabled if advanced[CONF_DISABLE_REGI2C_IN_IRAM]: