rv32g linux gcc,CNRV/riscv-gnu-toolchain

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/riscv/riscv-gnu-toolchain

Alternatively :

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

$ cd 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 (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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值