iPhone compile for thumb
Asked Answered
E

4

8

I've heard it might be a good idea to turn off "compile for thumb" in an iPhone target's settings to increase performance. I'm having some trouble finding this setting though. Since I couldn't find it in my current project, I decided to make a new one (where I could find and set it), and copy my files over to it (and also update all libs I'm using at the same time).

But now it seems like this setting has disapperad from this new project also. No matter what SDK I choose, simulator or device, the setting will not show up in the target settings! I do seem however to still have a variable called GCC_THUMB_SUPPORT under the category "User-defined" all of the sudden. What is this?

I tried making a new target, but the setting will not show up in that either (not even GCC_THUMB_SUPPORT).

Electroencephalograph answered 22/9, 2009 at 14:19 Comment(0)
G
14

GCC_THUMB_SUPPORT is the right variable. Just set it to NO to disable THUMB code generation.
A general rule of THUMB is, to disable it if your code is floating point heavy :)
More about that here.

Update:
The advice to compile for the THUMB instruction set is no longer valid (actually since the iPhone 3GS).

Giamo answered 22/9, 2009 at 14:23 Comment(3)
Is this still relevant as of iPhone 4, 4g & 5?Gman
@weichsel how about clang? Which is used in xcode now... is the thumb mode thing still relevant?Reassure
The above flag is almost irrelevant since the iPhone 3GS :) I updated my original answer with a link to a good SO thread related to Thumb/ARM compilation.Giamo
L
3

I've found that the compiler settings ("GCC 4.2 - Code Generation", "GCC 4.2 - Language", etc) only show up in the Target info build settings window when the Active SDK is set to Device -- and the "User-defined" category only shows up when the Active SDK is Simulator.

And yes, disabling Thumb compilation can be a big help to performance if you're dealing with lots of floating point math (e.g. floating-point audio processing). Though it's not, of course, an all-purpose magical speed-up (and supposedly Thumb-compiled code can run faster in some situations), so you'll probably only find disabling Thumb useful if your code has that kind of bottleneck.

Leverick answered 2/11, 2009 at 10:3 Comment(0)
E
2

"Compile for Thumb" should be under Target/Get Info/GCC 4.2 - Code Generation. If it's not there (I'd be surprised if it's not), set the user-defined variable.

Keep in mind that this improves performance only under a narrow set of circumstances that you should understand before fiddling with it.

Ebba answered 22/9, 2009 at 16:32 Comment(0)
I
2

The standard instruction set for ARM is 4-bytes. Using "Compile for Thumb", the compiler is able to use 2-byte instructions. This results in a much smaller library, but also a slower one (somewhat debatable). More critically, there are issues with running under ARMv6. In our case, we could not generate stable output from Monotouch (fix in MT4.0 alpha). In Xcode, you can find the setting by clicking on your Target, and looking under Build and searching for "thumb". Mine is under GCC 4.2 - Code Generation, but sometimes it is under LVVM GCC 4.2.

Compile for Thumb

Incommunicative answered 20/3, 2011 at 22:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.