Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make more reads of environment variables go through the Config #11754

Merged
merged 2 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/cargo/core/compiler/fingerprint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ use crate::util;
use crate::util::errors::CargoResult;
use crate::util::interning::InternedString;
use crate::util::{internal, path_args, profile, StableHasher};
use crate::CARGO_ENV;
use crate::{Config, CARGO_ENV};

use super::custom_build::BuildDeps;
use super::job::{Job, Work};
Expand Down Expand Up @@ -782,6 +782,7 @@ impl LocalFingerprint {
pkg_root: &Path,
target_root: &Path,
cargo_exe: &Path,
config: &Config,
) -> CargoResult<Option<StaleItem>> {
match self {
// We need to parse `dep_info`, learn about the crate's dependencies.
Expand Down Expand Up @@ -810,7 +811,7 @@ impl LocalFingerprint {
.to_string(),
)
} else {
env::var(key).ok()
config.get_env(key).ok()
};
if current == *previous {
continue;
Expand Down Expand Up @@ -1059,6 +1060,7 @@ impl Fingerprint {
pkg_root: &Path,
target_root: &Path,
cargo_exe: &Path,
config: &Config,
) -> CargoResult<()> {
assert!(!self.fs_status.up_to_date());

Expand Down Expand Up @@ -1166,7 +1168,7 @@ impl Fingerprint {
// message and bail out so we stay stale.
for local in self.local.get_mut().unwrap().iter() {
if let Some(item) =
local.find_stale_item(mtime_cache, pkg_root, target_root, cargo_exe)?
local.find_stale_item(mtime_cache, pkg_root, target_root, cargo_exe, config)?
{
item.log();
self.fs_status = FsStatus::StaleItem(item);
Expand Down Expand Up @@ -1328,6 +1330,7 @@ fn calculate(cx: &mut Context<'_, '_>, unit: &Unit) -> CargoResult<Arc<Fingerpri
unit.pkg.root(),
&target_root,
cargo_exe,
cx.bcx.config,
)?;

let fingerprint = Arc::new(fingerprint);
Expand Down
1 change: 1 addition & 0 deletions src/cargo/util/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ impl Config {
} else {
None
},
self,
)
}

Expand Down
12 changes: 8 additions & 4 deletions src/cargo/util/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use log::{debug, info, warn};
use serde::{Deserialize, Serialize};

use crate::util::interning::InternedString;
use crate::util::{profile, CargoResult, StableHasher};
use crate::util::{profile, CargoResult, Config, StableHasher};

/// Information on the `rustc` executable
#[derive(Debug)]
Expand Down Expand Up @@ -43,6 +43,7 @@ impl Rustc {
workspace_wrapper: Option<PathBuf>,
rustup_rustc: &Path,
cache_location: Option<PathBuf>,
config: &Config,
) -> CargoResult<Rustc> {
let _p = profile::start("Rustc::new");

Expand All @@ -52,6 +53,7 @@ impl Rustc {
&path,
rustup_rustc,
cache_location,
config,
);

let mut cmd = ProcessBuilder::new(&path);
Expand Down Expand Up @@ -173,10 +175,11 @@ impl Cache {
rustc: &Path,
rustup_rustc: &Path,
cache_location: Option<PathBuf>,
config: &Config,
) -> Cache {
match (
cache_location,
rustc_fingerprint(wrapper, workspace_wrapper, rustc, rustup_rustc),
rustc_fingerprint(wrapper, workspace_wrapper, rustc, rustup_rustc, config),
) {
(Some(cache_location), Ok(rustc_fingerprint)) => {
let empty = CacheData {
Expand Down Expand Up @@ -296,6 +299,7 @@ fn rustc_fingerprint(
workspace_wrapper: Option<&Path>,
rustc: &Path,
rustup_rustc: &Path,
config: &Config,
) -> CargoResult<u64> {
let mut hasher = StableHasher::new();

Expand Down Expand Up @@ -329,8 +333,8 @@ fn rustc_fingerprint(
let maybe_rustup = rustup_rustc == rustc;
match (
maybe_rustup,
env::var("RUSTUP_HOME"),
env::var("RUSTUP_TOOLCHAIN"),
config.get_env("RUSTUP_HOME"),
config.get_env("RUSTUP_TOOLCHAIN"),
) {
(_, Ok(rustup_home), Ok(rustup_toolchain)) => {
debug!("adding rustup info to rustc fingerprint");
Expand Down