Skip to content

build identity: hash the linker argv; key no-op fingerprint on embedded assets; watch worktree refs - #2068

Merged
zackees merged 4 commits into
mainfrom
fix/build-identity-2042
Nov 18, 2026
Merged

zackees merged 4 commits into
mainfrom
fix/build-identity-2042

Conversation

@zackees

@zackees zackees commented Nov 18, 2026

Copy link
Copy Markdown
Member

Part of #2042 (build identity group: items 6 and 7).

Item 6: link digest misses built-in link flags

  • New required Linker::link_command(objects, archives, output_dir, extra) -> Vec<String>: the argv link() runs, before any Windows response-file encoding. All eleven platform link() bodies now build their argv through it, so the digested argv is the argv the linker runs (refactor commit, no behaviour change).
  • link_digest hashes that argv (plus the version, link_fingerprint, bloat_analysis and the object list). Object paths are still hashed separately because AVR and ESP8266 fold core objects into an archive that the argv only names.
  • The ESP32 cross-project link-output key (link_output_cache::content_key) also hashes the argv. An argument naming an input becomes <in> and the output dir becomes <out>, so a fresh directory still gets a hit.
  • Nothing unstable goes in: response files and LTO temp env are added after link_command, and argv order is kept because link order matters.

Item 7a: uncommitted asset edits did not change the build identity

  • fbuild-core/build.rs hashes every non-Rust, non-Markdown file under each crate's src/ and assets/. That covers the MCU config JSONs, board JSONs, sam_architectures.json, avr_frameworks.json and the SCons harness.
  • The hash is stamped as build_id::EMBEDDED_ASSETS_DIGEST. fbuild_build_identity(), which feeds every orchestrator's no-op metadata hash, appends +assets.<sha256>. long_version() (fbuild --version) is unchanged.
  • I used a content hash instead of a dirty marker for three reasons: two different dirty edits share one marker, build.rs doesn't rerun on a working-tree edit anyway, and the hash also covers released binaries.
  • rerun-if-changed watches each asset file and each topmost directory that holds only assets. Directories that contain Rust source are not watched, so a .rs edit does not rerun the script or rebuild fbuild-core.

Item 7b: worktree branch-ref watch

  • The git layout is now read from the filesystem: .git can be a gitdir: file, and commondir names the shared dir.
  • HEAD and the index are watched in the per-checkout git dir. The branch ref is watched in the common dir.
  • If the branch has no loose ref, packed-refs and the ref's directory are watched, so the loose ref that the next commit writes is noticed.
  • Only paths that exist are emitted, because Cargo treats a missing path as always stale.

Tests

  • linker_tests: a changed built-in flag relinks, and it misses the cross-project cache (both RED before the fix).
  • link_digest: the digest follows the argv, including argv order.
  • identity_tests: the identity carries a 64-hex assets digest (RED before).
  • build_stamp_tests: gitdir parsing; plain, worktree (absolute and relative gitdir), packed-ref and detached layouts; asset selection; the digest follows asset bytes and names and ignores .rs/.md.

linker.rs was at 987 lines; the next commit adds a trait method. Moving
the inline test module out keeps the file under the 1000-line ceiling.
Tests are unchanged.

Part of #2042 (build identity group).
Adds a required Linker::link_command that returns the argv link() runs,
and routes all eleven platform link() bodies through it. No behaviour
change: the argv is the same, built in a separate method so the link
digest can hash it in the next commit.

Part of #2042 (build identity group).
The link digest hashed the fbuild version, LinkExtraArgs and the
platform's link_fingerprint hook, but not a platform's built-in link
flags (MCU config JSONs, board files, orchestrator code). Changing only
one of those within a version reused the old firmware.elf.

Both the per-project digest and the cross-project link-output key now
hash Linker::link_command, the argv the linker actually runs, so every
current and future flag source is covered. The cross-project key
replaces input paths with <in> and the output dir with <out>, so fresh
directories still hit. Object paths stay in the per-project digest
because AVR folds core objects into an archive the argv only names.

Part of #2042 (build identity group).
…ch worktree refs

(a) The no-op fingerprint keyed on long_version() (version + commit +
dirty flag). An uncommitted config JSON edit changes neither, so the
build no-oped until --clean. fbuild-core's build.rs now hashes every
non-Rust, non-Markdown file under each workspace crate's src/ and
assets/ (the include_str!/include_dir! assets: MCU config JSONs, board
JSONs, scripts), stamps it as build_id::EMBEDDED_ASSETS_DIGEST, and
fbuild_build_identity() appends it. Each asset file and each asset-only
directory is a rerun-if-changed input; directories with Rust source are
not watched, so a .rs edit does not rerun the script. A content hash is
used rather than a dirty marker because two different dirty edits share
one marker, and it covers released binaries too.

(b) The branch-ref watch read <git-dir>/<ref>, which in a linked
worktree is .git/worktrees/<name>/refs/... and never exists. The git
layout is now resolved from the filesystem: .git as a gitdir: file,
commondir for the shared dir, and packed-refs plus the ref's directory
when the branch has no loose ref.

The helpers live in src/build_stamp.rs, included by build.rs and
compiled into the library under cfg(test) for unit tests.

Part of #2042 (build identity group).
@coderabbitai

coderabbitai Bot commented Nov 18, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • 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

@zackees
zackees added this pull request to the merge queue Nov 18, 2026
Merged via the queue into main with commit d0fc325 Nov 18, 2026
87 checks passed
@fastled-project-sync fastled-project-sync Bot moved this to Triage in FastLED Tracker Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

1 participant