Quantcast
Viewing all articles
Browse latest Browse all 4824

SDK • Re: Help needed for Building RISC-V Compiler

Interesting, with an 'int main(void) { }' program I can compile that from the command line, using the '-march' which the 'cmake' seems to be using -

Code:

/usr/bin/riscv32-unknown-elf-gcc -march=rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb -mabi=ilp32 -S xyzzy.c
That produces an 'xyzzy.s' as expected. That contains what looks to be RISC-V assembler and includes -

Code:

.attribute arch, "rv32i2p1_m2p0_a2p1_c2p0_zicsr2p0_zifencei2p0_zba1p0_zbb1p0_zbkb1p0_zbs1p0"
So the compiler seems to be working, just not the assembler as also observed by building without the '-S' option -

Code:

pi@Pi4B:~/apps/riscv $ /usr/bin/riscv32-unknown-elf-gcc -march=rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb -mabi=ilp32 xyzzy.cAssembler messages:Error: unknown architecture `rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb'Error: unrecognized option -march=rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb
So seems to be down down to a missing or incorrectly configured assembler.

It looks like it's there so no idea why it's not working, isn't compiled for the architecture specified -

Code:

pi@Pi4B:~/apps/riscv $ /usr/bin/riscv32-unknown-elf-as --versionGNU assembler (GNU Binutils) 2.43Copyright (C) 2024 Free Software Foundation, Inc.This program is free software; you may redistribute it under the terms ofthe GNU General Public License version 3 or later.This program has absolutely no warranty.This assembler was configured for a target of `riscv32-unknown-elf'.
Assembling the previous 'xyzzy.s' works just fine, produces the anticipated 'a.out' -

Code:

pi@Pi4B:~/apps/riscv $ /usr/bin/riscv32-unknown-elf-as xyzzy.s

Code:

pi@Pi4B:~/apps/riscv $ file a.outa.out: ELF 32-bit LSB relocatable, UCB RISC-V, RVC, soft-float ABI, version 1 (SYSV), not stripped
Compiling with the '-march' and '-mabi' the 'cmake' seems to be applying also works -

Code:

pi@Pi4B:~/apps/riscv $ /usr/bin/riscv32-unknown-elf-as -march=rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb -mabi=ilp32 xyzzy.s
So why doesn't it work with 'cmake' ?

But, more so - Why does it work when done as a two-step process, but not with the single 'gcc' invocation ?

Solve that and I expect it will also fix 'cmake' builds.

Aha! It seems to be building with the 'gcc' at the location the './configure -prefix' put it -

Code:

pi@Pi4B:~/apps/riscv $ /opt/riscv/gcc14-rp2350-no-zcmp/bin/riscv32-unknown-elf-gcc  -arch=rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb -mabi=ilp32 xyzzy.c
So presumably it's not possible to simply copy stuff from where it is to where I want it to be and have it work.

Looks like I need to add where it is to my 'path' or rebuild with an appropriate './configure -prefix'.

Statistics: Posted by hippy — Fri Aug 16, 2024 5:37 pm



Viewing all articles
Browse latest Browse all 4824

Trending Articles