78
78
//! [`CompileKind`] (host/target) | ✓ | ✓ | ✓ | ✓
79
79
//! `__CARGO_DEFAULT_LIB_METADATA`[^4] | | ✓ | ✓ | ✓
80
80
//! `package_id` | | ✓ | ✓ | ✓
81
- //! authors, description, homepage, repo | ✓ | | |
82
81
//! Target src path relative to ws | ✓ | | |
83
82
//! Target flags (test/bench/for_host/edition) | ✓ | | |
84
83
//! -C incremental=… flag | ✓ | | |
189
188
//! files to learn about environment variables that the rustc compile depends on.
190
189
//! Cargo then later uses this to trigger a recompile if a referenced env var
191
190
//! changes (even if the source didn't change).
191
+ //! This also includes env vars generated from Cargo metadata like `CARGO_PKG_DESCRIPTION`.
192
+ //! (See [`crate::core::manifest::ManifestMetadata`]
192
193
//!
193
194
//! #### dep-info files for build system integration.
194
195
//!
@@ -612,10 +613,6 @@ pub struct Fingerprint {
612
613
memoized_hash : Mutex < Option < u64 > > ,
613
614
/// RUSTFLAGS/RUSTDOCFLAGS environment variable value (or config value).
614
615
rustflags : Vec < String > ,
615
- /// Hash of some metadata from the manifest, such as "authors", or
616
- /// "description", which are exposed as environment variables during
617
- /// compilation.
618
- metadata : u64 ,
619
616
/// Hash of various config settings that change how things are compiled.
620
617
config : u64 ,
621
618
/// The rustc target. This is only relevant for `.json` files, otherwise
@@ -831,11 +828,12 @@ impl LocalFingerprint {
831
828
& self ,
832
829
mtime_cache : & mut HashMap < PathBuf , FileTime > ,
833
830
checksum_cache : & mut HashMap < PathBuf , Checksum > ,
834
- pkg_root : & Path ,
831
+ pkg : & Package ,
835
832
target_root : & Path ,
836
833
cargo_exe : & Path ,
837
834
gctx : & GlobalContext ,
838
835
) -> CargoResult < Option < StaleItem > > {
836
+ let pkg_root = pkg. root ( ) ;
839
837
match self {
840
838
// We need to parse `dep_info`, learn about the crate's dependencies.
841
839
//
@@ -849,6 +847,12 @@ impl LocalFingerprint {
849
847
return Ok ( Some ( StaleItem :: MissingFile ( dep_info) ) ) ;
850
848
} ;
851
849
for ( key, previous) in info. env . iter ( ) {
850
+ if let Some ( value) = pkg. manifest ( ) . metadata ( ) . env_var ( key. as_str ( ) ) {
851
+ if Some ( value. as_ref ( ) ) == previous. as_deref ( ) {
852
+ continue ;
853
+ }
854
+ }
855
+
852
856
let current = if key == CARGO_ENV {
853
857
Some ( cargo_exe. to_str ( ) . ok_or_else ( || {
854
858
format_err ! (
@@ -932,7 +936,6 @@ impl Fingerprint {
932
936
local : Mutex :: new ( Vec :: new ( ) ) ,
933
937
memoized_hash : Mutex :: new ( None ) ,
934
938
rustflags : Vec :: new ( ) ,
935
- metadata : 0 ,
936
939
config : 0 ,
937
940
compile_kind : 0 ,
938
941
fs_status : FsStatus :: Stale ,
@@ -995,9 +998,6 @@ impl Fingerprint {
995
998
new : self . rustflags . clone ( ) ,
996
999
} ;
997
1000
}
998
- if self . metadata != old. metadata {
999
- return DirtyReason :: MetadataChanged ;
1000
- }
1001
1001
if self . config != old. config {
1002
1002
return DirtyReason :: ConfigSettingsChanged ;
1003
1003
}
@@ -1142,13 +1142,14 @@ impl Fingerprint {
1142
1142
& mut self ,
1143
1143
mtime_cache : & mut HashMap < PathBuf , FileTime > ,
1144
1144
checksum_cache : & mut HashMap < PathBuf , Checksum > ,
1145
- pkg_root : & Path ,
1145
+ pkg : & Package ,
1146
1146
target_root : & Path ,
1147
1147
cargo_exe : & Path ,
1148
1148
gctx : & GlobalContext ,
1149
1149
) -> CargoResult < ( ) > {
1150
1150
assert ! ( !self . fs_status. up_to_date( ) ) ;
1151
1151
1152
+ let pkg_root = pkg. root ( ) ;
1152
1153
let mut mtimes = HashMap :: new ( ) ;
1153
1154
1154
1155
// Get the `mtime` of all outputs. Optionally update their mtime
@@ -1249,7 +1250,7 @@ impl Fingerprint {
1249
1250
if let Some ( item) = local. find_stale_item (
1250
1251
mtime_cache,
1251
1252
checksum_cache,
1252
- pkg_root ,
1253
+ pkg ,
1253
1254
target_root,
1254
1255
cargo_exe,
1255
1256
gctx,
@@ -1279,7 +1280,6 @@ impl hash::Hash for Fingerprint {
1279
1280
profile,
1280
1281
ref deps,
1281
1282
ref local,
1282
- metadata,
1283
1283
config,
1284
1284
compile_kind,
1285
1285
ref rustflags,
@@ -1294,7 +1294,6 @@ impl hash::Hash for Fingerprint {
1294
1294
path,
1295
1295
profile,
1296
1296
& * local,
1297
- metadata,
1298
1297
config,
1299
1298
compile_kind,
1300
1299
rustflags,
@@ -1445,7 +1444,7 @@ fn calculate(build_runner: &mut BuildRunner<'_, '_>, unit: &Unit) -> CargoResult
1445
1444
fingerprint. check_filesystem (
1446
1445
& mut build_runner. mtime_cache ,
1447
1446
& mut build_runner. checksum_cache ,
1448
- unit. pkg . root ( ) ,
1447
+ & unit. pkg ,
1449
1448
& target_root,
1450
1449
cargo_exe,
1451
1450
build_runner. bcx . gctx ,
@@ -1529,9 +1528,6 @@ fn calculate_normal(
1529
1528
build_runner. lto [ unit] ,
1530
1529
unit. pkg . manifest ( ) . lint_rustflags ( ) ,
1531
1530
) ) ;
1532
- // Include metadata since it is exposed as environment variables.
1533
- let m = unit. pkg . manifest ( ) . metadata ( ) ;
1534
- let metadata = util:: hash_u64 ( ( & m. authors , & m. description , & m. homepage , & m. repository ) ) ;
1535
1531
let mut config = StableHasher :: new ( ) ;
1536
1532
if let Some ( linker) = build_runner. compilation . target_linker ( unit. kind ) {
1537
1533
linker. hash ( & mut config) ;
@@ -1560,7 +1556,6 @@ fn calculate_normal(
1560
1556
deps,
1561
1557
local : Mutex :: new ( local) ,
1562
1558
memoized_hash : Mutex :: new ( None ) ,
1563
- metadata,
1564
1559
config : Hasher :: finish ( & config) ,
1565
1560
compile_kind,
1566
1561
rustflags : extra_flags,
0 commit comments