|
| 1 | +From a4132f6d092b781b742679d2229c1c69f6ad7b16 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Alex Kiernan < [email protected]> |
| 3 | +Date: Sat, 30 Dec 2023 15:13:27 +0000 |
| 4 | +Subject: [PATCH 1/2] Handle non-existent/empty <CARGO_HOME>/registry/src |
| 5 | + |
| 6 | +If remap-debuginfo is set but cargo isn't vendored into |
| 7 | +.cargo/registry/src, don't panic: |
| 8 | + |
| 9 | +| thread 'main' panicked at src/core/builder.rs:1795:26: |
| 10 | +| std::fs::read_dir(registry_src) failed with No such file or directory (os error 2) |
| 11 | + |
| 12 | +Signed-off-by: Alex Kiernan < [email protected]> |
| 13 | +--- |
| 14 | + src/bootstrap/src/core/builder.rs | 16 ++++++++++------ |
| 15 | + 1 file changed, 10 insertions(+), 6 deletions(-) |
| 16 | + |
| 17 | +diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs |
| 18 | +index e85753a351232..08e7e0b348096 100644 |
| 19 | +--- a/src/bootstrap/src/core/builder.rs |
| 20 | ++++ b/src/bootstrap/src/core/builder.rs |
| 21 | +@@ -1812,15 +1812,19 @@ impl<'a> Builder<'a> { |
| 22 | + if self.config.rust_remap_debuginfo { |
| 23 | + // FIXME: handle vendored sources |
| 24 | + let registry_src = t!(home::cargo_home()).join("registry").join("src"); |
| 25 | +- let mut env_var = OsString::new(); |
| 26 | +- for entry in t!(std::fs::read_dir(registry_src)) { |
| 27 | ++ if registry_src.is_dir() { |
| 28 | ++ let mut env_var = OsString::new(); |
| 29 | ++ for entry in t!(std::fs::read_dir(registry_src)) { |
| 30 | ++ if !env_var.is_empty() { |
| 31 | ++ env_var.push("\t"); |
| 32 | ++ } |
| 33 | ++ env_var.push(t!(entry).path()); |
| 34 | ++ env_var.push("=/rust/deps"); |
| 35 | ++ } |
| 36 | + if !env_var.is_empty() { |
| 37 | +- env_var.push("\t"); |
| 38 | ++ cargo.env("RUSTC_CARGO_REGISTRY_SRC_TO_REMAP", env_var); |
| 39 | + } |
| 40 | +- env_var.push(t!(entry).path()); |
| 41 | +- env_var.push("=/rust/deps"); |
| 42 | + } |
| 43 | +- cargo.env("RUSTC_CARGO_REGISTRY_SRC_TO_REMAP", env_var); |
| 44 | + } |
| 45 | + |
| 46 | + // Enable usage of unstable features |
| 47 | + |
| 48 | +From 361f32e60788bb95011092a9b2a0472d4e6d38b1 Mon Sep 17 00:00:00 2001 |
| 49 | +From: Alex Kiernan < [email protected]> |
| 50 | +Date: Sat, 30 Dec 2023 15:15:40 +0000 |
| 51 | +Subject: [PATCH 2/2] Ignore blank |
| 52 | + RUSTC_DEBUGINFO_MAP/RUSTC_CARGO_REGISTRY_SRC_TO_REMAP |
| 53 | + |
| 54 | +If RUSTC_DEBUGINFO_MAP or RUSTC_CARGO_REGISTRY_SRC_TO_REMAP are empty, |
| 55 | +avoid inserting `--remap-path-prefix` with no associated argument. |
| 56 | + |
| 57 | +Signed-off-by: Alex Kiernan < [email protected]> |
| 58 | +--- |
| 59 | + src/bootstrap/src/bin/rustc.rs | 8 ++++++-- |
| 60 | + 1 file changed, 6 insertions(+), 2 deletions(-) |
| 61 | + |
| 62 | +diff --git a/src/bootstrap/src/bin/rustc.rs b/src/bootstrap/src/bin/rustc.rs |
| 63 | +index 38c55b2034496..a9dd687b75653 100644 |
| 64 | +--- a/src/bootstrap/src/bin/rustc.rs |
| 65 | ++++ b/src/bootstrap/src/bin/rustc.rs |
| 66 | +@@ -161,13 +161,17 @@ fn main() { |
| 67 | + } |
| 68 | + |
| 69 | + if let Ok(map) = env::var("RUSTC_DEBUGINFO_MAP") { |
| 70 | +- cmd.arg("--remap-path-prefix").arg(&map); |
| 71 | ++ if !map.is_empty() { |
| 72 | ++ cmd.arg("--remap-path-prefix").arg(&map); |
| 73 | ++ } |
| 74 | + } |
| 75 | + // The remap flags for Cargo registry sources need to be passed after the remapping for the |
| 76 | + // Rust source code directory, to handle cases when $CARGO_HOME is inside the source directory. |
| 77 | + if let Ok(maps) = env::var("RUSTC_CARGO_REGISTRY_SRC_TO_REMAP") { |
| 78 | + for map in maps.split('\t') { |
| 79 | +- cmd.arg("--remap-path-prefix").arg(map); |
| 80 | ++ if !map.is_empty() { |
| 81 | ++ cmd.arg("--remap-path-prefix").arg(map); |
| 82 | ++ } |
| 83 | + } |
| 84 | + } |
| 85 | + |
0 commit comments