Skip to content

fix(teensy): disable LTO on teensylc release profile (Thumb-1 offset overflow)#302

Merged
zackees merged 1 commit into
mainfrom
fix/teensylc-disable-lto
May 30, 2026
Merged

fix(teensy): disable LTO on teensylc release profile (Thumb-1 offset overflow)#302
zackees merged 1 commit into
mainfrom
fix/teensylc-disable-lto

Conversation

@zackees
Copy link
Copy Markdown
Member

@zackees zackees commented May 30, 2026

Summary

  • Every FastLED teensyLC release build on master fails at the assembler with Error: invalid offset, value too big (0x000004CC) on .lto-tmp/*.s, then lto-wrapper: fatal error: make returned 2 exit status.
  • Teensy LC = Cortex-M0+ = Thumb-1 only. Thumb-1 PC-relative loads (ldr Rd, [PC, #imm]) max out around 1 KB (10-bit word-aligned immediate → 0x3FC). LTO rearranges literal pools across TUs and overshoots that on FastLED-sized projects.
  • Every other Teensy MCU is Cortex-M3 or later (Thumb-2, 12-bit immediate) — they keep LTO.
  • Drop -flto=auto / -fno-fat-lto-objects / -fuse-linker-plugin from teensylc's release profile in crates/fbuild-build/src/teensy/configs/teensylc.json. Keep -Os for size.

Test plan

  • cargo check -p fbuild-build clean.
  • cargo test -p fbuild-build --lib teensy:: — 38/38 (including test_teensylc_linker_flags_match_platformio and test_linker_flags_match_platformio_reference which don't reference -flto in the linker_flags allow-list).
  • CI: teensyLC workflow should now link successfully.

Fixes #301

Generated with Claude Code (https://claude.com/claude-code)

…overflow)

Teensy LC is Cortex-M0+ — Thumb-1 only. Thumb-1 PC-relative loads
have an immediate-offset limit (~1 KB / 0x400) that LTO output
routinely overflows when whole-program optimization rearranges
literal pools. On FastLED's `teensyLC` workflow, every release build
now fails:

  .lto-tmp/ccWj7t00.s:193: Error: invalid offset, value too big (0x000004CC)
  .lto-tmp/ccWj7t00.s:206: Error: invalid offset, value too big (0x00000498)
  lto-wrapper: fatal error: make returned 2 exit status

Drop `-flto=auto` from teensylc's release profile (compile_flags +
link_flags). The cost is a slightly larger image but actual link
success — and on Teensy LC the image budget isn't the limiting
factor (64 KB flash on MKL26Z64; FastLED examples sit comfortably
inside without LTO).

Other Teensy profiles (teensy30/31/32/3x/4x — all Cortex-M3+/M4+/M7,
Thumb-2) keep LTO. This change is targeted to MKL26Z64 only.

Reference config (`configs/reference/teensylc.json`) does not list
`-flto` either, so the `test_linker_flags_match_platformio_reference`
guard continues to pass. All 38 `teensy::` tests pass.

Repro: any FastLED `teensyLC` workflow run on master before this
change (e.g. https://github.com/FastLED/FastLED/actions/runs/26686967724).
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

Warning

Review limit reached

@zackees, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 40 minutes and 15 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c54eac2d-bc32-4533-9e67-b76e3a550e5a

📥 Commits

Reviewing files that changed from the base of the PR and between 7057e21 and 4467893.

📒 Files selected for processing (1)
  • crates/fbuild-build/src/teensy/configs/teensylc.json
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/teensylc-disable-lto

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zackees zackees merged commit f1f00a8 into main May 30, 2026
86 of 87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

teensylc: -flto=auto overflows Thumb-1 PC-relative offset limit on Cortex-M0+

1 participant