交叉编译和直接在目标上编译时所需的GCC arm选项之间的区别? 我创建了一个C++应用程序,想为Debian Jesie 8的一个CuBeeBoad板ARM®皮质的Abbian目标编译它。™-A7双核。 -cat/proc/cpuinfo提供:

交叉编译和直接在目标上编译时所需的GCC arm选项之间的区别? 我创建了一个C++应用程序,想为Debian Jesie 8的一个CuBeeBoad板ARM®皮质的Abbian目标编译它。™-A7双核。 -cat/proc/cpuinfo提供:,c++,arm,g++,cross-compiling,C++,Arm,G++,Cross Compiling,以及-dpkg-print体系结构 我得出结论,我需要的交叉编译相关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 如果我想直接在板上构建同一个源代码,那么

以及-dpkg-print体系结构

我得出结论,我需要的交叉编译相关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(如果支持足够)还是我也需要上面的任何标志?

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

这是我的板Pine64-Cortex A53的输出,带有Linux 64位:

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]

谢谢你的回答。只有一个问题。当targer板上有一个编译时,仅使用g++或g++-march=native或具有相同效果的有什么区别吗?原则上是的,但是,GCC网站说:-march=native会使编译器自动检测构建计算机的体系结构。目前,此功能仅在GNU/Linux上受支持,并不是所有体系结构都得到认可。如果自动检测失败,则该选项无效。有没有办法通过命令或消息来确定自动检测是否失败?据我所知,没有什么可以告诉你的。但是,如果您使用-g标志编译,那么您可以使用字符串来获取标志,但我不是100%这样做的,它在我的板上工作$string您的_binary | grep=但我不确定这是否只是使用的命令。
--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 
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]