FreeBSD aarch64 buildworld target fails to build 32-bit compat LLVM compiler-rt due to fp support
Date: Sun, 24 Sep 2023 17:46:35 UTC
Hello,
I am trying to build the FreeBSD project for aarch64 to better support
the Raspberry Pi 3 and Raspberry Pi 4 boards in the project.
https://wiki.freebsd.org/arm/Raspberry%20Pi
I use the following build command (generic aarch64 target).
make TARGET_ARCH=aarch64 SRCCONF=/dev/null __MAKE_CONF=/dev/null -j 32 buildworld
I notice the following error related to HW floating point support on
armv7 (32-bit arch) target that is compiled for compat/32-bit build purposes.
--- fixunsdfsivfp.o ---
/usr/src/contrib/llvm-project/compiler-rt/lib/builtins/arm/fixunsdfsivfp.S:26:2: error: instruction requires: fp registers
--- lshrdi3.o ---
cc -march=armv7 -m32 -target armv7-unknown-freebsd15.0-gnueabihf -DCOMPAT_LIBCOMPAT=\"32\" -DCOMPAT_libcompat=\"32\" -DCOMPAT_LIB32 --sysroot=/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/tmp -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/tmp/usr/bin -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/tmp/usr/lib32 -O2 -pipe -fno-common -target armv7-unknown-freebsd -fpic -fvisibility=hidden -DVISIBILITY_HIDDEN -I/usr/src/contrib/llvm-project/libunwind/include -DEMIT_SYNC_ATOMICS -g -gz=zlib -MD -MF.depend.lshrdi3.o -MTlshrdi3.o -std=gnu99 -Wno-format-zero-length -Wsystem-headers -Werror -Wall -Wno-format-y2k -Wno-uninitialized -Wno-pointer-sign -Wdate-time -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-error=unused-but-set-parameter -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-sw--- fixunsdfsivfp.o ---
vmov d7, r0, r1
^
/usr/src/contrib/llvm-project/compiler-rt/lib/builtins/arm/fixunsdfsivfp.S:27:2: error: instruction requires: double precision VFP VFP2
vcvt.u32.f64 s15, d7
^
/usr/src/contrib/llvm-project/compiler-rt/lib/builtins/arm/fixunsdfsivfp.S:28:2: error: instruction requires: fp registers
vmov r0, s15
^
--- lshrti3.o ---
--- lshrdi3.o ---
itch-enum -Wno-knr-promoted-parameter -Qunused-arguments -c /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/lshrdi3.c -o lshrdi3.o
--- fixunssfsivfp.o ---
/usr/src/contrib/llvm-project/compiler-rt/lib/builtins/arm/fixunssfsivfp.S:26:2: error: instruction requires: fp registers
vmov s15, r0
^
/usr/src/contrib/llvm-project/compiler-rt/lib/builtins/arm/fixunssfsivfp.S:27:2: error: instruction requires: VFP2
vcvt.u32.f32 s15, s15
^
/usr/src/contrib/llvm-project/compiler-rt/lib/builtins/arm/fixunssfsivfp.S:28:2: error: instruction requires: fp registers
vmov r0, s15
^
--- moddi3.o ---
--- modsi3.o ---
--- lshrti3.o ---
cc -march=armv7 -m32 -target armv7-unknown-freebsd15.0-gnueabihf -DCOMPAT_LIBCOMPAT=\"32\" -DCOMPAT_libcompat=\"32\" -DCOMPAT_LIB32 --sysroot=/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/tmp -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/tmp/usr/bin -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/tmp/usr/lib32 -O2 -pipe -fno-common -target armv7-unknown-freebsd -fpic -fvisibility=hidden -DVISIBILITY_HIDDEN -I/usr/src/contrib/llvm-project/libunwind/include -DEMIT_SYNC_ATOMICS -g -gz=zlib -MD -MF.depend.lshrti3.o -MTlshrti3.o -std=gnu99 -Wno-format-zero-length -Wsystem-headers -Werror -Wall -Wno-format-y2k -Wno-uninitialized -Wno-pointer-sign -Wdate-time -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-error=unused-but-set-parameter -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-sw--- moddi3.o ---
cc -march=armv7 -m32 -target armv7-unknown-freebsd15.0-gnueabihf -DCOMPAT_LIBCOMPAT=\"32\" -DCOMPAT_libcompat=\"32\" -DCOMPAT_LIB32 --sysroot=/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/tmp -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/tmp/usr/bin -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/tmp/usr/lib32 -O2 -pipe -fno-common -target armv7-unknown-freebsd -fpic -fvisibility=hidden -DVISIBILITY_HIDDEN -I/usr/src/contrib/llvm-project/libunwind/include -DEMIT_SYNC_ATOMICS -g -gz=zlib -MD -MF.depend.moddi3.o -MTmoddi3.o -std=gnu99 -Wno-format-zero-length -Wsystem-headers -Werror -Wall -Wno-format-y2k -Wno-uninitialized -Wno-pointer-sign -Wdate-time -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-error=unused-but-set-parameter -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-swit--- lshrti3.o ---
itch-enum -Wno-knr-promoted-parameter -Qunused-arguments -c /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/lshrti3.c -o lshrti3.o
--- modsi3.o ---
cc -march=armv7 -m32 -target armv7-unknown-freebsd15.0-gnueabihf -DCOMPAT_LIBCOMPAT=\"32\" -DCOMPAT_libcompat=\"32\" -DCOMPAT_LIB32 --sysroot=/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/tmp -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/tmp/usr/bin -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/tmp/usr/lib32 -O2 -pipe -fno-common -target armv7-unknown-freebsd -fpic -fvisibility=hidden -DVISIBILITY_HIDDEN -I/usr/src/contrib/llvm-project/libunwind/include -DEMIT_SYNC_ATOMICS -g -gz=zlib -MD -MF.depend.modsi3.o -MTmodsi3.o -std=gnu99 -Wno-format-zero-length -Wsystem-headers -Werror -Wall -Wno-format-y2k -Wno-uninitialized -Wno-pointer-sign -Wdate-time -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-error=unused-but-set-parameter -Wno-tautological-compare -Wno-unused-value -Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-switch-enu--- moddi3.o ---
ch-enum -Wno-knr-promoted-parameter -Qunused-arguments -c /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/moddi3.c -o moddi3.o
--- modsi3.o ---
m -Wno-knr-promoted-parameter -Qunused-arguments -target armv7-unknown-freebsd -c /usr/src/contrib/llvm-project/compiler-rt/lib/builtins/arm/modsi3.S -o modsi3.o
--- fixunsdfsivfp.o ---
*** [fixunsdfsivfp.o] Error code 1
make[4]: stopped in /usr/src/lib/libcompiler_rt
--- fixunssfsivfp.o ---
*** [fixunssfsivfp.o] Error code 1
make[4]: stopped in /usr/src/lib/libcompiler_rt
2 errors
make[4]: stopped in /usr/src/lib/libcompiler_rt
make[3]: stopped in /usr/src
--- lib/libgcc_eh__PL ---
make[3]: stopped in /usr/src
make[2]: stopped in /usr/src
0.31 real 2.27 user 0.81 sys
*** [build32] Error code 2
make[1]: stopped in /usr/src
1 error
make[1]: stopped in /usr/src
make: stopped in /usr/src
I believe this is due to a couple of parts in the build system where I
am not sure what the right solution would be.
In lib/libcompiler_rt/Makefile.inc:
.for file in ${SRCF}
.if ${MACHINE_CPUARCH} == "arm" && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} == "") \
&& exists(${CRTSRC}/${CRTARCH}/${file}vfp.S)
SRCS+= ${file}vfp.S
. elif exists(${CRTSRC}/${CRTARCH}/${file}.S)
SRCS+= ${file}.S
. else
SRCS+= ${file}.c
. endif
.endfor
When 32-bit compat for aarch64 is compiled, the first conditional is
true and this leads to the vfp assembly variants under
contrib/llvm-project/compiler-rt/lib/builtins/arm being chosen as source
that needs to be assembled (but the compiler options seem to lack the
needed arguments for the specific fp register support needed for vfp).
I believe these options are determined by the following snippet in
share/mk/bsd.compat.mk.
.elif ${COMPAT_ARCH} == "aarch64"
HAS_COMPAT+= 32
.if empty(LIB32CPUTYPE)
LIB32CPUFLAGS= -march=armv7
.else
LIB32CPUFLAGS= -mcpu=${LIB32CPUTYPE}
.endif
The problem here is that armv7 is selected for the arch but there is no
indication of vfp support, which leads to the error seen. I am not sure
what the ideal fix is (avoid using vfp built-in for 32-bit compat or
hack up the compat build to indicate 32-bit compat for aarch64 always
has HW fp support).
You can find the full logs here if needed.
https://gist.github.com/Binary-Eater/1ced3c02530254e716c441ed77ce4d8c
--
Thanks,
Rahul Rameshbabu