您的位置:首页 > 移动开发 > Objective-C

ARM compilation error, VPF registered used by executable, not object file

2016-04-22 10:03 1456 查看
http://stackoverflow.com/questions/9753749/arm-compilation-error-vpf-registered-used-by-executable-not-object-file
I have been having this problem for the last few days and I can't get my head around what is really happening here, or what is the problem.

I have a makefile with these flags:
CC = arm-linux-gnueabihf-gcc-4.6
FLAGS = -O3 -march=armv7-a -mtune=cortex-a9 -mfpu=neon -ftree-vectorize -mfloat-abi=softfp -std=gnu99


I have a library in a .a file, which has some object files, all I need to do is link them in with my executable. I know the prototypes and all that, the only thing that complains is the following:
/usr/bin/ld: error: *EXECUTABLE* uses VFP register arguments, *OBJECTFILE* does not
/usr/bin/ld: failed to merge target specific data of file *OBJECTFILE*


When I don't use the -mfloat-abi=softfp, I get another error relating to floating point registers.

Does anyone have any idea what is causing this, and what I can do to fix this, such as making it so that my executable does not use Virtual Floating Point Register arguments?
x@x:~/Desktop/perf_test$ make
arm-linux-gnueabihf-gcc-4.6 -c -O3 -march=armv7-a -mtune=cortex-a9 -mfpu=neon -ftree-vectorize -std=gnu99 -mfloat-abi=softfp  perf_test.c ../baseline/util.c
arm-linux-gnueabihf-gcc-4.6 -o perf_test perf_test.o util.o  ../baseline/lib.a
/usr/bin/ld: error: perf_test uses VFP register arguments, perf_test.o does not
/usr/bin/ld: failed to merge target specific data of file perf_test.o
/usr/bin/ld: error: perf_test uses VFP register arguments, util.o does not
/usr/bin/ld: failed to merge target specific data of file util.o
/usr/bin/ld: error: perf_test uses VFP register arguments, ../baseline/lib.a(a.o) does not
/usr/bin/ld: failed to merge target specific data of file ../baseline/lib.a(a.o)
/usr/bin/ld: error: perf_test uses VFP register arguments, ../baseline/lib.a(b.o) does not
/usr/bin/ld: failed to merge target specific data of file ../baseline/lib.a(b.o)
/usr/bin/ld: error: perf_test uses VFP register arguments, ../baseline/lib.a(c.o) does not
/usr/bin/ld: failed to merge target specific data of file ../baseline/lib.a(c.o)
/usr/bin/ld: error: perf_test uses VFP register arguments, ../baseline/lib.a(d.o) does not
/usr/bin/ld: failed to merge target specific data of file ../baseline/lib.a(d.o)
/usr/bin/ld: error: perf_test uses VFP register arguments, ../baseline/lib.a(e.o) does not
/usr/bin/ld: failed to merge target specific data of file ../baseline/lib.a(e.o)
/usr/bin/ld: error: perf_test uses VFP register arguments, ../baseline/lib.a(f.o) does not
/usr/bin/ld: failed to merge target specific data of file ../baseline/lib.a(f.o)
collect2: ld returned 1 exit status
make: *** [perf_test] Error 1


gcc compilation arm
shareimprove
this question
edited Mar
17 '12 at 21:51

asked Mar 17 '12 at 21:09





Jim
1,16152034

1
Full compile and link command lines please.. – blueshift Mar
17 '12 at 21:18
I have added the full compile error summary. – Jim Mar
17 '12 at 21:29
1
I found this to be very informative: developer.toradex.com/software-resources/arm-family/linux/…E-richOct
31 '14 at 17:45
add
a comment


6 Answers

activeoldestvotes

up vote25down
voteaccepted
Your target triplet indicates that your compiler is configured for the hard-float ABI. This means that the libgcc library will also be hardfp. The error message indicates that at least part of your system
is usingsoft-float ABI.

If the compiler has multilib enabled (you can tell with
-print-multi-lib
)
then you can use
-mfloat-abi=softfp
,
but if not then that option won't help you much: gcc will happily generate softfp code, but then there'll be no compatible libgcc to link against.

Basically, hardfp and softfp are just not compatible. You need to get your whole system configured one way or the other.

EDIT: some distros are, or will be, "multiarch". If you have one of those then it's possible to install bothABIs at once, but that's done by doubling everything up -- the compatibility issues still exist.

shareimprove
this answer
answered Mar 17 '12 at 21:36





ams
14.1k12349

When i compile with -hard then it removes the executable and code that I wrote, but still errors with the library. My
question is basically pretend I don't know anything about anything. What is happening here, and why? – Jim Mar
17 '12 at 21:53
3
Your libraries and/or executable are not compatible because they use different procedure calling conventions: one passes
float values in VFP registers and the other passes them in core registers. – ams Mar
17 '12 at 23:42
add
a comment
up vote9down
vote
I have found on an arm hardfloat system where glibc binutils and gcc were crosscompiled, using gcc gives the same error.

It is solved by exporting
-mfloat-abi=hard
to
flags, then gcc compiles without errors.

shareimprove
this answer
answered Dec 15 '12 at 11:28





白い熊
12615

add
a comment
up vote4down
vote
Also the error can be solved by adding several flags, like
-marm
-mthumb-interwork
. It was helpful for me to avoid this same error.

shareimprove
this answer
edited May
29 '12 at 6:44





Botz3000
27.2k75795

answered May 28 '12 at 11:18





AVG
434

add
a comment
up vote1down
vote
This is guesswork, but you may need to supply some or all of the floating point related switches for the link stage as well.

shareimprove
this answer
answered Mar 17 '12 at 21:36





blueshift
4,2122442

add
a comment
up vote1down
vote
In my case
CFLAGS
= -O0 -g -Wall -I. -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=soft
has helped. As you can see, i used it for my stm32f407.

shareimprove
this answer
answered May 18 '15 at 15:56





user4912846
111

add
a comment
up vote0down
vote
Use the same compiler options for linking also.

Example:
gcc  -mfloat-abi=hard fpu=neon -c -o test.cpp test.o
gcc  -mfloat-abi=hard fpu=neon -c test1.cpp test1.o
gcc test.o test1.o mfloat-abi=hard fpu=neon HardTest


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: