在 Xcode 中编译 i386 与 x86_64 之间的差异?

发布于 2024-09-09 12:25:38 字数 299 浏览 1 评论 0原文

在 Xcode 中将 Active Architecture 设置为 i386 与 x86_64(在主窗口左上角的下拉列表中选择)编译 Mac 应用程序之间有什么区别?在项目的“构建”设置中,“架构”选项为“标准”(32/64 位通用)、“32 位通用”和“64 位 Intel”。实际上,这些意味着什么以及如何决定?

假设目标是 OS X 10.5 及更高版本。我在活动监视器中看到,针对 x86_64 进行编译会导致应用程序使用比针对 i386 编译的应用程序更多的内存。优点是什么?我知道 64 位是“未来”,但考虑到更高的内存使用量,选择 32 位是否有意义?

What are the differences between compiling a Mac app in Xcode with the Active Architecture set to i386 vs x86_64 (chosen in the drop down at the top left of the main window)? In the Build settings for the project, the Architecture options are Standard (32/64-bit Universal), 32-bit Universal, and 64-bit Intel. Practically, what do these mean and how does one decide?

Assume one is targeting OS X 10.5 and above. I see in the Activity Monitor that compiling for x86_64 results in an app that uses more memory than one compiled for i386. What is the advantage? I know 64-bit is "the future", but given the higher memory usage, would it make sense to choose 32-bit ever?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

愿与i 2024-09-16 12:25:43

除非您有理由针对 x86_64 进行编译,否则我建议您只针对 i386 进行编译(如果您支持的话,还可以针对 PPC 进行编译)。阅读 苹果对此事的立场

尽管 64 位可执行文件可以
让您更轻松地管理大数据
集(与内存映射相比
32 位应用程序中的大文件),
使用 64 位可执行文件可能
提出其他问题。因此你
应该将您的软件转换为
仅当 64 位可执行格式
64 位环境提供了引人注目的
为您的特定目的提供优势。

Unless you have a reason to compile for x86_64, I recommend just compiling for i386 (and PPC if you support that). Read Apple's stance on the matter:

Although 64-bit executables make it
easier for you to manage large data
sets (compared to memory mapping of
large files in a 32-bit application),
the use of 64-bit executables may
raise other issues. Therefore you
should transition your software to a
64-bit executable format only when the
64-bit environment offers a compelling
advantage for your specific purposes.

冷情 2024-09-16 12:25:41

iOS 应用程序需要在许多不同的体系结构上运行:

arm7: Used in the oldest iOS 7-supporting devices[32 bit]
arm7s: As used in iPhone 5 and 5C[32 bit]
arm64: For the 64-bit ARM processor in iPhone 5S[64 bit]

i386: For the 32-bit simulator
x86_64: Used in 64-bit simulator

Xcode 基本上根据有效体系结构中设置的内容模拟 32 位或 64 位环境 - 分别为 i386 或 x86_64

每个体系结构都需要不同的二进制文件,当您构建应用程序时 Xcode 会为您当前正在使用的任何内容构建正确的架构。例如,如果您要求它在模拟器中运行,那么它只会构建 i386 版本(或 64 位的 x86_64)。

iOS apps need to run on many different architectures:

arm7: Used in the oldest iOS 7-supporting devices[32 bit]
arm7s: As used in iPhone 5 and 5C[32 bit]
arm64: For the 64-bit ARM processor in iPhone 5S[64 bit]

i386: For the 32-bit simulator
x86_64: Used in 64-bit simulator

Xcode basically emulates the environment of 32 bit or 64 bit based on what is set in the Valid Architecture - i386 or x86_64 respectively

Every architecture requires a different binary, and when you build an app Xcode will build the correct architecture for whatever you’re currently working with. For instance, if you’ve asked it to run in the simulator, then it’ll only build the i386 version (or x86_64 for 64-bit).

埋情葬爱 2024-09-16 12:25:40

32/64 位通用 - i386、x86_64、ppc

32 位通用 - i386、ppc

64 位 Intel -

不再支持仅 64 位 Intel ppc64。


由于多种原因,x86_64 二进制文件速度更快;更快的 ABI、更多的寄存器,在许多(大多数和所有新机器)机器上,内核都是 64 位和 64 位。内核调用速度更快,等等...

虽然 64 位有一些内存开销,通常与应用程序数据结构的指针重量直接相关,但请记住,32 位应用程序会拖入 32 位版本所有框架。如果您的应用程序是系统上唯一的 32 位应用程序,那么与 64 位版本相比,它将产生大量的开销。

64 位应用程序还可以享受最新、最好的 Objective-C ABI;合成的 ivars、非脆弱的 ivars、统一的 C++/ObjC 异常、零成本 @try 块等...还有许多优化也只能在 64 位中实现。

32/64-bit Universal -- i386, x86_64, ppc

32-bit Universal -- i386, ppc

64-bit Intel -- 64 bit Intel only

ppc64 is no longer supported.


x86_64 binaries are faster for a number of reasons; faster ABI, more registers, on many (most & all new machines) machines the kernel is 64 bit & kernel calls are faster, etc.etc.etc...

While 64 bit has a bit of memory overhead directly related, generally, to how pointer heavy your app's data structures are, keep in mind that 32 bit applications drag in the 32 bit versions of all frameworks. If yours is the only 32 bit app on the system, it is going to incur a massive amount of overhead compare to the 64 bit version.

64 bit apps also enjoy the latest and greatest Objective-C ABI; synthesized ivars, non-fragile ivars, unified C++/ObjC exceptions, zero-cost @try blocks etc... and there are a number of optimizations that are only possible in 64 bit, too.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文