ld warning: too many personality routines for comp

2020-02-10 15:14发布

问题:

The linker for an iOS simulator target I have is reporting the following warning:

ld: warning: too many personality routines for compact unwind to encode

No line number is given, nor anything else that is actionable. Googling turned up some Apple open source code, but I'm not groking it.

What does it mean and what can I do to address it?

回答1:

I found some information in the C++ ABI for Itanium docs that sheds some light on what this means.

The personality routine is the function in the C++ (or other language) runtime library which serves as an interface between the system unwind library and language-specific exception handling semantics.

Extrapolating, this warning indicates that you've got too many kinds of exception handling in the same binary, and at least one of them may fail. Indeed this is exactly what is observed in this question.

Sadly, there's no clear way to fix this, only workarounds. You can suppress the warning, remove code, rewrite code in a different language, disable a language's exception handing and possibly others.



回答2:

If you have a crash on exception with this warning, i.e. ::terminate() call on every throw, the workaround is to use old dwarf exception-handling tables. Add following flags to Build Settings/Linking/Other Linker Flags:

-Wl,-keep_dwarf_unwind -Wl,-no_compact_unwind


回答3:

You can try silencing the warning with -Wl,-no_compact_unwind for the Other Linker Flags setting. I think it's harmless.



回答4:

I bumped into this issue as well when trying to run on the iOS simulator while my code was running correctly on the device. In my case, it was not a warning but a linker error.

Luckily, i remembered that I added two flags for luajit to run correctly following the instructions of this page under the section Embedding LuaJIT:

-pagezero_size 10000 -image_base 100000000

My guess is that the image_base address is simply out of bounds on the host CPU.

Anyway, removing these settings made it work in my configuration.

So go to your project's settings and look for any hard wired values of this kind if not the same.

Hope this helps,

M