Go to file
Rui Huang 37b9dd4d77
Add windows toolchain compile command
./configure --prefix=/opt/kendryte-toolchain --host=i686-w64-mingw32 --with-host=i686-w64-mingw32 --with-cmodel=medany --with-arch=rv64imafc --with-abi=lp64f LDFLAGS="-static" --without-system-zlib
2019-04-12 15:20:44 +08:00
linux-headers/include Update to gcc 8.2.0 2018-10-23 11:34:46 +08:00
regression Add many "build-*" targets 2017-11-03 18:42:44 -07:00
riscv-binutils-gdb@00f223631f Update to gcc 8.2.0 2018-10-23 11:34:46 +08:00
riscv-gcc@5b254d7c60 Fix building problem on OSX with new isl 0.20 2019-03-25 15:47:42 +08:00
riscv-newlib@01de41f55e Update newlib 2019-02-12 21:01:14 +08:00
scripts Fail mail_tail when make fails 2017-09-22 17:09:38 -07:00
test Whitelist a log1p failure in newlib 2017-12-16 10:19:15 -08:00
.gitignore Add a local regression Makefile 2017-10-25 15:54:56 -07:00
.gitmodules Enable libatomic 2018-11-06 20:18:54 +08:00
.travis.yml Don't run the glibc tests for now 2017-10-10 17:44:29 -07:00
LICENSE Add license 2016-04-20 14:02:45 -07:00
Makefile.in Enable libatomic 2018-11-06 20:18:54 +08:00
README.md Add windows toolchain compile command 2019-04-12 15:20:44 +08:00
configure modify cmodel 2018-04-12 12:12:40 +00:00
configure.ac Split the glibc and newlib multilib names in the Makefile 2017-09-13 16:48:58 -07:00

README.md

Kendryte RISC-V GNU Compiler Toolchain

This is the Kendryte 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/kendryte/kendryte-gnu-toolchain

Alternatively :

$ git clone https://github.com/kendryte/kendryte-gnu-toolchain
$ cd kendryte-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 libexpat-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 expat-devel

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

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

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/kendryte-toolchain, then add /opt/kendryte-toolchain/bin to your PATH now. Then, simply run the following command:

./configure --prefix=/opt/kendryte-toolchain --with-cmodel=medany --with-arch=rv64imafc --with-abi=lp64f
make -j8

You should now be able to use riscv64-unknown-elf-gcc and its cousins.

  • Linux

Ensure you have write access to /opt/kendryte-toolchain

./configure --prefix=/opt/kendryte-toolchain --with-cmodel=medany --with-arch=rv64imafc --with-abi=lp64f

make -j8

Static link some libraries:

git clone --recursive https://github.com/kendryte/kendryte-gnu-toolchain
cd kendryte-gnu-toolchain
cd riscv-gcc
./contrib/download_prerequisites
cd ..
./configure --prefix=/opt/kendryte-toolchain --with-cmodel=medany --with-arch=rv64imafc --with-abi=lp64f
make -j8
  • OSX
./configure --prefix=/usr/local/opt/kendryte-toolchain --with-cmodel=medany --with-arch=rv64imafc --with-abi=lp64f
make -j8
  • Windows

Must cross-compile under linux using mingw.

Install mingw.

sudo apt install binutils-mingw-w64 binutils-mingw-w64-i686 binutils-mingw-w64-x86-64 g++-mingw-w64 g++-mingw-w64-i686 g++-mingw-w64-x86-64 gcc-mingw-w64 gcc-mingw-w64-base gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 libz-mingw-w64-dev mingw-w64-common mingw-w64-i686-dev mingw-w64-x86-64-dev

Hack the zlib.

xz -9 /usr/i686-w64-mingw32/lib/libz.dll.a
xz -9 /usr/i686-w64-mingw32/lib/zlib1.dll

Compile expat-2.2.6

apt install docbook2x

export CC=i686-w64-mingw32-gcc
export CXX=i686-w64-mingw32-g++

./configure --prefix=/usr/i686-w64-mingw32 --host=i686-w64-mingw32 --disable-shared --enable-static LDFLAGS="-static"
make -j16
make install

Compile make-4.2

export CHOST=i686-w64-mingw32
export CC=i686-w64-mingw32-gcc
export CXX=i686-w64-mingw32-g++

./configure --host=i686-w64-mingw32 --prefix=/opt/kendryte-toolchain LDFLAGS="-static"
ln -s glob/glob.h .
make -j16
make install

Compile toolchain

export CHOST=i686-w64-mingw32

git clone --recursive https://github.com/kendryte/kendryte-gnu-toolchain
cd kendryte-gnu-toolchain
cd riscv-gcc
./contrib/download_prerequisites
cd ..
./configure --prefix=/opt/kendryte-toolchain --host=i686-w64-mingw32 --with-host=i686-w64-mingw32 --with-cmodel=medany --with-arch=rv64imafc --with-abi=lp64f LDFLAGS="-static" --without-system-zlib
make -j16

Advanced Options

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