https://github.com/riscv-collab/riscv-gnu-toolchain
国内的镜像地址:
https://gitee.com/mirrors/riscv-gnu-toolchain.git
几个 riscv-* 子模块的 gitee 镜像地址:
Submodule 'riscv-binutils' (https://gitee.com/mirrors/riscv-binutils-gdb.git) registered for path 'riscv-binutils'
Submodule 'riscv-dejagnu' (https://gitee.com/mirrors/riscv-dejagnu.git) registered for path 'riscv-dejagnu'
Submodule 'riscv-gcc' (https://gitee.com/mirrors/riscv-gcc.git) registered for path 'riscv-gcc'
Submodule 'riscv-gdb' (https://gitee.com/mirrors/riscv-binutils-gdb.git) registered for path 'riscv-gdb'
Submodule 'riscv-glibc' (https://gitee.com/mirrors/riscv-glibc.git) registered for path 'riscv-glibc'
Submodule 'riscv-newlib' (https://gitee.com/mirrors/riscv-newlib.git) registered for path 'riscv-newlib'
git clone --recursive https://gitee.com/mirrors/riscv-dejagnu.git
git clone --recursive https://gitee.com/mirrors/riscv-gcc.git
git clone --recursive https://gitee.com/mirrors/riscv-glibc.git glibc
git clone --recursive https://gitee.com/mirrors/riscv-newlib.git newlib
# riscv-binutils与riscv-gdb来自于同一个仓库,且与本地要求的文件夹名称不同,需用命令指定本地名
git clone --recursive -b fsf-gdb-10.1-with-sim https://gitee.com/mirrors/riscv-binutils-gdb.git riscv-gdb
git clone --recursive -b riscv-binutils-2.38 https://gitee.com/mirrors/riscv-binutils-gdb.git riscv-binutils
onlylove@ubuntu:~/my/gcc$ ls
gcc-linaro-6.5.0 gcc-linaro-6.5.0-2018.12-x86_64_arm-linux-gnueabihf.tar
onlylove@ubuntu:~/my/gcc$ git clone https://gitee.com/mirrors/riscv-gnu-toolchain
Cloning into 'riscv-gnu-toolchain'...
remote: Enumerating objects: 8839, done.
remote: Counting objects: 100% (134/134), done.
remote: Compressing objects: 100% (124/124), done.
remote: Total 8839 (delta 79), reused 12 (delta 10), pack-reused 8705
Receiving objects: 100% (8839/8839), 5.08 MiB | 951.00 KiB/s, done.
Resolving deltas: 100% (4818/4818), done.
onlylove@ubuntu:~/my/gcc$ ls
gcc-linaro-6.5.0 gcc-linaro-6.5.0-2018.12-x86_64_arm-linux-gnueabihf.tar riscv-gnu-toolchain
onlylove@ubuntu:~/my/gcc$ cd riscv-gnu-toolchain/
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls
configure contrib LICENSE Makefile.in newlib qemu regression riscv-dejagnu riscv-gdb spike
configure.ac glibc linux-headers musl pk README.md riscv-binutils riscv-gcc scripts test
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls riscv-dejagnu/
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ git clone --recursive https://gitee.com/mirrors/riscv-dejagnu.git
Cloning into 'riscv-dejagnu'...
remote: Enumerating objects: 5208, done.
remote: Total 5208 (delta 0), reused 0 (delta 0), pack-reused 5208
Receiving objects: 100% (5208/5208), 3.10 MiB | 703.00 KiB/s, done.
Resolving deltas: 100% (3957/3957), done.
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls riscv-dejagnu/
aclocal.m4 ChangeLog-1992 config.sub COPYING INSTALL Makefile.am README testglue.c
AUTHORS compile configure dejagnu.h install-sh Makefile.in runtest testsuite
baseboards config configure.ac depcomp lib missing runtest.exp texinfo.tex
ChangeLog config.guess contrib doc MAINTAINERS NEWS stub-loader.c TODO
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls
configure contrib LICENSE Makefile.in newlib qemu regression riscv-dejagnu riscv-gdb spike
configure.ac glibc linux-headers musl pk README.md riscv-binutils riscv-gcc scripts test
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls riscv-gcc/
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ git clone --recursive https://gitee.com/mirrors/riscv-gcc.git
Cloning into 'riscv-gcc'...
remote: Enumerating objects: 2710459, done.
remote: Counting objects: 100% (26222/26222), done.
remote: Compressing objects: 100% (10576/10576), done.
remote: Total 2710459 (delta 18081), reused 20135 (delta 15430), pack-reused 2684237
Receiving objects: 100% (2710459/2710459), 1.43 GiB | 3.56 MiB/s, done.
Resolving deltas: 100% (2109107/2109107), done.
Updating files: 100% (100556/100556), done.
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls riscv-gcc/
ABOUT-NLS configure gnattools libdecnumber libphobos lto-plugin mkinstalldirs
ar-lib configure.ac gotools libffi libquadmath ltoptions.m4 move-if-change
ChangeLog contrib include libgcc libsanitizer ltsugar.m4 multilib.am
ChangeLog.jit COPYING INSTALL libgfortran libssp ltversion.m4 README
ChangeLog.tree-ssa COPYING3 install-sh libgo libstdc++-v3 MAINTAINERS symlink-tree
compile COPYING3.LIB intl libgomp libtool-ldflags maintainer-scripts test-driver
config COPYING.LIB libada libhsail-rt libtool.m4 Makefile.def ylwrap
config.guess COPYING.RUNTIME libatomic libiberty libvtv Makefile.in zlib
config-ml.in depcomp libbacktrace libitm ltgcc.m4 Makefile.tpl
config.rpath fixincludes libcc1 libobjc ltmain.sh missing
config.sub gcc libcpp liboffloadmic lt~obsolete.m4 mkdep
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls
configure contrib LICENSE Makefile.in newlib qemu regression riscv-dejagnu riscv-gdb spike
configure.ac glibc linux-headers musl pk README.md riscv-binutils riscv-gcc scripts test
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls riscv-glibc
ls: cannot access 'riscv-glibc': No such file or directory
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls glibc/
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ git clone --recursive https://gitee.com/mirrors/riscv-glibc.git glibc
Cloning into 'glibc'...
remote: Enumerating objects: 497747, done.
error: RPC failed; curl 56 GnuTLS recv error (-54): Error in the pull function.
fatal: the remote end hung up unexpectedly
fatal: early EOF
fatal: index-pack failed
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ git clone --recursive https://gitee.com/mirrors/riscv-glibc.git glibc
Cloning into 'glibc'...
remote: Enumerating objects: 497747, done.
remote: Total 497747 (delta 0), reused 0 (delta 0), pack-reused 497747
Receiving objects: 100% (497747/497747), 154.52 MiB | 2.89 MiB/s, done.
Resolving deltas: 100% (425283/425283), done.
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls glibc/
README.md
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls
configure contrib LICENSE Makefile.in newlib qemu regression riscv-dejagnu riscv-gdb spike
configure.ac glibc linux-headers musl pk README.md riscv-binutils riscv-gcc scripts test
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls newlib/
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ git clone --recursive https://gitee.com/mirrors/riscv-newlib.git newlib
Cloning into 'newlib'...
remote: Enumerating objects: 171854, done.
remote: Total 171854 (delta 0), reused 0 (delta 0), pack-reused 171854
Receiving objects: 100% (171854/171854), 100.64 MiB | 3.95 MiB/s, done.
Resolving deltas: 100% (139387/139387), done.
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls newlib/
ChangeLog configure COPYING.NEWLIB libtool.m4 MAINTAINERS mkinstalldirs symlink-tree
compile configure.ac depcomp ltgcc.m4 Makefile.def move-if-change texinfo
config COPYING djunpack.bat ltmain.sh Makefile.in newlib winsup
config.guess COPYING3 etc lt~obsolete.m4 Makefile.tpl README ylwrap
config-ml.in COPYING3.LIB include ltoptions.m4 makefile.vms README-maintainer-mode
config.rpath COPYING.LIB install-sh ltsugar.m4 missing setup.com
config.sub COPYING.LIBGLOSS libgloss ltversion.m4 mkdep src-release
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls
configure contrib LICENSE Makefile.in newlib qemu regression riscv-dejagnu riscv-gdb spike
configure.ac glibc linux-headers musl pk README.md riscv-binutils riscv-gcc scripts test
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls riscv-gdb/
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ git clone --recursive -b fsf-gdb-10.1-with-sim https://gitee.com/mirrors/riscv-binutils-gdb.git riscv-gdb
Cloning into 'riscv-gdb'...
remote: Enumerating objects: 1006157, done.
remote: Counting objects: 100% (14209/14209), done.
remote: Compressing objects: 100% (5683/5683), done.
remote: Total 1006157 (delta 9231), reused 12136 (delta 8498), pack-reused 991948
Receiving objects: 100% (1006157/1006157), 405.04 MiB | 3.82 MiB/s, done.
Resolving deltas: 100% (839032/839032), done.
Updating files: 100% (35594/35594), done.
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls riscv-gdb/
ar-lib configure depcomp gprof ltmain.sh missing sim
bfd configure.ac djunpack.bat include lt~obsolete.m4 mkdep src-release.sh
binutils contrib elfcpp install-sh ltoptions.m4 mkinstalldirs symlink-tree
ChangeLog COPYING etc intl ltsugar.m4 move-if-change test-driver
compile COPYING3 gas ld ltversion.m4 multilib.am texinfo
config COPYING3.LIB gdb libctf MAINTAINERS opcodes ylwrap
config.guess COPYING.LIB gdbserver libdecnumber Makefile.def readline zlib
config-ml.in COPYING.LIBGLOSS gdbsupport libiberty Makefile.in README
config.rpath COPYING.NEWLIB gnulib libtool.m4 Makefile.tpl README-maintainer-mode
config.sub cpu gold ltgcc.m4 makefile.vms setup.com
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls
configure contrib LICENSE Makefile.in newlib qemu regression riscv-dejagnu riscv-gdb spike
configure.ac glibc linux-headers musl pk README.md riscv-binutils riscv-gcc scripts test
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls riscv-binutils/
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ git clone --recursive -b riscv-binutils-2.38 https://gitee.com/mirrors/riscv-binutils-gdb.git riscv-binutils
Cloning into 'riscv-binutils'...
remote: Enumerating objects: 1006157, done.
remote: Counting objects: 100% (14209/14209), done.
remote: Compressing objects: 100% (5683/5683), done.
remote: Total 1006157 (delta 9230), reused 12136 (delta 8498), pack-reused 991948
Receiving objects: 100% (1006157/1006157), 405.04 MiB | 3.87 MiB/s, done.
Resolving deltas: 100% (839031/839031), done.
Updating files: 100% (37128/37128), done.
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
sudo apt-get install autoconf automake autotools-dev curl python3 libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
./configure --prefix=/home/onlylove/my/gcc/riscv --enable-multilib
onlylove@ubuntu:~/my/gcc$ ls
gcc-linaro-6.5.0 gcc-linaro-6.5.0-2018.12-x86_64_arm-linux-gnueabihf.tar riscv riscv-gnu-toolchain
onlylove@ubuntu:~/my/gcc$ cd riscv-gnu-toolchain/
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ls
configure contrib LICENSE Makefile.in newlib qemu regression riscv-dejagnu riscv-gdb spike
configure.ac glibc linux-headers musl pk README.md riscv-binutils riscv-gcc scripts test
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$ ./configure --prefix=/home/onlylove/my/gcc/riscv --enable-multilib
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for fgrep... /usr/bin/grep -F
checking for grep that handles long lines and -e... (cached) /usr/bin/grep
checking for bash... /bin/bash
checking for __gmpz_init in -lgmp... yes
checking for mpfr_init in -lmpfr... yes
checking for mpc_init2 in -lmpc... yes
checking for curl... /usr/bin/curl
checking for wget... /usr/bin/wget
checking for ftp... /usr/bin/ftp
configure: creating ./config.status
config.status: creating Makefile
config.status: creating scripts/wrapper/awk/awk
config.status: creating scripts/wrapper/sed/sed
onlylove@ubuntu:~/my/gcc/riscv-gnu-toolchain$
make -j4
onlylove@ubuntu:~/my/gcc$ ls
gcc-linaro-6.5.0 gcc-linaro-6.5.0-2018.12-x86_64_arm-linux-gnueabihf.tar riscv riscv-gnu-toolchain
onlylove@ubuntu:~/my/gcc$ cd riscv
onlylove@ubuntu:~/my/gcc/riscv$ ls
bin include lib libexec riscv64-unknown-elf share
onlylove@ubuntu:~/my/gcc/riscv$ cd bin/
onlylove@ubuntu:~/my/gcc/riscv/bin$ ls
riscv64-unknown-elf-addr2line riscv64-unknown-elf-gcc-nm riscv64-unknown-elf-nm
riscv64-unknown-elf-ar riscv64-unknown-elf-gcc-ranlib riscv64-unknown-elf-objcopy
riscv64-unknown-elf-as riscv64-unknown-elf-gcov riscv64-unknown-elf-objdump
riscv64-unknown-elf-c++ riscv64-unknown-elf-gcov-dump riscv64-unknown-elf-ranlib
riscv64-unknown-elf-c++filt riscv64-unknown-elf-gcov-tool riscv64-unknown-elf-readelf
riscv64-unknown-elf-cpp riscv64-unknown-elf-gdb riscv64-unknown-elf-run
riscv64-unknown-elf-elfedit riscv64-unknown-elf-gdb-add-index riscv64-unknown-elf-size
riscv64-unknown-elf-g++ riscv64-unknown-elf-gprof riscv64-unknown-elf-strings
riscv64-unknown-elf-gcc riscv64-unknown-elf-ld riscv64-unknown-elf-strip
riscv64-unknown-elf-gcc-10.2.0 riscv64-unknown-elf-ld.bfd
riscv64-unknown-elf-gcc-ar riscv64-unknown-elf-lto-dump
onlylove@ubuntu:~/my/gcc/riscv/bin$ ./riscv64-unknown-elf-gcc -v
Using built-in specs.
COLLECT_GCC=./riscv64-unknown-elf-gcc
COLLECT_LTO_WRAPPER=/home/onlylove/my/gcc/riscv/libexec/gcc/riscv64-unknown-elf/10.2.0/lto-wrapper
Target: riscv64-unknown-elf
Configured with: /home/onlylove/my/gcc/riscv-gnu-toolchain/riscv-gcc/configure --target=riscv64-unknown-elf --prefix=/home/onlylove/my/gcc/riscv --disable-shared --disable-threads --enable-languages=c,c++ --with-pkgversion=gca312387ab1 --with-system-zlib --enable-tls --with-newlib --with-sysroot=/home/onlylove/my/gcc/riscv/riscv64-unknown-elf --with-native-system-header-dir=/include --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --disable-tm-clone-registry --src=.././riscv-gcc --enable-multilib --with-abi=lp64d --with-arch=rv64imafdc --with-tune=rocket --with-isa-spec=2.2 'CFLAGS_FOR_TARGET=-Os -mcmodel=medlow' 'CXXFLAGS_FOR_TARGET=-Os -mcmodel=medlow'
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 10.2.0 (gca312387ab1)
onlylove@ubuntu:~/my/gcc/riscv/bin$