From 3e7cf10d75ad9942574b9bedad5270eb4536af27 Mon Sep 17 00:00:00 2001 From: Roberto Hexsel <roberto@inf.ufpr.br> Date: Wed, 8 Mar 2017 09:55:29 -0300 Subject: [PATCH] improved instructions to build and install mips-gcc --- cMIPS/bin/build.sh | 11 ++++---- cMIPS/docs/installCrosscompiler | 38 +++++++++++++++++++------ cMIPS/tests/doTests.sh | 2 +- cMIPS/tests/pointer.c | 49 +++++++++++++++++++++++++++++++++ cMIPS/tests/pointer.expected | 7 +++++ 5 files changed, 92 insertions(+), 15 deletions(-) create mode 100644 cMIPS/tests/pointer.c create mode 100644 cMIPS/tests/pointer.expected diff --git a/cMIPS/bin/build.sh b/cMIPS/bin/build.sh index ff83ee5..f06adcf 100755 --- a/cMIPS/bin/build.sh +++ b/cMIPS/bin/build.sh @@ -25,7 +25,8 @@ cat <<EOF $0: error in compiling VHDL sources - + remove cMIPS/vhdl/.last_import and cMIPS/vhdl/work-obj93.cf + and re-compile EOF exit 1 @@ -74,14 +75,12 @@ src="aux.vhd altera.vhd macnica.vhd cache.vhd instrcache.vhd sdram.vhd ram.vhd r #ghdl -a --ieee=standard "${srcVHDL}"/packageMemory.vhd || exit 1 #ghdl -a --ieee=standard "${srcVHDL}"/packageExcp.vhd || exit 1 #for F in ${src} ; do -# if [ ! -s ${F}.o -o "${srcVHDL}"/${F}.vhd -nt ${F}.o ] ; then -# ghdl -a --ieee=standard "${srcVHDL}"/${F}.vhd || exit 1 +# if [ ! -s ${F%.vhd}.o -o "${srcVHDL}"/${F} -nt ${F%.vhd}.o ] ; then +# ghdl -a --ieee=standard "${srcVHDL}"/${F} || exit 1 # fi #done # -#ghdl -c "${srcVHDL}"/*.vhd -e ${simulator} || exit 1 - - +#ghdl -c "${srcVHDL}"/*.vhd -e ${simulator} || exit 1 # NOTE: when you add a new sourcefile to this project, you must include it diff --git a/cMIPS/docs/installCrosscompiler b/cMIPS/docs/installCrosscompiler index a816ed9..e1350f4 100644 --- a/cMIPS/docs/installCrosscompiler +++ b/cMIPS/docs/installCrosscompiler @@ -1,24 +1,30 @@ ### ### this file in NOT a shell script, -### yet it was written to make it easy for cutting-n-pasting with the pointer +### yet it was written to make it easy for cutting-n-pasting with the mouse ### # to compile GCC, these three libraries may have to be fetched: -wget http://www.mpfr.org/mpfr-current/mpfr-3.1.3.tar.gz -wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.2.tar.gz -wget ftp://ftp.gmplib.org/pub/gmp/gmp-6.0.0.tar.bz2 +wget http://www.mpfr.org/mpfr-current/mpfr-3.1.5.tar.gz +wget ftp://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz +wget ftp://ftp.gmplib.org/pub/gmp/gmp-6.1.2.tar.bz2 + +# it is (very) likely that new(er) versions have been released; please +# fetch the new(est) versions. # and, according to instructions in # http://gcc.gnu.org/install/prerequisites.html -# expand the tarballs into the directory with GCC sources, change their +# after you downloaded and expanded the GCC sources, expand the three +# tarballs into the directory with GCC sources, change their # directory names to mpfr mpc gmp (removing the version suffixes); -# these libraries are then compiled along with GCC +# then these libraries will be automagically compiled as part of GCC. # OTOH, if you are very lucky, the libraries installed by aptitude will do... # fetch all the auxiliary programs -- this assumes a Debian installation aptitude install make flex bison libgmp-dev libmpfr-dev libmpc-dev g++ + +# clean up any aliases/function replacements for /bin/ls unset ls # make sure the installed files are read-exec by all @@ -33,12 +39,17 @@ COMPILER=gcc-5.1.0 wget -c http://ftp.gnu.org/gnu/binutils/${BINUTILS}.tar.bz2 wget -c http://ftp.gnu.org/gnu/gcc/${COMPILER}/${COMPILER}.tar.gz +# the cross-compiler will be installed in /opt/cross so it does not, +# in any way, conflicts with the native GCC or binutils. + # set the installation pathname as PREFIX so that {bin,lib,man} are put there # make sure you have write permission to /opt/cross, # else perform the "make install" steps as root (with umask 022) export PREFIX=/opt/cross/ export TARGET=mips +## build and install binutils (takes a few minutes) + tar -xvjf ${BINUTILS}.tar.bz2 cd ${BINUTILS} ./configure --target=$TARGET --prefix=$PREFIX --disable-nls @@ -49,10 +60,20 @@ make make install cd .. +## build and install GCC (takes rather more than a few minutes) + tar -xvzf ${COMPILER}.tar.gz cd ${COMPILER} -# you may want/need to expand the libraries' tarballs at this point +# you may want/need to expand the libraries' tarballs at this point, +# by doing +# [[ do not copy these commands unless versions are same as shown below ]] +# tar -xvjf ../gmp-6.1.2.tar.bz2 +# mv gmp-6.1.2/ gmp +# tar -xvzf ../mpc-1.0.3.tar.gz +# mv mpc-1.0.3/ mpc +# tar -xxvf ../mpfr-3.1.5.tar.xz +# mv mpfr-3.1.5/ mpfr export PATH=$PATH:$PREFIX/bin ./configure --target=$TARGET --prefix=$PREFIX --disable-nls \ @@ -66,6 +87,7 @@ cd .. # once GCC and Binutils are compiled and installed, all that is needed is # for you to add the new path to your PATH, preferably in your ~/.bashrc +# do not forget to substitute ${PREFIX} by /opt/cross in ~/.bashrc export PATH=${PATH}:${PREFIX}/bin export MANPATH=${MANPATH}:${PREFIX}/man @@ -83,7 +105,7 @@ export MANPATH=${MANPATH}:${PREFIX}/man # to download the .deb files onto the same directory as ghdl*.deb # # When doing dpkg -i ghdl*.deb it will whine and complain about versions. -# What I have done is to use the following DANGEROUS and RISKY command: +# What I have done is to use the following RISKY command: # # dpkg --ignore-depends=ghdl*.deb --ignore-depends=libgnat-4.6 -i ghdl*.deb # diff --git a/cMIPS/tests/doTests.sh b/cMIPS/tests/doTests.sh index c746be6..f75510c 100755 --- a/cMIPS/tests/doTests.sh +++ b/cMIPS/tests/doTests.sh @@ -105,7 +105,7 @@ fi c_small="divmul fat fib count sieve ccitt16 gcd matrix negcnt reduz rand" -c_types="xram sort-byte sort-half sort-int memcpy" +c_types="pointer xram sort-byte sort-half sort-int memcpy" c_sorts="bubble insertion merge quick selection shell" c_FPU="FPU_m" diff --git a/cMIPS/tests/pointer.c b/cMIPS/tests/pointer.c new file mode 100644 index 0000000..daae9c7 --- /dev/null +++ b/cMIPS/tests/pointer.c @@ -0,0 +1,49 @@ +#include <cMIPS.h> + +#define NIL ((void *)0) + +typedef struct elem { + struct elem *next; + int vet[3]; +} elemType; + +elemType strct[16]; +elemType *head; + +elemType *insert(elemType *h, elemType *e) { + elemType *p; + + p = h; + while ((void *)p->next != NIL) { + p = p->next; + } + p->next = e; + e->next = NIL; + return e; +} + + +int main(void) { + int i,j; + elemType *x; + + head = &(strct[0]); + + for (i=0; i < 5; i++) { // initialize 5 elements, not in sequence + j = 2*i + 5; + // print((int)&(strct[j])); // print address of strct's element + x = insert(head, &(strct[j])); + x->vet[1] = j; + } + + to_stdout('\n'); // print blank line + + x = head->next; // get first element + for (i=0; i < 5; i++) { + print(x->vet[1]); + x = x->next; // get next element + } + + to_stdout('\n'); // print blank line + +} diff --git a/cMIPS/tests/pointer.expected b/cMIPS/tests/pointer.expected new file mode 100644 index 0000000..90721f6 --- /dev/null +++ b/cMIPS/tests/pointer.expected @@ -0,0 +1,7 @@ + +00000005 +00000007 +00000009 +0000000b +0000000d + -- GitLab