Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 24 Sep 2023 17:46:35 +0000
From:      Rahul Rameshbabu <sergeantsagara@protonmail.com>
To:        freebsd-arm@FreeBSD.org
Cc:        Rahul Rameshbabu <sergeantsagara@protonmail.com>
Subject:   FreeBSD aarch64 buildworld target fails to build 32-bit compat LLVM compiler-rt due to fp support
Message-ID:  <87h6njh3ba.fsf@protonmail.com>

next in thread | raw e-mail | index | archive | help
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=3Daarch64 SRCCONF=3D/dev/null __MAKE_CONF=3D/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 purpose=
s.

  --- 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=3Darmv7 -m32 -target armv7-unknown-freebsd15.0-gnueabihf  -DCOM=
PAT_LIBCOMPAT=3D\"32\"  -DCOMPAT_libcompat=3D\"32\"  -DCOMPAT_LIB32  --sysr=
oot=3D/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/t=
mp  -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/t=
mp/usr/bin -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aa=
rch64/tmp/usr/lib32  -O2 -pipe -fno-common -target armv7-unknown-freebsd  -=
fpic -fvisibility=3Dhidden -DVISIBILITY_HIDDEN -I/usr/src/contrib/llvm-proj=
ect/libunwind/include -DEMIT_SYNC_ATOMICS -g -gz=3Dzlib -MD  -MF.depend.lsh=
rdi3.o -MTlshrdi3.o -std=3Dgnu99 -Wno-format-zero-length -Wsystem-headers -=
Werror -Wall -Wno-format-y2k -Wno-uninitialized -Wno-pointer-sign -Wdate-ti=
me -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-err=
or=3Dunused-but-set-parameter -Wno-tautological-compare -Wno-unused-value -=
Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unu=
sed-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-sw--- fixu=
nsdfsivfp.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=3Darmv7 -m32 -target armv7-unknown-freebsd15.0-gnueabihf  -DCOM=
PAT_LIBCOMPAT=3D\"32\"  -DCOMPAT_libcompat=3D\"32\"  -DCOMPAT_LIB32  --sysr=
oot=3D/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/t=
mp  -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/t=
mp/usr/bin -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aa=
rch64/tmp/usr/lib32  -O2 -pipe -fno-common -target armv7-unknown-freebsd  -=
fpic -fvisibility=3Dhidden -DVISIBILITY_HIDDEN -I/usr/src/contrib/llvm-proj=
ect/libunwind/include -DEMIT_SYNC_ATOMICS -g -gz=3Dzlib -MD  -MF.depend.lsh=
rti3.o -MTlshrti3.o -std=3Dgnu99 -Wno-format-zero-length -Wsystem-headers -=
Werror -Wall -Wno-format-y2k -Wno-uninitialized -Wno-pointer-sign -Wdate-ti=
me -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-err=
or=3Dunused-but-set-parameter -Wno-tautological-compare -Wno-unused-value -=
Wno-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unu=
sed-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-sw--- modd=
i3.o ---
  cc -march=3Darmv7 -m32 -target armv7-unknown-freebsd15.0-gnueabihf  -DCOM=
PAT_LIBCOMPAT=3D\"32\"  -DCOMPAT_libcompat=3D\"32\"  -DCOMPAT_LIB32  --sysr=
oot=3D/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/t=
mp  -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch64/t=
mp/usr/bin -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aa=
rch64/tmp/usr/lib32  -O2 -pipe -fno-common -target armv7-unknown-freebsd  -=
fpic -fvisibility=3Dhidden -DVISIBILITY_HIDDEN -I/usr/src/contrib/llvm-proj=
ect/libunwind/include -DEMIT_SYNC_ATOMICS -g -gz=3Dzlib -MD  -MF.depend.mod=
di3.o -MTmoddi3.o -std=3Dgnu99 -Wno-format-zero-length -Wsystem-headers -We=
rror -Wall -Wno-format-y2k -Wno-uninitialized -Wno-pointer-sign -Wdate-time=
 -Wno-empty-body -Wno-string-plus-int -Wno-unused-const-variable -Wno-error=
=3Dunused-but-set-parameter -Wno-tautological-compare -Wno-unused-value -Wn=
o-parentheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unuse=
d-local-typedef -Wno-address-of-packed-member -Wno-switch -Wno-swit--- lshr=
ti3.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=3Darmv7 -m32 -target armv7-unknown-freebsd15.0-gnueabihf -DCOMP=
AT_LIBCOMPAT=3D\"32\" -DCOMPAT_libcompat=3D\"32\" -DCOMPAT_LIB32 --sysroot=
=3D/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/u=
sr/bin -B/home/binary-eater/Documents/crochet/work/obj/usr/src/arm64.aarch6=
4/tmp/usr/lib32 -O2 -pipe -fno-common -target armv7-unknown-freebsd  -fpic =
-fvisibility=3Dhidden -DVISIBILITY_HIDDEN -I/usr/src/contrib/llvm-project/l=
ibunwind/include -DEMIT_SYNC_ATOMICS -g -gz=3Dzlib -MD  -MF.depend.modsi3.o=
 -MTmodsi3.o -std=3Dgnu99 -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=3Dun=
used-but-set-parameter -Wno-tautological-compare -Wno-unused-value -Wno-par=
entheses-equality -Wno-unused-function -Wno-enum-conversion -Wno-unused-loc=
al-typedef -Wno-address-of-packed-member -Wno-switch -Wno-switch-enu--- mod=
di3.o ---
  ch-enum -Wno-knr-promoted-parameter  -Qunused-arguments    -c /usr/src/co=
ntrib/llvm-project/compiler-rt/lib/builtins/moddi3.c -o moddi3.o
  --- modsi3.o ---
  m -Wno-knr-promoted-parameter  -Qunused-arguments     -target armv7-unkno=
wn-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} =3D=3D "arm" && (!defined(CPUTYPE) || ${CPUTYPE:M*=
soft*} =3D=3D "") \
      && exists(${CRTSRC}/${CRTARCH}/${file}vfp.S)
  SRCS+=3D=09=09${file}vfp.S
  . elif exists(${CRTSRC}/${CRTARCH}/${file}.S)
  SRCS+=3D=09=09${file}.S
  . else
  SRCS+=3D=09=09${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} =3D=3D "aarch64"
  HAS_COMPAT+=3D=0932
  .if empty(LIB32CPUTYPE)
  LIB32CPUFLAGS=3D=09-march=3Darmv7
  .else
  LIB32CPUFLAGS=3D=09-mcpu=3D${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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?87h6njh3ba.fsf>