Chapter 1 build error: can't link double-float modules with soft-float modules
Opened this issue · 2 comments
I was getting this error when trying to get chapter 1 working:
riscv64-unknown-linux-gnu-g++ -Wall -Wextra -pedantic -Wextra -O0 -g -std=c++17 -static -ffreestanding -nostdlib -fno-rtti -fno-exceptions -march=rv64gc -mabi=lp64 -Tsrc/lds/virt.lds -o os.elf src/asm/boot.S src/asm/trap.S -L./target/riscv64gc-unknown-none-elf/debug -lsos -lgcc
/.../riscv64-unknown-linux-gnu/bin/ld: ./target/riscv64gc-unknown-none-elf/debug/libsos.a(sos-f8a9629c7efd9190.3y75fbrs59hl4tt.rcgu.o): can't link double-float modules with soft-float modules
/.../riscv64-unknown-linux-gnu/bin/ld: failed to merge target specific data of file ./target/riscv64gc-unknown-none-elf/debug/libsos.a(sos-f8a9629c7efd9190.3y75fbrs59hl4tt.rcgu.o)
...
I think I found a fix. Posting here in case it helps anyone else out.
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 invokation 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.
(I also posted this to Stack Overlow: https://stackoverflow.com/a/75652961/1669860)
Thank you! I had the same issue, this solved it for me
Thank you! I had the same issue
You can propose a pr
that may help more people