On Apple platforms, we generate .apple_names, .apple_types, .apple_namespaces and .apple_objc Apple accelerator tables for DWARF 4 and earlier. For DWARF 5, I would expect us to generate .debug_names, but instead we get no accelerator tables at all.
In the backend we are correctly determining that we should be emitting .debug_names instead of .apple_names. However, when we get to the point of emitting the section, CU debug name table kind is not "default" are skipped. This property is controlled by the -gpubnames argument. Indeed, passing -gdwarf-5 -gpubnames does generate .debug_names section, on all platforms.
On Apple platforms, the .debug_names section should be emitted by default. There's a few ways to address this issue:
- We could always pass -gpubnames to CC1 for MachO. My concerns with this approach that it's lossy in the sense that you can't tell if -gpubnames was passed explicitly or because we're targeting an Apple platform. If you are not emitting apple accelerator tables or debug names this will results in an actual pubnames section, which we don't want.
- We could pass a new flag -gapplenames to CC1 and set DebugNameTableKind to Default. There are a few places that assume that DebugNameTableKind::Default == pubnames but I don't think that assumption actually hurts.
- We could pass a new flag -gapplenames to CC1 and set DebugNameTableKind to Apple. That way we know that the CU was compiled with the intent of always emitting accelerator tables. For dwarf 4 and earlier, that means Apple accelerator tables. For dwarf 5 and later, that means .debug names.
The third approach seemed the most principled and is what this patch implements, but I'm happy to discuss alternatives.
I thought -gapplenames went away?