【问题标题】:Apple's gcc, what's the difference between -arch i386 and -m32?苹果的gcc,-arch i386和-m32有什么区别?
【发布时间】:2010-12-17 18:55:54
【问题描述】:

根据Apple's gcc 4.2.1 doc

-拱拱
为指定目标编译 建筑拱门。允许的 值为“i386”、“x86_64”、“ppc”和 'ppc64'。多个选项有效,并且 指导编译器产生 “通用”二进制文件,包括对象 指定的每个架构的代码 与 -arch。此选项仅在以下情况下有效 汇编器和库可用 对于每个指定的架构。 (仅限苹果)

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

gcc -arch i386 program.c

gcc -m32 program.c

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

【问题讨论】:

    标签: macos gcc 32-bit


    【解决方案1】:

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

    我想唯一真正的区别是-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
    

    【讨论】:

      猜你喜欢
      • 2017-09-22
      • 2012-05-07
      • 2015-08-09
      • 1970-01-01
      • 2011-04-17
      • 1970-01-01
      • 1970-01-01
      • 2010-10-14
      相关资源
      最近更新 更多