Usage of LLDB with Swift on Linux - apt-get version vs bundled version

(Ron Olson) #1

Hi all-

I’ve been working with Linux and Swift and it occurs to me that I have two copies of LLDB on my Ubuntu system: lldb 4.0.1 installed from apt-get, and 4.0.0 from my /usr/local/swift/usr/bin directory. I have /usr/bin before the swift one, so if I do a ‘which lldb’, I get the apt-get installed one, but when I run the Swift REPL, it works correctly which I assume means it’s using the Swift-aware version of lldb in the swift/usr/bin directory.

I’m guessing that the Swift expects to find lldb (which is a symlink to lldb-4.0.0) in the same directory as the swift executable. As a test I changed the lldb symlink to the one in /usr/bin and got what I expected: “LLDB isn’t configured with REPL support for any languages.”

So a couple of questions arise from this:

  • Am I correct in my understanding of how Swift and LLDB work together in an environment where another LLDB is installed?
  • Is there any plans to push these modifications upstream to the LLDB project (I didn’t find any mention of Swift in the LLDB SVN repo, but I may have not searched correctly…it’s been years since I used SVN). I was looking in the wrong place; it seems Swift support is in the latest Subversion code

Thanks for any info!


(Jim Ingham) #2

At present, for swift debugging to work (and surprising though it may seem the REPL is actually just a special-purpose debug session) the lldb binary’s version must match the swift compiler and library versions exactly. So you are right, the swift Driver does look next to itself for the version of lldb to run. It would be unlikely to work otherwise.

Moreover, if you have multiple lldb’s on the system, and want to debug swift code, you will have to ensure that you run the lldb that came from the toolchain that you built your swift program with. You obviously can’t use the version since it has no swift support. But you also can’t use an lldb from another swift toolchain, the lldb & swift compilers have to match.

I don’t know what you saw that led you to think that there’s actually swift support in the sources for lldb. There’s a definition of the language in the languages list, but that’s about all.

(Ron Olson) #3

I downloaded a new copy of the lldb source from the subversion repo and found

include/lldb/lldb-enumerations.h:439: eLanguageTypeSwift = 0x001e, ///< Swift.

There are other references to Swift in the codebase, but compiling and testing it out (it builds to version 7.0.0) it does not include, out-of-the-box, any support for Swift.

I guess I hadn’t fully grokked the full ramifications of the LLVM-Swift connection in that the changes to make LLDB work with Swift happen downstream as to be Swift-specific (as the comment about needing to be in lock-step, version-wise states) and presumably there’s no thought to make any of those changes available upstream in the llvm/lldb project.