I recently installed the Swift 5.8 toolchain on my machine via
winget following the official installation instructions, and ran into two issues related to DLL loading that were surprisingly frustrating to debug. (I didn't post this in Swift Required DLLs on Windows 10 as that thread seems more related to Swift program distribution, and I'm just trying to run Swift locally here; though, if this is a good fit for that thread, happy to copy this over.)
The first roadblock: attempting to run
swift.exe immediately presented dialogs indicating that
swiftDispatch.dll could not be found, despite the fact that these DLLs had been successfully installed in
C:\Program Files\swift\runtime-development\usr\bin, and were in the
%PATH%. The solution was to copy the contents of this directory into
C:\Library\Developer\Toolchains\unknown-Asserts-development.xctoolchain\usr\bin so that the DLLs were present alongside the executables in question.
The second roadblock: attempting to run
swift.exe repl resulted in
error: failed to retrieve frontend target info. Vaguely remembering having run into this in the past with LLDB, I tried running
lldb.exe from the same directory, and got the same error dialog about
python310.dll not being found (also despite being in my
%PATH%). The solution was the same: copy
python310.dll into the toolchain directory, and run again.
Having done both of those, I'm able to now run
swift.exe repl, though:
- Only from within the toolchain directory — otherwise I get
error: failed to retrieve frontend target infoagain
- Attempting to actually evaluate anything yields
Assertion failed: false && "called into swift language runtime stub", file D:\a\1\s\llvm-project\lldb\source\Plugins\LanguageRuntime\Swift\SwiftLanguageRuntime.cpp, line 393, presumably because the runtime also isn't getting loaded correctly
- Alternatively, attempting to compile a file without the repl leads either to the
frontend target infoerror if running from a directory outside of the toolchain dir, or
<unknown>:0: error: error opening input file '<path here>' (no such file or directory)if running from inside of it. (The file does exist and is accessible, but I suspect that some other failure just leads to this error line)
Knowing very little about Windows development, I'm wondering:
- Am I doing something wrong here? Is there something about how the toolchain is packaged, or getting installed via
wingetthat's leading to these issues, or is this somewhat expected?
- Is it expected that these tools can't find the DLLs they're relying on, despite those DLLs being present in the
%PATH%? I know DLL loading is complex, but from my very limited knowledge, I would expect these things to Just Work™ (famous last words!). Is there something I need to manually do to get dynamic loading to work?
- Is there a good path forward here in terms of reporting these issues? I'm just messing around with Swift on my PC here, so this is super low-stakes for me, but I do want to help if I can. (The LLDB
python310.dllissue, for example, appears to come up every now and again on
llvm/llvm-project, but it seems that most of those are resolved by the original authors once they learn to copy
python3<x>.dllinto the LLDB dir — but this doesn't feel sustainable.) Are there more central issues tracking these problems, and if not, do we want there to be?
/CC @compnerd as the person most likely to be able to comment on some of these issues, though I don't mean to just dump this wall of text directly on you! Thanks for any help, and please let me know how I might be able to contribute back!