redirect the floating-point capable vfprintf / vfscanf symbols to picolibc's integer-only variant (#24720)

This commit is contained in:
Jason2866
2026-05-09 10:45:29 +02:00
committed by GitHub
parent c68667181a
commit f5cafb7a0e
2 changed files with 27 additions and 1 deletions
+26
View File
@@ -0,0 +1,26 @@
#
# Picolibc-specific linker flags.
#
# When the Arduino ESP32 framework is built against picolibc (detected via
# `-specs=picolibc.specs`), redirect the floating-point capable vfprintf / vfscanf
# symbols to picolibc's integer-only variants (__i_vfprintf / __i_vfscanf).
# This drops the float/double formatting code path from the firmware and saves
# a noticeable amount of flash.
#
Import("env")
def _picolibc_in_use(env):
for var in ("CCFLAGS", "CFLAGS", "CXXFLAGS", "LINKFLAGS"):
for flag in env.get(var, []):
if "picolibc.specs" in str(flag):
return True
return False
if _picolibc_in_use(env):
env.Append(LINKFLAGS=[
"-Wl,--defsym=vfprintf=__i_vfprintf",
"-Wl,--defsym=vfscanf=__i_vfscanf",
])
+1 -1
View File
@@ -49,6 +49,7 @@ lib_ignore =
ArduinoOTA
extra_scripts = pre:pio-tools/add_c_flags.py
pre:pio-tools/solidify-from-url.py
post:pio-tools/picolibc_flags.py
post:pio-tools/dump-defines.py
post:pio-tools/gen-berry-defines.py
post:pio-tools/gen-berry-structures.py
@@ -103,4 +104,3 @@ platform = https://github.com/tasmota/platform-espressif32/re
platform_packages =
build_unflags = ${esp32_defaults.build_unflags}
build_flags = ${esp32_defaults.build_flags}