gpt4 book ai didi

macos - Apple 的 gcc,-arch i386 和 -m32 有什么区别?

转载 作者:行者123 更新时间:2023-12-04 02:13:51 24 4
gpt4 key购买 nike

根据 Apple's gcc 4.2.1 doc :

-arch arch
Compile for the specified target architecture arch. The allowable values are 'i386', 'x86_64', 'ppc' and 'ppc64'. Multiple options work, and direct the compiler to produce “universal” binaries including object code for each architecture specified with -arch. This option only works if assembler and libraries are available for each architecture specified. (APPLE ONLY)



那么这两个调用之间有什么区别:

gcc -arch i386 程序.c



gcc -m32 程序.c

难道只是这样 -arch 更强大,因为它更灵活并且在指定多个拱门时可以生成通用二进制文件?

最佳答案

我不确定,但是通过阅读手册页,我得出了与您类似的结论。

我想唯一真正的区别是 -arch可用于创建通用二进制文件。

因为这可以创建通用二进制文件

gcc -arch i386 -arch x86_64 foo.c

但您实际上无法确定以下的语义应该是什么(它们甚至可能是无效的语法)。特别是第三个应该是无效的,因为手册页说为 32 位或 64 位环境生成。
gcc -m32 -arch i386 -arch x86_64 foo.c
gcc -m64 -arch i386 -arch x86_64 foo.c
gcc -m32 -m64 -arch i386 -arch x86_64 foo.c

-m32
-m64
Generate code for a 32-bit or 64-bit environment. The 32-bit environment
sets int, long and pointer to 32 bits and generates code that runs on any
i386 system. The 64-bit environment sets int to 32 bits and long and
pointer to 64 bits and generates code for AMDs x86-64 architecture.
For darwin only the -m64 option turns off the -fno-pic and
-mdynamic-no-pic options.

-arch //already included in question

关于macos - Apple 的 gcc,-arch i386 和 -m32 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1754460/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com