branch out of range compile error

2019-07-20 13:42发布

问题:

I get the following compile errors when compiling to the device. (When compiling to simulator everything is OK)

/var/folders/3B/3BAjD+ANHHmfh-eIWrtXDU+++TI/-Tmp-/cc-hojnUD.s:1784380:branch out of range /var/folders/3B/3BAjD+ANHHmfh-eIWrtXDU+++TI/-Tmp-/cc-hojnUD.s:1784372:branch out of range /var/folders/3B/3BAjD+ANHHmfh-eIWrtXDU+++TI/-Tmp-/cc-hojnUD.s:1784364:branch out of range /var/folders/3B/3BAjD+ANHHmfh-eIWrtXDU+++TI/-Tmp-/cc-hojnUD.s:1784356:branch out of range

In various places I read something about turning off "Thumb". I don't really know if this would resolve the issue since I can't find this compile option anywhere.

I have some pretty large init files (with more than 50k lines) doing nothing else but defining NSMutuable array and stuf like that.

I can't get my app to compile for the iPhone anymore because of this error.

Do you have any idea what I can do about this?

ps. I use Xcode 4.2 with Apple LLVM 3.0 (using ARM, so I can't change the compiler)

Many thanks!

回答1:

(Moved from comment). Is your init file one huge function? If so, it may help to break the function into smaller pieces and have a master function call the pieces in order.



回答2:

This is a known linker bug (rdar://16186742). The problem is with the armv7 compiler, when it needs to synthesize branch islands to jump further than 16 MB, and the jump happens to be exactly 16 MB. The work around is to rearrange the source files in the project build phases and/or libraries in the Link Binary with Libraries section. With a few re-arrangements this problem should go away.