]> git.lizzy.rs Git - rust.git/commitdiff
Rollup merge of #53973 - tromey:prefer-rust-enabled-lldb, r=alexcrichton
authorkennytm <kennytm@gmail.com>
Sat, 8 Sep 2018 08:07:40 +0000 (16:07 +0800)
committerkennytm <kennytm@gmail.com>
Sat, 8 Sep 2018 10:26:37 +0000 (18:26 +0800)
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
https://github.com/rust-lang-nursery/rustup.rs/pull/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 #48168

src/bootstrap/dist.rs
src/etc/rust-lldb

index 167e4a78edaf8e9a251d21eb7e9273c306e9c3dd..2d94704fda7d600f847f918b6bdc871b0f2d996d 100644 (file)
@@ -2056,7 +2056,8 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
         drop(fs::remove_dir_all(&image));
 
         // Prepare the image directory
-        let dst = image.join("bin");
+        let root = image.join("lib/rustlib").join(&*target);
+        let dst = root.join("bin");
         t!(fs::create_dir_all(&dst));
         for program in &["lldb", "lldb-argdumper", "lldb-mi", "lldb-server"] {
             let exe = bindir.join(exe(program, &target));
@@ -2065,7 +2066,7 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
 
         // The libraries.
         let libdir = builder.llvm_out(target).join("lib");
-        let dst = image.join("lib");
+        let dst = root.join("lib");
         t!(fs::create_dir_all(&dst));
         for entry in t!(fs::read_dir(&libdir)) {
             let entry = entry.unwrap();
@@ -2093,7 +2094,7 @@ fn run(self, builder: &Builder) -> Option<PathBuf> {
             let entry = t!(entry);
             if let Ok(name) = entry.file_name().into_string() {
                 if name.starts_with("python") {
-                    let dst = image.join(libdir_name)
+                    let dst = root.join(libdir_name)
                         .join(entry.file_name());
                     t!(fs::create_dir_all(&dst));
                     builder.cp_r(&entry.path(), &dst);
index 6a2849b55485e0ae05454ce93c96d6c518ab5bb5..6ed8210349e1727210e95b6f066ef48ae08778b6 100755 (executable)
 # Exit if anything fails
 set -e
 
-LLDB_VERSION=`lldb --version 2>/dev/null | head -1 | cut -d. -f1`
+# Find out where to look for the pretty printer Python module
+RUSTC_SYSROOT=`rustc --print sysroot`
+
+# Find the host triple so we can find lldb in rustlib.
+host=`rustc -vV | sed -n -e 's/^host: //p'`
+
+lldb=lldb
+if [ -f "$RUSTC_SYSROOT/lib/rustlib/$host/bin/lldb" ]; then
+    lldb="$RUSTC_SYSROOT/lib/rustlib/$host/bin/lldb"
+else
+    LLDB_VERSION=`"$lldb" --version 2>/dev/null | head -1 | cut -d. -f1`
 
-if [ "$LLDB_VERSION" = "lldb-350" ]
-then
-    echo "***"
+    if [ "$LLDB_VERSION" = "lldb-350" ]
+    then
+        echo "***"
        echo \
 "WARNING: This version of LLDB has known issues with Rust and cannot \
 display the contents of local variables!"
-    echo "***"
+        echo "***"
+    fi
 fi
 
-# Find out where to look for the pretty printer Python module
-RUSTC_SYSROOT=`rustc --print sysroot`
-
 # Prepare commands that will be loaded before any file on the command line has been loaded
 script_import="command script import \"$RUSTC_SYSROOT/lib/rustlib/etc/lldb_rust_formatters.py\""
 category_definition="type summary add --no-value --python-function lldb_rust_formatters.print_val -x \".*\" --category Rust"
 category_enable="type category enable Rust"
 
 # Call LLDB with the commands added to the argument list
-exec lldb --one-line-before-file="$script_import" \
+exec "$lldb" --one-line-before-file="$script_import" \
     --one-line-before-file="$category_definition" \
     --one-line-before-file="$category_enable" \
     "$@"