Building a RISCV toolchain

1,172 views
Skip to first unread message

Peter Lieber

unread,
Dec 12, 2021, 10:57:31 PM12/12/21
to RISC-V SW Dev
Is there a good resource for building a basic RISCV toolchain using LLVM 13? I'd like to be able to build LLVM with clang, then compile a simple hello.c with newlib support.  Do we have to use a gcc linker or do we have llvm linker and assembler support in LLVM 13? 

Does anyone know of a  good primer on setting up an LLVM/RISCV cross compile for an LLVM newbie?

Thanks, Peter 

Tommy Murphy

unread,
Dec 13, 2021, 8:24:28 AM12/13/21
to Peter Lieber, RISC-V SW Dev
Do you actually need to build the llvm toolchain yourself or can you use it straight from your Linux distro's software repositories?

If you do need to build it yourself for some reason then, as far as I know, you should just go to the master/upstream llvm project repository and build from there.

I don't know if there's any RISC-V specific instructions for building and using the toolchain there but, if not, I guess that that's the place to ask about same?

Khem Raj

unread,
Dec 13, 2021, 12:55:09 PM12/13/21
to Tommy Murphy, Peter Lieber, RISC-V SW Dev
if you are looking for creating a clang based cross compiler toolchain
for RV32/RV64/Linux, you could try yocto with clang layer see
https://github.com/kraj/meta-clang#readme

>
> --
> 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/LO2P265MB4776FE61ECDECA2D4456A7FEF9749%40LO2P265MB4776.GBRP265.PROD.OUTLOOK.COM.

Peter Lieber

unread,
Dec 16, 2021, 10:54:46 AM12/16/21
to RISC-V SW Dev, raj....@gmail.com, Peter Lieber, RISC-V SW Dev, tommy_...@hotmail.com
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.

However, I am running into a libc issue as I can't find any way other than to use the gnu toolchain for linking and libc access.  This gets to the heart of my question... has anyone used lvvm to link and a different c library so I can either avoid gnu for my low level testing, or to at least use gnu and avoid errors when compiling such as:

~/dev/riscv-experiments$ clang hello.c --target=riscv64 --gcc-toolchain=../riscv-gnu-toolchain/build/ --sysroot=../riscv-gnu-toolchain/build/riscv64-unknown-elf/
../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/../../../../riscv64-unknown-elf/bin/ld: /tmp/hello-1aed28.o: can't link soft-float modules with double-float modules
../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file /tmp/hello-1aed28.o
clang-13: error: ld command failed with exit code 1 (use -v to see invocation)

Obviously the GCC toolchain c library doesn't link well with my clang build hello.c. Do I need to rebuild libc with LLVM/clang, and is this documented somewhere?  The other interesting thing is that the --sysroot option is not documented in clang help, but works (barring the link error) and is suggested in some documents online.

Khem Raj

unread,
Dec 16, 2021, 11:54:03 AM12/16/21
to Peter Lieber, RISC-V SW Dev, tommy_...@hotmail.com
On Thu, Dec 16, 2021 at 7:54 AM Peter Lieber <petera...@gmail.com> wrote:
>
> 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.
>
> However, I am running into a libc issue as I can't find any way other than to use the gnu toolchain for linking and libc access. This gets to the heart of my question... has anyone used lvvm to link and a different c library so I can either avoid gnu for my low level testing, or to at least use gnu and avoid errors when compiling such as:
>
> ~/dev/riscv-experiments$ clang hello.c --target=riscv64 --gcc-toolchain=../riscv-gnu-toolchain/build/ --sysroot=../riscv-gnu-toolchain/build/riscv64-unknown-elf/
> ../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/../../../../riscv64-unknown-elf/bin/ld: /tmp/hello-1aed28.o: can't link soft-float modules with double-float modules
> ../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/../../../../riscv64-unknown-elf/bin/ld: failed to merge target specific data of file /tmp/hello-1aed28.o
> clang-13: error: ld command failed with exit code 1 (use -v to see invocation)


you have ABI mismatch here. Can you post output of compiler invocation
after adding -v, you might need to use --target=riscv64-unknown-elf
to match the ABI to gcc toolchain and runtime you are using from sysroot.

Bruce Hoult

unread,
Dec 16, 2021, 4:58:31 PM12/16/21
to Peter Lieber, RISC-V SW Dev, raj....@gmail.com, tommy_...@hotmail.com
On Fri, Dec 17, 2021 at 4:54 AM Peter Lieber <petera...@gmail.com> wrote:
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.

gcc hasn't been updated for quite some time, but as far as I know the assembler, linker, objdump etc are fine for the ratified RVV.

Peter Lieber

