有没有一种方法来编译ARM而不是Xcode 4中的Thumb? [英] Is there a way to compile for ARM rather than Thumb in Xcode 4?

查看:491
本文介绍了有没有一种方法来编译ARM而不是Xcode 4中的Thumb?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果有许多浮点运算,苹果建议编译ARM而不是thumb。我的整个应用程序几乎是一个大的浮点操作。



这是他们在iOS应用程式开发工作流程指南中说的:


iOS器件支持两个指令集,ARM和Thumb。 Xcode默认使用
Thumb指令,因为使用Thumb通常将
代码大小相对于ARM减少约35%。具有
广泛浮点代码的应用程序如果使用ARM
指令而不是Thumb,可能表现更好。您可以关闭
应用程序的Thumb,因此通过将Thumb
构建设置的编译设置为No,可以编译ARM。


但是,我在我的构建设置中找不到任何Compile for Thumb设置。他们重命名了吗?或者这是不是现在与Xcode 4?

解决方案

首先,建议不编译Thumb指令集,浮点性能只真的适用于旧的ARMv6设备。



ARMv7硬件(iPhone 3G S及更高版本,包括所有iPad)使用更高效的Thumb-2指令集,不会遭受同样的浮点减速。对于ARMv7构建,建议在为Thumb构建的几乎所有情况下。我在我的回答(从4.2.1,从我听到的),其中浮点计算编译错误在Thumb下为ARMv6的错误。如果您使用的是特定版本的Xcode,您需要这样做才能在旧设备上正常运行。


Apple is recommending to compiling for ARM rather than thumb if there are many floating point operations going on. My whole app is almost one big floating point operation.

Here's what they say in the iOS App Development Workflow Guide:

iOS devices support two instruction sets, ARM and Thumb. Xcode uses Thumb instructions by default because using Thumb typically reduces code size by about 35 percent relative to ARM. Applications that have extensive floating-point code might perform better if they use ARM instructions rather than Thumb. You can turn off Thumb for your application, so it compiles for ARM, by setting the Compile for Thumb build setting to No.

However, I cannot find any "Compile for Thumb" setting in my build settings. Did they rename it? Or is this unavailable now with Xcode 4?

解决方案

First, the advice to not compile for the Thumb instruction set in order to improve floating point performance only really applies to the old ARMv6 devices.

ARMv7 hardware (iPhone 3G S and newer, including all iPads) uses the more efficient Thumb-2 instruction set, which does not suffer the same sort of floating point slowdowns. For ARMv7 builds, it is recommended in almost all cases that you build for Thumb. I provide a little more detail about this in my answer here.

This might be why this compiler setting is no longer exposed as a common option, because ARMv7 devices are the vast majority of iOS devices out there.

If you want to do this for just your ARMv6 builds, you can go to your build settings and mouse over the "Other C Flags" option. Click on the little plus button that appears to the right of this option and add a condition for the ARMv6 architecture. Do this again to create one for the ARMv7 architecture. Under the ARMv6 architecture, add the extra compiler flag of -mno-thumb (as Kevin suggests).

You should end up with something that looks like the following:

I do this in one of my applications, because I did see a performance boost on the older ARMv6 devices with that. However, another of my applications was slower when not building for Thumb on ARMv6, so you'll want to profile this first.

Additionally, there is currently a bug in the LLVM Compiler 3.0 that ships with Xcode 4.2 (which has since been fixed in 4.2.1, from what I hear) where floating point calculations are compiled wrong under Thumb for ARMv6. If you're using that particular version of Xcode, you'll need to do this for proper behavior on the older devices.

这篇关于有没有一种方法来编译ARM而不是Xcode 4中的Thumb?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