Giter VIP home page Giter VIP logo

pulp-riscv-gnu-toolchain's Introduction

RISC-V GNU Compiler Toolchain

This is the RISC-V C and C++ cross-compiler. It supports two build modes: a generic ELF/Newlib toolchain and a more sophisticated Linux-ELF/glibc toolchain.

Getting the sources

This repository uses submodules. You need the --recursive option to fetch the submodules automatically

$ git clone --recursive https://github.com/pulp-platform/pulp-riscv-gnu-toolchain

Alternatively :

$ git clone https://github.com/pulp-platform/pulp-riscv-gnu-toolchain
$ cd pulp-riscv-gnu-toolchain
$ git submodule update --init --recursive

Prerequisites

Several standard packages are needed to build the toolchain. On Ubuntu, executing the following command should suffice:

$ sudo apt-get install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev

On Fedora/CentOS/RHEL OS, executing the following command should suffice:

$ sudo yum install autoconf automake libmpc-devel mpfr-devel gmp-devel gawk  bison flex texinfo patchutils gcc gcc-c++ zlib-devel

On OS X, you can use Homebrew to install the dependencies:

$ brew install gawk gnu-sed gmp mpfr libmpc isl zlib

To build the glibc (Linux) on OS X, you will need to build within a case-sensitive file system. The simplest approach is to create and mount a new disk image with a case sensitive format. Make sure that the mount point does not contain spaces. This is not necessary to build newlib or gcc itself on OS X.

This process will start by downloading about 200 MiB of upstream sources, then will patch, build, and install the toolchain. If a local cache of the upstream sources exists in $(DISTDIR), it will be used; the default location is /var/cache/distfiles. Your computer will need about 8 GiB of disk space to complete the process.

Installation (Pulp)

To build the Newlib cross-compiler for all pulp variants, pick an install path. If you choose, say, /opt/riscv, then add /opt/riscv/bin to your PATH now. Then, simply run the following command:

./configure --prefix=/opt/riscv --with-arch=rv32imc --with-cmodel=medlow --enable-multilib
make

This will use the multilib support to build the libraries for the various cores (riscy, zeroriscy and so on). The right libraries will be selected depending on which compiler options you use.

Installation (Newlib)

To build the Newlib cross-compiler, pick an install path. If you choose, say, /opt/riscv, then add /opt/riscv/bin to your PATH now. Then, simply run the following command:

./configure --prefix=/opt/riscv
make

You should now be able to use riscv-gcc and its cousins.

Installation (Linux)

To build the Linux cross-compiler, pick an install path. If you choose, say, /opt/riscv, then add /opt/riscv/bin to your PATH now. Then, simply run the following command:

./configure --prefix=/opt/riscv
make linux

The build defaults to targetting RV64G (64-bit), even on a 32-bit build environment. To build the 32-bit RV32G toolchain, use:

./configure --prefix=/opt/riscv --with-arch=rv32g --with-abi=ilp32d
make linux

Supported architectures are rv32i or rv64i plus standard extensions (a)tomics, (m)ultiplication and division, (f)loat, (d)ouble, or (g)eneral for MAFD.

Supported ABIs are ilp32 (32-bit soft-float), ilp32d (32-bit hard-float), ilp32f (32-bit with single-precision in registers and double in memory, niche use only), lp64 lp64f lp64d (same but with 64-bit long and pointers).

Installation (Linux multilib)

To build the Linux cross-compiler with support for both 32-bit and 64-bit, run the following commands:

./configure --prefix=/opt/riscv --enable-multilib
make linux

The multilib compiler will have the prefix riscv-unknown-linux-gnu-, rather than the usual prefix (riscv32-... or riscv64-...).

Advanced Options

There are a number of additional options that may be passed to configure. See './configure --help' for more details.

Test Suite

The DejaGnu test suite has been ported to RISC-V. This can run with GDB simulator for elf toolchain or Qemu for linux toolchain, and GDB simulator doesn't support floating-point. To test GCC, run the following commands:

./configure --prefix=$RISCV --disable-linux --with-arch=rv64ima # or --with-arch=rv32ima
make newlib
make check-gcc-newlib

./configure --prefix=$RISCV
make linux
# Need qemu-riscv32 or qemu-riscv64 in your `PATH`.
make check-gcc-linux

pulp-riscv-gnu-toolchain's People

Contributors

a0u avatar andreaskurth avatar arsv avatar arunthomas avatar aswaterman avatar colinschmidt avatar darius-bluespec avatar eflamand avatar gkelly avatar gtagliavini avatar haugoug avatar kito-cheng avatar kyrias avatar manuelafm avatar martinmaas avatar omasanori avatar palmer-dabbelt avatar pmundkur avatar rbarzic avatar sbeamer avatar sorear avatar svenstucki avatar timsifive avatar tjyang avatar vapier avatar yaooooo avatar yunsup avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pulp-riscv-gnu-toolchain's Issues

"Linux multilib" fails to build, final link failed

