Skip to content

ci: teensy41 link fails on master — SpiHw2/4MXRT1062 undefined reference to SPIClass, SPI, SPI1, SPI2 #3775

Closed

Description

@zackees

teensy41 has been failing on master since 2026-07-30. Like #3774 it is not PR-specific and blocks the matrix on every PR.

Unlike #3774 (a tool-provisioning gap) this one is a real link-level regression: the Teensy SPI library is not being linked into the firmware, so every symbol fl::SpiHw2MXRT1062 / fl::SpiHw4MXRT1062 needs is unresolved.

Evidence it is master

run branch / commit result
30431060834 master, #3766 (2026-07-29) success
30434174486 master, #3768 (2026-07-29) success
30509160856 master, WS2814 #3770 (2026-07-30) failure
30599312243 PR #3771 failure, byte-identical

The failure text on master and on PR #3771 is identical down to the section offsets (.text+0x2672, .text+0x26b0, ...), which is what you would expect if the PR contributes nothing to it — #3771 is a Python-only build-system change.

The failure

Linking firmware.elf
build error: build failed: arm-none-eabi-gcc link failed:
ld: .lto-tmp/ccRkNord.ltrans1.ltrans.o: in function `fl::SpiHw4MXRT1062::begin(fl::SpiHw4::Config const&)':
<artificial>:(.text+0x2672): undefined reference to `SPIClass::setSCK(unsigned char)'
<artificial>:(.text+0x2682): undefined reference to `SPIClass::setMOSI(unsigned char)'
<artificial>:(.text+0x2692): undefined reference to `SPIClass::setMISO(unsigned char)'
<artificial>:(.text+0x2698): undefined reference to `SPIClass::begin()'
<artificial>:(.text+0x26b0): undefined reference to `SPI'
<artificial>:(.text+0x26b4): undefined reference to `SPI1'
<artificial>:(.text+0x26b8): undefined reference to `SPI2'
ld: in function `fl::SpiHw2MXRT1062::cleanup()':
<artificial>:(.text+0x46b6): undefined reference to `SPIClass::end()'
ld: in function `fl::SpiHw2MXRT1062::begin(fl::SpiHw2::Config const&)':
<artificial>:(.text+0x6fb4): undefined reference to `SPIClass::setSCK(unsigned char)'
...
collect2: error: ld returned 1 exit status

Every unresolved symbol comes from the Teensy core's SPI library (SPIClass and the SPI/SPI1/SPI2 global instances). Compilation succeeds — this fails only at link, and only under LTO (.lto-tmp/...ltrans.o).

Notes for whoever picks this up

  • Both SpiHw2MXRT1062 and SpiHw4MXRT1062 are affected, in begin() and cleanup(), so it looks like the whole SPI library dependency dropped out of the teensy41 link line rather than one call site drifting.
  • Worth checking whether the library is being pruned because nothing references it from a translation unit the dependency scanner sees — LTO plus an Arduino-style library auto-detection pass is a common way to lose a library that is only referenced from a .cpp.hpp pulled in indirectly.
  • The three check_teensy3x_size workflows are also red on master on the same commit, which may share a cause.

