rust-lang / rust-lang/rust-analyzer

forced recompiling no code changes due to rust analyzer

Open
#17,155 3 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

Hi, thanks for rust-analyzer!

I'm having trouble with rust-analyzer forcing rebuild of a project and all its deps even though there are no code changes. I tried to diagnose what's causing it reading #16640 and with CARGO_LOG=cargo::core::compiler::fingerprint=info cargo build I'm seeing e.g.:

cargo::core::compiler::fingerprint: dependency on `build_script_build` is newer than we are 1714234960.242826421s > 1714234952.135008268s "/home/tz/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.16"

...

cargo::core::compiler::fingerprint: fingerprint dirty for crossbeam-utils v0.8.16/Build/TargetInner { ..: lib_target("crossbeam-utils", ["lib"], "/home/tz/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.16/src/lib.rs", Edition2018) }
cargo::core::compiler::fingerprint:     dirty: FsStatusOutdated(StaleDependency { name: "build_script_build", dep_mtime: FileTime { seconds: 1714234960, nanos: 242826421 }, max_mtime: FileTime { seconds: 1714234952, nanos: 135008268 } })
cargo::core::compiler::fingerprint: fingerprint dirty for crossbeam-utils v0.8.16/RunCustomBuild/TargetInner { ..: custom_build_target("build-script-build", "/home/tz/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.16/build.rs", Edition2018) }
cargo::core::compiler::fingerprint:     dirty: UnitDependencyInfoChanged { old_name: "build_script_build", old_fingerprint: 2579957232512875769, new_name: "build_script_build", new_fingerprint: 11333844636011871432 }
cargo::core::compiler::fingerprint: fingerprint dirty for crossbeam-utils v0.8.16/Build/TargetInner { ..: custom_build_target("build-script-build", "/home/tz/.cargo/registry/src/github.com-1ecc6299db9ec823/crossbeam-utils-0.8.16/build.rs", Edition2018) }

This appears for all the deps with build scripts so it seems that for some reason there is difference in how the build scripts are compiled.

I tried to remove all my user settings (both in VSCode and in terminal) to make sure it's not due to my config.

I also tried to set "rust-analyzer.cargo.buildScripts.useRustcWrapper": false with no success. I'm using "rust-analyzer.rust.analyzerTargetDir": true as a workaround which unfortunately bloats the build artifacts.

rust-analyzer version: Release: 2024-04-22 (v0.3.1932)

rustc version: rustc 1.76.0 (07dca489a 2024-02-04)

editor or extension: VSCode v0.3.1932

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the no-change build with rust-analyzer 2024-04-22 and CARGO_LOG=cargo::core::compiler::fingerprint=info cargo build. Compare the reported fingerprints for dependencies with build scripts, including crossbeam-utils, and check the effects of rust-analyzer.cargo.buildScripts.useRustcWrapper and rust.analyzerTargetDir. Done means repeated builds no longer rebuild unchanged dependencies.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.