Issues with ninja build and lldb on M1 machine

Hi folks! After finally upgrading to an M1 machine I'm having some issues with the compiler build. After a seemingly successful ninja build (--release-debuginfo --debug-swift), I'm not really able to debug effectively because lldb can't properly load the debug information from the generated object files.

Specifically, trying to set breakpoints results in a deluge of errors:

(lldb) break set -n simplifyKeyPathConstraint
error: libswiftSema.a(BuilderTransform.cpp.o) failed to load objfile for /Users/freddy/Developer/git/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/lib/libswiftSema.a
error: libswiftSema.a(CSApply.cpp.o) failed to load objfile for /Users/freddy/Developer/git/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/lib/libswiftSema.a
error: libswiftSema.a(CSBindings.cpp.o) failed to load objfile for /Users/freddy/Developer/git/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/lib/libswiftSema.a
error: libswiftSema.a(CSClosure.cpp.o) failed to load objfile for /Users/freddy/Developer/git/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/lib/libswiftSema.a
error: libswiftSema.a(CSGen.cpp.o) failed to load objfile for /Users/freddy/Developer/git/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/lib/libswiftSema.a
error: libswiftSema.a(CSRanking.cpp.o) failed to load objfile for /Users/freddy/Developer/git/swift-project/build/Ninja-RelWithDebInfoAssert+swift-DebugAssert/swift-macosx-arm64/lib/libswiftSema.a

for, as far as I can tell, every object file in the library containing the named symbol. I've seen whispers of similar issues with M1 machines online but nothing conclusive, and nothing related to the Swift build specifically. Wondering if I somehow missed a setup step when building the compiler for this machine, or if there's any known issues with the build on M1 that other folks have encountered?

1 Like

Hey Frederick,
I'm also on M1 for sometime now, never seems any issues like that, but since trying new setup having some issues with debug info, but I don't think they are related to what you are seeing.
One question is how are you launching the swift-frontend executable from lldb? I'm using Xcode to launch ninja built executable and everything looks fine.
Also what is the full build script command that you are using? Maybe I can try similar setup and check.

I saw this too debugging with --release-debuginfo. Somehow rebuilding the libraries seemed to have kicked it.

Ok so having thought about it some more I think my case was:

  • I was debugging a dylib that was stale, specifically libsourcekitdInProc.dylib
  • I was making changes to its dependencies and only rebuilding sourcekitd with ninja sourcekitd
  • Its static library dependencies were correctly being rebuilt since sourcekitd depends on them as well, but the dylib itself wasn't being rebuilt

I would need to look at lldb source to understand how it knows that an object file in an archive isn't the one its looking for, since I thought only the paths were encoded in the N_OSO stabs and the object file / archive paths weren't chanaging since I was only changing source. If I'm understanding this case correctly I think lldb could probably have a better error, but it was just user error.