How to build glibc with HW FPU properly
VVIsaev opened this issue · 1 comments
I tried to build glibc with following configuration:
$ CROSS_COMPILE=arc64-linux-gnu- ASFLAGS='-mfpu=fpud' CFLAGS='-O2 -mfpu=fpud' CXXFLAGS='-O2 -mfpu=fpud' ../configure --target=arc64-linux-gnu --host=arc64-linux-gnu --build=x86_64 --enable-shared --disable-profile --disable-werror --without-gd --prefix=/home/isaev/tmp/glibc-gnuhf
$ make
Then I checked __longjmp()
in libc.so.6, see source:
...
LDR.as r24, r0, 15
#if defined(__ARCV3__)
LDR.as r25, r0, 16
LDR.as r26, r0, 17
#endif
#if defined (__ARC_FLOAT_ABI_HARD__)
FLDR.as f16, r0, 18
...
FLDR.as f31, r0, 33
#endif
MOVR.f r0, r1
j.d [blink]
...
But in built libc I do't see such code:
0000000000035608 <__longjmp>:
...
35644: 100f 0e58 ldl.as r24,[r0,15]
35648: 1010 0e59 ldl.as r25,[r0,16]
3564c: 1011 0e5a ldl.as r26,[r0,17]
35650: 580a 8040 movl.f r0,r1
35654: 2021 07c0 j.d [blink]
...
So I don't see fp related code in __longjmp
.
Somehow adding libc_cv_cc_submachine="-mfpu=fpud"
to your configure command-line helps. Likely due to https://sourceware.org/bugzilla/show_bug.cgi?id=10118 & a fix for it https://sourceware.org/bugzilla/attachment.cgi?id=3927&action=diff:
000000000003570c <__longjmp>:
3570c:» 1000 0e5f » ldl.as» blink,[r0]
35710:» 1001 0e5c » ldl.as» sp,[r0,1]
35714:» 1002 0e5b » ldl.as» fp,[r0,2]
35718:» 1003 0e5e » ldl.as» r30,[r0,3]
3571c:» 1004 0e4d » ldl.as» r13,[r0,4]
35720:» 1005 0e4e » ldl.as» r14,[r0,5]
35724:» 1006 0e4f » ldl.as» r15,[r0,6]
35728:» 1007 0e50 » ldl.as» r16,[r0,7]
3572c:» 1008 0e51 » ldl.as» r17,[r0,8]
35730:» 1009 0e52 » ldl.as» r18,[r0,9]
35734:» 100a 0e53 » ldl.as» r19,[r0,10]
35738:» 100b 0e54 » ldl.as» r20,[r0,11]
3573c:» 100c 0e55 » ldl.as» r21,[r0,12]
35740:» 100d 0e56 » ldl.as» r22,[r0,13]
35744:» 100e 0e57 » ldl.as» r23,[r0,14]
35748:» 100f 0e58 » ldl.as» r24,[r0,15]
3574c:» 1010 0e59 » ldl.as» r25,[r0,16]
35750:» 1011 0e5a » ldl.as» r26,[r0,17]
35754:» e012 041a » fld64.as» f16,[r0,18]
35758:» e013 045a » fld64.as» f17,[r0,19]
3575c:» e014 049a » fld64.as» f18,[r0,20]
35760:» e015 04da » fld64.as» f19,[r0,21]
35764:» e016 051a » fld64.as» f20,[r0,22]
35768:» e017 055a » fld64.as» f21,[r0,23]
3576c:» e018 059a » fld64.as» f22,[r0,24]
35770:» e019 05da » fld64.as» f23,[r0,25]
35774:» e01a 061a » fld64.as» f24,[r0,26]
35778:» e01b 065a » fld64.as» f25,[r0,27]
3577c:» e01c 069a » fld64.as» f26,[r0,28]
35780:» e01d 06da » fld64.as» f27,[r0,29]
35784:» e01e 071a » fld64.as» f28,[r0,30]
35788:» e01f 075a » fld64.as» f29,[r0,31]
3578c:» e020 079a » fld64.as» f30,[r0,32]
35790:» e021 07da » fld64.as» f31,[r0,33]
35794:» 580a 8040 » movl.f» r0,r1
35798:» 2021 07c0 » j.d» [blink]
3579c:» 20ca 0061 » mov.eq» r0,0x1
And now we need to figure out how to do that consistently. My guess is configuring GCC with --with-fpu=fpud
(like we do in Buildroot when enabled BR2_GCC_TARGET_FPU
, see https://github.com/foss-for-synopsys-dwc-arc-processors/buildroot/blob/arc64/arch/Config.in.arc#L111) should be good enough as then regardless of ASFLAGS
GCC will have __ARC_FLOAT_ABI_HARD__
defined by default.