Re: C++ program-build problems for aarch64 -m32 use; examples: undefined symbol: __muldf3 , undefined symbol: __divdf3 , undefined symbol: __ltdf2

Mark Millard <[email protected]>
Newsgroups gmane.os.freebsd.devel.arm
Message-ID <[email protected]>

On Jul 26, 2023, at 12:38, Mark Millard <[email protected]> wrote:

> I do not yet have a reduced form of this.
> 
> This is via use of local makefiles and such, not from a port.
> It is a variant of a older not -m32 that I adjusted to use -m32.
> 
> clang++ -v -m32 -std=c++20 -Wpedantic -Wall -Wextra   -I../other_src_used  -pedantic  -g3 -O3 -mcpu=cortex-a7 -flto  -pthread -fuse-ld=lld -flto ../objs/cpp_thousandslocale-clang++_16_O3lto-libc++.o  ../objs/cpp_clockinfo-clang++_16_O3lto-libc++.o -o ../cpp_clockinfo_main-HoneyComb-65536MiB-threads_16-ILP32-FreeBSD_main_n264334_215bab7924f6_64bit-clang++_16_O3lto-libc++  -DCPPCLOCKINFO_VERS='"acpphint_0.1.36"'  ../other_src_used/cpp_clockinfo_main.cpp
> FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)
> Target: arm-unknown-freebsd14.0
> Thread model: posix
> InstalledDir: /usr/bin
> "/usr/bin/clang++" -cc1 -triple armv7-unknown-freebsd14.0 -emit-llvm-bc -flto=full -flto-unit -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name cpp_clockinfo_main.cpp -mrelocation-model static -mframe-pointer=all -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu cortex-a7 -target-feature +soft-float -target-feature +soft-float-abi -target-feature -crc -target-feature +dsp -target-feature -ras -target-feature -sb -target-feature -i8mm -target-feature -lob -target-feature -cdecp0 -target-feature -cdecp1 -target-feature -cdecp2 -target-feature -cdecp3 -target-feature -cdecp4 -target-feature -cdecp5 -target-feature -cdecp6 -target-feature -cdecp7 -target-feature -pacbti -target-feature +hwdiv-arm -target-feature +hwdiv -target-feature -vfp2 -target-feature -vfp2sp -target-feature -vfp3 -target-feature -vfp3d16 -target-feature -vfp3d16sp -target-feature -vfp3sp -target-feature -fp16 -target-feature -vfp4 -target-feature -vfp4d16 -target-feature -vfp4d16sp -target-feature -vfp4sp -target-feature -fp-armv8 -target-feature -fp-armv8d16 -target-feature -fp-armv8d16sp -target-feature -fp-armv8sp -target-feature -fullfp16 -target-feature -fp64 -target-feature -d32 -target-feature -neon -target-feature -dotprod -target-feature -fp16fml -target-feature -bf16 -target-feature -mve -target-feature -mve.fp -target-feature -fpregs -target-feature -crypto -target-feature -sha2 -target-feature -aes -target-feature +strict-align -target-abi aapcs-linux -msoft-float -mfloat-abi soft -Wunaligned-access -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=standalone -dwarf-version=4 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/home/root/acpphint/acpphint_src -resource-dir /usr/lib/clang/16 -I ../other_src_used -D "CPPCLOCKINFO_VERS=\"acpphint_0.1.36\"" -internal-isystem /usr/include/c++/v1 -internal-isystem /usr/lib/clang/16/include -internal-externc-isystem /usr/include -O3 -Wpedantic -Wall -Wextra -pedantic -std=c++20 -fdeprecated-macro -fdebug-compilation-dir=/usr/home/root/acpphint/acpphint_src -ferror-limit 19 -pthread -fno-signed-char -fgnuc-version=4.2.1 -fno-implicit-modules -fcxx-exceptions -fexceptions -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/cpp_clockinfo_main-bd1520.o -x c++ ../other_src_used/cpp_clockinfo_main.cpp
> clang -cc1 version 16.0.6 based upon LLVM 16.0.6 default target aarch64-unknown-freebsd14.0
> #include "..." search starts here:
> #include <...> search starts here:
> ../other_src_used
> /usr/include/c++/v1
> /usr/lib/clang/16/include
> /usr/include
> End of search list.
> "/usr/bin/ld.lld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o ../cpp_clockinfo_main-HoneyComb-65536MiB-threads_16-ILP32-FreeBSD_main_n264334_215bab7924f6_64bit-clang++_16_O3lto-libc++ /usr/lib32/crt1.o /usr/lib32/crti.o /usr/lib32/crtbegin.o -L/usr/lib32 -plugin-opt=mcpu=cortex-a7 -plugin-opt=O3 ../objs/cpp_thousandslocale-clang++_16_O3lto-libc++.o ../objs/cpp_clockinfo-clang++_16_O3lto-libc++.o /tmp/cpp_clockinfo_main-bd1520.o -lc++ -lm -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib32/crtend.o /usr/lib32/crtn.o
> ld.lld: error: undefined symbol: __muldf3
>>>> referenced by cpp_clockinfo_main.cpp:153 (../other_src_used/cpp_clockinfo_main.cpp:153)
>>>>              lto.tmp:(main::$_0::operator()(ClkInfo const&) const)
>>>> did you mean: __muldc3
>>>> defined in: /usr/lib32/libgcc_s.so
> 
> ld.lld: error: undefined symbol: __divdf3
>>>> referenced by cpp_clockinfo_main.cpp:180 (../other_src_used/cpp_clockinfo_main.cpp:180)
>>>>              lto.tmp:(main::$_0::operator()(ClkInfo const&) const)
>>>> did you mean: __divdc3
>>>> defined in: /usr/lib32/libgcc_s.so
> 
> ld.lld: error: undefined symbol: __ltdf2
>>>> referenced by cpp_clockinfo_main.cpp:185 (../other_src_used/cpp_clockinfo_main.cpp:185)
>>>>              lto.tmp:(main::$_0::operator()(ClkInfo const&) const)
> clang++: error: linker command failed with exit code 1 (use -v to see invocation)
> *** Error code 1
> 
> Stop.
> make: stopped in /usr/home/root/acpphint/acpphint_src
> 

I tried something simpler and ended up discovering that
system clang can picking up /usr/local/bin/aarch64-unknown-freebsd14.0-ld
instead of /usr/bin/ld.lld :

# more basic_double_use.c 
int main(void)
{
    volatile double a=10;
    volatile double b=13;
    return (a*b<b/a) ? 0 : 1;
}

Non -m32 use:

# cc -pedantic -O2 basic_double_use.c 
# ./a.out
#

-m32:

# cc -pedantic -m32 -O2 basic_double_use.c
/usr/local/bin/aarch64-unknown-freebsd14.0-ld: /usr/lib32/crt1.o: error adding symbols: file in wrong format
cc: error: linker command failed with exit code 1 (use -v to see invocation)

So:

# cc -v -pedantic -m32 -O2 basic_double_use.c
FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)
Target: arm-unknown-freebsd14.0
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/cc" -cc1 -triple armv4t-unknown-freebsd14.0 -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name basic_double_use.c -mrelocation-model static -mframe-pointer=all -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu arm7tdmi -target-feature +soft-float -target-feature +soft-float-abi -target-feature -vfp2 -target-feature -vfp2sp -target-feature -vfp3 -target-feature -vfp3d16 -target-feature -vfp3d16sp -target-feature -vfp3sp -target-feature -fp16 -target-feature -vfp4 -target-feature -vfp4d16 -target-feature -vfp4d16sp -target-feature -vfp4sp -target-feature -fp-armv8 -target-feature -fp-armv8d16 -target-feature -fp-armv8d16sp -target-feature -fp-armv8sp -target-feature -fullfp16 -target-feature -fp64 -target-feature -d32 -target-feature -neon -target-feature -sha2 -target-feature -aes -target-feature -dotprod -target-feature -fp16fml -target-feature -bf16 -target-feature -mve -target-feature -mve.fp -target-feature -fpregs -target-feature +strict-align -target-abi aapcs-linux -msoft-float -mfloat-abi soft -Wunaligned-access -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/home/root/c_tests -resource-dir /usr/lib/clang/16 -internal-isystem /usr/lib/clang/16/include -internal-externc-isystem /usr/include -O2 -pedantic -fdebug-compilation-dir=/usr/home/root/c_tests -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/basic_double_use-816254.o -x c basic_double_use.c
clang -cc1 version 16.0.6 based upon LLVM 16.0.6 default target aarch64-unknown-freebsd14.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/clang/16/include
 /usr/include
End of search list.
 "/usr/local/bin/aarch64-unknown-freebsd14.0-ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --hash-style=both --enable-new-dtags -o a.out /usr/lib32/crt1.o /usr/lib32/crti.o /usr/lib32/crtbegin.o -L/usr/lib32 /tmp/basic_double_use-816254.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib32/crtend.o /usr/lib32/crtn.o
/usr/local/bin/aarch64-unknown-freebsd14.0-ld: /usr/lib32/crt1.o: error adding symbols: file in wrong format
cc: error: linker command failed with exit code 1 (use -v to see invocation)

For reference for the non -m32 command ( which also picks up
/usr/local/bin/aarch64-unknown-freebsd14.0-ld ):

# cc -v -pedantic -O2 basic_double_use.c
FreeBSD clang version 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a259152)
Target: aarch64-unknown-freebsd14.0
Thread model: posix
InstalledDir: /usr/bin
 "/usr/bin/cc" -cc1 -triple aarch64-unknown-freebsd14.0 -emit-obj -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name basic_double_use.c -mrelocation-model static -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu generic -target-feature +neon -target-feature +v8a -target-abi aapcs -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/usr/home/root/c_tests -resource-dir /usr/lib/clang/16 -internal-isystem /usr/lib/clang/16/include -internal-externc-isystem /usr/include -O2 -pedantic -fdebug-compilation-dir=/usr/home/root/c_tests -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/basic_double_use-ab1d22.o -x c basic_double_use.c
clang -cc1 version 16.0.6 based upon LLVM 16.0.6 default target aarch64-unknown-freebsd14.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/clang/16/include
 /usr/include
End of search list.
 "/usr/local/bin/aarch64-unknown-freebsd14.0-ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 --enable-new-dtags -o a.out /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/lib /tmp/basic_double_use-ab1d22.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o

So it looks like some care is needed being sure the right set of
tools is in use.

===
Mark Millard
marklmi at yahoo.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.