Skip to content

feat(debug): print link command on -v + always emit firmware.map (fixes #305)#308

Merged
zackees merged 1 commit into
mainfrom
fix/305-debuggability
May 30, 2026
Merged

feat(debug): print link command on -v + always emit firmware.map (fixes #305)#308
zackees merged 1 commit into
mainfrom
fix/305-debuggability

Conversation

@zackees
Copy link
Copy Markdown
Member

@zackees zackees commented May 30, 2026

Summary

Fixes #305. Two tiny patches:

  1. Per-platform linkers' -v-gated log of the link command line now goes through eprintln! in addition to tracing::info!, so plain CLI users see it without configuring tracing subscribers.
  2. Every per-platform linker that produces a firmware.elf via -o now adds -Wl,-Map=firmware.map next to the ELF. Tiny artifact, huge debugging value.

Linkers covered

Linker -v eprintln -Wl,-Map=
avr/avr_linker.rs yes yes
ch32v/ch32v_linker.rs yes yes
esp8266/esp8266_linker.rs yes yes
generic_arm/arm_linker.rs yes yes
nrf52/nrf52_linker.rs yes yes
renesas/renesas_linker.rs yes yes
sam/sam_linker.rs yes yes
silabs/silabs_linker.rs yes yes
teensy/teensy_linker.rs yes yes

Out of scope

  • ESP32 and WASM linker paths skipped per the issue — different pipeline / different artifact shape (per the comments in pipeline/sequential.rs:27-28). Happy to follow up if a maintainer wants those covered too.
  • Fix C from the issue (a standalone fbuild diag subcommand) deferred — the -v + map file combo already unblocks the kind of investigation that motivated the issue.

Implementation notes

  • eprintln! is added alongside tracing::info! — log integration is preserved, and stderr surfacing is additive.
  • The map flag uses an absolute path (output_dir.join("firmware.map")) so the artifact lands deterministically next to firmware.elf.
  • avr_linker.rs extracts arg-building into a private build_link_args() helper so the new unit test can assert the argv without invoking the toolchain. No behavior change.

Verification

  • soldr cargo check -p fbuild-build — clean.
  • soldr cargo clippy -p fbuild-build --all-targets -- -D warnings — exit 0 (only the pre-existing global "MSRV in clippy.toml differs from Cargo.toml" warning, unrelated to this PR).
  • soldr cargo test -p fbuild-build --lib avr_linker — 2 passed, 0 failed (new test_avr_link_args_contain_map_flag asserts the argv contains -Wl,-Map= and that the path resolves to <output_dir>/firmware.map).
  • AVR / device builds not exercised on this box (no toolchain) — additive flag, no behavior change beyond the new artifact.

#305)

Two small debuggability patches per the issue:

A. Linker invocations now eprintln! the full command line when -v is
   passed. tracing::info! is kept for log integration but also goes to
   stderr so plain CLI users see it.

B. Every per-platform linker now adds -Wl,-Map=firmware.map to the link
   command. Lands next to firmware.elf in output_dir. Cost is essentially
   zero (~50-500 KB plain text) and pays for itself the first time
   anyone asks "why is this symbol in my ELF?" (See #304
   for the recent investigation that took 45 min for want of a map.)

WASM and ESP32 paths intentionally skipped — different artifact shapes.

Closes #305.
@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 22 minutes and 22 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: 2211474b-a083-4ef9-bf7b-99cb6f26a7a2

📥 Commits

Reviewing files that changed from the base of the PR and between 57ce6af and 98447b7.

📒 Files selected for processing (9)
  • crates/fbuild-build/src/avr/avr_linker.rs
  • crates/fbuild-build/src/ch32v/ch32v_linker.rs
  • crates/fbuild-build/src/esp8266/esp8266_linker.rs
  • crates/fbuild-build/src/generic_arm/arm_linker.rs
  • crates/fbuild-build/src/nrf52/nrf52_linker.rs
  • crates/fbuild-build/src/renesas/renesas_linker.rs
  • crates/fbuild-build/src/sam/sam_linker.rs
  • crates/fbuild-build/src/silabs/silabs_linker.rs
  • crates/fbuild-build/src/teensy/teensy_linker.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/305-debuggability

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 ab085c4 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.

Debuggability: print link command in -v output and always emit firmware.map

1 participant