Add stage 2 RISC-V GNU toolchain
authorRichard W.M. Jones <rjones@redhat.com>
Sun, 31 Jul 2016 19:26:41 +0000 (20:26 +0100)
committerRichard W.M. Jones <rjones@redhat.com>
Mon, 1 Aug 2016 13:51:23 +0000 (14:51 +0100)
.gitignore
Makefile
README
stage1-riscv-qemu/riscv-qemu.spec
stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec [new file with mode: 0644]

index ee73460..12e04eb 100644 (file)
@@ -1,2 +1,3 @@
 *~
 *.tar.gz
+stamp-*
index 0175eff..f8dd949 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,12 +3,14 @@
 
 all: stage1 stage2 stage3 stage4
 
+# Stage 1
+
 stage1: stage1-riscv-qemu/riscv-qemu-94f5eb73.tar.gz \
        stamp-riscv-qemu-installed
 
 stage1-riscv-qemu/riscv-qemu-94f5eb73.tar.gz:
        rm -f $@ $@-t
-       wget 'https://github.com/riscv/riscv-qemu/archive/94f5eb73091fb4fe272db3e943f173ecc0f78ffd/riscv-qemu-94f5eb73.tar.gz' -O $@-t
+       wget -O $@-t 'https://github.com/riscv/riscv-qemu/archive/94f5eb73091fb4fe272db3e943f173ecc0f78ffd/riscv-qemu-94f5eb73.tar.gz'
        mv $@-t $@
 
 stamp-riscv-qemu-installed:
@@ -23,16 +25,74 @@ stamp-riscv-qemu-installed:
          echo; \
          exit 1; \
        }
+       @qemu-system-riscv --version || { \
+         echo "ERROR: qemu-system-riscv is not working."; \
+         echo "Make sure you installed the riscv-qemu package."; \
+         exit 1; \
+       }
        touch $@
 
-stage2:
-       echo "XXX TO DO"
-       exit 1
+# Stage 2
+
+stage2: stage2-riscv-gnu-toolchain/riscv-gnu-toolchain-1374381e.tar.gz \
+       stage2-riscv-gnu-toolchain/binutils-2.26.tar.gz \
+       stage2-riscv-gnu-toolchain/gcc-6.1.0.tar.gz \
+       stage2-riscv-gnu-toolchain/glibc-2.23.tar.gz \
+       stage2-riscv-gnu-toolchain/newlib-2.2.0.tar.gz \
+       stamp-riscv-gnu-toolchain-installed
+
+stage2-riscv-gnu-toolchain/riscv-gnu-toolchain-1374381e.tar.gz:
+       rm -f $@ $@-t
+       wget -O $@-t https://github.com/lowRISC/riscv-gnu-toolchain/archive/1374381e01b30832581d65a56219388fe7d47584/riscv-gnu-toolchain-1374381e.tar.gz
+       mv $@-t $@
+
+stage2-riscv-gnu-toolchain/binutils-2.26.tar.gz:
+       rm -f $@ $@-t
+       wget -O $@-t http://mirrors.kernel.org/gnu/binutils/binutils-2.26.tar.gz
+       mv $@-t $@
+
+stage2-riscv-gnu-toolchain/gcc-6.1.0.tar.gz:
+       rm -f $@ $@-t
+       wget -O $@-t http://mirrors.kernel.org/gnu/gcc/gcc-6.1.0/gcc-6.1.0.tar.gz
+       mv $@-t $@
+
+stage2-riscv-gnu-toolchain/glibc-2.23.tar.gz:
+       rm -f $@ $@-t
+       wget -O $@-t http://mirrors.kernel.org/gnu/glibc/glibc-2.23.tar.gz
+       mv $@-t $@
+
+stage2-riscv-gnu-toolchain/newlib-2.2.0.tar.gz:
+       rm -f $@ $@-t
+       wget -O $@-t ftp://sourceware.org/pub/newlib/newlib-2.2.0.tar.gz
+       mv $@-t $@
+
+stamp-riscv-gnu-toolchain-installed:
+       rm -f $@
+       @rpm -q riscv-gnu-toolchain >/dev/null || { \
+         echo "ERROR: You must install riscv-gnu-toolchain:"; \
+         echo; \
+         echo "       dnf copr enable rjones/riscv"; \
+         echo "       dnf install riscv-gnu-toolchain"; \
+         echo; \
+         echo "OR: you can build it yourself from the stage2-riscv-gnu-toolchain directory."; \
+         echo; \
+         exit 1; \
+       }
+       @riscv64-unknown-elf-gcc --version || { \
+         echo "ERROR: riscv64-unknown-elf-gcc (cross compiler) is not working."; \
+         echo "Make sure you installed the riscv-gnu-toolchain package."; \
+         exit 1; \
+       }
+       touch $@
+
+# Stage 3
 
 stage3:
        echo "XXX TO DO"
        exit 1
 
+# Stage 4
+
 stage4:
        echo "XXX TO DO"
        exit 1
diff --git a/README b/README
index 295519d..1224fa5 100644 (file)
--- a/README
+++ b/README
@@ -97,8 +97,9 @@ Bootstrapping stages
 
 (1a) riscv-qemu.x86_64: QEMU + RISC-V system emulation
 
-Current status: Not upstream, fork of qemu 2.5.0.
+Not upstream, fork of qemu 2.5.0.
 https://github.com/riscv/riscv-qemu
+Status: done http://copr-fe.cloud.fedoraproject.org/coprs/rjones/riscv-qemu/
 
 Note this package runs on x86-64 hosts, and is intended for people who
 want to run Fedora/RISC-V but who do not have FPGA/hardware.
