Skip to content

Commit 5cc51ad

Browse files
committed
Rollup merge of rust-lang#53973 - tromey:prefer-rust-enabled-lldb, r=alexcrichton
Have rust-lldb look for the rust-enabled lldb We're shipping a rust-enabled lldb, but the "lldb" executable is not installed into the "bin" directory by rustup. See the discussion in rust-lang/rustup#1492 for background on this decision. There, we agreed to have rust-lldb prefer the rust-enabled lldb if it is installed. This patch changes rust-lldb to look in the sysroot and use the lldb found there, if any. See issue rust-lang#48168
2 parents dbc9ec9 + 8aae6ca commit 5cc51ad

File tree

2 files changed

+21
-12
lines changed

2 files changed

+21
-12
lines changed

src/bootstrap/dist.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -2056,7 +2056,8 @@ impl Step for Lldb {
20562056
drop(fs::remove_dir_all(&image));
20572057

20582058
// Prepare the image directory
2059-
let dst = image.join("bin");
2059+
let root = image.join("lib/rustlib").join(&*target);
2060+
let dst = root.join("bin");
20602061
t!(fs::create_dir_all(&dst));
20612062
for program in &["lldb", "lldb-argdumper", "lldb-mi", "lldb-server"] {
20622063
let exe = bindir.join(exe(program, &target));
@@ -2065,7 +2066,7 @@ impl Step for Lldb {
20652066

20662067
// The libraries.
20672068
let libdir = builder.llvm_out(target).join("lib");
2068-
let dst = image.join("lib");
2069+
let dst = root.join("lib");
20692070
t!(fs::create_dir_all(&dst));
20702071
for entry in t!(fs::read_dir(&libdir)) {
20712072
let entry = entry.unwrap();
@@ -2093,7 +2094,7 @@ impl Step for Lldb {
20932094
let entry = t!(entry);
20942095
if let Ok(name) = entry.file_name().into_string() {
20952096
if name.starts_with("python") {
2096-
let dst = image.join(libdir_name)
2097+
let dst = root.join(libdir_name)
20972098
.join(entry.file_name());
20982099
t!(fs::create_dir_all(&dst));
20992100
builder.cp_r(&entry.path(), &dst);

src/etc/rust-lldb

+17-9
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,35 @@
1212
# Exit if anything fails
1313
set -e
1414

15-
LLDB_VERSION=`lldb --version 2>/dev/null | head -1 | cut -d. -f1`
15+
# Find out where to look for the pretty printer Python module
16+
RUSTC_SYSROOT=`rustc --print sysroot`
17+
18+
# Find the host triple so we can find lldb in rustlib.
19+
host=`rustc -vV | sed -n -e 's/^host: //p'`
20+
21+
lldb=lldb
22+
if [ -f "$RUSTC_SYSROOT/lib/rustlib/$host/bin/lldb" ]; then
23+
lldb="$RUSTC_SYSROOT/lib/rustlib/$host/bin/lldb"
24+
else
25+
LLDB_VERSION=`"$lldb" --version 2>/dev/null | head -1 | cut -d. -f1`
1626

17-
if [ "$LLDB_VERSION" = "lldb-350" ]
18-
then
19-
echo "***"
27+
if [ "$LLDB_VERSION" = "lldb-350" ]
28+
then
29+
echo "***"
2030
echo \
2131
"WARNING: This version of LLDB has known issues with Rust and cannot \
2232
display the contents of local variables!"
23-
echo "***"
33+
echo "***"
34+
fi
2435
fi
2536

26-
# Find out where to look for the pretty printer Python module
27-
RUSTC_SYSROOT=`rustc --print sysroot`
28-
2937
# Prepare commands that will be loaded before any file on the command line has been loaded
3038
script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
3139
category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
3240
category_enable="type category enable Rust"
3341

3442
# Call LLDB with the commands added to the argument list
35-
exec lldb --one-line-before-file="$script_import" \
43+
exec "$lldb" --one-line-before-file="$script_import" \
3644
--one-line-before-file="$category_definition" \
3745
--one-line-before-file="$category_enable" \
3846
"$@"

0 commit comments

Comments
 (0)