unread,
Dec 17, 2021, 1:10:26 AM12/17/21
to RISC-V SW Dev, raj....@gmail.com, RISC-V SW Dev, tommy_...@hotmail.com, Peter Lieber
This is the output with the -v option

peter@EPIC-BOSS:~/dev/riscv-experiments$ clang hello.c --target=riscv64-unknown-elf --gcc-toolchain=../riscv-gnu-toolchain/build/ --sysroot=../riscv-gnu-toolchain/build/riscv64-unknown-elf/ -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/build/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/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-compilation-dir=/home/peter/dev/riscv-experiments -resource-dir /home/peter/dev/llvm-project/build/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-d1ee5d.o -x c hello.c
clang -cc1 version 13.0.0 based upon LLVM 13.0.0 default target riscv64-unkown-elf
#include "..." search starts here:
#include <...> search starts here:
 ../riscv-gnu-toolchain/build/riscv64-unknown-elf/include
 /home/peter/dev/llvm-project/build/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-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
../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/../../../../bin/riscv64-unknown-elf-ld: /tmp/hello-d1ee5d.o: can't link soft-float modules with double-float modules
../riscv-gnu-toolchain/build/lib/gcc/riscv64-unknown-elf/10.1.0/../../../../bin/riscv64-unknown-elf-ld: failed to merge target specific data of file /tmp/hello-d1ee5d.o

clang-13: error: ld command failed with exit code 1 (use -v to see invocation)

The riscv-gnu-toolchain I am attempting to use is one I built from https://github.com/riscv-collab/riscv-gnu-toolchain  

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? 

- Peter

Jim Wilson

unread,
Dec 17, 2021, 10:56:03 AM12/17/21
to Peter Lieber, RISC-V SW Dev, raj....@gmail.com, tommy_...@hotmail.com
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.out

There 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

Peter Lieber

unread,
Dec 18, 2021, 9:56:22 PM12/18/21
to RISC-V SW Dev, jim.wil...@gmail.com, RISC-V SW Dev, raj....@gmail.com, tommy_...@hotmail.com, Peter Lieber
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,

Peter Lieber

unread,
Dec 18, 2021, 10:45:30 PM12/18/21
to RISC-V SW Dev, Peter Lieber, jim.wil...@gmail.com, RISC-V SW Dev, raj....@gmail.com, tommy_...@hotmail.com
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


Nelson Chu

unread,
Dec 18, 2021, 11:04:40 PM12/18/21
to Peter Lieber, RISC-V SW Dev, jim.wil...@gmail.com, raj....@gmail.com, tommy_...@hotmail.com


Peter Lieber <petera...@gmail.com>:
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

I remember this should be a warning rather than error, so you probably can use a newer binutils, maybe checkout to mainline or 2.37 branch.  If you are using the bumped binutils branch in riscv-gnu-toolchain, then it is still 2.36.1, that’s too old.

Thanks
Nelson


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.out

There 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.

Peter Lieber

unread,
Dec 18, 2021, 11:27:51 PM12/18/21
to Nelson Chu, RISC-V SW Dev, jim.wil...@gmail.com, raj....@gmail.com, tommy_...@hotmail.com
That would make sense. However, isn't llvm at 1.0 vector as well? I'm checked out to the latest on main branch for LLVM, but maybe I'm missing something to get the latest.

Peter Lieber

unread,
Dec 21, 2021, 9:28:21 PM12/21/21
to RISC-V SW Dev, Peter Lieber, RISC-V SW Dev, jim.wil...@gmail.com, raj....@gmail.com, tommy_...@hotmail.com, nelso...@sifive.com
I also checked and the current bumped binutils in riscv-gnu-toolchain is 2.37... as of 4 months ago.

Jim Wilson

unread,
Dec 22, 2021, 2:39:20 AM12/22/21
to Peter Lieber, RISC-V SW Dev, raj....@gmail.com, tommy_...@hotmail.com, nelso...@sifive.com
On Tue, Dec 21, 2021 at 6:28 PM Peter Lieber <petera...@gmail.com> wrote:
I also checked and the current bumped binutils in riscv-gnu-toolchain is 2.37... as of 4 months ago.

riscv-gnu-toolchain only contains FSF releases, and we rarely backport patches, usually only when this is unavoidable, because this is time consuming, and there is no staff to do the work.  If you want something new, like V support, use the upstream sources.

it is possible to pull upstream sources into riscv-gnu-toolchain.  I've commented on this before, such as here
There are also the --with-binutils-src, --with-gcc-src, etc configure options mentioned in the README.md file that can be used to do this.

Jim

Reply all
Reply to author
Forward
0 new messages