[PATCH] D144999: [RFC][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

Vy Nguyen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 6 12:55:04 PST 2023


oontvoo added a comment.

In D144999#4167531 <https://reviews.llvm.org/D144999#4167531>, @int3 wrote:

> As I understand, ld64's best workaround for this right now is the `-no_compact_unwind` flag. This would be trivial for us to support but of course not ideal from a binary size standpoint. However, from a UX standpoint, "getting an error when you add an additional object to the link" is basically the current situation. I think it is more important for us to prioritize perf + implementation simplicity over a somewhat rare UX edge case...

+1 Agreed that impl simplicity should be prioritized.

> So my proposal is to have a `--prefer-dwarf-unwind` flag. If both compact and DWARF unwind are available in the object file, this flag will tell LLD to prefer DWARF instead of compact unwind. Coupled with the abovementioned change to the assembler, this will get us compact unwind when compiling for "canonical" languages while giving us DWARF unwind for the others, while not requiring us to simultaneously track both encodings in the linker.

I've slept on this a bit and I'm not sure how this flag would preserve performance while ALSO simplify the implementation.

1. If this is set to true, then the linker will end up using only CU  formats for C++ and ObjC, but DWARFs for others. (ie., presumably, this will be set when there are 4+ personalities).
2. If this is false, then the linker will try to use all CUs (and only fallback to DWARF when CU is not present).

So in other words for case #1, we'd end up with one "unused" CU slot. (Because, if I understand it correctly, you're proposing this flag to avoid the complexity of deciding which personality gets the free slot).

But now that you've seen the full picture, I wonder if we could take a step back and re-consider the original proposal (maybe with some modification):
MC changes:

- For the two ObjC and C++ personalities, always emits compact-unwinds (unless DWARF is explicitly required)
- For the rest, always emit DWARF (unless compact-unwinds is explicitly required, maybe via something new flag that's default to off)

Linker changes:

- For the two ObjC and C++ personalities, always assume CUs (unless it's not present then fallback to dwarf - this is not a change in behaviour)
- For the rest, always use DWARF (unless CU is requested for a specific personality specified via a new flag).

Would this be a bit simpler?

Pros:

- We don't increase too much binary size (ie., compared to the proposal where we emits both CUs and DWARF)
- Can still preserve the performance when possible

Cons:

- Need two new flags (1 in the assembler and 1 in the linker)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144999/new/

https://reviews.llvm.org/D144999



More information about the llvm-commits mailing list