Master is currently red on five checks (this, #3774, and check_teensy32/35/36_size), so "all checks green" is not presently a reachable merge bar.

Activity

  1. zackees commented on Jul 31, 2026

    @zackees
    MemberAuthor

    Root-caused and reproduced locally. The original attribution in this issue was wrong, and so was my first hypothesis — correcting both.

    It is not #3770, and not dead-code resurrection

    My initial guess was that #3770 added a reference chain that resurrected previously dead-stripped SPI code. That is false. git show 5dd05daff6 touches nothing Teensy, nothing SPI, and nothing reaching SpiHw2/4MXRT1062; the last change under src/platforms/arm/teensy/teensy4_common/ was #3577, long before the regression window.

    What actually happened is the inverse. Comparing the green run (5345d6a) to the red one (5dd05da):

    example green run red run
    AnalogOutput 58.00 KB 31.00 KB
    Animartrix 327.00 KB 299.00 KB
    AnimartrixRing 350.00 KB 322.00 KB
    Apa102 154.00 KB, SUCCESS link error

    A uniform ~27 KB shrink across every firmware, with byte-identical compiler flags, identical toolchain hash and identical fbuild version. That is a library leaving the link line, not an optimizer change.

    The green run's first example logged Compiled 1/1 files — the whole object set, including the Teensy SPI library object, was restored warm from cache. The red run logged Compiled 84/84 files: #3770 modified src/, busting the cache and forcing the first cold dependency resolution in a long time. That resolution does not include libraries/SPI. So #3770 is a cache-buster that exposed a latent defect, not the defect.

    The real bug is a pre-existing undeclared dependency: FastLED's Teensy 4.x LPSPI drivers hard-require the Arduino SPI library, and nothing puts it on the link line.

    Local reproduction

    bash compile teensy41 --examples Blink succeeds — which is why this looked board-wide but is not. Clockless-only sketches dead-strip the SPI drivers. bash compile teensy41 --examples Apa102 fails with the identical error. CI runs args: teensy41 all, so it hits Apa102, Apa102HD, Audio, AudioInput, AudioReactive, AutoResearch, ...

    Four fixes attempted — only one works, and it is not one FastLED controls

    # attempt result
    1 lib_ldf_mode = "deep" on the teensy41 board no effect — emitted into the generated ini, ignored
    2 lib_deps = ["SPI"] on the teensy41 board no effect — emitted into the generated ini, ignored
    3 "dependencies": [{"name": "SPI", "platforms": "teensy"}] in library.json no effect
    4 #include <SPI.h> added to examples/Apa102/Apa102.ino links — Flash 129.00 KB, SUCCESS

    All four were reverted; the working tree is clean.

    Conclusion

    fbuild's library dependency finder resolves only includes visible from the sketch. It does not scan library sources or library headers, and it honors neither lib_deps nor lib_ldf_mode from the generated platformio.ini, nor dependencies in library.json.

    Corroborating evidence from the CI log itself: Ports/PJRCSpectrumAnalyzer — whose .ino includes SPI.h directly — compiled 147/147 files including libraries/SPI/SPI.cpp and linked fine in the same failing run. Apa102, whose only path to SPI.h runs through FastLED's own headers (FastLED.h → fastspi.h:42 → platforms/spi_device_proxy.h → arm/mxrt1062/spi_device_proxy.h:33 → <SPI.h>), does not.

    Note that this header chain already exists and is reachable from the sketch's #include <FastLED.h>. PlatformIO's own chain LDF would follow it. fbuild does not, which is why no amount of FastLED-side declaration helps.

    So there is no supported FastLED-side fix. bash compile teensy41 --examples Apa102 is a 30-second reproduction for whoever picks this up. Per CLAUDE.md ("do not add a temporary workaround for an fbuild gap"), I am not patching around it by sprinkling #include <SPI.h> into eight examples — that would fix CI while leaving the actual defect in place and would not help anyone building FastLED with fbuild outside this repo.

    Filing upstream at FastLED/fbuild.

  2. zackees commented on Aug 2, 2026

    @zackees
    MemberAuthor

    Follow-up filed as #3838 for the broader current eensy41 all baseline: master also omits the Teensy Audio set_audioClock implementation and the Adafruit_NeoPixel implementation at link. #3775 remains the SPI-specific root-cause thread.

  3. zackees commented on Aug 20, 2026

    @zackees
    MemberAuthor

    Resolved by #3802 (merge 2841fe8439), which implemented the #3777 design:

    The SPI-specific link regression reported here is no longer present. Broader all-examples dependency gaps remain tracked separately in #3838.

  4. moved this from Triage to Done in FastLED Trackeron Aug 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions