From 83f510188e4bce3b83e2ea250cda6cfe98afde8b Mon Sep 17 00:00:00 2001 From: George Tokmaji Date: Fri, 10 Jul 2026 10:49:12 +0200 Subject: [PATCH] Look for the cdb architecture that corresponds to the target triple instead of the build triple Debugging other architectures with the build target CDB is neither a common nor a good user experience - for example, when targeting i686 from a x86_64 build target, you get all the internal WOW64 events, which also break debuginfo tests. Use the cdb.exe that corresponds to the target's architecture instead. --- src/bootstrap/src/core/debuggers/cdb.rs | 28 +++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/bootstrap/src/core/debuggers/cdb.rs b/src/bootstrap/src/core/debuggers/cdb.rs index 7f835f3618724..c3d3c5c3c7a8b 100644 --- a/src/bootstrap/src/core/debuggers/cdb.rs +++ b/src/bootstrap/src/core/debuggers/cdb.rs @@ -1,4 +1,3 @@ -use std::env; use std::path::PathBuf; use crate::core::config::TargetSelection; @@ -8,18 +7,19 @@ pub(crate) struct Cdb { } /// We consult the registry to find the installed cdb.exe and try "Program Files" if that fails. +#[cfg(windows)] pub(crate) fn discover_cdb(target: TargetSelection) -> Option { - if !cfg!(windows) || !target.ends_with("-pc-windows-msvc") { + if !target.ends_with("-pc-windows-msvc") { return None; } - let cdb_arch = if cfg!(target_arch = "x86") { + let cdb_arch = if target.starts_with("i686") { "x86" - } else if cfg!(target_arch = "x86_64") { + } else if target.starts_with("x86_64") { "x64" - } else if cfg!(target_arch = "aarch64") { + } else if target.starts_with("aarch64") || target.starts_with("arm64") { "arm64" - } else if cfg!(target_arch = "arm") { + } else if target.starts_with("arm") || target.starts_with("thumb") { "arm" } else { return None; // No compatible CDB.exe in the Windows 10 SDK @@ -29,6 +29,11 @@ pub(crate) fn discover_cdb(target: TargetSelection) -> Option { Some(Cdb { cdb: path }) } +#[cfg(not(windows))] +pub(crate) fn discover_cdb(_target: TargetSelection) -> Option { + None +} + #[cfg(windows)] fn discover_cdb_registry(cdb_arch: &'static str) -> Option { use windows_registry::LOCAL_MACHINE; @@ -39,14 +44,11 @@ fn discover_cdb_registry(cdb_arch: &'static str) -> Option { path.exists().then_some(path) } -#[cfg(not(windows))] -fn discover_cdb_registry(_cdb_arch: &'static str) -> Option { - None -} - +#[cfg(windows)] fn discover_cdb_program_files(cdb_arch: &'static str) -> Option { - let mut path = - PathBuf::from(env::var_os("ProgramFiles(x86)").or_else(|| env::var_os("ProgramFiles"))?); + let mut path = PathBuf::from( + std::env::var_os("ProgramFiles(x86)").or_else(|| std::env::var_os("ProgramFiles"))?, + ); path.extend([r"Windows Kits\10\Debuggers", cdb_arch, r"cdb.exe"]); path.exists().then_some(path) }