Config RISCV with GSL library on Ubuntu


(Ali imran Siddiqui) #1

Hello,
I’m trying to compile GSL with RISCv compiler.
if i configure GSL for cross comiling with the following command

./configure --host=riscv64-unknown-elf --prefix=$ path to riscv install toolchain/bin

then it gives the following error

riscv-unknown-elf-gcc/lib/libgsl.a(fdiv.o): ABI is incompatible with that of the selected emulation:
target emulation elf64-littleriscv' does not matchelf32-littleriscv’

and if i use 32bit flags in the config command

./configure --host=riscv64-unknown-elf --prefix=$ path to riscv install toolchain/bin --with-march=rv32i --with-mabi=ilp32

then the failure is incompatible libraries.

Can anyone please guide me what is the mistake and what i’m missing.
Thank you.


(Jim Wilson) #2

You are using --host=riscv64-unknown-elf but the error message mentions riscv-unknown-elf. riscv-unknown-elf is a non-standard configure triplet, suggests maybe you are using Liviu’s toolchain. Anyways, it looks like your compiler is 32-bit by default, so you probably need to use riscv32-unknown-elf (or riscv-unknown-elf) as the --host option to make this work. If you really want 64-bit code, then you need to configure for riscv64-unknown-elf and add -march/-mabi options to emit 64-bit code.


(Ali imran Siddiqui) #3

Hello Jim,
Thank you for your reply.

i’m trying to cross compile GSL library(https://www.gnu.org/software/gsl/) for RISCV architecture.
i used the following command to configure the GSL library for cross comiling

./configure --host=riscv64-unknown-elf --build=x86_64-pc-linux-gnu --target=riscv64-unknown-elf --prefix=$RISCV CFLAGS="-march=rv32i -mabi=ilp32"

and the incompatible issue is now resolved.

i have another issue “ram size problem”
The error is

main.elf section .text' will not fit in region ram’
/home/ali/Microsemi_SoftConsole_v5.3/riscv-unknown-elf-gcc/bin/…/lib/gcc/riscv64-unknown-elf/7.2.0/…/…/…/…/riscv64-unknown-elf/bin/ld: region `ram’ overflowed by 288784 bytes.

i think now the code is much bigger than the allowed ram.
Do you have any idea how can i solve this…???

Thank you very much.


(Jim Wilson) #4

You need to make the program smaller or the target memory bigger. Using a -march with more features would help. Compiling with -Os if not already would help. Maybe the prorgam has optional features that can be configured off to reduce program size. I don’t know GSL so I can’t offer any specific suggestions.


(Ali imran Siddiqui) #5

Thank you Jim,
I compiled with -Os and the size is approx 70% reduce but bigger than my memory.
I also tried to delete some folder but the size remains the same in memory.
if you have another idea then please share.
Thank you for your help.