【问题标题】:Difference between GCC arm options necessary when cross-compiling and when compiling directly on target?交叉编译和直接在目标上编译时所需的 GCC arm 选项之间的区别?
【发布时间】:2018-02-01 13:07:55
【问题描述】:

我已经创建了一个 c++ 应用程序,并希望为 cubietruck 板(ARM® Cortex™-A7 双核)的 debian jessie 8.0 armbian 目标编译它。 - cat /proc/cpuinfo 给出:

Processor       : ARMv7 Processor rev 4 (v7l)
processor       : 0
BogoMIPS        : 956.30

processor       : 1
BogoMIPS        : 959.75

Features        : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 4

Hardware        : sun7i
Revision        : 0000
Serial          : 1651668805c0e142
Chipid          : 16516688-80515475-52574848-05c0e142

还有- dpkg --print-architecture

armhf

我得出的结论是我需要的交叉编译的相关arm gcc选项是:

--with-abi=aapcs-linux  (-mabi)
--with-cpu=cortex-a7  (-mcpu)
--with-tune=cortex-a7 (-mtune)
--with-mode=arm/thumb  (-marm  -mthumb)
--with-fpu=neon-vfpv4  (-mfpu)
--with-float=hard 

如果我想直接在船上构建相同的源代码,-march=native(如果支持)选项是否足够,或者我是否还需要上述任何标志?

【问题讨论】:

    标签: c++ arm g++ cross-compiling


    【解决方案1】:

    要查找-march=native 激活的标志,请使用gcc -march=native -Q --help=target。

    这是我板上的输出(Pine64 - Cortex A53 with Linux 64 bits):

    debian@pine64:~$ gcc -march=native -Q --help=target
    The following options are target specific:
        -mabi=ABI                           lp64
        -march=ARCH                         native
        -mbig-endian                        [disabled]
        -mbionic                            [disabled]
        -mcmodel=                           small
        -mcpu=CPU                           
        -mfix-cortex-a53-835769             [enabled]
        -mgeneral-regs-only                 [disabled]
        -mglibc                             [enabled]
        -mlittle-endian                     [enabled]
        -mlra                               [enabled]
        -momit-leaf-frame-pointer           [enabled]
        -mstrict-align                      [disabled]
        -mtls-dialect=                      desc
        -mtune=CPU                          
        -muclibc                            [disabled]
        ....
        [Omitted output]
    

    【讨论】:

    • 感谢您的回答。就一个问题。当在目标板上编译时,仅使用 g++ 或使用 g++ -march=native 编译或具有相同的效果有什么区别?
    • 原则上是的,但是,GCC 网站说:-march=native 导致编译器自动检测构建计算机的体系结构。目前,该功能仅在 GNU/Linux 上支持,并非所有架构都被认可。如果自动检测不成功,则该选项无效。 gcc.gnu.org/onlinedocs/gcc/ARM-Options.html
    • 有没有办法(命令或消息)找出自动检测是否失败?
    • 据我所知,没有什么可以告诉你的。但是,如果您使用 -g 标志进行编译,那么您可以使用 strings 来获取标志,但我不是 100% 的,它在我的板上工作。 $strings your_binary | grep = 但我不确定这是否只是使用的命令。
    猜你喜欢
    • 2020-02-05
    • 1970-01-01
    • 2011-08-20
    • 1970-01-01
    • 1970-01-01
    • 2016-02-05
    • 1970-01-01
    • 2014-09-26
    • 1970-01-01
    相关资源
    最近更新 更多