The machine runs centos 7, provided by the IIS at ETH, with preinstalled dependencies (so I didn't mess with that).

msc18f22@badile08:[/]: lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description:    CentOS Linux release 7.4.1708 (Core) 
Release:        7.4.1708
Codename:       Core
msc18f22@badile08:[/]: uname -rms
Linux 3.10.0-693.17.1.el7.x86_64 x86_64

I build on /scratch to prevent any nfs related errors, such as cp -p complaining about ownership.

./configure --prefix=$HOME/.riscv --enable-multilib && make -j8 linux

fails with

/home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/libgcc.a(div.o): ABI is incompatible with that of the selected emulation:
  target emulation `elf64-littleriscv' does not match `elf32-littleriscv'
/home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/../../../../riscv64-unknown-linux-gnu/bin/ld: failed to merge target specific data of file /home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/libgcc.a(div.o)
/home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/../../../../riscv64-unknown-linux-gnu/bin/ld: Attempt to do relocatable link with elf64-littleriscv input and elf32-littleriscv output
/home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/libgcc.a(div.o): file class ELFCLASS64 incompatible with ELFCLASS32
/home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/../../../../riscv64-unknown-linux-gnu/bin/ld: final link failed: File in wrong format
collect2: error: ld returned 1 exit status
make[3]: *** [/scratch/tmp/pulp-riscv-gnu-toolchain/build-glibc-linux-rv32imcxpulpv2-ilp32/elf/librtld.map] Error 1
make[3]: *** Waiting for unfinished jobs....
riscv64-unknown-linux-gnu-gcc -march=rv32ic -mabi=ilp32   -nostdlib -nostartfiles -r -o /scratch/tmp/pulp-riscv-gnu-toolchain/build-glibc-linux-rv32ic-ilp32-mreg16/libc_pic.os \
 -Wl,-d -Wl,--whole-archive /scratch/tmp/pulp-riscv-gnu-toolchain/build-glibc-linux-rv32ic-ilp32-mreg16/libc_pic.a -o /scratch/tmp/pulp-riscv-gnu-toolchain/build-glibc-linux-rv32ic-ilp32-mreg16/libc_pic.os
riscv64-unknown-linux-gnu-gcc -march=rv32ic -mabi=ilp32   -nostdlib -nostartfiles -r -o /scratch/tmp/pulp-riscv-gnu-toolchain/build-glibc-linux-rv32ic-ilp32-mreg16/elf/librtld.map.o '-Wl,-(' /scratch/tmp/pulp-riscv-gnu-toolchain/build-glibc-linux-rv32ic-ilp32-mreg16/elf/dl-allobjs.os /scratch/tmp/pulp-riscv-gnu-toolchain/build-glibc-linux-rv32ic-ilp32-mreg16/libc_pic.a -lgcc '-Wl,-)' -Wl,-Map,/scratch/tmp/pulp-riscv-gnu-toolchain/build-glibc-linux-rv32ic-ilp32-mreg16/elf/librtld.mapT
/home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/libgcc.a(muldi3.o): ABI is incompatible with that of the selected emulation:
  target emulation `elf64-littleriscv' does not match `elf32-littleriscv'
/home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/../../../../riscv64-unknown-linux-gnu/bin/ld: failed to merge target specific data of file /home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/libgcc.a(muldi3.o)
/home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/libgcc.a(div.o): ABI is incompatible with that of the selected emulation:
  target emulation `elf64-littleriscv' does not match `elf32-littleriscv'
/home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/../../../../riscv64-unknown-linux-gnu/bin/ld: failed to merge target specific data of file /home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/libgcc.a(div.o)
/home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/../../../../riscv64-unknown-linux-gnu/bin/ld: Attempt to do relocatable link with elf64-littleriscv input and elf32-littleriscv output
/home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/../../../../riscv64-unknown-linux-gnu/bin/ld: /home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/libgcc.a(muldi3.o): file class ELFCLASS64 incompatible with ELFCLASS32
/home/msc18f22/.riscv/lib/gcc/riscv64-unknown-linux-gnu/7.1.1/../../../../riscv64-unknown-linux-gnu/bin/ld: final link failed: File in wrong format
collect2: error: ld returned 1 exit status
make[3]: *** [/scratch/tmp/pulp-riscv-gnu-toolchain/build-glibc-linux-rv32ic-ilp32-mreg16/elf/librtld.map] Error 1
make[3]: *** Waiting for unfinished jobs....
make[3]: Leaving directory `/scratch/tmp/pulp-riscv-gnu-toolchain/riscv-glibc/elf'
make[2]: *** [elf/subdir_lib] Error 2
make[2]: Leaving directory `/scratch/tmp/pulp-riscv-gnu-toolchain/riscv-glibc'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/scratch/tmp/pulp-riscv-gnu-toolchain/build-glibc-linux-rv32imcxpulpv2-ilp32'
make: *** [stamps/build-glibc-linux-rv32imcxpulpv2-ilp32] Error 2
make[3]: Leaving directory `/scratch/tmp/pulp-riscv-gnu-toolchain/riscv-glibc/elf'
make[2]: *** [elf/subdir_lib] Error 2
make[2]: Leaving directory `/scratch/tmp/pulp-riscv-gnu-toolchain/riscv-glibc'
make[1]: *** [all] Error 2
make[1]: Leaving directory `/scratch/tmp/pulp-riscv-gnu-toolchain/build-glibc-linux-rv32ic-ilp32-mreg16'
make: *** [stamps/build-glibc-linux-rv32ic-ilp32-mreg16] Error 2

I don't understand enough about the build and link process of this toolchain to understand the core issue of that error.

error when $ make linux ( pulp-riscv-gnu-toolchain)

checking for riscv32-unknown-linux-gnu-gcc... /home/cu_cai/pulp-riscv-gnu-toolchain/build-gcc-linux-stage1/./gcc/xgcc -B/home/cu_cai/pulp-riscv-gnu-toolchain/build-gcc-linux-stage1/./gcc/ -B/opt/riscv/riscv32-unknown-linux-gnu/bin/ -B/opt/riscv/riscv32-unknown-linux-gnu/lib/ -isystem /opt/riscv/riscv32-unknown-linux-gnu/include -isystem /opt/riscv/riscv32-unknown-linux-gnu/sys-include
checking for suffix of object files... configure: error: in /home/cu_cai/pulp-riscv-gnu-toolchain/build-gcc-linux-stage1/riscv32-unknown-linux-gnu/libgcc': configure: error: cannot compute suffix of object files: cannot compile See config.log' for more details.
make[1]: *** [Makefile:11138: configure-target-libgcc] Error 1
make[1]: Leaving directory '/home/cu_cai/pulp-riscv-gnu-toolchain/build-gcc-linux-stage1'
make: *** [Makefile:156: stamps/build-gcc-linux-stage1] Error 2

Error in MSYS2 32-bit.

make[2]: *** [Makefile:10463: all-gdb] Error 2
make[2]: Leaving directory '/home/nicol/pulp-riscv-gnu-toolchain/build-binutils-newlib'
make[1]: *** [Makefile:858: all] Error 2
make[1]: Leaving directory '/home/nicol/pulp-riscv-gnu-toolchain/build-binutils-newlib'
make: *** [Makefile:213: stamps/build-binutils-newlib] Error 2

Any hint is welcome.

Minor issues related to builtins

Hi,

I am wrapping available builtins for ri5cy core pulpv3 extension instruction and by testing those have found some minor issues in the compiler related code:

  • pulp_builtins.def
    1. lines 160-163 related to mulhh[su][R]N, prototype description should use INT instead of SHORT for arguments to match corresponding md instructions descriptions, otherwise the builtins usage leads to compile time errors;
    2. lines 179-182 same for machh[us][R]N.

  • riscv-builtins.c
    1. line 339, for mac[hh][us]RN arguments check, although a norm of 0 has little interest as it becomes a simple mac[hh] the line 338 check allows it but line 339 check in such situation is machine dependent as a left shift by -1 is performed : ((1 << (Norm - 1)) == Round), a possible fix is ((Norm == 0) && (Round == 0)) || (Norm && ((1 << (Norm - 1)) == Round));
    2. line 359, same as previously but for instructions mul[hh][su]RNr, addRN[u] and subRN[u];
    3. line 398 and 408 for clip[u]_minmax, the arguments check stops with N == 29 but 30 is also a valid value, it can be reached with following fix, for (i = 0; i <= 30; i ++);
    4. lines 450-451, for invsipat1 (binsert), again although it has little interest, it is possible to insert a full 32b data at offset 0 (so to perform a move), the mask being in such a case 0xffffffff. This means that the computed size for the mask is 32 and this value is then used in a lshift in integer context so the result might be machine dependent. Also if mask is 0 and offset is also 0, no error is issued but the resulting instructions issued are hazardeous (sorry I have not captured them ...). One way to fix this check is :
    if ((MaskBar == ~Mask) && (Offset <= 31) && Mask && ((Size == 32)? (Mask == 0xffffffff) : ((unsigned int) (((1<<Size) - 1) << Offset) == Mask))) return 1;
    5. lines 463, 465, 470, 472, 477, 479, 484, 486, 491, 493, 498, 500, 505, 507, the valid CSR addresses range from 0 to 4095 ^^.

  • riscv.c
    1. lines 2587 and 2591, report clip modification to allow N == 30;
    2. line 2608, add checks :
    if (!val && !val1) return 1; if (!val) return 0;
    to align with all norm and round from immediate args modification.

All suggested modifications have been implemented and tested.

Thank you !

CSRW Instruction error during compilation using PULP-RISC-V toolchain

Hello! I'm having an issue when I try to compile an OS using the PULP-RISC-V toolchain. During the process, I've reached this Error: Instruction csrw requires absolute expression.
The mentioned function is the following:

static inline void rv32gc_satp_write(rv32gc_word_t val)
{
asm volatile(
"csrw satp, %0;"
:
: "r" (val)
);
}

make error on CentOS 7.5

./configure --prefix=/home/wsun/riscv --with-arch=rv32imc --with-cmodel=medlow --enable-multilib
make
make[3]: Entering directory /home/wsun/work/github/pulp-riscv-gnu-toolchain/build-binutils-newlib/sim' /home/wsun/riscv make[4]: Entering directory /home/wsun/riscv'
make[4]: *** No targets specified and no makefile found. Stop.
make[4]: Leaving directory /home/wsun/riscv' make[3]: *** [all] Error 1 make[3]: Leaving directory /home/wsun/work/github/pulp-riscv-gnu-toolchain/build-binutils-newlib/sim'
make[2]: *** [all-sim] Error 2
make[2]: Leaving directory /home/wsun/work/github/pulp-riscv-gnu-toolchain/build-binutils-newlib' make[1]: *** [all] Error 2 make[1]: Leaving directory /home/wsun/work/github/pulp-riscv-gnu-toolchain/build-binutils-newlib'
make: *** [stamps/build-binutils-newlib] Error 2

Makefile:524: *** missing separator. Stop.

Hi, thanks for your job,
i encountered a error when i ran"make" after "./configure --prefix=/opt/riscv --with-arch=rv32imc --with-cmodel=medlow --enable-multilib" . The error snippet is shown below:


make -C build-binutils-newlib
make[1]: Entering directory /root/risc-v/pulp-riscv-gnu-toolchain/build-binutils-newlib' Makefile:524: *** missing separator. Stop. make[1]: Leaving directory /root/risc-v/pulp-riscv-gnu-toolchain/build-binutils-newlib'
make: *** [stamps/build-binutils-newlib] Error 2


I've tested it on Ubuntu and centos.
I would appreciate it if you could give me some help.

Compile application for Ariane

Hello
the new toolchain is a little bit confusing sorry.
If I want to compile c code to run with on Ariane core knowing that I might use floaiting point in the code. which option should I use to build the toolchain. is this ok:
./configure --prefix=/opt/riscv --with-arch=rv32imc --with-cmodel=medlow --enable-multilib make
or I should use:
./configure --prefix=/opt/riscv --with-arch=rv64g --with-cmodel=medlow --enable-multilib

Thank you

make error

In file included from /home/potato/Desktop/tool/ri5cy_gnu_toolchain/build/src/newlib-gcc/gcc/cp/except.c:1023:0:
cfns.gperf: In function ‘const char* libc_name_p(const char*, unsigned int)’:
cfns.gperf:101:1: error: ‘const char* libc_name_p(const char*, unsigned int)’ redeclared inline with ‘gnu_inline’ attribute
cfns.gperf:26:14: note: ‘const char* libc_name_p(const char*, unsigned int)’ previously declared here
cfns.gperf: At global scope:
cfns.gperf:26:14: warning: inline function ‘const char* libc_name_p(const char*, unsigned int)’ used but never defined
Makefile:1064: recipe for target 'cp/except.o' failed
make[4]: *** [cp/except.o] Error 1
make[4]: Leaving directory '/home/potato/Desktop/tool/ri5cy_gnu_toolchain/build/build-gcc-newlib/gcc'
Makefile:4112: recipe for target 'all-gcc' failed
make[3]: *** [all-gcc] Error 2
make[3]: Leaving directory '/home/potato/Desktop/tool/ri5cy_gnu_toolchain/build/build-gcc-newlib'
Makefile:867: recipe for target 'all' failed
make[2]: *** [all] Error 2
make[2]: Leaving directory '/home/potato/Desktop/tool/ri5cy_gnu_toolchain/build/build-gcc-newlib'
Makefile:214: recipe for target 'stamps/build-gcc-newlib' failed
make[1]: *** [stamps/build-gcc-newlib] Error 2
make[1]: Leaving directory '/home/potato/Desktop/tool/ri5cy_gnu_toolchain/build'
Makefile:28: recipe for target 'build' failed
make: *** [build] Error 2

Making hardware loop feature optional in the tool chain

Hi PULP team,

In the CV32E40P (aka RI5CY) the 'hardware loop' feature (related to the lpstart0, lpend0, lpcount0, lpstart1, lpend1, lpcount1 CSRs) will still be supported, but it has been decided to make it an optional feature, i.e. based on a top level RTL parameter. (FYI: The parameter discussion for CV32E40P is summarized in this document: https://github.com/openhwgroup/core-v-docs/blob/master/cores/cv32e40p/CV32E40P_and%20CV32E40_Features_Parameters.pdf)

Soon we expect to include this parameterization in the RTL (openhwgroup/cv32e40p#327).

Could you please make sure that the hardware loop feature becomes an optional part of the tool chain as well (controllable from the command line)? Reason is that users who use a CV32E40P with PULP_HWLP=0 would experience illegal instructions otherwise (if their compiled code would still contain hardware loop based constructs).

Best regards,
Arjan

Compiler behaves unexpectedly

Hi,

There are some problems encountered here. During the calculation of the unsign memory load behavior, it was found that the behavior of the compiler may be wrong through the analysis of the assembly.

Related C code test.c :
#include <stdio.h>unsigned int sum_output = 0;int main() {unsigned int MEM[][2] = { {0x1000,0x1000}, {0x1000,0x1000},{0x1000,0x1000}, {0x1000,0x1000}, }; for (unsigned char data = 0x7F; data < 0xFF; data ++) { for (unsigned int i = 0; i < sizeof(MEM) / 4 / 2; i++) { volatile unsigned char *address = (unsigned char *)MEM[i][0]; for (unsigned int j = 0; j < (MEM[i][1] - MEM[i][0]) / sizeof(unsigned char) + 1; j++) { asm volatile("nop;nop;"); asm volatile("nop;nop;"); sum_output += address[j]; asm volatile("nop;nop;"); asm volatile("nop;nop;"); } } } return 0;}

format edit by bluew:

#include <stdio.h>

unsigned int sum_output = 0;
int main() {
   unsigned int MEM[][2] = {
   {0x1000,0x1000},
   {0x1000,0x1000},
   {0x1000,0x1000},
   {0x1000,0x1000}, };
   for (unsigned char data = 0x7F; data < 0xFF; data ++) {
       for (unsigned int i = 0; i < sizeof(MEM) / 4 / 2; i++) {
           volatile unsigned char *address = (unsigned char *)MEM[i][0];
           for (unsigned int j = 0; j < (MEM[i][1] - MEM[i][0]) / sizeof(unsigned char) + 1; j++) {
               asm volatile("nop;nop;"); asm volatile("nop;nop;");
               sum_output += address[j];
               asm volatile("nop;nop;"); asm volatile("nop;nop;");
           }
       }
    }
    return 0;
}

Compiler Version : Release Label v1.0.16-pulp-riscv-gcc
https://github.com/pulp-platform/pulp-riscv-gnu-toolchain/releases/download/v1.0.16/v1.0.16-pulp-riscv-gcc-ubuntu-16.tar.bz2

**The analysis process is as follows:
Step 1(original) :
riscv32-unknown-elf-gcc -O2 -march=rv32IMCXpulpv2 -Wa,-march=rv32IMCXpulpv2 -Wextra -Wall -Wno-unused-function -fmerge-all-constants -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections -fdiagnostics-color=always -fstack-usage -nostartfiles -fsigned-char -Wno-pointer-sign -Wl,--no-check-sections -Wl,--gc-sections -Wall -Werror -Wno-shift-negative-value -Wno-unused-but-set-variable -Wno-unused-variable -msave-restore -c test.c -o test.o
image

Note : I used "unsigned char *" assigned to memory, but assembly use 'p.lb' not 'p.lbu' This instruction has a sign extension behavior, so use the instruction will cause a1 register value error, when value >= 0x80, because 0x80 will sign extension to 0xFFFF_FF80,The next operation(add/sub....) will cause an error result.

Step 2 ("unsigned char *" modify to "unsigned short *") :
riscv32-unknown-elf-gcc -O2 -march=rv32IMCXpulpv2 -Wa,-march=rv32IMCXpulpv2 -Wextra -Wall -Wno-unused-function -fmerge-all-constants -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections -fdiagnostics-color=always -fstack-usage -nostartfiles -fsigned-char -Wno-pointer-sign -Wl,--no-check-sections -Wl,--gc-sections -Wall -Werror -Wno-shift-negative-value -Wno-unused-but-set-variable -Wno-unused-variable -msave-restore -c test.c -o test.o
image

Note : Assembly behaves as expected use 'p.lhu'

Step 3 (change -march to original RISCV32) :
riscv32-unknown-elf-gcc -O2 -march=rv32IMC -Wa,-march=rv32IMC -Wextra -Wall -Wno-unused-function -fmerge-all-constants -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fdata-sections -ffunction-sections -fdiagnostics-color=always -fstack-usage -nostartfiles -fsigned-char -Wno-pointer-sign -Wl,--no-check-sections -Wl,--gc-sections -Wall -Werror -Wno-shift-negative-value -Wno-unused-but-set-variable -Wno-unused-variable -msave-restore -c test.c -o test.o
image

Note : Assembly behaves as expected use 'lbu'

Conclusion :
Through the above three experiments, can find Compiler behaves unexpectedly on above programming method.

Please help clarify whether this situation is correct

build failed when compile gdb - python.c, logs below.

[ ubuntu-22.04.2LTS gcc-11.3.0(default) ]
-git clone https://github.com/pulp-platform/pulp-riscv-gnu-toolchain
-cd pulp-riscv-gnu-toolchain/
-git submodule update --init --recursive
-./configure --prefix=/opt/pupl_riscv --enable-multilib
-make linux
=== compile log :

/opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/btrace.h:84:1: note: in expansion of macro ‘DEF_VEC_O’
84 | DEF_VEC_O (btrace_insn_s);
| ^~~~~~~~~
In file included from /opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/target.h:74,
from /opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/progspace.h:24,
from /opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/python/python.c:26:
/opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/btrace.h:67:8: note: ‘btrace_insn_s’ {aka ‘struct btrace_insn’} declared here
67 | struct btrace_insn
| ^~~~~~~~~~~
/opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/python/python.c: In function ‘void _initialize_python()’:
/opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/python/python.c:1739:22: warning: ‘void PyEval_InitThreads()’ is deprecated [-Wdeprecated-declarations]
1739 | PyEval_InitThreads ();
| ~~~~~~~~~~~~~~~~~~~^~
In file included from /usr/include/python3.10/Python.h:130,
from /opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/python/python-internal.h:94,
from /opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/python/python.c:94:
/usr/include/python3.10/ceval.h:122:37: note: declared here
122 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
| ^~~~~~~~~~~~~~~~~~
/opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/python/python.c:1744:26: error: too few arguments to function ‘int _PyImport_FixupBuiltin(PyObject*, const char*, PyObject*)’
1744 | _PyImport_FixupBuiltin (gdb_module, "_gdb");
| ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/python3.10/import.h:91,
from /usr/include/python3.10/Python.h:134,
from /opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/python/python-internal.h:94,
from /opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/python/python.c:94:
/usr/include/python3.10/cpython/import.h:19:17: note: declared here
19 | PyAPI_FUNC(int) _PyImport_FixupBuiltin(
| ^~~~~~~~~~~~~~~~~~~~~~
/opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/python/python.c:1845:22: warning: ‘void PyEval_ReleaseLock()’ is deprecated [-Wdeprecated-declarations]
1845 | PyEval_ReleaseLock ();
| ~~~~~~~~~~~~~~~~~~~^~
In file included from /usr/include/python3.10/Python.h:130,
from /opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/python/python-internal.h:94,
from /opt/Riscv/snitch/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/python/python.c:94:
/usr/include/python3.10/ceval.h:128:37: note: declared here
128 | Py_DEPRECATED(3.2) PyAPI_FUNC(void) PyEval_ReleaseLock(void);
| ^~~~~~~~~~~~~~~~~~
make[3]: *** [Makefile:1891: python.o] Error 1
make[3]: Leaving directory '/opt/Riscv/snitch/pulp-riscv-gnu-toolchain/build-binutils-linux/gdb'
make[2]: *** [Makefile:10456: all-gdb] Error 2
make[2]: Leaving directory '/opt/Riscv/snitch/pulp-riscv-gnu-toolchain/build-binutils-linux'
make[1]: *** [Makefile:851: all] Error 2
make[1]: Leaving directory '/opt/Riscv/snitch/pulp-riscv-gnu-toolchain/build-binutils-linux'
make: *** [Makefile:91: stamps/build-binutils-linux] Error 2

Incremental compilation and installation w/o root

Hi,
the top-level makefile does not only compile but also (tries to) install everything. Moreover, it does start all over again because it removes all previous compilation results. This is not the typical Unix workflow at all and very annoying. It would be better if (at least optionally) the install step could be triggered individually and previous compilation results are not cleaned unconditionally on each run.

where is bin folder?

Hello,everyone.When I do this step"export PULP_RISCV_GCC_TOOLCHAIN=".
I can't found bin folder in toolchain,please help!

objdump issue on p.abs-->p.avg ; p.subRNr-->p.mac.zh.sh ; p.adduRNr" --> "p.mac.sh.sl

following are compiling 3 issues we have encountered using objdump:

  1. the following code:
    p.abs x4, x3
    is turning to
    80000082: 04018233 p.avg tp,gp,zero

  2. p.subrnr into p.mac.zh.sh
    Original code:

               c.addi a5, -22
               p.subrnr a3, sp, gp
               and s0, a0, a0
    

Disassembled code:

8000014a:
17a9 addi
a5,a5,-22
8000014c:
403176db p.mac.zh.sh
a3,sp,gp,zero
80000150:
00a57433 and
s0,a0,a0

  1. Instruction "p.adduRNr" Somehow become "p.mac.sh.sl"

Original code:
xori a4, s4, -576
p.addurnr a2, t6, t6
p.subun t0, tp, a7, 17

coremark result

Is there coremark result using this new toolchain? Thanks.

make problem

Hello, thank you for your work. I'm trying to build the Newlib cross-compiler for all pulp variants following the instructions under the section Installation (Pulp), but when I issue the command make i obtain the following error:
image

I'm using xubuntu 16.04.
Can someone help me?

Thanks for your help.

Incorrect CSR mnemonics

Several CSR mnemonics are incorrect. See the various requested fixes below.

I’m compiling with the following options for CV32E40P (aka RI5CY):
-march=rv32imc -w -Os -g -nostdlib - -static -I $RISCV_TOOL_DIR/riscv32-unknown-elf/include -L $RISCV_TOOL_DIR/lib -lc -lm -lgcc
Github tag: v1.0.16

FIX 1: Standard mnemonics not found:

(I would assume we want these all fixed regardless of being used in RI5CY or CV32E40P)

ustatus		(note 1)
uie
utvec		(note 1)
uscratch
uepc		(note 1)
ucause		(note 1)
utval
uip
mtval		(note2)
mcountinhibit	(note 2) 
dscratch0	(note 3,note4)
dscratch1	(note 3)

Note 1: Implemented in RI5CY, not needed for CV32E40P
Note 2: Not implemented in RI5CY, will be needed for CV32E40P
Note 3: Implemented in RI5CY and needed for CV32E40P
Note 4: dscratch is implemented and maps to dscratch0

FIX 2: Custom RI5CY/CV32E40P mnemonics not found

lpstart0	0x800
lpend0		0x801
lpcount0	0x802
lpstart1	0x804
lpend1		0x805
lpcount1	0x806
mie1		0x7D0
mip1		0x7D1
uhartid		0xCC0
privlv		0xCC1
fprec		0x807
pcer_user	0xCC0	(note 5)
pcmr_user	0xCC1 	(note 5)
pcer_machine	0x7E0 	(note 5)
pcmr_machine	0x7E1 	(note 5)
pccr0		0x780 	(note 5)
…
pccr31         	0x79F 	(note 5)

Note 5: These registers may not be needed in CV32E40P since replacing with RISC-V performance counters

FIX3: mnemonics that have incorrect names out of dissembler:

csrr t2, hpmcounter16	->	csrr t2,privlv
csrr t2, tselect	->	csrr t2, pcer
csrr t2, tdata1 	->	csrr t2, pcmr
csrr t2, dcsr 		->	csrr t2, lpstart0
csrr t2, dpc 		->	csrr t2, lpend0

FIX4: mnemonics that have ‘slightly’ incorrect names out of dissembler:

csrr t2, fflags	->	frflags t2
csrr t2, frm	->	frrm t2
csrr t2, fcsr	->	frsr t2
csrr t2, cycle	->	rdcycle t2
csrr t2, time	->	rdtime t2
csrr t2, instret->	rdinstret t2
csrr t2, cycleh	->	rdcycleh t2
csrr t2, timeh	->	rdtimeh t2
csrr t2, instreth->	rdinstreth t2

OK: mnemonics that have correct names out of dissembler:

csrr t2, mhartid ->	csrr t2, mhartid
csrr t2, mstatus ->	csrr t2, mstatus
csrr t2, mtvec	->	csrr t2, mtvec
csrr t2, mepc	 ->	csrr t2, mepc
csrr t2, mcause	 ->	csrr t2, mcause

FIX5: The remaining mnemonics simply get converted to an address as opposed to mnemonics.

For example, csrr t2, mie -> csrr t2, 0x304

facing error in gcc toolchain

I was running below command to genearte hex file, but its shiw error(command not found
command_error
)

command:
riscv64-unknown-elf-gcc -Ofast -mabi=lp64 -march=rv64i -o hello-world.o hello-world.c

in make

            from /home/Desktop/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/defs.h:28,
             from /home/Desktop/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/gdb/gdb.c:19:

/usr/include/c++/7/bits/stl_algo.h: In function ‘_ForwardIterator std::__stable_partition(_ForwardIterator, _ForwardIterator, _Predicate)’:
/usr/include/c++/7/bits/stl_algo.h:1624:7: error: ‘_Temporary_buffer’ was not declared in this scope
_Temporary_buffer<_ForwardIterator, _ValueType> __buf(__first, __last);
^~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_algo.h:1624:41: error: expected primary-expression before ‘,’ token
_Temporary_buffer<_ForwardIterator, _ValueType> __buf(__first, __last);
^
/usr/include/c++/7/bits/stl_algo.h:1624:53: error: expected primary-expression before ‘>’ token
_Temporary_buffer<_ForwardIterator, _ValueType> __buf(__first, __last);
^
/usr/include/c++/7/bits/stl_algo.h:1627:21: error: ‘__buf’ was not declared in this scope
_DistanceType(__buf.requested_size()),
^~~~~
/usr/include/c++/7/bits/stl_algo.h:1627:21: note: suggested alternative: ‘__wur’
_DistanceType(__buf.requested_size()),
^~~~~
__wur
/usr/include/c++/7/bits/stl_algo.h: In function ‘void std::__inplace_merge(_BidirectionalIterator, _BidirectionalIterator, _BidirectionalIterator, _Compare)’:
/usr/include/c++/7/bits/stl_algo.h:2542:15: error: ‘_Temporary_buffer’ does not name a type
typedef _Temporary_buffer<_BidirectionalIterator, _ValueType> _TmpBuf;
^~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_algo.h:2543:7: error: ‘_TmpBuf’ was not declared in this scope
_TmpBuf __buf(__first, __last);
^~~~~~~
/usr/include/c++/7/bits/stl_algo.h:2545:11: error: ‘__buf’ was not declared in this scope
if (__buf.begin() == 0)
^~~~~
/usr/include/c++/7/bits/stl_algo.h:2545:11: note: suggested alternative: ‘__wur’
if (__buf.begin() == 0)
^~~~~
__wur
/usr/include/c++/7/bits/stl_algo.h: In function ‘void std::__stable_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare)’:
/usr/include/c++/7/bits/stl_algo.h:5002:15: error: ‘_Temporary_buffer’ does not name a type
typedef _Temporary_buffer<_RandomAccessIterator, _ValueType> _TmpBuf;
^~~~~~~~~~~~~~~~~
/usr/include/c++/7/bits/stl_algo.h:5003:7: error: ‘_TmpBuf’ was not declared in this scope
_TmpBuf __buf(__first, __last);
^~~~~~~
/usr/include/c++/7/bits/stl_algo.h:5005:11: error: ‘__buf’ was not declared in this scope
if (__buf.begin() == 0)
^~~~~
/usr/include/c++/7/bits/stl_algo.h:5005:11: note: suggested alternative: ‘__wur’
if (__buf.begin() == 0)
^~~~~
__wur
Makefile:1854: recipe for target 'gdb.o' failed
make[3]: *** [gdb.o] Error 1
make[3]: Leaving directory '/home/uie24011/Desktop/pulp-riscv-gnu-toolchain/build-binutils-newlib/gdb'
Makefile:10454: recipe for target 'all-gdb' failed
make[2]: *** [all-gdb] Error 2
make[2]: Leaving directory '/home/uie24011/Desktop/pulp-riscv-gnu-toolchain/build-binutils-newlib'
Makefile:849: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/uie24011/Desktop/pulp-riscv-gnu-toolchain/build-binutils-newlib'
Makefile:210: recipe for target 'stamps/build-binutils-newlib' failed
make: *** [stamps/build-binutils-newlib] Error 2

How to add custom instruction to this pulp-riscv-gnu-toolchain

Hi.

I slightly modify the cv32e40p so I need to add custom instruction to this gcc.
It is enough if I can use inline assembly which is named to be built-in in paper.

like volatile asm {
instrucitons;
}

I try to follow this tutorial https://nitish2112.github.io/post/adding-instruction-riscv/
but I think I don't have to use riscv-tools and It would be better if I can choose MATCH_CUSTOM and MASK_CUSTOM.
It would be better if you can let me know how to fill the filed in the appropriate way.

Can you help me? or please tell me where to start.

Thanks.

HW loop compact instruction restriction

Can assembly code to implement HW loops be restricted to 32 bit instructions,
For instance, if a NOP is written can it be enforced to be 32 bits.
How to verifity the eventual compiler restrictions.

Gdb fails to build with Python 3.7

Hi.

Building pulp-platform/pulp-riscv-gnu-toolchain errors out when I compile on arch linux.
It seems you have the same problem as riscv/riscv-binutils-gdb has:
riscvarchive/riscv-binutils-gdb#161

"With Python 3.7, gdb fails to build because it uses internal-only function _PyImport_FixupBuiltin whose signature has changed."

Regards Robin.

make error with --with-arch=rv32imcf

Hi, I'm trying to build the compiler with --with-arch=rv32imcf, but I get the error. (Platform: pulpissimo)
error
I use the following code:
void test_floating() { float i, j; i = 0.6; j = 0.7; j = j + i; }
Dump this to assembly code, I can't find floating point instruction.
Do I miss some configuration about this compiler or pulp-sdk?

Thanks in advance.

Unrecognized opcode 'lwu'

Hi,

while compiling the toolchain under CentOS (installed in a docker) with the following options

./configure --prefix=/opt/riscv --with-arch=rv32g --with-abi=ilp32d
make linux

I got this error

/home/masgia01/Designs/pulp-riscv-gnu-toolchain/build-gcc-linux-stage1/./gcc/xgcc -B/home/masgia01/Designs/pulp-riscv-gnu-toolchain/build-gcc-linux-stage1/./gcc/ -B/opt/riscv/riscv32-unknown-linux-gnu/bin/ -B/opt/riscv/riscv32-unknown-linux-gnu/lib/ -isystem /opt/riscv/riscv32-unknown-linux-gnu/include -isystem /opt/riscv/riscv32-unknown-linux-gnu/sys-include    -g -O2 -O2  -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -fPIC -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc  -fPIC -I. -I. -I../.././gcc -I/home/masgia01/Designs/pulp-riscv-gnu-toolchain/riscv-gcc/libgcc -I/home/masgia01/Designs/pulp-riscv-gnu-toolchain/riscv-gcc/libgcc/. -I/home/masgia01/Designs/pulp-riscv-gnu-toolchain/riscv-gcc/libgcc/../gcc -I/home/masgia01/Designs/pulp-riscv-gnu-toolchain/riscv-gcc/libgcc/../include  -DHAVE_CC_TLS  -o unwind-dw2.o -MT unwind-dw2.o -MD -MP -MF unwind-dw2.dep -fexceptions -c /home/masgia01/Designs/pulp-riscv-gnu-toolchain/riscv-gcc/libgcc/unwind-dw2.c -fvisibility=hidden -DHIDE_EXPORTS
/tmp/ccbEgsyR.s: Assembler messages:
/tmp/ccbEgsyR.s:4954: Error: unrecognized opcode `lwu a1,.LANCHOR0+2'
/tmp/ccbEgsyR.s:5170: Error: unrecognized opcode `lwu a5,.LANCHOR0'
/tmp/ccbEgsyR.s:5249: Error: unrecognized opcode `lwu a4,.LANCHOR0+2'
/tmp/ccbEgsyR.s:5896: Error: unrecognized opcode `lwu a2,.LANCHOR0+2'
/tmp/ccbEgsyR.s:5988: Error: unrecognized opcode `lwu a3,.LANCHOR0+2'
make[2]: *** [unwind-dw2.o] Error 1
make[2]: Leaving directory `/home/masgia01/Designs/pulp-riscv-gnu-toolchain/build-gcc-linux-stage1/riscv32-unknown-linux-gnu/libgcc'
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory `/home/masgia01/Designs/pulp-riscv-gnu-toolchain/build-gcc-linux-stage1'
make: *** [stamps/build-gcc-linux-stage1] Error 2

Is this expected?
How could I solve the problem?

Thanks

Build fails on mac while compiling readline

I am compiling on MacOS Catalina...10.15.7

Cloned toolchain from.

git clone --recursive https://github.com/pulp-platform/pulp-riscv-gnu-toolchain

Configured using..

./configure --prefix=/opt/riscv --with-arch=rv32imc --with-cmodel=medlow --enable-multilib

Build fails during compiling readline

..
gcc -c -DHAVE_CONFIG_H    -I. -I/Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline -DRL_LIBRARY_VERSION='"6.2"' -g -O2 /Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline/readline.c
rm -f vi_mode.o
gcc -c -DHAVE_CONFIG_H    -I. -I/Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline -DRL_LIBRARY_VERSION='"6.2"' -g -O2 /Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline/vi_mode.c
rm -f funmap.o
gcc -c -DHAVE_CONFIG_H    -I. -I/Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline -DRL_LIBRARY_VERSION='"6.2"' -g -O2 /Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline/funmap.c
rm -f keymaps.o
gcc -c -DHAVE_CONFIG_H    -I. -I/Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline -DRL_LIBRARY_VERSION='"6.2"' -g -O2 /Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline/keymaps.c
rm -f parens.o
gcc -c -DHAVE_CONFIG_H    -I. -I/Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline -DRL_LIBRARY_VERSION='"6.2"' -g -O2 /Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline/parens.c
rm -f search.o
gcc -c -DHAVE_CONFIG_H    -I. -I/Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline -DRL_LIBRARY_VERSION='"6.2"' -g -O2 /Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline/search.c
rm -f rltty.o
gcc -c -DHAVE_CONFIG_H    -I. -I/Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline -DRL_LIBRARY_VERSION='"6.2"' -g -O2 /Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline/rltty.c
/Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline/rltty.c:83:7: error: implicit declaration of function 'ioctl' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
  if (ioctl (tty, TIOCGWINSZ, &w) == 0)
      ^
/Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline/rltty.c:720:3: error: implicit declaration of function 'ioctl' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
  ioctl (fildes, TIOCSTART, 0);
  ^
/Users/venkat/work/pp/vega/tool_chain_build2/pulp-riscv-gnu-toolchain/riscv-binutils-gdb/readline/rltty.c:759:3: error: implicit declaration of function 'ioctl' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
  ioctl (fildes, TIOCSTOP, 0);
  ^
3 errors generated.
make[3]: *** [rltty.o] Error 1
make[2]: *** [all-readline] Error 2
make[1]: *** [all] Error 2

objdump issue with dcsr

found issue with register address decoding in csrw instruction when we used objdump tool.
Here is original source code:

_start:
li x1, 0x9107
csrw dcsr, x1

Part of objdump output:

80000094 <_start>:
_start():
80000094:
000090b7 lui
ra,0x9
80000098:
10708093 addi
ra,ra,263 # 9107 <_start_exp-0x7fff6ef9>
8000009c:
7b009073 csrw
lpstart0,ra

it seems like dcsr register was decoded as lpstart0 in this case.

Potential GP_REG t6 (x31) prologue/epilogue save to stack issue in pulp-riscv-gcc/gcc/config/riscv/riscv.c

Hi,
There might be a minor issue related to prologue and epilogue GP registers saving:

Context

I was trying to remove the limitation related to the ISRs regarding functions calls, that is to say allowing such calls at my own risk. I reasoned that I should save all caller-saved regs instead on simply the ones used by the ISR. I managed to do so but was a bit puzzled as t6 (x31) did not appear as part of the regs saved to the stack during my ISR prologue (and respectively retrieved from it during the epilogue).

Issue

I found at lines 4233 (riscv_for_each_saved_reg), 4365 (riscv_adjust_lib_call_cfi_prologue) and 4506 (riscv_adjust_lib_call_cfi_epilogue) a "for" loop that might contain a typo:
for (int regno = GP_REG_FIRST; regno <= GP_REG_LAST-1; regno++)

Trial

I did not know if it was done purposefully but anyway made the following modification:
for (int regno = GP_REG_FIRST; regno <= GP_REG_LAST; regno++)
This time t6 was saved on the stack.

Thank you !

using release or building from source code?

i am kind of new to RISC-V and other toolchains

I cloned this repo, in order to use for pulpino SoC

I then build the toolchain, well from handling minor error issues and then building the system took like 2-3 hours.

Instead of this, is there any difference using ubuntu release? If I am not wrong, to use release build, I just download the tar, unrar it to opt folder and that's it ???

Thanks,

ebreak instruction always assembles to the 16bit compressed version

This issue is a low priority request.

The ebreak instruction seems to always be assembled into the 16bit c.ebreak instruction. This happens regardless of removing the -c option flag.

Also, what is the expectation of ebreak when -c option is set? Should it be 32bit or 16bit.

Error in installing the riscv gnu tool chain

While runing the installing for riscv tools as below:

./configure --prefix=./pulp/riscv_install --with-arch=rv32imc --with-cmodel=medlow --enable-multilib
Make

I see below error:
checking for riscv32-unknown-elf-gcc... ./pulp/pulp-riscv-gnu-toolchain/build-gcc-newlib-stage2/./gcc/xgcc -B./pulp/pulp-riscv-gnu-toolchain/build-gcc-newlib-stage2/./gcc/ -B./pulp/riscv_install/riscv32-unknown-elf/bin/ -B./pulp/riscv_install/riscv32-unknown-elf/lib/ -isystem ./pulp/riscv_install/riscv32-unknown-elf/include -isystem ./pulp/riscv_install/riscv32-unknown-elf/sys-include
checking for suffix of object files... configure: error: in ./pulp/pulp-riscv-gnu-toolchain/build-gcc-newlib-stage2/riscv32-unknown-elf/libgcc': configure: error: cannot compute suffix of object files: cannot compile See config.log' for more details.
make[2]: *** [configure-target-libgcc] Error 1
make[2]: Leaving directory /home/amgarg/project/Portaskela/SOC/pulp/pulp-riscv-gnu-toolchain/build-gcc-newlib-stage2' make[1]: *** [all] Error 2 make[1]: Leaving directory /home/amgarg/project/Portaskela/SOC/pulp/pulp-riscv-gnu-toolchain/build-gcc-newlib-stage2'
make: *** [stamps/build-gcc-newlib-stage2] Error 2

Any idea ?

make error on windows10

hi,
I 'm try to build the compiler on msys2, but when I got to the Installation (Pulp), I got the error

msys2_error

so, do you know how to make it?

Difference to pulp-platform/riscv-gnu-toolchain

When working with this toolchain I stumbled across strange behavior i.e. restrictions on function calls in functions annotated for interrupts.
Upon further investigation, I noticed that there is another riscv-gnu-toolchain repository on the pulp-platform organization, which was updated more recently than this variant.
This variant of the toolchain for example fixed the issue I was having.

What is the difference between these two toolchains? Is there any good reason not to merge them into a single repository for a better overview?

CC @micprog @bluewww

la tp,0' instruction and why it is not allowed in pulp-riscv compiler

we encountered an issue with `la tp,0' instruction

pulp-riscv compiler mark it as illegal.

taken from the spec(RISC-V Unprivileged ISA p.139):
la rd, symbol (PIC ) auipc rd, delta[31 : 12] + delta[11] Load absolute address

page 20 - regarding AUIPC (add upper immediate to pc) instruction:
command syntax is-
U-immediate[31:12] dest AUIPC

The current PC can be obtained by setting the U-immediate to 0. Although a JAL +4
instruction could also be used to obtain the local PC (of the instruction following the JAL),
it might cause pipeline breaks in simpler microarchitectures or pollute BTB structures in more
complex microarchitectures.

so it seems like a correct synatx, but perhaps not implemented in ri5cy?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.