I am working in the Graphics SIG and my eventual goal is to compile hand written assembly or C-intrinsics with RVV 1.0 instructions and run on spike.I am able to compile spike and pk. My first step is to run a hello.c program without any RVV just to get the toolchain correct. I want to use LVVM only, as the gnu toolchain is not up to date with RVV.
"/home/peter/dev/llvm-project/build/bin/clang-13" -cc1 -triple riscv64-unknown-unknown-elf -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name hello.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -nostdsysteminc -target-feature +m -target-feature +a -target-feature +c -target-feature +relax -target-feature -save-restore -target-abi lp64 -msmall-data-limit 8 -debugger-tuning=gdb -v -fcoverage-
"../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/../../../../bin/riscv64-unknown-elf-ld" --sysroot=../riscv-gnu-toolchain/build/riscv64-unknown-elf/ -m elf64lriscv ../riscv-gnu-toolchain/build/riscv64-unknown-elf//lib/crt0.o ../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/crtbegin.o /tmp/hello-d1ee5d.o -L../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0 -L../riscv-gnu-toolchain/build/riscv64-unknown-elf//lib --start-group -lc -lgloss --end-group -lgcc ../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/crtend.o -o a.out
Since I don't need RVV at this point, is there an upstream gnu toolchain that has basic RISCV support?
For the ABI, is that what soft-float / double-float are?
I finally got it building with lp64d and march=rv64gc. It runs in spike just fine like this.Now, eventually I will be experimenting with RVV instructions. I am able to get close, but somehow there is a mismatch internally in LLVM13 with the v extension. It will only allow me to compile with rv64gcv0p10, not rv64gcv1p0. But when I do this, I get a linker error. Looks like the gnu toolchain I compiled uses a different version ( believe it is the one that supports 1.0).However, I thought llvm 13 would support the latest, and not gnu...peter@EPIC-BOSS:~/dev/riscv-experiments$ clang hello.c --target=riscv64-unknown-elf -mabi=lp64d -march=rv64gcv0p10 --gcc-toolchain=../riscv-gnu-toolchain/build/ --sysroot=../riscv-gnu-toolchain/build/riscv64-unknown-elf/ -menable-experimental-extensions -v
clang version 13.0.0 (g...@github.com:llvm/llvm-project.git d7b669b3a30345cfcdb2fde2af6f48aa4b94845d)
Target: riscv64-unknown-unknown-elf
Thread model: posix
InstalledDir: /home/peter/dev/llvm-project/riscv_install/bin
Found candidate GCC installation: ../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0
Selected GCC installation: ../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0
"/home/peter/dev/llvm-project/riscv_install/bin/clang-13" -cc1 -triple riscv64-unknown-unknown-elf -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name hello.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -nostdsysteminc -target-feature +m -target-feature +a -target-feature +f -target-feature +d -target-feature +c -target-feature +experimental-v -target-feature +experimental-zvlsseg -target-feature +relax -target-feature -save-restore -target-abi lp64d -msmall-data-limit 8 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/home/peter/dev/riscv-experiments -resource-dir /home/peter/dev/llvm-project/riscv_install/lib/clang/13.0.0 -isysroot ../riscv-gnu-toolchain/build/riscv64-unknown-elf/ -internal-isystem ../riscv-gnu-toolchain/build/riscv64-unknown-elf/include -fdebug-compilation-dir=/home/peter/dev/riscv-experiments -ferror-limit 19 -fno-signed-char -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -o /tmp/hello-5fa051.o -x c hello.c
clang -cc1 version 13.0.0 based upon LLVM 13.0.0 default target riscv64-unknown-elf
#include "..." search starts here:
#include <...> search starts here:
../riscv-gnu-toolchain/build/riscv64-unknown-elf/include
/home/peter/dev/llvm-project/riscv_install/lib/clang/13.0.0/include
End of search list.
"../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/../../../../bin/riscv64-unknown-elf-ld" --sysroot=../riscv-gnu-toolchain/build/riscv64-unknown-elf/ -m elf64lriscv ../riscv-gnu-toolchain/build/riscv64-unknown-elf//lib/crt0.o ../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/crtbegin.o /tmp/hello-5fa051.o -L../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0 -L../riscv-gnu-toolchain/build/riscv64-unknown-elf//lib --start-group -lc -lgloss --end-group -lgcc ../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/crtend.o -o a.out
../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/../../../../bin/riscv64-unknown-elf-ld: error: /tmp/hello-5fa051.o: Mis-matched ISA version for 'v' extension. 0.10 vs 1.0
On Saturday, December 18, 2021 at 7:56:22 PM UTC-7 Peter Lieber wrote:Jim,If I understand correctly, my clang build is defaulting to the lp64 ABI (soft-float) but the gnu toolchain I builts used the lp64d (hard-float). I think I want to start with hard float, so if I change my clang invocation (or rebuild with different defaults), it should be happy?I want to use LLVM (and build it myself) because I want to eventually add instructions and play with some things and I think that will be the easiest route for me.Thanks for the help,On Friday, December 17, 2021 at 8:56:03 AM UTC-7 jim.wil...@gmail.com wrote:On Thu, Dec 16, 2021 at 10:10 PM Peter Lieber <petera...@gmail.com> wrote:"/home/peter/dev/llvm-project/build/bin/clang-13" -cc1 -triple riscv64-unknown-unknown-elf -emit-obj -mrelax-all --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name hello.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -nostdsysteminc -target-feature +m -target-feature +a -target-feature +c -target-feature +relax -target-feature -save-restore -target-abi lp64 -msmall-data-limit 8 -debugger-tuning=gdb -v -fcoverage-"-target-abi lp64" means FP registers are not used for argument passing, i.e. soft-float. Looks like rv64imac is the arch."../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/../../../../bin/riscv64-unknown-elf-ld" --sysroot=../riscv-gnu-toolchain/build/riscv64-unknown-elf/ -m elf64lriscv ../riscv-gnu-toolchain/build/riscv64-unknown-elf//lib/crt0.o ../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/crtbegin.o /tmp/hello-d1ee5d.o -L../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0 -L../riscv-gnu-toolchain/build/riscv64-unknown-elf//lib --start-group -lc -lgloss --end-group -lgcc ../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/crtend.o -o a.outThere is no explicit -march/-mabi option passed here, and this was probably built with the default rv64gc/lp64d arch/abi, which is not compatible with rv64imac/lp64. This is also probably not multilib. So this isn't going to work. llvm and gcc need to have compatible arch/abi. Or configure riscv-gnu-toolchain with --enable-multilib.Since I don't need RVV at this point, is there an upstream gnu toolchain that has basic RISCV support?Since 2017, but upstream sources don't help you, as riscv-gnu-toolchain is already using upstream sources. Recent debian and very recent ubuntu (21.04) have riscv64 embedded elf gcc compiler packages, which were built multilib. I don't know if they have clang cross compiler packages.For the ABI, is that what soft-float / double-float are?See https://www.sifive.com/blog/all-aboard-part-1-compiler-args which talks about march/abi options.Jim
--
You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/a2fb614d-bf71-4ad0-be4d-6f2c9b61e90bn%40groups.riscv.org.
I also checked and the current bumped binutils in riscv-gnu-toolchain is 2.37... as of 4 months ago.