Archive hangs with IL2CPP unless -O0 optimization setting is used

Using the IL2CPP settings with the standard -Os optimisation setting for Release builds causes XCode to hang while it’s generating an Archive. The only solution to this has been to modify the optimisation setting to -O0.

However, the build size then bloats 50%, from 40MB to 56MB.

We have built other projects using IL2CPP and keeping the optimisation at -Os, so I’m wondering if there is anyway to determine what code may be causing the hang / dead loop?

Unlike other projects we have built, this game uses tk2d. I’ve written to Tk2D and they confirm they have no known issues with IL2CPP support.

The problem was to do with a large Dictionary object containing over 7000 Vector objects, defined in code.

The resulting CPP code generated by IL2CPP is about 50,000 lines, causes XCode to hang when it attempts to optimise the code with -Os. (code generated via Mono has no such problems in XCode).

To add insult to injury, the offending script is no longer used. A reminder to always delete unused scripts, as Unity will always compile them.