Skip to content

Development documentation for scripts for ARC‐V GNU toolchain

Yuriy Kolerov edited this page Dec 12, 2025 · 6 revisions

Buildlib for ARC-V GNU toolchain

riscv64-snps-elf-buildlib is a Python script which helps a user to build Picolibc, libgcc and libstdc++ for a custom target configuration.

Building an application with custom libraries

To build and link an application with a custom library, you need to pass extra arguments:

  1. -specs=./buildlib/buildlib.specs - include a .specs file which turns off default multilib rules.
  2. -isystem ./buildlib/riscv64-snps-elf/sys-include -isystem ./buildlib/riscv64-snps-elf/include - use included from a custom Picolibc.
  3. -B./buildlib/lib/gcc -B./buildlib/riscv64-snps-elf/lib - use custom libraries by default instead of original.

Consider this example:

int main()
{
    printf("Hello, World!\n");
    return 0;
}

How to link an application with custom libraries (also, we pass -Wl,-t to ensure that custom libraries are linked with our application):

$ riscv64-snps-elf-gcc \
     -march=rv32imac \
     -mabi=ilp32 \
     -mtune=arc-v-rmx-100-series \
     -mcmodel=medlow \
     -isystem ./buildlib/riscv64-snps-elf/sys-include \
     -isystem ./buildlib/riscv64-snps-elf/include \
     -B./buildlib/lib/gcc \
     -B./buildlib/riscv64-snps-elf/lib \
     -specs=picolibc.specs \
     -specs=buildlib.specs \
     --oslib=semihost \
     --crt0=semihost \
     hello.c -o hello.elf \
    -Wl,-t
./buildlib/riscv64-snps-elf/lib/crt0-semihost.o
/tmp/ccUptbxg.o
./buildlib/lib/gcc/riscv64-snps-elf/15.2.0/libgcc.a
./buildlib/lib/gcc/riscv64-snps-elf/15.2.0/libgcc.a
./buildlib/riscv64-snps-elf/lib/libc.a
./buildlib/riscv64-snps-elf/lib/libsemihost.a
./buildlib/lib/gcc/riscv64-snps-elf/15.2.0/libgcc.a
./buildlib/riscv64-snps-elf/lib/libc.a
./buildlib/riscv64-snps-elf/lib/libsemihost.a
./buildlib/lib/gcc/riscv64-snps-elf/15.2.0/libgcc.a

Now we can run the example:

$ nsimdrv -p nsim_isa_family=rv32 -p nsim_isa_ext=-all.i.m.a.c.zicsr -p nsim_semihosting=1 -p enable_exceptions=0 hello.elf
Hello, World!

Clone this wiki locally