1From 5e37ea7cb9d99d91f2c5ac6edf19ff777f95bb88 Mon Sep 17 00:00:00 2001
2From: Arlo Siemsen <arsiem@microsoft.com>
3Date: Thu, 4 Jan 2024 11:40:56 -0600
4Subject: [PATCH] Handle vendored sources when remapping paths
5
6Upstream-Status: Submitted [https://github.com/rust-lang/rust/pull/119582]
7Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
8---
9 src/bootstrap/src/core/builder.rs | 19 ++++++++++++-------
10 1 file changed, 12 insertions(+), 7 deletions(-)
11
12diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs
13index cd276674dee6..48fdb2c7f7b7 100644
14--- a/src/bootstrap/src/core/builder.rs
15+++ b/src/bootstrap/src/core/builder.rs
16@@ -1789,15 +1789,20 @@ pub fn cargo(
17         }
18
19         if self.config.rust_remap_debuginfo {
20-            // FIXME: handle vendored sources
21-            let registry_src = t!(home::cargo_home()).join("registry").join("src");
22             let mut env_var = OsString::new();
23-            for entry in t!(std::fs::read_dir(registry_src)) {
24-                if !env_var.is_empty() {
25-                    env_var.push("\t");
26-                }
27-                env_var.push(t!(entry).path());
28+            if self.config.vendor {
29+                let vendor = self.build.src.join("vendor");
30+                env_var.push(vendor);
31                 env_var.push("=/rust/deps");
32+            } else {
33+                let registry_src = t!(home::cargo_home()).join("registry").join("src");
34+                for entry in t!(std::fs::read_dir(registry_src)) {
35+                    if !env_var.is_empty() {
36+                        env_var.push("\t");
37+                    }
38+                    env_var.push(t!(entry).path());
39+                    env_var.push("=/rust/deps");
40+                }
41             }
42             cargo.env("RUSTC_CARGO_REGISTRY_SRC_TO_REMAP", env_var);
43         }
44--
452.39.0
46
47