====== Deploy PIC32MX gcc toolchain on Ubuntu 24.04.2 LTS ======
* tool chain has been built based on binutils 2.36, gcc 10.3.0, newlib 4.1.0.
===== install prerequisites =====
$ sudo apt install libgmp3-dev libmpfr-dev libmpc-dev
===== binutils 2.36 =====
$ mkdir -p ~/projects/gcc-mips-10.3.0/
$ cd ~/projects/gcc-mips-10.3.0/
$ wget http://ftp.gnu.org/gnu/binutils/binutils-2.36.tar.gz -O ~/Downloads/binutils-2.36.tar.gz
$ tar xvpf /tmp/binutils-2.36.tar.gz
$ mkdir build-binutils-el-2.36
$ cd build-binutils-el-2.36
$ ../binutils-2.36/configure --target=mipsel --prefix=/opt/mipsel-10.3.0
$ make
$ sudo make install
===== gcc 10.3.0 with newlib 4.1.0 =====
* prepare working area
$ cd ~/projects/gcc-mips-10.3.0/
$ mkdir build-gcc-el-10.3.0
$ mkdir build-newlib-el-4.1.0
* download and unpack
$ wget http://ftp.gnu.org/gnu/gcc/gcc-10.3.0/gcc-10.3.0.tar.gz -O /tmp/gcc-10.3.0.tar.gz
$ tar xvpf /tmp/gcc-10.3.0.tar.gz
$ wget ftp://sourceware.org/pub/newlib/newlib-4.1.0.tar.gz -O /tmp/newlib-4.1.0.tar.gz
$ tar xvpf /tmp/newlib-4.1.0.tar.gz
* build and install (tools will be installed into /opt/mipsel-10.3.0/ directory). Building gcc with newlib is done in three steps.
===== Stage 1 - build bootstrap gcc =====
$ cd build-gcc-el-10.3.0
$ ../gcc-10.3.0/configure --target=mipsel --prefix=/opt/mipsel-10.3.0 --without-headers --with-gnu-as --with-gnu-ld --with-newlib --enable-languages=c --with-local-prefix=/opt/mipsel-10.3.0 --with-native-system-header-dir=/opt/mipsel-10.3.0/include/ --disable-nls --disable-shared --enable-multilib --disable-decimal-float -disable-threads --disable-libmudflap --disable-libssp --disable-libgomp --disable-libquadmath
$ make
$ sudo make install
* **--enable-multilib** - builds several variants of libraries (big-endian, little-endian hard-float and soft-float). Default is little-endian hard-float.
$ /opt/mipsel-10.3.0/bin/mipsel-gcc -print-multi-lib
.;
soft-float;@msoft-float
eb;@EB
soft-float/eb;@msoft-float@EB
$
===== Stage 2 - deploy newlib =====
* newlib requires mips-cc
# cd /opt/mipsel-10.3.0/bin
# ln -s mipsel-gcc mipsel-cc
* build and install
$ export PATH=/opt/mipsel-10.3.0/bin:$PATH
$ cd ~/projects/gcc-mips-10.3.0/build-newlib-el-4.1.0
$ ../newlib-4.1.0/configure --target=mipsel --prefix=/opt/mipsel-10.3.0
$ make ; echo $?
$ sudo make install
===== Stage 3 - deploy gcc and g++ with newlib suport =====
$ cd ~/projects/gcc-mips-10.3.0/build-gcc-el-10.3.0
$ ../gcc-10.3.0/configure --target=mipsel --prefix=/opt/mipsel-10.3.0 --with-gnu-as --with-gnu-ld --with-newlib --enable-languages=c,c++ --with-local-prefix=/opt/mipsel-10.3.0 --with-native-system-header-dir=/opt/mipsel-10.3.0/include --disable-nls --disable-shared --enable-multilib --disable-decimal-float -disable-threads --disable-libmudflap --disable-libssp --disable-libgomp --disable-libquadmath
$ make -j 10 ; echo $?
$ sudo make install
===== copy Microchip libraries =====
# mkdir /opt/mipsel-10.3.0/lib/microchip/
# cp libc_s_n.a libdsp.a libgcc_s_n.a /opt/mipsel-10.3.0/lib/microchip/