Skip to content

fix(build): always recompile version.o with explicit 7-char revision - #1125

Merged
nerdCopter merged 1 commit into
emuflight:masterfrom
nerdCopter:fix/version-stale-object-rebuild
Apr 25, 2026
Merged

fix(build): always recompile version.o with explicit 7-char revision#1125
nerdCopter merged 1 commit into
emuflight:masterfrom
nerdCopter:fix/version-stale-object-rebuild

Conversation

@nerdCopter

@nerdCopter nerdCopter commented Apr 24, 2026

Copy link
Copy Markdown
Member

Summary

Two Makefile bugs that caused firmware to report uncommitted version even on a clean tree:

  • Stale version.o: The rule $(OBJECT_DIR)/.../version.o : $(SRC) only triggered recompilation when a source file changed. A dirty-tree build (REVISION=uncommitted_YYYYMMDD) followed by a clean-tree build with no source changes left a stale object — firmware embedded uncommitted_... while the filename correctly showed the commit hash. Fixed by replacing $(SRC) with a FORCE phony target so version.o always recompiles (matching the comment's stated intent).

  • Non-deterministic hash length: git log --format="%h" auto-detects the minimum unique hash length and grows as the repo gets larger (currently 10 chars). GIT_SHORT_REVISION_LENGTH is defined as 7, so the MSP protocol was silently dropping 3 chars. Changed to git rev-parse --short=7 HEAD to pin exactly 7 chars — matching the defined constant and keeping source, filename, and protocol wire format consistent.

Test plan

  • Build any target — confirm hex filename shows 7-char hash (e.g. ..._Build_d649d0a.hex)
  • Flash and confirm configurator version field shows the 7-char hash instead of uncommitted
  • Verify make followed by make (no changes) still produces correct hash (FORCE rebuilds version.o every time)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Improved build system reliability with optimized version generation during incremental builds.

@coderabbitai

coderabbitai Bot commented Apr 24, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@nerdCopter has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 47 minutes and 41 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 47 minutes and 41 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9356906f-652e-4d80-bf59-c4ff38fcc1e4

📥 Commits

Reviewing files that changed from the base of the PR and between d649d0a and 3fa7ef2.

📒 Files selected for processing (1)
  • Makefile
📝 Walkthrough

Walkthrough

The Makefile has been modified to adjust REVISION computation to use a deterministic short commit hash when the working tree has no diff, and to change the version.o target dependency to a phony prerequisite to ensure regeneration on each incremental build.

Changes

Cohort / File(s) Summary
Build System Configuration
Makefile
Modified REVISION computation to use git rev-parse --short=7 HEAD instead of git log -1 --format="%h" when working tree has no diff. Changed version.o target dependency from $(SRC) to FORCE phony prerequisite to force regeneration on each incremental build.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: fixing the build system to always recompile version.o and using an explicit 7-character revision hash.
Description check ✅ Passed The description is comprehensive and covers the problem, solution, and test plan. However, it does not follow the required template structure which specifies issue references and other guidance.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@Makefile`:
- Line 110: The REVISION assignment uses git rev-parse --short=7 which
guarantees at least 7 chars, so enforce an exact 7-character hash by truncating
the output: update the Makefile's REVISION assignment (the REVISION variable) to
pipe git rev-parse --short=7 HEAD into a fixed-width truncation (e.g., cut -c1-7
or similar) so the value stored in REVISION is exactly seven characters to match
GIT_SHORT_REVISION_LENGTH and MSP protocol expectations.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d5c69635-9adb-450c-a288-b7e7ac001572

📥 Commits

Reviewing files that changed from the base of the PR and between f8f51a7 and d649d0a.

📒 Files selected for processing (1)
  • Makefile

Comment thread Makefile Outdated
Two Makefile bugs that caused firmware to report uncommitted version
even on a clean tree:

1. version.o depended on $(SRC) — only rebuilt when a source file
   changed. A dirty-tree build (REVISION=uncommitted_...) followed by
   a clean-tree build with no source changes left a stale object, so
   the firmware reported "uncommitted" even though the filename
   correctly embedded the commit hash.
   Fix: replace $(SRC) with FORCE so version.o always recompiles,
   matching the comment's stated intent.

2. git rev-parse --short=7 guarantees a minimum of 7 chars but
   auto-extends for uniqueness, so the length can still exceed
   GIT_SHORT_REVISION_LENGTH (7). The MSP protocol field sends
   exactly GIT_SHORT_REVISION_LENGTH bytes, silently truncating any
   excess and producing an inconsistent hash between filename and
   configurator as the repo grows.
   Fix: git rev-parse HEAD | cut -c1-7 hard-truncates the full SHA to
   exactly 7 chars regardless of repo size or git configuration.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nerdCopter
nerdCopter force-pushed the fix/version-stale-object-rebuild branch from d649d0a to 3fa7ef2 Compare April 24, 2026 21:01
@nerdCopter
nerdCopter merged commit e8d439d into emuflight:master Apr 25, 2026
8 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.

1 participant