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

Handle non-existent/empty .cargo/registry/src and empty env vars #119445

Closed
wants to merge 2 commits into from
Closed
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
8 changes: 6 additions & 2 deletions src/bootstrap/src/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,17 @@ fn main() {
}

if let Ok(map) = env::var("RUSTC_DEBUGINFO_MAP") {
cmd.arg("--remap-path-prefix").arg(&map);
if !map.is_empty() {
cmd.arg("--remap-path-prefix").arg(&map);
}
}
// The remap flags for Cargo registry sources need to be passed after the remapping for the
// Rust source code directory, to handle cases when $CARGO_HOME is inside the source directory.
if let Ok(maps) = env::var("RUSTC_CARGO_REGISTRY_SRC_TO_REMAP") {
for map in maps.split('\t') {
cmd.arg("--remap-path-prefix").arg(map);
if !map.is_empty() {
cmd.arg("--remap-path-prefix").arg(map);
}
}
}

Expand Down
16 changes: 10 additions & 6 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1812,15 +1812,19 @@ impl<'a> Builder<'a> {
if self.config.rust_remap_debuginfo {
// FIXME: handle vendored sources
let registry_src = t!(home::cargo_home()).join("registry").join("src");
let mut env_var = OsString::new();
for entry in t!(std::fs::read_dir(registry_src)) {
if registry_src.is_dir() {
let mut env_var = OsString::new();
for entry in t!(std::fs::read_dir(registry_src)) {
if !env_var.is_empty() {
env_var.push("\t");
}
env_var.push(t!(entry).path());
env_var.push("=/rust/deps");
}
if !env_var.is_empty() {
env_var.push("\t");
cargo.env("RUSTC_CARGO_REGISTRY_SRC_TO_REMAP", env_var);
}
env_var.push(t!(entry).path());
env_var.push("=/rust/deps");
}
cargo.env("RUSTC_CARGO_REGISTRY_SRC_TO_REMAP", env_var);
}

// Enable usage of unstable features
Expand Down
Loading