Debug Swift Build fails

No matter what I try, this comand always fails with:

FAILED: SwiftCompilerSources/Basic.o /home/xaver/swiftDevelopment/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-linux-x86_64/SwiftCompilerSources/Basic.o
cd /home/xaver/swiftDevelopment/swift/SwiftCompilerSources && /usr/bin/swiftc -c -o /home/xaver/swiftDevelopment/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-linux-x86_64/SwiftCompilerSources/Basic.o -I /usr/bin/../lib -I /usr/lib -target x86_64-unknown-linux-gnu -module-name Basic -emit-module -emit-module-path /home/xaver/swiftDevelopment/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-linux-x86_64/SwiftCompilerSources/Basic.swiftmodule -parse-as-library /home/xaver/swiftDevelopment/swift/SwiftCompilerSources/Sources/Basic/SourceLoc.swift /home/xaver/swiftDevelopment/swift/SwiftCompilerSources/Sources/Basic/StringParser.swift /home/xaver/swiftDevelopment/swift/SwiftCompilerSources/Sources/Basic/Utils.swift -wmo -color-diagnostics -Xfrontend -validate-tbd-against-ir=none -Xfrontend -disable-target-os-checking -Xcc -std=c++17 -Xcc -DCOMPILED_WITH_SWIFT -Xcc -DSWIFT_TARGET -Xcc -UIBOutlet -Xcc -UIBAction -Xcc -UIBInspectable -cxx-interoperability-mode=default -g -Xcc -UNDEBUG -Xcc -DPURE_BRIDGING_MODE -Xcc -I -Xcc /home/xaver/swiftDevelopment/llvm-project/llvm/include -Xcc -I -Xcc /home/xaver/swiftDevelopment/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/llvm-linux-x86_64/include -Xcc -I -Xcc /home/xaver/swiftDevelopment/llvm-project/clang/include -Xcc -I -Xcc /home/xaver/swiftDevelopment/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/llvm-linux-x86_64/tools/clang/include -Xcc -I -Xcc /home/xaver/swiftDevelopment/swift/include -Xcc -I -Xcc /home/xaver/swiftDevelopment/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-linux-x86_64/SwiftCompilerSources/../include -I /home/xaver/swiftDevelopment/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-linux-x86_64/SwiftCompilerSources
SwiftDriverExecution/MultiJobExecutor.swift:207: Fatal error: multiple producers for output /home/xaver/swiftDevelopment/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-linux-x86_64/SwiftCompilerSources/Basic.o: Wrapping Swift module Basic & Compiling Basic SourceLoc.swift

I am on Ubuntu 23.04. I have installed all the dependencies and swift 5.8.1 is in my path. This is the command:
./utils/build-script --release-debuginfo --debug-swift

This is the complete log:

dump config:

As I understand --debug-swift turns off optimizations in order to debug better.
Any idea how to get it to compile?

23.04 is currently not tested on the official CI and I notice you are running the 22.04 toolchain instead, with that swift-driver crashing when building the Swift portions of the trunk compiler. You could try installing Neil's 23.04 build of the 5.8.1 toolchain instead and see if that makes a difference.

@xavgru do you mind testing if Fix Swift Compiler Modules support in Debug mode by drodriguez · Pull Request #73506 · apple/swift · GitHub works for you? I found the same problem and those changes allow me to get things working. It would be great to have verification by another person in another system.

But I think the best recommendation is not trying to use Debug mode at all and stick with --release-debuginfo and avoid --debug-swift.

I am trying it again with Ubuntu 24.04 and ran into another compile error.
If we offer the option --debug-swift, it should work.
I wanted to turn off optimizations inside swift/lib/Sema in order to debug better.

failing build:

config