1

I am building a program with the riscv compiler and, when the linking process start, I have the following problem:

/home/luna/noelv-buildroot/output/images/riscv64-buildroot-linux-musl_sdk-buildroot/bin/../lib/gcc/riscv64-buildroot-linux-musl/8.3.0/../../../../riscv64-buildroot-linux-musl/bin/ld: /home/luna/noelv-buildroot/output/images/riscv64-buildroot-linux-musl_sdk-buildroot/bin/../lib/gcc/riscv64-buildroot-linux-musl/8.3.0/libgcc.a(_clzsi2.o): can't link double-float modules with soft-float modules

I am using the compiler to compile and linker my code. This is my compiler:

$ riscv64-linux-gcc --verbose 
COLLECT_GCC=/home/luna/noelv-buildroot/output/images/riscv64-buildroot-linux-musl_sdk-buildroot/bin/riscv64-linux-gcc.br_real
COLLECT_LTO_WRAPPER=/home/luna/noelv-buildroot/output/images/riscv64-buildroot-linux-musl_sdk-buildroot/bin/../libexec/gcc/riscv64-buildroot-linux-musl/8.3.0/lto-wrapper
Configured with ./configure --prefix=/home/luna/noelv-buildroot/output/host --sysconfdir=/home/luna/noelv-buildroot/output/host/etc --enable-static --target=riscv64-buildroot-linux-musl --with-sysroot=/home/luna/noelv-buildroot/output/host/riscv64-buildroot-linux-musl/sysroot --enable-__cxa_atexit --with-gnu-ld --disable-libssp --disable-multilib --disable-decimal-float --with-gmp=/home/luna/noelv-buildroot/output/host --with-mpc=/home/luna/noelv-buildroot/output/host --with-mpfr=/home/luna/noelv-buildroot/output/host --with-pkgversion='Buildroot 2020.02' --with-bugurl=http://bugs.buildroot.net/ --disable-libmpx --disable-libquadmath --disable-libsanitizer --enable-tls --enable-threads --without-isl --without-cloog --with-arch=rv64imafd --with-abi=lp64d --enable-languages=c,c++ --with-build-time-tools=/home/luna/noelv-buildroot/output/host/riscv64-buildroot-linux-musl/bin --enable-shared --disable-libgomp
Modelo de hilos: posix
gcc version 8.3.0 (Buildroot 2020.02) 
Lane
  • 161
  • 2
  • 14
  • Are you targeting soft FP or hard FP? The linker complains about a mismatch, but which half is wrong? – MSalters Nov 27 '20 at 12:15

3 Answers3

3

Your compiler was build with disable-multilib and for rv64imafd arch. So basically all the libraries provided with the compiler are compiled for this arch.

If you try to compile some code with an other arch , you will not be able to link against it by default. Also, if you provide a library, you will need to be sure it was compiled for this arch to use it in the same time with the libraries provided by the tool chain.

You can see the exact arch and abi of your library with readelf -h.

yflelion
  • 1,698
  • 2
  • 5
  • 16
2

I was getting this error when trying to get chapter 1 of Stephen Marz's osblog working.

Updating this line in //risc_v/chapters/ch1/Makefile fixed it for me:

+++ CFLAGS+=-march=rv64gc -mabi=lp64d
--- CFLAGS+=-march=rv64gc -mabi=lp64

I'm not a compiler expert but I think the essential problem is that the RISC-V GNU Compiler Toolchain was generated to use double floats but the invocation of the toolchain in //risc_v/chapters/ch1/Makefile is trying to use soft floats.

From the RISC-V GNU Compiler Toolchain README:

Supported ABIs are ilp32 (32-bit soft-float), ilp32d (32-bit hard-float), ilp32f (32-bit with single-precision in registers and double in memory, niche use only), lp64 lp64f lp64d (same but with 64-bit long and pointers).

I can get chapter 1 building and running now. I haven't verified that subsequent chapters still work.

Kayce Basques
  • 23,849
  • 11
  • 86
  • 120
1

Can't comment since too low rep, but have you tried adding the -msoft-float flag also where are you running that command/program, like hardware specs? depending on your hardware specs it may be the complete opposite and therefore you should try to avoid the double keyword Could you also share some code?

Imeguras
  • 436
  • 6
  • 18