Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS armv7: How to slice a (too) large object prior to linking

Tags:

xcode

ios

ld

I have a particular nasty ld problem: I'm generating a large object file (a "boot image", armv7 only) which is later used by an Xcode project.

The boot-image.o is always created successfuly, no matter how large it is. However, when building the Xcode project, Xcode later fails with:

ld: Unable to insert branch island. No insertion point available. for architecture armv7

A few things to mention at this point:

  • I have no way to influence how this boot image file is generated. Meaning I can't influence to create multiple of these boot images.
  • I have an idea where this error comes from [1]. And it happens when the boot image is around the 16+ MB mark
  • I was looking into using Link time optimization, but was told that for this boot image generator it was no good idea (because the authors of this boot image generator tried that and said LTO proved unreliable)

Considering the above, I think my only option will be to somehow segment my boot-image.o into several objects prior building with Xcode. But how?

[1] http://docs.unity3d.com/412/Documentation/Manual/TroubleShooting.html

like image 400
benjist Avatar asked Oct 21 '25 19:10

benjist


2 Answers

enter image description here

Make sure you have not selected "Any iOS Device" as your build target. select any iOS simulator or a real device then the problem will be fixed.

like image 90
Mehrdad Avatar answered Oct 23 '25 08:10

Mehrdad


We just ran in the same issues in one of our current Unity 3D projects. It really seems to be the only option, to get the size of "too large" .o files down.

You can try the following (helped us a lot):

  1. Strip debug symbols (build options), as debug symbols can increase the .o files a lot. https://developer.apple.com/library/ios/qa/qa1795/_index.html#//apple_ref/doc/uid/DTS40014195-CH1-BUILD_SETTINGS
  2. Split the code in more files (in Unity you can precompile your code in multiple dlls, which will end up in ".o files" during Xcode build phase), may be you can ask the boot image generator developers for splitting their code.
  3. See the following post for more specific hints on optimizing (C# / Unity), don't know if this is applicable for you. http://forum.unity3d.com/threads/unity-ios-linker-error-unable-to-insert-branch-island-no-insertion-point-available.239200/

Depending on the architecture / setup, the limits seem to be 14MB or 30MB. See also here: http://www.opensource.apple.com/source/ld64/ld64-133.3/src/ld/passes/branch_island.cpp http://forum.unity3d.com/threads/unable-to-debug-on-device-ld-unable-to-insert-branch-island.148563/#post-1841860

like image 36
d4Rk Avatar answered Oct 23 '25 09:10

d4Rk