Skip to content

Commit

Permalink
Rollup merge of rust-lang#119582 - arlosi:bootstrap-vendor-remap, r=w…
Browse files Browse the repository at this point in the history
…esleywiser

bootstrap: handle vendored sources when remapping crate paths

rust-lang#115872 introduced a feature to add path remapping for crate dependencies, but only when they came from Cargo's registry cache, not a vendor directory.

This caused builds that used remapped debuginfo and vendor directories to fail with:
```
std::fs::read_dir(registry_src) failed with No such file or directory (os error 2)
```
or (if the `registry/src` directory exists but is empty)
```
error: --remap-path-prefix must contain '=' between FROM and TO
```

Fixes rust-lang#117885 by explicitly supporting the `vendor` directory and adding it to `RUSTC_CARGO_REGISTRY_SRC_TO_REMAP`.

Note that `bootstrap.py` already assumes that `./vendor` within the rust repo is the only supported vendoring location.

r? `@pietroalbini`
  • Loading branch information
matthiaskrgr committed Jan 18, 2024
2 parents 8424f8e + 4b7e0a0 commit 1caa419
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1799,15 +1799,20 @@ 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 !env_var.is_empty() {
env_var.push("\t");
}
env_var.push(t!(entry).path());
if self.config.vendor {
let vendor = self.build.src.join("vendor");
env_var.push(vendor);
env_var.push("=/rust/deps");
} else {
let registry_src = t!(home::cargo_home()).join("registry").join("src");
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");
}
}
cargo.env("RUSTC_CARGO_REGISTRY_SRC_TO_REMAP", env_var);
}
Expand Down

0 comments on commit 1caa419

Please sign in to comment.