Swift 5.1 (Development) working with Fedora

So post-WWDC, Swift 5.1 seems to be in high gear for release, I presume, with Xcode 11. I made a few attempts at getting it to build and package properly and after some modest changes, removing outdated patches and a particularly scary Lua scriptlet in the spec file, it packaged correctly. Whee, go me.

However, while the compiler (swiftc) has always been reliably working, the REPL has always given me fits. In 5.1 the old clangloc.patch was invalid and I traced down the changes to lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp and found that I needed to change the suffixes it was looking for in static const llvm::StringRef kResourceDirSuffixes[]. This was something of a pain because in the original version, the first thing in the list is lib, which I figured was okay, so I made the appropriate changes and....it didn't work.

I knew that I didn't have an lldb directory in /usr/lib, and in reality it was looking for the clang-specific files, which I had put in /usr/lib/swift/clang. On a hunch I added some printf()s in the function that read this array and, with lib in the array, the lldb executable, which controls the REPL, was looking for:

/usr/lib/lib/swift/clang

To verify that was, in fact, the problem, I spun up a Fedora Docker image, added the RPMs, and fiddled with the /usr/lib directory to mimic above and, hey, it worked! So the fix was easy, just remove lib from the array, and, sure enough, we have a working 5.1 REPL on Fedora: