Can’t build libswiftDispatch.so

how do i identify the failing compilation command? i’ve never invoked swift-frontend directly, and i’m not familiar with how that tool fits into the higher-level utils/build-script command i’ve been running.

i wondered if you were referring to one of the bash commands that the build script echos to the terminal, such as the one that begins with

: && /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swiftc 

when i tried copying it and running it in isolation, it failed with:

/swift/swift-project/swift$ /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swiftc -output-file-map src/swift/CMakeFiles/swiftDispatch.dir/Release/output-file-map.json -incremental -j 12 -emit-library -o libswiftDispatch.so -module-name Dispatch -module-link-name swiftDispatch -emit-module -emit-module-path src/swift/swift/Dispatch.swiftmodule -emit-dependencies -DswiftDispatch_EXPORTS -module-cache-path "/swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/module-cache" -O -Xcc -fblocks -Xcc -fmodule-map-file=/swift/swift-project/swift-corelibs-libdispatch/dispatch/module.modulemap -Xcc -I/swift/swift-project/swift-corelibs-libdispatch -Xcc -I/swift/swift-project/swift-corelibs-libdispatch/src/swift/shims -vfsoverlay /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/dispatch-vfs-overlay.yaml -I /swift/swift-project/swift-corelibs-libdispatch/src/BlocksRuntime -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64 -I /swift/swift-project/swift-corelibs-libdispatch -I /swift/swift-project/swift-corelibs-libdispatch/src -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src /swift/swift-project/swift-corelibs-libdispatch/src/swift/Block.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Data.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Dispatch.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/IO.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Private.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Queue.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Source.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Time.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Wrapper.swift -no-toolchain-stdlib-rpath -Xlinker -soname -Xlinker libswiftDispatch.so  -L /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src/swift  -L /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64  -L /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64   -L /usr/lib/gcc/x86_64-amazon-linux/11 -Xlinker -rpath -Xlinker /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64:  src/swift/libDispatchStubs.a  libdispatch.so  libBlocksRuntime.so  -lstdc++  -lm  -lgcc_s  -lgcc  -lc  -lgcc_s  -lgcc
error: unable to load output file map 'src/swift/CMakeFiles/swiftDispatch.dir/Release/output-file-map.json': FileSystemError(kind: TSCBasic.FileSystemError.Kind.noEntry, path: Optional(<AbsolutePath:"/swift/swift-project/swift/src/swift/CMakeFiles/swiftDispatch.dir/Release/output-file-map.json">))

this is of course, not the same error i get when i run the build script as a whole (that ends in error: fatalError), but i also don’t know enough about how the build script works to know if that result is even meaningful.

It should be the last one from the verbose output you listed in the third post in this thread. Try running that swift-frontend command alone to make sure. If it works, it may be one of the earlier commands, as it is running 12 simultaneously, so try each of the previous 11 commands too.

build-script simply invokes CMake to configure each repo, then ninja to build them. That will invoke the appropriate compiler for the source, clang for C/C++ code and swiftc for Swift code. swiftc invokes the standalone swift-driver binary to parse compilation options passed to it, then invokes swift-frontend to compile Swift source to binary objects, swift-autolink-extract to extract which libraries to link against, and finally clang to link all those objects and libraries together.

Since the last command you listed in the verbose output is swift-frontend, that is most likely the one crashing and the one you want to examine in lldb. Note the -- I added after swift-frontend above to make sure its compilation options are not passed to lldb instead.

okay, so that means i was running the subcommand in the wrong directory. so, retracing those steps:

$ cd ../build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/
$ /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swiftc -v -output-file-map src/swift/CMakeFiles/swiftDispatch.dir/Release/output-file-map.json -incremental -j 12 -emit-library -o libswiftDispatch.so -module-name Dispatch -module-link-name swiftDispatch -emit-module -emit-module-path src/swift/swift/Dispatch.swiftmodule -emit-dependencies -DswiftDispatch_EXPORTS -module-cache-path "/swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/module-cache" -O -Xcc -fblocks -Xcc -fmodule-map-file=/swift/swift-project/swift-corelibs-libdispatch/dispatch/module.modulemap -Xcc -I/swift/swift-project/swift-corelibs-libdispatch -Xcc -I/swift/swift-project/swift-corelibs-libdispatch/src/swift/shims -vfsoverlay /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/dispatch-vfs-overlay.yaml -I /swift/swift-project/swift-corelibs-libdispatch/src/BlocksRuntime -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64 -I /swift/swift-project/swift-corelibs-libdispatch -I /swift/swift-project/swift-corelibs-libdispatch/src -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src /swift/swift-project/swift-corelibs-libdispatch/src/swift/Block.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Data.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Dispatch.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/IO.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Private.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Queue.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Source.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Time.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Wrapper.swift -no-toolchain-stdlib-rpath -Xlinker -soname -Xlinker libswiftDispatch.so  -L /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src/swift  -L /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64  -L /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64   -L /usr/lib/gcc/x86_64-amazon-linux/11 -Xlinker -rpath -Xlinker /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64:  src/swift/libDispatchStubs.a  libdispatch.so  libBlocksRuntime.so  -lstdc++  -lm  -lgcc_s  -lgcc  -lc  -lgcc_s  -lgcc
Swift version 5.11-dev (LLVM 497a64a78b2fba6, Swift 0bbcae4e9278768)
Target: x86_64-unknown-linux-gnu
/swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift-frontend -frontend -c -primary-file /swift/swift-project/swift-corelibs-libdispatch/src/swift/Block.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Data.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Dispatch.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/IO.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Private.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Queue.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Source.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Time.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Wrapper.swift -emit-module-path src/swift/CMakeFiles/swiftDispatch.dir/Block.swift.swiftmodule -emit-module-doc-path src/swift/CMakeFiles/swiftDispatch.dir/Block.swift.swiftdoc -emit-module-source-info-path src/swift/CMakeFiles/swiftDispatch.dir/Block.swift.swiftsourceinfo -emit-dependencies-path src/swift/CMakeFiles/swiftDispatch.dir/Block.swift.o.d -emit-reference-dependencies-path src/swift/CMakeFiles/swiftDispatch.dir/Block.swift.o.swiftdeps -target x86_64-unknown-linux-gnu -disable-objc-interop -I /swift/swift-project/swift-corelibs-libdispatch/src/BlocksRuntime -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64 -I /swift/swift-project/swift-corelibs-libdispatch -I /swift/swift-project/swift-corelibs-libdispatch/src -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src -vfsoverlay /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/dispatch-vfs-overlay.yaml -color-diagnostics -module-cache-path /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/module-cache -module-link-name swiftDispatch -O -D swiftDispatch_EXPORTS -empty-abi-descriptor -resource-dir /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift -Xcc -fblocks -Xcc -fmodule-map-file=/swift/swift-project/swift-corelibs-libdispatch/dispatch/module.modulemap -Xcc -I/swift/swift-project/swift-corelibs-libdispatch -Xcc -I/swift/swift-project/swift-corelibs-libdispatch/src/swift/shims -module-name Dispatch -plugin-path /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/host/plugins -plugin-path /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/local/lib/swift/host/plugins -enable-default-cmo -parse-as-library -o src/swift/CMakeFiles/swiftDispatch.dir/Block.swift.o
/swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift-frontend -frontend -c /swift/swift-project/swift-corelibs-libdispatch/src/swift/Block.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Data.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Dispatch.swift -primary-file /swift/swift-project/swift-corelibs-libdispatch/src/swift/IO.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Private.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Queue.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Source.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Time.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Wrapper.swift -emit-module-path src/swift/CMakeFiles/swiftDispatch.dir/IO.swift.swiftmodule -emit-module-doc-path src/swift/CMakeFiles/swiftDispatch.dir/IO.swift.swiftdoc -emit-module-source-info-path src/swift/CMakeFiles/swiftDispatch.dir/IO.swift.swiftsourceinfo -emit-dependencies-path src/swift/CMakeFiles/swiftDispatch.dir/IO.swift.o.d -emit-reference-dependencies-path src/swift/CMakeFiles/swiftDispatch.dir/IO.swift.o.swiftdeps -target x86_64-unknown-linux-gnu -disable-objc-interop -I /swift/swift-project/swift-corelibs-libdispatch/src/BlocksRuntime -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64 -I /swift/swift-project/swift-corelibs-libdispatch -I /swift/swift-project/swift-corelibs-libdispatch/src -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src -vfsoverlay /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/dispatch-vfs-overlay.yaml -color-diagnostics -module-cache-path /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/module-cache -module-link-name swiftDispatch -O -D swiftDispatch_EXPORTS -empty-abi-descriptor -resource-dir /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift -Xcc -fblocks -Xcc -fmodule-map-file=/swift/swift-project/swift-corelibs-libdispatch/dispatch/module.modulemap -Xcc -I/swift/swift-project/swift-corelibs-libdispatch -Xcc -I/swift/swift-project/swift-corelibs-libdispatch/src/swift/shims -module-name Dispatch -plugin-path /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/host/plugins -plugin-path /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/local/lib/swift/host/plugins -enable-default-cmo -parse-as-library -o src/swift/CMakeFiles/swiftDispatch.dir/IO.swift.o
/swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift-frontend -frontend -c /swift/swift-project/swift-corelibs-libdispatch/src/swift/Block.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Data.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Dispatch.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/IO.swift -primary-file /swift/swift-project/swift-corelibs-libdispatch/src/swift/Private.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Queue.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Source.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Time.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Wrapper.swift -emit-module-path src/swift/CMakeFiles/swiftDispatch.dir/Private.swift.swiftmodule -emit-module-doc-path src/swift/CMakeFiles/swiftDispatch.dir/Private.swift.swiftdoc -emit-module-source-info-path src/swift/CMakeFiles/swiftDispatch.dir/Private.swift.swiftsourceinfo -emit-dependencies-path src/swift/CMakeFiles/swiftDispatch.dir/Private.swift.o.d -emit-reference-dependencies-path src/swift/CMakeFiles/swiftDispatch.dir/Private.swift.o.swiftdeps -target x86_64-unknown-linux-gnu -disable-objc-interop -I /swift/swift-project/swift-corelibs-libdispatch/src/BlocksRuntime -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64 -I /swift/swift-project/swift-corelibs-libdispatch -I /swift/swift-project/swift-corelibs-libdispatch/src -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src -vfsoverlay /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/dispatch-vfs-overlay.yaml -color-diagnostics -module-cache-path /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/module-cache -module-link-name swiftDispatch -O -D swiftDispatch_EXPORTS -empty-abi-descriptor -resource-dir /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift -Xcc -fblocks -Xcc -fmodule-map-file=/swift/swift-project/swift-corelibs-libdispatch/dispatch/module.modulemap -Xcc -I/swift/swift-project/swift-corelibs-libdispatch -Xcc -I/swift/swift-project/swift-corelibs-libdispatch/src/swift/shims -module-name Dispatch -plugin-path /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/host/plugins -plugin-path /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/local/lib/swift/host/plugins -enable-default-cmo -parse-as-library -o src/swift/CMakeFiles/swiftDispatch.dir/Private.swift.o
/swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift-frontend -frontend -c /swift/swift-project/swift-corelibs-libdispatch/src/swift/Block.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Data.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Dispatch.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/IO.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Private.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Queue.swift -primary-file /swift/swift-project/swift-corelibs-libdispatch/src/swift/Source.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Time.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Wrapper.swift -emit-module-path src/swift/CMakeFiles/swiftDispatch.dir/Source.swift.swiftmodule -emit-module-doc-path src/swift/CMakeFiles/swiftDispatch.dir/Source.swift.swiftdoc -emit-module-source-info-path src/swift/CMakeFiles/swiftDispatch.dir/Source.swift.swiftsourceinfo -emit-dependencies-path src/swift/CMakeFiles/swiftDispatch.dir/Source.swift.o.d -emit-reference-dependencies-path src/swift/CMakeFiles/swiftDispatch.dir/Source.swift.o.swiftdeps -target x86_64-unknown-linux-gnu -disable-objc-interop -I /swift/swift-project/swift-corelibs-libdispatch/src/BlocksRuntime -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64 -I /swift/swift-project/swift-corelibs-libdispatch -I /swift/swift-project/swift-corelibs-libdispatch/src -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src -vfsoverlay /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/dispatch-vfs-overlay.yaml -color-diagnostics -module-cache-path /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/module-cache -module-link-name swiftDispatch -O -D swiftDispatch_EXPORTS -empty-abi-descriptor -resource-dir /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift -Xcc -fblocks -Xcc -fmodule-map-file=/swift/swift-project/swift-corelibs-libdispatch/dispatch/module.modulemap -Xcc -I/swift/swift-project/swift-corelibs-libdispatch -Xcc -I/swift/swift-project/swift-corelibs-libdispatch/src/swift/shims -module-name Dispatch -plugin-path /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/host/plugins -plugin-path /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/local/lib/swift/host/plugins -enable-default-cmo -parse-as-library -o src/swift/CMakeFiles/swiftDispatch.dir/Source.swift.o
/swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift-frontend -frontend -c /swift/swift-project/swift-corelibs-libdispatch/src/swift/Block.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Data.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Dispatch.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/IO.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Private.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Queue.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Source.swift -primary-file /swift/swift-project/swift-corelibs-libdispatch/src/swift/Time.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Wrapper.swift -emit-module-path src/swift/CMakeFiles/swiftDispatch.dir/Time.swift.swiftmodule -emit-module-doc-path src/swift/CMakeFiles/swiftDispatch.dir/Time.swift.swiftdoc -emit-module-source-info-path src/swift/CMakeFiles/swiftDispatch.dir/Time.swift.swiftsourceinfo -emit-dependencies-path src/swift/CMakeFiles/swiftDispatch.dir/Time.swift.o.d -emit-reference-dependencies-path src/swift/CMakeFiles/swiftDispatch.dir/Time.swift.o.swiftdeps -target x86_64-unknown-linux-gnu -disable-objc-interop -I /swift/swift-project/swift-corelibs-libdispatch/src/BlocksRuntime -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64 -I /swift/swift-project/swift-corelibs-libdispatch -I /swift/swift-project/swift-corelibs-libdispatch/src -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src -vfsoverlay /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/dispatch-vfs-overlay.yaml -color-diagnostics -module-cache-path /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/module-cache -module-link-name swiftDispatch -O -D swiftDispatch_EXPORTS -empty-abi-descriptor -resource-dir /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift -Xcc -fblocks -Xcc -fmodule-map-file=/swift/swift-project/swift-corelibs-libdispatch/dispatch/module.modulemap -Xcc -I/swift/swift-project/swift-corelibs-libdispatch -Xcc -I/swift/swift-project/swift-corelibs-libdispatch/src/swift/shims -module-name Dispatch -plugin-path /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/host/plugins -plugin-path /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/local/lib/swift/host/plugins -enable-default-cmo -parse-as-library -o src/swift/CMakeFiles/swiftDispatch.dir/Time.swift.o
error: fatalError

(why is it using a 5.11 compiler?)

i only see 5 swift-frontend invocations here, and running them each invididually succeeds:

  • Block.swift.o
  • IO.swift.o
  • Private.swift.o
  • Source.swift.o
  • Time.swift.o

so i assume it must be an error in the swiftc invocation.

attaching lldb did not work initially, due to this issue.

lldb: error while loading shared libraries: libpython3.7m.so.1.0: cannot open shared object file: No such file or directory

i tried to adapt your suggestion in that thread by running:

$ sudo ln -s /usr/lib64/libpython3.9.so.1.0 /usr/lib64/libpython3.7m.so.1.0

that got lldb to launch, but it just failed later with

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'lldb'

fortunately this is a well-known issue and on Amazon Linux 2023 you can just run:

$ sudo yum install python3-lldb

but then i get a different python error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.9/site-packages/lldb/__init__.py", line 952, in <module>
    eArgTypeReproducerProvider = _lldb.eArgTypeReproducerProvider
AttributeError: module '_lldb' has no attribute 'eArgTypeReproducerProvider'

the error always occurs when running lldb, even just lldb --version

$ lldb --version
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.9/site-packages/lldb/__init__.py", line 952, in <module>
    eArgTypeReproducerProvider = _lldb.eArgTypeReproducerProvider
AttributeError: module '_lldb' has no attribute 'eArgTypeReproducerProvider'
lldb version 13.0.0git (https://github.com/apple/llvm-project.git revision 2b42c5ce063a374fb22676e27505a22fe411ea8c)
Swift version 5.9.2 (swift-5.9.2-RELEASE)

this appears to be a new problem in swift 5.9, and i have not been able to find a solution yet.


EDIT: one hypothesis is that lldb (which comes from /opt/swift/5.9.2/usr/bin/lldb) is version 13, but the version of python-lldb installed is 15.0.7. unfortunately, i do not know of a way to install an older version of python-lldb:

$ yum --showduplicates list python3-lldb | expand
Last metadata expiration check: 0:01:41 ago on Tue Jan 16 22:40:56 2024.
Installed Packages
python3-lldb.x86_64              15.0.7-3.amzn2023.0.1              @amazonlinux
Available Packages
python3-lldb.x86_64              15.0.6-1.amzn2023.0.3              amazonlinux 
python3-lldb.x86_64              15.0.7-3.amzn2023.0.1              amazonlinux 

You are building the main branch from source, right? That is currently Swift 5.11, planned to branch off in a couple months and release near the end of the year. Once a fresh 5.11 compiler has been built in /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/, it is used to build the corelibs like libdispatch or foundation and SwiftPM. The prebuilt host 5.9 compiler is only used to build some components run inside of the fresh 5.11 compiler, like the swift-syntax parser and early swift-driver.

I was worried that it would be some other command we don't see that's failing: I'm dubious that it is the swiftc invocation failing in the middle though.

Can you try the remaining four swift-frontend invocations by hand, as swiftc is run with 9 Swift files from libdispatch? It shouldn't be hard to modify one of the existing swift-frontend invocations to generate the last four invocations.

If all 9 work, then it may be swiftc that's failing.

If you're having problems with the Swift-forked lldb that comes with the Swift 5.9 toolchain, just use your normal system lldb to get a backtrace. The function symbols may not be demangled but that's good enough.

1 Like

so on closer inspection, i realized that each time i invoke swiftc, a different subset of 3-5 files gets compiled for some reason. so i didn’t have to reconstruct those commands, i just ran the swiftc command several times to sample the swift-frontend commands, and i ran them without the final -o to track my progress. ultimately, i was able to manually compile all nine .o files without errors.

$ ls -lt
total 2240
-rw-rw-r-- 1 ec2-user ec2-user  58816 Jan 17 22:06 Wrapper.o
-rw-rw-r-- 1 ec2-user ec2-user  61944 Jan 17 22:02 Queue.o
-rw-rw-r-- 1 ec2-user ec2-user  33208 Jan 17 22:01 Block.o
-rw-rw-r-- 1 ec2-user ec2-user  14720 Jan 17 22:01 Private.o
-rw-rw-r-- 1 ec2-user ec2-user  46112 Jan 17 22:00 IO.o
-rw-rw-r-- 1 ec2-user ec2-user  56704 Jan 17 22:00 Source.o
-rw-rw-r-- 1 ec2-user ec2-user  72008 Jan 17 21:59 Data.o
-rw-rw-r-- 1 ec2-user ec2-user  18256 Jan 17 21:59 Time.o
-rw-rw-r-- 1 ec2-user ec2-user  27200 Jan 17 21:57 Dispatch.o

i tried doing this and setting a breakpoint on fatalError, which did not reveal anything in swiftc.

$ /usr/bin/lldb /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swiftc -- -v -output-file-map src/swift/CMakeFiles/swiftDispatch.dir/Release/output-file-map.json -incremental -j 12 -emit-library -o libswiftDispatch.so -module-name Dispatch -module-link-name swiftDispatch -emit-module -emit-module-path src/swift/swift/Dispatch.swiftmodule -emit-dependencies -DswiftDispatch_EXPORTS -module-cache-path "/swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/module-cache" -O -Xcc -fblocks -Xcc -fmodule-map-file=/swift/swift-project/swift-corelibs-libdispatch/dispatch/module.modulemap -Xcc -I/swift/swift-project/swift-corelibs-libdispatch -Xcc -I/swift/swift-project/swift-corelibs-libdispatch/src/swift/shims -vfsoverlay /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/dispatch-vfs-overlay.yaml -I /swift/swift-project/swift-corelibs-libdispatch/src/BlocksRuntime -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64 -I /swift/swift-project/swift-corelibs-libdispatch -I /swift/swift-project/swift-corelibs-libdispatch/src -I /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src /swift/swift-project/swift-corelibs-libdispatch/src/swift/Block.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Data.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Dispatch.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/IO.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Private.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Queue.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Source.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Time.swift /swift/swift-project/swift-corelibs-libdispatch/src/swift/Wrapper.swift -no-toolchain-stdlib-rpath -Xlinker -soname -Xlinker libswiftDispatch.so  -L /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64/src/swift  -L /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64  -L /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64   -L /usr/lib/gcc/x86_64-amazon-linux/11 -Xlinker -rpath -Xlinker /swift/swift-project/build/Ninja-ReleaseAssert/libdispatch-linux-x86_64:  src/swift/libDispatchStubs.a  libdispatch.so  libBlocksRuntime.so  -lstdc++  -lm  -lgcc_s  -lgcc  -lc  -lgcc_s  -lgcc
(lldb) b fatalError
Breakpoint 1: no locations (pending).
WARNING:  Unable to resolve breakpoint to any actual locations.
(lldb) r
Process 96 launched: '/swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swiftc' (x86_64)
1 location added to breakpoint 1
Swift version 5.11-dev (LLVM 497a64a78b2fba6, Swift 0bbcae4e9278768)
Target: x86_64-unknown-linux-gnu
Process 96 exited with status = -1 (0xffffffff) lost connection
(lldb) breakpoint list
Current breakpoints:
1: name = 'fatalError', locations = 1, resolved = 1, hit count = 0
  1.1: where = libswiftCore.so`swift::fatalError(unsigned int, char const*, ...), address = 0x00007ffff76bb390, resolved, hit count = 0 

(lldb) 

either i did not set the breakpoint correctly, or swiftc is merely parroting a fatalError printed by swift-driver.

That's good, that means swift-frontend is unlikely to be the issue as we originally suspected.

Likely the latter, I have not previously looked into exactly which process launches the swift-frontend process, swiftc or swift-driver, but it probably is the latter. Given the early swift-driver flakiness you already reported, it is probably the point of failure. Unfortunately, that is currently tough to debug, as the verbose output does not list the swift-driver invocation it is using.

Try this: run the exact swiftc command spit out by CMake but add the flags -v -disallow-use-new-driver. That invokes the legacy Driver written in C++, so if that works, you know where the problem is.

You can then avoid the early swift-driver altogether by passing --skip-early-swift-driver to build-script, after deleting the one you already built, rm /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift-driver.

ha, i can confirm this fixes the issue; manually running the swiftc command with that option succeeds. :sweat_smile:

unfortunately, i can’t seem to disable the swift driver when building the toolchain using build-script, even when i deleted the one i compiled and adding --skip-early-swift-driver. the exact steps i did were:

$ rm /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift-driver
$ ls /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/
complete-test		 swift-ast-script		 swift-llvm-opt
lldb-moduleimport-test	 swift-autolink-extract		 swift-parse-test
lldb-with-tools		 swift-backtrace-linux-x86_64	 swift-plugin-server
sil-func-extractor	 swift-cache-tool		 swift-refactor
sil-llvm-gen		 swift-compatibility-symbols	 swift-reflection-dump
sil-nm			 swift-def-to-strings-converter  swift-reflection-test-LINUX
sil-opt			 swift-demangle			 swift-reflection-test-linux-x86_64
sil-passpipeline-dumper  swift-demangle-yamldump	 swift-remoteast-test
sourcekitd-repl		 swift-dependency-tool		 swift-scan-test
sourcekitd-test		 swift-frontend			 swift-serialize-diagnostics
swift			 swift-help			 swift-symbolgraph-extract
swift-api-digester	 swift-ide-test			 swiftc
swift-api-dump.py	 swift-indent			 swiftc-legacy-driver
swift-api-extract	 swift-legacy-driver
$ utils/build-script --release --assertions -T --xctest --skip-test-swift --skip-early-swift-driver --reconfigure

despite the --skip-early-swift-driver option, the build fails with the same fatalError as before, and moreover, the swift-driver binary reappears in swift-linux-x86_64/bin/.

1 Like

:sparkler:

You may need a --reconfigure passed to build-script too. If that doesn't work, try deleting the compiler frontend build, rm -rf /swift/swift-project/build/Ninja-ReleaseAssert/swift-linux-x86_64/.

1 Like

restarting the build from scratch worked for me :+1: thanks!

i guess the next step for me is to actually get an installable toolchain packaged. i tried naïvely adding --skip-early-swift-driver to --preset buildbot_linux, but that doesn’t seem to parse. is there a way to override this setting while still getting something similar to the downloadable toolchains on swift.org?

Great.

I thought that should work, if you place the additional flag after the preset flag. If it doesn't, you can always modify the preset itself.

after much trial and error, i was finally able to build a plausible toolchain using the following custom preset:

[preset: buildbot_linux_amazon_linux_2023]
mixin-preset=buildbot_linux
skip-early-swift-driver
skip-test-swift
skip-test-lldb
skip-test-swift-driver
skip-test-swiftpm

$ utils/build-script \
--preset buildbot_linux_amazon_linux_2023 \
install_destdir=/swift/ec2-user/swift-install \
installable_package=/swift/ec2-user/swift-DEVELOPMENT-SNAPSHOT-$(date +'%F')-a.tar.gz

most of the tests had to be disabled because they don’t particularly like that swift-driver is missing, so i guess only time will tell if this toolchain will actually be usable in production.

as a smoke test, i tried installing this toolchain and compiling the swift-nio project, which worked fine.

$ sudo rm -r /opt/swift/
$ sudo cp -r ../../ec2-user/swift-install/usr/bin/* /usr/bin
$ sudo cp -r ../../ec2-user/swift-install/usr/include/* /usr/include/
$ sudo cp -r ../../ec2-user/swift-install/usr/libexec/* /usr/libexec/
$ sudo cp -r ../../ec2-user/swift-install/usr/local/* /usr/local 
$ sudo cp -r ../../ec2-user/swift-install/usr/share/* /usr/share
$ source ~/.bashrc

$ swift --version
Swift version 5.11-dev (LLVM beb97e1115a1901, Swift ec7a7c6a966fbc9)
Target: x86_64-unknown-linux-gnu
$ git clone https://github.com/apple/swift-nio
$ swift build

thank you @Finagolfin for all your help!

1 Like

I don't think that's the reason, as the compiler simply uses the legacy Driver written in C++ instead. What failed for those other three repos whose tests you disabled, other than the single Reflection test in the compiler validation suite before? And that's not "most of the tests," it looks like the corelibs and all other tests must have passed for you.

There's a guy from Amazon working on an official toolchain, @sebsto, you should talk to him about getting ALI2023 in as an official platform.

Glad to hear it is working. You should try building it again with this toolchain and see if the early swift-driver crashes recur.