Repository navigation
Description
2026-06-15 revision: original numbers in this issue came from a flawed map-parser methodology (see retraction comment on #3075 / #3078). Issue body now reflects real
arm-none-eabi-nm --print-sizedata on the ELF. Substance of the bug is confirmed and bigger than originally reported.
Symptom
Despite the FL_PLATFORM_HAS_LARGE_MEMORY == 0 "no soft-FP" invariant intended for Low-memory targets, the LPC845 LowMemory + FASTLED_LPC_RX_SCT_WS2812=1 link pulls in 8,332 bytes of libgcc/libc soft-FP and integer-division routines from the cortex-m0plus nofp newlib variant (arm-none-eabi/lib/thumb/v6-m/nofp/).
Real nm breakdown:
| Symbol | Bytes |
|---|---|
__aeabi_dadd (double add) |
2,088 |
__aeabi_dmul (double mul) |
1,392 |
__aeabi_fsub (float sub) |
1,172 |
__aeabi_fadd (float add) |
1,110 |
__clzdi2 (64-bit count-leading-zeros) |
860 |
__aeabi_fmul (float mul) |
660 |
__aeabi_fdiv (float div) |
556 |
Others (smaller __div* / __fix* / __float*) |
~500 |
| Total | ~8,300 |
LPC845 has no FPU. Any double arithmetic in a reachable code path costs 30 to 80 times more flash than an integer equivalent. The __aeabi_dadd + __aeabi_dmul pair alone (~3.5 KB) is more than the entire base LowMemory sketch.
Why this is surprising
This is exactly the invariant #3022 / #3038 / #3000 were supposed to enforce. We have a centralized FL_PLATFORM_HAS_LARGE_MEMORY macro and a documented link-symbol check (src/platforms/arm/lpc/README.md). Either:
- The link-symbol check is not being run for the
RX_SCT_WS2812config (it may be only checked for the base LowMemory config), OR - Something in
<FastLED.h>or its transitive headers has adoubleliteral in a reachable code path that the soft-FP guard did not catch.
Suspects to chase
fl::ieee754_format_decimal(594 B) +fl::ieee754_parse_decimal(482 B) +fl::kPow10MantLUT (824 B) — the JSON number formatter/parser uses a manual IEEE-754 decimal path that should be int-only, but if any reachable code path lifts tofloatordoubleit'd pull the soft-FP cascade.- The
fl::jsonfloat-coercion path (fl::json::as_float()) — should be int-tagged via#3022but the test-config delta matters; verify it stays out of the link when only int-typed RPC methods are registered. - Any header transitively pulled by
<FastLED.h>that has astatic constexpr doubleorstatic const floatconstant in an inlined function.
Repro
Build LPC845 with -DFASTLED_LPC_RX_SCT_WS2812=1. Until FastLED/fbuild#594 lands, this requires hand-patching the LD script:
# Bump LENGTH from 64K to 128K in:
~/.fbuild/prod/cache/platforms/zackees-ArduinoCore-LPC8xx/.../lpc845_flash.ld
PLATFORMIO_SRC_DIR=examples/AutoResearch fbuild build -e lpc845brk
# Then run nm --print-size on the resulting ELF:
arm-none-eabi-nm --print-size --demangle .fbuild/build/lpc845brk/release/firmware.elf | \
grep -E '__aeabi_[fdiu]|__[afsmd][udl][bd]df|__div|__floatsi|__fix|__clz'
Acceptance
-
arm-none-eabi-nm firmware.elfreports zero references to__aeabi_dadd,__aeabi_dsub,__aeabi_dmul,__aeabi_ddivand less than 1 KB combined for the float variants for the LPC845 LowMemory + RX_SCT_WS2812 config - The link-symbol guard test is extended to cover this config (not just the base LowMemory build)
- Documented in
src/platforms/arm/lpc/README.mdwhichnminvocation is the canonical guard
Related
- bash bloat / fbuild symbols: no arm-none-eabi path; can't measure LPC845 bloat from FastLED's wrapper fbuild#594 — tooling gap (no
bash bloatfor arm-none-eabi) - fl::json: custom 64-bit packed tagged-number type (replaces variant<i64, float, double> in #3002) #3022 / feat(json): integer-only IEEE 754 codec replaces soft-FP cascade (refs #3022) #3038 — soft-FP elimination from fl::json (already shipped; coverage gap is this issue)
- Meta META: LPC845 64 KB flash bloat hunt -- clear 11 KB overage to unblock FASTLED_LPC_RX_SCT_WS2812=1 #3079
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
zackees commentedon Jun 15, 2026
Tracked under meta #3079 (LPC845 64 KB flash bloat hunt) alongside three sibling bloat sub-issues and the FastLED/fbuild#594 tooling-gap dependency.
[-]LPC845 bloat: ~5 KB of double-precision soft-FP leaks past the no-soft-FP invariant[/-][+]LPC845 bloat: 8.3 KB of soft-FP / integer-div leaks past the no-soft-FP invariant on LowMemory + RX_SCT_WS2812[/+]zackees commentedon Jun 15, 2026
Issue body and title revised 2026-06-15 with real
nm --print-sizedata. Now part of revised meta #3079 sub-issue set: {#3076 soft-FP, #3077 variant, #3081 RPC dispatch, #3082 JSON codec}. Two earlier sub-issues #3075 #3078 closed as filed-in-error.zackees commentedon Jun 15, 2026
Investigation findings (2026-06-15)
Ran
arm-none-eabi-nm --print-size --demangleon the LPC845 ELF (built with FLASH region temporarily relaxed to 128 KB so the link succeeds) and traced the soft-FP cascade.Not the culprit (DCE'd cleanly)
fl::json::as_double()andfl::json_value::as_double()— not present in the linked binary.class json's in-header inline definitions get DCE'd when nothing calls them.fl::float_conversion_visitor<double>— not instantiated.fl::int_conversion_visitor<int>::operator()(const double&)— the "dead-code-by-design" overload atsrc/fl/stl/json/types.h:281is not reachable in the link.Actually reachable visitor instantiations on this build
SerializerVisitorwalks the variant to emit a JSON string. For thefloatalternative it callsfl::ieee754_format_decimal(594 B in the binary) which depends on thefl::kPow10MantLUT (824 B rodata). That's the float formatting path.Why double soft-FP is still present
The single-precision soft-FP helpers (
__aeabi_fadd,__aeabi_fsub,__aeabi_fmul,__aeabi_fdiv) on the cortex-m0plusnofpnewlib variant internally call double soft-FP for some operations. Specifically,__aeabi_faddand__aeabi_fsubuse the__addsf3/__subsf3paths that share infrastructure with__adddf3/__subdf3in libgcc's softfp.h. Linking any float operation transitively pulls__aeabi_dadd(2,088 B) and friends.This explains why simply auditing for
doubleliterals in C++ source doesn't help — the leak comes from libgcc's internal float-via-double implementation, not from user-level double usage.Real fix paths
This is more invasive than originally scoped. Three viable approaches:
floatalternative fromjson_value::variant_ton Low-memory targets. Replaces the variant with a 9-alternative version that hasi64,string,array,object,vector<i16>,vector<u8>,vector<float>(still has the byte-array one — would need a sibling decision) but no scalarfloat. Removes theSerializerVisitor::operator()(const float&)andieee754_format_decimalpaths from the link.ieee754_format_decimalwith an integer-only fixed-point decimal formatter on Low-memory. Loses precision for large floats but avoids the soft-FP path. Costs ~1 KB rodata for the integer-decimal multipliers.__aeabi_f*operations are reachable and whether using LLVM compiler-rt instead of libgcc would avoid the internal double dependencies. Toolchain-level change; out of scope here.Scope honesty
Original acceptance criteria ("zero references to
__aeabi_daddetc.") was based on the assumption that the fix would be small. The actual fix requires JSON variant surgery (path #1) or a new decimal codec (path #2). Both are 2-3 PR design exercises, not a quick fix.Marking this as scoped for design discussion before further PR work. Path #1 is most aligned with the integer-only LPC8xx RPC contract; #2 is more generally useful but bigger.
perf(fl::json): route i64->float conversions through i32 to eliminate…
perf(fl::json): route i64->float conversions through i32 to eliminate…
perf(rpc/lpc): gate schema generator + enable RX_SCT_WS2812 default o…
zackees commentedon Jun 16, 2026
Concrete bloat numbers from the LPC845-BRK LowMemory build today
Investigated as part of the #3102 bench-validation meta, Section 1. Build is
examples/AutoResearch/AutoResearch.inowith-DFASTLED_AUTORESEARCH_LOW_MEMORY=1, the LPC8xx low-memory branch. Currently overflows the 64 KB flash budget by 7,472 bytes -- which lines up almost exactly with this issue's 8.3 KB headline and confirms the same root cause.How I produced an ELF to measure
Temporarily expanded the LPC845 linker script's
FLASHregion from 64K -> 128K (reverted before commit) so the link could complete. Resulting firmware was 71.62 KB / 64 KB (111.9%). RAM was fine: 8.51 KB / 16 KB (53.2%, see ranged-stack caveat at the end).Then ran
fbuild symbols firmware.elffor a sized symbol table andarm-none-eabi-objdump -dC | awkto chase BL call-graph edges for the soft-FP helpers.Top FLASH symbols (text section)
Soft-FP helpers, total cost
__aeabi_dadd(double add)__aeabi_l2f__aeabi_dmul(double mul)__aeabi_l2f__aeabi_fsub(single sub)fl::basic_string::append(float, int)__aeabi_fadd(single add)fl::parseFloat(3x),fl::basic_string::append(float, int)__aeabi_fmul(single mul)fl::parseFloat(3x),fl::basic_string::append(float, int)__aeabi_fdiv(single div)fl::parseFloat(1x)That's 6,978 bytes of pure libgcc soft-FP, which is ~94% of the 7,472-byte overflow. Eliminate it and the LowMemory build fits 64 KB with ~500 bytes of margin.
Call-graph entry points (from
objdump -dC)Concrete entry points pulling in the soft-FP chain:
So the real picture is:
fl::jsonstores parsed numbers infl::variant<float, ...>. Even though the AutoResearch RPCs take(int, int, int, int), the variant has a float alternative and its constructor invokes__aeabi_l2fon long-to-float conversion.__aeabi_l2fis implemented in libgcc using double-precision intermediates -- which pulls in__aeabi_dadd(2088 B),__aeabi_dmul(1392 B), and__aeabi_d2f(4 calls). That cascade alone is 3,876 bytes.fl::parseFloatis invoked fromJsonTokenizer::parsewhen the tokenizer hits a number with a decimal point or exponent. Pulls in__aeabi_fmul,__aeabi_fadd,__aeabi_fdivdirectly.fl::basic_string::append(float, int)is the float-overload ofstring::append, invoked fromfl::sstream::operator<<(float)(probably). The pin-toggle handler doess << static_cast<fl::u32>(n_read)etc -- all integer operands -- but theappend(float)overload still gets instantiated via some path I haven't isolated yet.fl::json_value::as_int()doesif (val < INT_MAX && val > INT_MIN) return (int)valagainst the variant's float branch, hence fcmplt + fcmpgt + f2iz.Two concrete fix vectors I see
Path A -- kill the float branch in
fl::variant<float, fl::Empty>on LowMemory targets.The cascade of 3876 bytes from
__aeabi_l2f -> __aeabi_dmul/dadd/d2fexists because the variant's type list containsfloat. Even if no LowMemory code path ever stores a float in that variant, the constructor forvariant<float, ...>(long)instantiates the long-to-float branch and the linker can't dead-code-eliminate it because it's reachable from RTTI-style template dispatch.If
fl::variant<float, fl::Empty>were replaced (under a LowMemory orFL_PLATFORM_HAS_TINY_MEMORY=1guard) withfl::variant<i32, fl::Empty>or similar integer-only alternative, the entire l2f -> double cascade goes away. That's the #3038 follow-up the platformio.ini comment hints at:Estimated saving: 3,876 + ~1,000 = ~5 KB.
Path B -- kill the float overloads of
fl::basic_string::appendandfl::parseFloaton LowMemory.parseFloatis called fromJsonTokenizer::parseonly when a token has a./e/E. The LowMemory JSON-RPC contract takes integers only (the RPC schema ispinToggleRx: [int, int, int, int]). IfparseFloatand the related decimal-parse path were#ifdef-out underFL_PLATFORM_HAS_TINY_MEMORY(with an error-on-decimal-number fallback), we'd save another ~2,500 bytes.Same for
string::append(float, int)-- LowMemory doesn't need float formatting; the sstream<<chain uses only integer operands. Saving: ~1 KB.How this maps to FastLED #3079 / #3076 / #3102
Unrelated side find -- RAM bomb in pinToggleRx
While in the symbol table I noticed
pinToggleRxdeclaresfl::EdgeTime edges_buf[2048];on the stack. EachEdgeTimeis 4 bytes (bitfield + alignment), so that's a 8 KB stack frame on a 16 KB SRAM part. .bss already uses 8.5 KB. The handler will stack-overflow at runtime even if flash fits. Should probably be moved tostaticstorage or down-sized to ~256 entries (~1 KB) for the Phase-1 pin-toggle test.Repro / verification
Method I used (working repro after zccache 1.12.7's namespace fix landed):
Happy to bundle the full symbol report or run additional teardown if it's useful.
Filed via Claude Code on behalf of [email protected].
zackees commentedon Jun 16, 2026
Validation against current master — bloat fix confirmed working
Re-tested against today's master (post
4f620ff0d, which includes the bloat-reduction sweep: #3084 / #3085 / #3087 / #3088 / #3089).Reproduction case from the issue body:
Before the sweep (recorded in my 19:14 UTC comment): build overflowed 64 KB by 7,472 bytes due to ~7 KB of libgcc soft-FP helpers (
__aeabi_dadd,__aeabi_dmul,__aeabi_fadd,__aeabi_fmul,__aeabi_fdiv).After the sweep (now): build succeeds at 64 KB flash. Firmware flashes via pyocd, device boots, echo RPC round-trips cleanly through the JSON-RPC pipe. The
FASTLED_LPC_RX_SCT_WS2812=1flag now ships default-on inplatformio.ini(per #3089) -- so the original "exceeds 64 KB budget" comment is also retired.This issue's symptom is gone. Closure stands.
Two follow-ups surfaced from the same bench session
pinToggleRxhandler then silently dies at runtime (echo works, pinToggleRx repliesNone). Smoking gun is an 8 KB stack-allocatedfl::EdgeTime edges_buf[2048]on a 16 KB SRAM part. Filed with concrete reproduction + three fix shapes..cppfiles inexamples/AutoResearch/(Ble / Helpers / Net / Ota / Remote / Test) need aFASTLED_AUTORESEARCH_LOW_MEMORYgate mirroringAutoResearch.ino's own. Without the gate, current master throws'memcpy' was not declaredatAutoResearchRemote.cpp:3650when LowMemory is selected. PR open.Both are separate concerns from this issue's bloat scope; recording them here so the bench-validation trail in #3102 Section 1 is traceable.
fix(examples/autoresearch): gate companion .cpp files on FASTLED_AUTO…