GCC soft float ABI接口gcc-arm-Linux-gnueabi/ARMARCH7gnu和gcc-arm-linux-gnueabihf以及ARMARCH7sfgnu

本文介绍了GCC针对ARM架构的软浮点ABI选项,包括'soft'、'softfp'和'hard'模式的含义及用途。在Linux平台上,'gcc-arm-linux-gnueabi'和'gcc-arm-linux-gnueabihf'用于armel和armhf架构,分别对应不同的浮点处理策略。在VxWorks平台中,'ARMARCH7gnu'和'ARMARCH7sfgnu'使用不同的编译选项来处理浮点运算,其中涉及软浮点和硬浮点模式的选择。选择正确的浮点ABI对于程序的性能和兼容性至关重要。
摘要由CSDN通过智能技术生成

In addition, each of these target machine types can have its own special options, starting
with ‘-m’, to choose among various hardware models or configurations—for example, 68010
vs 68020, floating coprocessor or none.

-mfloat-abi=name
Specifies which floating-point ABI to use. Permissible values are: ‘soft’,
‘softfp’ and ‘hard’.
Specifying ‘soft’ causes GCC to generate output containing library calls for
floating-point operations. ‘softfp’ allows the generation of code using hardware
floating-point instructions, but still uses the soft-float calling conventions.
‘hard’ allows generation of floating-point instructions and uses FPU-specific
calling conventions.
The default depends on the specific target configuration. Note that the hardfloat
and soft-float ABIs are not link-compatible; you must compile your entire
program with the same ABI, and link with a compatible set of libraries.
-mhard-float
Equivalent to ‘-mfloat-abi=hard’.
-msoft-float
Equivalent to ‘-mfloat-abi=soft’.
一、Linux平台
gnueabi相关的两个交叉编译器: gnueabi和gnueabihf

gcc-arm-Linux-gnueabi – The GNU C compiler for armel architecture

gcc-arm-linux-gnueabihf – The GNU C compiler for armhf architecture

分别使用gcc-arm-Linux-gnueabi和gcc-arm-linux-gnueabihf

//floatadd.c
float add3f(float a,float b,float c)
{
    float d;
    d=a+b;
    d=d*d/c;
    return d;
}

1.使用arm-linux-gnueabihf-gcc编译,使用“-v”选项以获取更详细的信息:

$ arm-linux-gnueabihf-gcc -v mfloat.c

COLLECT_GCC_OPTIONS=’-v’ ‘-march=armv7-a’ ‘-mfloat-abi=hard’ ‘-mfpu=vfpv3-d16′ ‘-mthumb’

-mfloat-abi=hard,可看出使用hard硬件浮点模式。

  1. 使用arm-linux-gnueabi-gcc编译:

$ arm-linux-gnueabi-gcc -v mfloat.c

COLLECT_GCC_OPTIONS=’-v’ ‘-march=armv7-a’ ‘-mfloat-abi=softfp’ ‘-mfpu=vfpv3-d16′ ‘-mthumb’

-mfloat-abi=softfp,可看出使用softfp模式。

可见这两个交叉编译器适用于armel和armhf两个不同的架构, armel和armhf这两种架构在对待浮点运算采取了不同的策略(有fpu的arm才能支持这两种浮点运算策略)。

其实这两个交叉编译器只不过是gcc的选项-mfloat-abi的默认值不同。 gcc的选项-mfloat-abi有三种值soft,softfp,hard(其中后两者都要求arm里有fpu浮点运算单元,soft与后两者是兼容的,但softfp和hard两种模式互不兼容):

soft: 不用fpu进行浮点计算,即使有fpu浮点运算单元也不用,而是使用软件模式。

softfp : armel架构(对应的编译器为gcc-arm-linux-gnueabi)采用的默认值,用fpu计算,但是传参数用普通寄存器传,这样中断的时候,只需要保存普通寄存器,中断负荷小,但是参数需要转换成浮点的再计算。

hard: armhf架构(对应的编译器gcc-arm-linux-gnueabihf)采用的默认值,用fpu计算,传参数也用fpu中的浮点寄存器传,省去了转换, 性能最好,但是中断负荷高。

二、VxWorks平台
ARMARCH7gnu使用的编译选项是CC_ARCH_SPEC=t7 -mfpu=vfp -mfloat-abi=softfp
ARMARCH7sfgnu使用的编译选项是CC_ARCH_SPEC=t7 -msoft_float=softfp
使用ARMARCH7gnu和ARMARCH7sfgnu 编译floatadd.c的命令行输出。

//floatadd.c
float add3f(float a,float b,float c)
{
    float d;
    d=a+b;
    d=d*d/c;
    return d;
}

platform: Wind River VxWorks 6.9
Command: make –no-print-directory BUILD_SPEC=ARMARCH7sfgnu DEBUG_MODE=1 TRACE=1
Working Directory: C:/LUA/CSRP2/workSpace/SMP/xxxx/ARMARCH7sfgnu
if [ ! -d “dirname "xxxx_partialImage/Debug/Objects/xxxx/floatadd.o"” ]; then mkdir -p “dirname "xxxx_partialImage/Debug/Objects/xxxx/floatadd.o"“; fi;echo “building xxxx_partialImage/Debug/Objects/xxxx/floatadd.o”; ccarm -g -t7 -msoft-float -ansi -fno-zero-initialized-in-bss -Wall -MD -MP -DCPU=_VX_ARMARCH7 -DTOOL_FAMILY=gnu -DTOOL=sfgnu -D_WRS_KERNEL -D_VSB_CONFIG_FILE=\”C:/WindRiver/vxworks-6.9/target/lib/h/config/vsbConfig.h\” -DARMEL -DARMEL -DIP_PORT_VXWORKS=69 -IC:/WindRiver/vxworks-6.9/target/h -IC:/WindRiver/vxworks-6.9/target/h/wrn/coreip -o “xxxx_partialImage/Debug/Objects/xxxx/floatadd.o” -c “C:/LUA/CSRP2/workSpace/SMP/xxxx/floatadd.c”
building xxxx_partialImage/Debug/Objects/xxxx/floatadd.o
if [ ! -d “dirname "xxxx_partialImage/Debug/xxxx_partialImage.o"” ]; then mkdir -p “dirname "xxxx_partialImage/Debug/xxxx_partialImage.o"“; fi

gcc-4.6.4/arm-arm1176jzfssf-linux-gnueabi/include是arm-linux-gcc编译器中的一个目录,用于存放头文件。根据您提供的引用,CROSS_COMPILE?的值是/usr/local/arm/arm-none-linux-gnueabi/bin/arm-none-linux-gnueabi-,这是用于交叉编译的编译器前缀。而arm-linux-gcc编译器的32位版本4.6.4和其他版本的编译器也可以在您的资源中找到。您已经执行了export PATH=/usr/local/arm/arm-none-linux-gnueabi/bin:$PATH命令来设置编译器的路径。因此,gcc-4.6.4/arm-arm1176jzfssf-linux-gnueabi/include目录应该是在编译器安装路径下的一个子目录,用于存放特定版本的头文件。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [【转】飞凌嵌入式(Forlinx)TE/OK6410内核编译:“make: arm-none-linux-gnueabi-gcc:命令未找到”](https://blog.csdn.net/weixin_42300398/article/details/116758451)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [arm-linux-gcc-4.6.4-arm-x86_32.tar](https://download.csdn.net/download/dsqsyspa/10586746)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值