Skip to content

Commit

Permalink
Merge pull request #8488 from ehuss/beta-fix-fingerprint-loc
Browse files Browse the repository at this point in the history
[beta] Avoid colliding with older Cargo fingerprint changes
  • Loading branch information
alexcrichton authored Jul 15, 2020
2 parents 4f74d9b + c810ed0 commit 4481ef5
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/cargo/core/compiler/context/compilation_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ use crate::core::compiler::{CompileMode, CompileTarget, CrateType, FileType, Uni
use crate::core::{Target, TargetKind, Workspace};
use crate::util::{self, CargoResult, StableHasher};

/// This is a generic version number that can be changed to make
/// backwards-incompatible changes to any file structures in the output
/// directory. For example, the fingerprint files or the build-script
/// output files. Normally cargo updates ship with rustc updates which will
/// cause a new hash due to the rustc version changing, but this allows
/// cargo to be extra careful to deal with different versions of cargo that
/// use the same rustc version.
const METADATA_VERSION: u8 = 2;

/// The `Metadata` is a hash used to make unique file names for each unit in a
/// build. It is also use for symbol mangling.
///
Expand Down Expand Up @@ -162,7 +171,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
/// Used for the metadata when `metadata` returns `None`.
pub fn target_short_hash(&self, unit: &Unit) -> String {
let hashable = unit.pkg.package_id().stable_hash(self.ws.root());
util::short_hash(&hashable)
util::short_hash(&(METADATA_VERSION, hashable))
}

/// Returns the directory where the artifacts for the given unit are
Expand Down Expand Up @@ -483,14 +492,7 @@ fn compute_metadata(
}
let mut hasher = StableHasher::new();

// This is a generic version number that can be changed to make
// backwards-incompatible changes to any file structures in the output
// directory. For example, the fingerprint files or the build-script
// output files. Normally cargo updates ship with rustc updates which will
// cause a new hash due to the rustc version changing, but this allows
// cargo to be extra careful to deal with different versions of cargo that
// use the same rustc version.
2.hash(&mut hasher);
METADATA_VERSION.hash(&mut hasher);

// Unique metadata per (name, source, version) triple. This'll allow us
// to pull crates from anywhere without worrying about conflicts.
Expand Down

0 comments on commit 4481ef5

Please sign in to comment.