iosxcodeclangdebug-symbolsmach-o

No DWARF in a Xcode debug build with debug type set to DWARF


Xcode 14.2, iOS Objective C project. I chose debug info format to be DWARF (not "DWARF with dSYM"), rebuilt. In the debug-iossimulator product bundle, there is an executable. The mod time is consistent with having been built just now. I then checked its contents with two different MachO file viewers - there are no DWARF sections (except __eh_frame, not properly DWARF).

Where do debug symbols go in this scenario?

There is no dSYM bundle that I can see.

EDIT: same on a dummy, MacOS X command line tool type project.

EDIT: the object file in the intermediates directory contains the DWARF sections. The link command goes:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-target x86_64-apple-macos12.7
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.1.sdk
-L/Users/valekseyev/Library/Developer/Xcode/DerivedData/beoo-cbiftetyqjqijjajruzsycuxxduj/Build/Intermediates.noindex/EagerLinkingTBDs
-L/Users/valekseyev/Library/Developer/Xcode/DerivedData/beoo-cbiftetyqjqijjajruzsycuxxduj/Build/Products/Debug
-F/Users/valekseyev/Library/Developer/Xcode/DerivedData/beoo-cbiftetyqjqijjajruzsycuxxduj/Build/Intermediates.noindex/EagerLinkingTBDs
-F/Users/valekseyev/Library/Developer/Xcode/DerivedData/beoo-cbiftetyqjqijjajruzsycuxxduj/Build/Products/Debug
-filelist /Users/valekseyev/Library/Developer/Xcode/DerivedData/beoo-cbiftetyqjqijjajruzsycuxxduj/Build/Intermediates.noindex/beoo.build/Debug/beoo.build/Objects-normal/x86_64/beoo.LinkFileList
-Xlinker -object_path_lto
-Xlinker /Users/valekseyev/Library/Developer/Xcode/DerivedData/beoo-cbiftetyqjqijjajruzsycuxxduj/Build/Intermediates.noindex/beoo.build/Debug/beoo.build/Objects-normal/x86_64/beoo_lto.o
-Xlinker -export_dynamic
-Xlinker -no_deduplicate
-Xlinker -no_adhoc_codesign
-Xlinker -dependency_info
-Xlinker /Users/valekseyev/Library/Developer/Xcode/DerivedData/beoo-cbiftetyqjqijjajruzsycuxxduj/Build/Intermediates.noindex/beoo.build/Debug/beoo.build/Objects-normal/x86_64/beoo_dependency_info.dat
-o /Users/valekseyev/Library/Developer/Xcode/DerivedData/beoo-cbiftetyqjqijjajruzsycuxxduj/Build/Products/Debug/beoo

Solution

  • the object file in the intermediates directory contains the DWARF sections. The link command goes

    There DWARF information still exists. Only that it's not packaged into a dSYM. That's expected if you set the debug format to DWARF and not DWARF with dSYM. As you mentioned it's in the object files.

    It's because extracting a dSYM (which is done using dsymutil) takes time. During a repetitive process of building you don't want to constantly be extracting a dSYM. Because any change will require a new dSYM, which means more longer build times...

    You only want dSYM from RELEASE builds because otherwise if you didn't strip out your debug symbols then it results in a significant size increase in the final product...

    For more information see this other answer


    More specifically, the references to the object files where DWARF can be found reside in the __LINKEDIT segment of the built binary. You can see them with the dsymutil --symtab <binary> command on a Mac - the N_OSO lines are object file references.