josecm / riscv-hyp-tests

A bare-metal application to test specific features of the risc-v hypervisor extension
GNU General Public License v3.0
34 stars 21 forks source link

compile failure for qemu platform while success for spike platform #17

Open robert-hz opened 8 months ago

robert-hz commented 8 months ago

Hi, I've tried to compile this unit test bin with riscv gnu toolchain, configured as:

./configure --prefix=/opt/riscv-new --disable-multilib --with-cmodel=medany --with-arch=rv64imafdc_zicsr --with-abi=lp64d

meanwhile, modify this bin's Makefile as below, in order to avoid soft float issure reported in https://github.com/josecm/riscv-hyp-tests/issues/14

 ifdef GCCVERSION
-       GENERIC_FLAGS += -march=rv64imac_zicsr
+       GENERIC_FLAGS += -march=rv64imafdc_zicsr
 else
-       GENERIC_FLAGS += -march=rv64imac
+       GENERIC_FLAGS += -march=rv64imafdc
 endif
-GENERIC_FLAGS += -mabi=lp64 -g3 -mcmodel=medany -O3 $(inc_dirs)
+GENERIC_FLAGS += -mabi=lp64d -g3 -mcmodel=medany -O3 $(inc_dirs)

 ASFLAGS = $(GENERIC_FLAGS)
 CFLAGS = $(GENERIC_FLAGS)

But link error:

/opt/riscv-new/lib/gcc/riscv64-unknown-linux-gnu/13.2.0/../../../../riscv64-unknown-linux-gnu/bin/ld: /opt/riscv-new/sysroot/usr/lib/libc.a(dl-support.o): in function `_dl_aux_init':
dl-support.c:(.text+0x3c): undefined reference to `_start'
/opt/riscv-new/lib/gcc/riscv64-unknown-linux-gnu/13.2.0/../../../../riscv64-unknown-linux-gnu/bin/ld: dl-support.c:(.text+0xb8): undefined reference to `__ehdr_start'
/opt/riscv-new/lib/gcc/riscv64-unknown-linux-gnu/13.2.0/../../../../riscv64-unknown-linux-gnu/bin/ld: build/qemu/rvh_test.elf: hidden symbol `_start' isn't defined
/opt/riscv-new/lib/gcc/riscv64-unknown-linux-gnu/13.2.0/../../../../riscv64-unknown-linux-gnu/bin/ld: final link failed: bad value

While compile platform=spike succeeds.

Du-Chao commented 6 months ago

I think you should use a 'riscv64-unknown-elf-' toolchain, instead of the 'riscv64-unknown-linux-gnu' toolchain.