Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chapter 1 build error: can't link double-float modules with soft-float modules #34

Open
kaycebasques opened this issue Mar 6, 2023 · 2 comments

Comments

@kaycebasques
Copy link

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)

@HonzaLed
Copy link

Thank you! I had the same issue, this solved it for me

@summer-boythink
Copy link

Thank you! I had the same issue
You can propose a pr that may help more people

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants