Skip to content

build: enable LTO and drop newlib crt0 - #72

Merged
jamesarich merged 2 commits into
masterfrom
build/lto
Oct 25, 2026
Merged

jamesarich merged 2 commits into
masterfrom
build/lto

Conversation

@jamesarich

@jamesarich jamesarich commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Checklist

  • PR title specifically describes the change
  • tools/build_all.py (or CI's board matrix) passes

Description of Change

Frees about 3.7 KB on every board, which takes the T114 from 512 B free to about 4.2 KB and pays for the other 2.6 changes. LTO is about 3.3 KB of that. main never returns, so newlib's startup and exit machinery is dead weight: Reset_Handler now copies .data, clears exactly .bss (not .noinit) and calls main, another 368 B.

The .bootloaderConfig, UICR and .noinit sections keep their addresses and the set of SoftDevice svc call sites is identical on all 19 boards. Tested on the X1, T1000-E, Wio Tracker L1 (S140 7.3.0) and RAK4631 (S140 6.1.1): bootloader self-update, UF2 app install, CURRENT.UF2 dump and restore, serial DFU, factory erase, BLE OTA. Not tested: BLE OTA without USB on the RAK4631 (no battery on the bench board). __libc_fini_array stays linked through atexit; it never runs.

Summary by CodeRabbit

  • Improvements
    • Bootloader images are approximately 3.3 KB smaller, reducing their flash footprint.
    • Section addresses and SoftDevice call sites remain unchanged.
    • The smaller images retain the same behavior, with no reported changes to how the bootloader operates.

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 54ea690e-f8dd-4cd5-818c-1d4cbff2abdc
Commits

Reviewing files that changed from the base of the PR and between e1731c5 and 7ed1818.

Files selected for processing: 1
  • changelog.md
Files skipped from review as they are similar to previous changes: 1
  • changelog.md

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

The Makefile enables link-time optimization and adds startup settings for main and .bss clearing. The linker script adds zero-length .tbss and .sbss bounds. The changelog reports an image-size reduction of about 3.3 KB and states that section addresses and SoftDevice call sites remain unchanged.

Changes: Bootloader build and startup

Layer / File(s) Summary
Compiler, startup, and linker configuration
Makefile, linker/nrf_common.ld, changelog.md
The build enables -flto, sets startup macros for main and .bss clearing, and adds zero-length .tbss and .sbss bounds. The changelog reports an image-size reduction of about 3.3 KB and no change to section addresses or SoftDevice call sites.

Priority: Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Possibly related PRs

Merge Risk: Minimal · up to 7ed18

No issue requiring a pre-merge fix was identified in the build and startup changes.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main changes: enabling LTO and removing the newlib crt0 startup path.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks the linker bounds,
Then hops where startup clears its ground.
LTO trims the flash away,
While main is ready for the day.
The bootloader leaps along its way.

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

@jamesarich jamesarich changed the title build: enable LTO build: enable LTO and drop newlib crt0 Oct 24, 2026
@jamesarich

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@jamesarich
jamesarich added this pull request to the merge queue Oct 25, 2026
Merged via the queue into master with commit 22f4736 Oct 25, 2026
23 checks passed
@jamesarich
jamesarich deleted the build/lto branch October 25, 2026 22:40
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.

1 participant