@@ -108,17 +109,18 @@ want to run Fedora/RISC-V but who do not have FPGA/hardware.
 Various sources, see:
 http://www.lowrisc.org/docs/untether-v0.2/fpga-demo/
 
-(1c) Berkley Bootloader (bbl)
-
-Used to boot the kernel and mount the root filesystem on FPGAs and
-QEMU.  See link above.
-
 * Stage 2
 
 (2a) GNU cross-compiler toolchain.
 
 https://github.com/lowRISC/riscv-gnu-toolchain
 
+(2b) Berkley Bootloader (bbl)
+
+https://github.com/lowrisc/riscv-pk.git
+Used to boot the kernel and mount the root filesystem on FPGAs and
+QEMU.
+
 * Stage 3
 
 (3a) kernel.riscv64: The Linux kernel, cross-compiled.
index bf31c1c..5ca0df7 100644 (file)
@@ -5,7 +5,7 @@
 
 Name:           riscv-qemu
 Version:        2.5.0
-Release:        0.git%{shortcommit}.1%{?dist}
+Release:        0.1.git%{shortcommit}%{?dist}
 Summary:        RISC-V fork of QEMU
 License:        GPLv2+ and LGPLv2+ and BSD
 
diff --git a/stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec b/stage2-riscv-gnu-toolchain/riscv-gnu-toolchain.spec
new file mode 100644 (file)
index 0000000..5211dd7
--- /dev/null
@@ -0,0 +1,107 @@
+%global debug_package %{nil}
+
+# Don't rm -rf $RPM_BUILD_ROOT at the top of install rule.
+%global __spec_install_pre %{___build_pre}
+
+%global commit      1374381e01b30832581d65a56219388fe7d47584
+%global shortcommit 1374381e
+
+Name:           riscv-gnu-toolchain
+Version:        0
+Release:        0.1.git%{shortcommit}%{?dist}
+Summary:        RISC-V GNU cross-toolchain, containing binutils and GCC
+License:        GPLv2+ and LGPLv2+ and BSD
+
+URL:            https://github.com/riscv/riscv-qemu
+Source0:        https://github.com/riscv/%{name}/archive/%{commit}/%{name}-%{shortcommit}.tar.gz
+
+Source1:        http://mirrors.kernel.org/gnu/binutils/binutils-2.26.tar.gz
+Source2:        http://mirrors.kernel.org/gnu/glibc/glibc-2.23.tar.gz
+Source3:        http://mirrors.kernel.org/gnu/gcc/gcc-6.1.0/gcc-6.1.0.tar.gz
+Source4:        ftp://sourceware.org/pub/newlib/newlib-2.2.0.tar.gz
+
+# XXX These BuildRequires are just culled from the GCC spec
+# and probably overestimate the real requirements.
+BuildRequires: binutils
+BuildRequires: glibc-static
+BuildRequires: zlib-devel, gettext, bison, flex
+BuildRequires: texinfo, texinfo-tex, /usr/bin/pod2man
+BuildRequires: systemtap-sdt-devel
+BuildRequires: gmp-devel, mpfr-devel, libmpc-devel
+BuildRequires: hostname, procps
+BuildRequires: gdb
+BuildRequires: glibc-devel
+BuildRequires: elfutils-devel
+BuildRequires: elfutils-libelf-devel
+BuildRequires: glibc
+BuildRequires: glibc-devel
+BuildRequires: libunwind
+BuildRequires: isl
+BuildRequires: isl-devel
+BuildRequires: doxygen
+BuildRequires: graphviz, texlive-collection-latex
+
+
+%description
+This is the RISC-V fork of the GNU cross-compiler toolchain.  It
+includes binutils and GCC.
+
+
+%prep
+%setup -q -n %{name}-%{commit}
+
+
+%build
+%configure
+
+# The ordinary Makefile downloads upstream GNU packages.  Instead we
+# provide these as local files.  Note this is "DISTDIR" not "DESTDIR".
+export DISTDIR=%{_sourcedir}
+
+# Since the Makefile installs as it goes along, set DESTDIR too, and
+# clean the buildroot now (instead of at the top of install).
+export DESTDIR=$RPM_BUILD_ROOT
+rm -rf $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT
+
+# We need to use the tools we built as we go along.
+export PATH=$RPM_BUILD_ROOT%{_bindir}:$PATH
+
+make
+
+# The 'make linux' rule builds GCC linked against glibc (instead of
+# newlib).  However I couldn't make this work, and it's not really
+# needed anyway.
+#make linux
+
+
+%install
+# Not needed since the make installs as it goes along.
+#make install DESTDIR=$RPM_BUILD_ROOT
+
+# Remove some documentation, language files
+rm -r $RPM_BUILD_ROOT%{_datadir}/info
+rm -r $RPM_BUILD_ROOT%{_mandir}
+rm -r $RPM_BUILD_ROOT%{_datadir}/locale
+
+# Remove this libtool linker file.
+rm $RPM_BUILD_ROOT%{_libdir}/libcc1.la
+
+
+%files
+%doc README.md LICENSE
+%{_bindir}/riscv64-unknown-elf-*
+#%{_bindir}/riscv64-unknown-linux-gnu-*
+%{_libdir}/libcc1.so
+%{_libdir}/libcc1.so.0
+%{_libdir}/libcc1.so.0.0.0
+%{_libexecdir}/gcc/riscv64-unknown-elf
+#%{_libexecdir}/gcc/riscv-unknown-linux-gnu
+%{_prefix}/lib/gcc/riscv64-unknown-elf
+#%{_prefix}/lib/gcc/riscv64-unknown-linux-gnu
+%{_prefix}/riscv64-unknown-elf
+#%{_prefix}/riscv64-unknown-linux-gnu
+%{_datadir}/gcc-6.1.0
+
+
+%changelog