Skip to content

Commit

Permalink
Unrolled build for rust-lang#127112
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#127112 - ChrisDenton:lldb, r=Kobzol

Bootstrap: Don't get output if `lldb --version` errors

fixes rust-lang#126892

`Command` can error in two ways: the OS can fail to run the binary at all or else the binary can return an error exit code. Unfortunately the distinction between the two is not clear cut. The OS may succeed in starting the binary but it may still error before `main` (e.g. if a necessary library fails to load) and this will be reported via the exit code.

Fortunately this case is simpler. We can assume that `lldb --version` will only ever error if there's a startup issue of some kind. so both kinds of errors are caused by the OS. Thus it's safe for us to treat them equally for the sake of this specific check.
  • Loading branch information
rust-timer authored Jun 29, 2024
2 parents f845335 + a6ef91e commit f0c0872
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1817,23 +1817,25 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the
cmd.arg("--gdb").arg(gdb);
}

let run = |cmd: &mut Command| {
cmd.output().map(|output| {
String::from_utf8_lossy(&output.stdout)
.lines()
.next()
.unwrap_or_else(|| panic!("{:?} failed {:?}", cmd, output))
.to_string()
})
};

let lldb_exe = builder.config.lldb.clone().unwrap_or_else(|| PathBuf::from("lldb"));
let lldb_version = Command::new(&lldb_exe)
.arg("--version")
.output()
.map(|output| String::from_utf8_lossy(&output.stdout).to_string())
.ok();
.map(|output| {
(String::from_utf8_lossy(&output.stdout).to_string(), output.status.success())
})
.ok()
.and_then(|(output, success)| if success { Some(output) } else { None });
if let Some(ref vers) = lldb_version {
let run = |cmd: &mut Command| {
cmd.output().map(|output| {
String::from_utf8_lossy(&output.stdout)
.lines()
.next()
.unwrap_or_else(|| panic!("{:?} failed {:?}", cmd, output))
.to_string()
})
};
cmd.arg("--lldb-version").arg(vers);
let lldb_python_dir = run(Command::new(&lldb_exe).arg("-P")).ok();
if let Some(ref dir) = lldb_python_dir {
Expand Down

0 comments on commit f0c0872

Please sign in to comment.