I am trying to cross-build from amd64 to armv7 and I get the following
linker
errors from the cross-toolchain for anything I try to build:
home/serega/obsd/armv7/usr/arm-unknown-openbsd7.8/bin/cc -static -pie
-o cat cat.o
arm-unknown-openbsd7.8-ld: error: duplicate symbol: __umodsi3
>>> defined at umodsi3.S:32
(/home/serega/obsd/src/gnu/lib/libcompiler_rt/../../llvm/compiler-rt/lib/builtins/arm/umodsi3.S:32)
>>> umodsi3.o:(__umodsi3) in archive
/home/serega/obsd/armv7/usr/lib/libcompiler_rt.a
>>> defined at divsi3.S:26
(/home/serega/obsd/src/lib/libc/arch/arm/gen/divsi3.S:26)
>>> divsi3.o:(.text+0x0) in archive
/home/serega/obsd/armv7/usr/lib/libc.a
arm-unknown-openbsd7.8-ld: error: duplicate symbol: __modsi3
>>> defined at modsi3.S:41
(/home/serega/obsd/src/gnu/lib/libcompiler_rt/../../llvm/compiler-rt/lib/builtins/arm/modsi3.S:41)
>>> modsi3.o:(__modsi3) in archive
/home/serega/obsd/armv7/usr/lib/libcompiler_rt.a
>>> defined at divsi3.S:35
(/home/serega/obsd/src/lib/libc/arch/arm/gen/divsi3.S:35)
>>> divsi3.o:(.text+0x18) in archive
/home/serega/obsd/armv7/usr/lib/libc.a
arm-unknown-openbsd7: error: linker command failed with exit code 1 (use
-v to see invocation)
*** Error 1 in /home/serega/obsd/src/bin/cat (<bsd.prog.mk>:126 'cat')
The toolchain was produced by the following commands:
eval export $(make -f Makefile.cross TARGET=armv7
CROSSDIR=$HOME/obsd/armv7 cross-env)
doas make -f Makefile.cross TARGET=armv7 CROSSDIR=$HOME/obsd/armv7
cross-dirs
doas make -f Makefile.cross TARGET=armv7 CROSSDIR=$HOME/obsd/armv7
cross-tools
Of the two conflicting implementations, lib/libc/arch/arm/gen/divsi3.S
gnu/llvm/compiler-rt/lib/builtins/arm/divsi3.S, the latter is newer --
introduced as a part of the commit that imports compiler-rt 1.0.1 (5 years
ago).
And there is one more in libkern: ./sys/lib/libkern/arch/arm/divsi3.S
I can believe that cross-build for armv7 was not exercised since 2020,
but can somebody explain me why is it apparently
not a problem for native armv7 builds? The arm64 cross-building works
fine (with and without the patch below).
diff --git a/gnu/lib/libcompiler_rt/Makefile
b/gnu/lib/libcompiler_rt/Makefile
index abc4184616d..0d3f359aa20 100644
--- a/gnu/lib/libcompiler_rt/Makefile
+++ b/gnu/lib/libcompiler_rt/Makefile
@@ -99,7 +99,6 @@ GEN_SRCS= absvdi2 \
lshrdi3 \
lshrti3 \
moddi3 \
- modsi3 \
modti3 \
muldc3 \
muldi3 \
@@ -140,7 +139,6 @@ GEN_SRCS= absvdi2 \
udivmodti4 \
udivti3 \
umoddi3 \
- umodsi3 \
umodti3
.if ${RTARCH} != "arm"
@@ -158,12 +156,14 @@ GEN_SRCS+= adddf3 \
fixunssfdi \
floatsidf \
floatsisf \
+ modsi3 \
muldf3 \
mulsf3 \
subdf3 \
subsf3 \
truncdfsf2 \
- udivsi3
+ udivsi3 \
+ umodsi3
.endif
# Architecture-specific TF (quad-precision) functions