Repository navigation
build identity: hash the linker argv; key no-op fingerprint on embedded assets; watch worktree refs - #2068
Merged
Conversation
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).
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
This was referenced Nov 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #2042 (build identity group: items 6 and 7).
Item 6: link digest misses built-in link flags
Linker::link_command(objects, archives, output_dir, extra) -> Vec<String>: the argvlink()runs, before any Windows response-file encoding. All eleven platformlink()bodies now build their argv through it, so the digested argv is the argv the linker runs (refactor commit, no behaviour change).link_digesthashes that argv (plus the version,link_fingerprint,bloat_analysisand the object list). Object paths are still hashed separately because AVR and ESP8266 fold core objects into an archive that the argv only names.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.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.rshashes every non-Rust, non-Markdown file under each crate'ssrc/andassets/. That covers the MCU config JSONs, board JSONs,sam_architectures.json,avr_frameworks.jsonand the SCons harness.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.build.rsdoesn't rerun on a working-tree edit anyway, and the hash also covers released binaries.rerun-if-changedwatches each asset file and each topmost directory that holds only assets. Directories that contain Rust source are not watched, so a.rsedit does not rerun the script or rebuildfbuild-core.Item 7b: worktree branch-ref watch
.gitcan be agitdir:file, andcommondirnames the shared dir.packed-refsand the ref's directory are watched, so the loose ref that the next commit writes is noticed.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.