Skip to content

Commit 12776c7

Browse files
kornelskisylvestre
authored andcommitted
Avoid hashing CARGO_ variables that are redundant or don't affect results
1 parent 77ce75c commit 12776c7

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/compiler/rust.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,15 +1518,19 @@ where
15181518
continue;
15191519
}
15201520

1521-
// CARGO_MAKEFLAGS will have jobserver info which is extremely non-cacheable.
1522-
// CARGO_REGISTRIES_*_TOKEN contains non-cacheable secrets.
1523-
// Registry override config doesn't need to be hashed, because deps' package IDs
1524-
// already uniquely identify the relevant registries.
1525-
// CARGO_BUILD_JOBS only affects Cargo's parallelism, not rustc output.
1526-
if var == "CARGO_MAKEFLAGS"
1527-
|| var.starts_with("CARGO_REGISTRIES_")
1528-
|| var == "CARGO_BUILD_JOBS"
1529-
{
1521+
let may_skip = var == "CARGO_MAKEFLAGS" // will have jobserver info which is extremely non-cacheable.
1522+
|| var == "CARGO_BUILD_JOBS" // does not affect results
1523+
|| var.starts_with("CARGO_REGISTRIES_") // CARGO_REGISTRIES_*_TOKEN contains non-cacheable secrets, and package IDs already uniquely identify the relevant registries.
1524+
|| var.starts_with("CARGO_REGISTRY_") // same as CARGO_REGISTRIES_*
1525+
|| var == "CARGO_TARGET_DIR" // already included in the file paths
1526+
|| var == "CARGO_BUILD_BUILD_DIR"
1527+
|| var == "CARGO_BUILD_TARGET_DIR"
1528+
|| var.starts_with("CARGO_HTTP_") // not relevant
1529+
|| var.starts_with("CARGO_NET_")
1530+
|| var.starts_with("CARGO_TERM_")
1531+
|| var.starts_with("CARGO_ALIAS_")
1532+
|| var == "CARGO_CACHE_AUTO_CLEAN_FREQUENCY";
1533+
if may_skip {
15301534
continue;
15311535
}
15321536

@@ -3502,6 +3506,7 @@ proc_macro false
35023506
OsString::from("CARGO_BUILD_JOBS"),
35033507
OsString::from("ignored"),
35043508
),
3509+
(OsString::from("CARGO_TERM_COLOR"), OsString::from("never")),
35053510
]
35063511
.to_vec(),
35073512
false,

0 commit comments

Comments
 (0)