This is an old revision of the document!
Table of Contents
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 $? ... mipsel-cc -B/home/dambi/projects/gcc-mips/build-newlib-el/mipsel/newlib/ -isystem /home/dambi/projects/gcc-mips/build[27/1919] l/mipsel/newlib/targ-include -isystem /home/dambi/projects/gcc-mips/newlib-4.1.0/newlib/libc/include -B/home/dambi/projects/gcc-mips/build-newlib-el/mipsel/libgloss/mips -L/home/dambi/projects/gcc-mips/build-newlib-el/mipsel/libgloss/libnosys -L/home/d ambi/projects/gcc-mips/newlib-4.1.0/libgloss/mips -DPACKAGE_NAME=\"newlib\" -DPACKAGE_TARNAME=\"newlib\" -DPACKAGE_VERSION= \"4.1.0\" -DPACKAGE_STRING=\"newlib\ 4.1.0\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -I. -I../../../../../newlib-4.1.0/new lib/libc/stdlib -fno-builtin -DMISSING_SYSCALL_NAMES -DHAVE_INIT_FINI -g -O2 -c -o lib_a-dtoa.o `test -f 'dtoa.c' || echo '../../../../../newlib-4.1.0/newlib/libc/stdlib/'`dtoa.c In file included from ../../../../../newlib-4.1.0/newlib/libc/stdlib/mprec.h:29, from ../../../../../newlib-4.1.0/newlib/libc/stdlib/dtoa.c:33: /home/dambi/projects/gcc-mips/newlib-4.1.0/newlib/libc/include/ieeefp.h:152:2: error: #error "double and long double are the s ame size but LDBL_EQ_DBL is not defined" 152 | #error "double and long double are the same size but LDBL_EQ_DBL is not defined" | ^~~~~ /home/dambi/projects/gcc-mips/newlib-4.1.0/newlib/libc/include/ieeefp.h:195:3: error: unknown type name '__ieee_ext_field_type ' 195 | __ieee_ext_field_type ext_fracl : EXT_FRACLBITS; | ^~~~~~~~~~~~~~~~~~~~~ /home/dambi/projects/gcc-mips/newlib-4.1.0/newlib/libc/include/ieeefp.h:195:38: error: 'EXT_FRACLBITS' undeclared here (not in a function); did you mean 'EXT_FRACBITS'? 195 | __ieee_ext_field_type ext_fracl : EXT_FRACLBITS; | ^~~~~~~~~~~~~ | EXT_FRACBITS /home/dambi/projects/gcc-mips/newlib-4.1.0/newlib/libc/include/ieeefp.h:195:26: error: bit-field 'ext_fracl' width not an inte ger constant 195 | __ieee_ext_field_type ext_fracl : EXT_FRACLBITS; | ^~~~~~~~~ /home/dambi/projects/gcc-mips/newlib-4.1.0/newlib/libc/include/ieeefp.h:196:3: error: unknown type name '__ieee_ext_field_type ' 196 | __ieee_ext_field_type ext_frach : EXT_FRACHBITS; | ^~~~~~~~~~~~~~~~~~~~~ /home/dambi/projects/gcc-mips/newlib-4.1.0/newlib/libc/include/ieeefp.h:196:38: error: 'EXT_FRACHBITS' undeclared here (not in a function); did you mean 'EXT_FRACBITS'? 196 | __ieee_ext_field_type ext_frach : EXT_FRACHBITS; | ^~~~~~~~~~~~~ | EXT_FRACBITS /home/dambi/projects/gcc-mips/newlib-4.1.0/newlib/libc/include/ieeefp.h:196:26: error: bit-field 'ext_frach' width not an inte ger constant 196 | __ieee_ext_field_type ext_frach : EXT_FRACHBITS; | ^~~~~~~~~ /home/dambi/projects/gcc-mips/newlib-4.1.0/newlib/libc/include/ieeefp.h:197:3: error: unknown type name '__ieee_ext_field_type ' 197 | __ieee_ext_field_type ext_exp : EXT_EXPBITS; | ^~~~~~~~~~~~~~~~~~~~~ /home/dambi/projects/gcc-mips/newlib-4.1.0/newlib/libc/include/ieeefp.h:197:38: error: 'EXT_EXPBITS' undeclared here (not in a function); did you mean 'EXT_EXP_BIAS'? 197 | __ieee_ext_field_type ext_exp : EXT_EXPBITS; | ^~~~~~~~~~~ | EXT_EXP_BIAS /home/dambi/projects/gcc-mips/newlib-4.1.0/newlib/libc/include/ieeefp.h:197:26: error: bit-field 'ext_exp' width not an integer constant 197 | __ieee_ext_field_type ext_exp : EXT_EXPBITS; | ^~~~~~~ /home/dambi/projects/gcc-mips/newlib-4.1.0/newlib/libc/include/ieeefp.h:198:3: error: unknown type name '__ieee_ext_field_type' 198 | __ieee_ext_field_type ext_sign : 1; | ^~~~~~~~~~~~~~~~~~~~~ make[5]: *** [Makefile:734: lib_a-dtoa.o] Error 1 make[5]: Leaving directory '/data/smb/users/dambi/projects/gcc-mips/build-newlib-el/mipsel/newlib/libc/stdlib' make[4]: *** [Makefile:683: all-recursive] Error 1 make[4]: Leaving directory '/data/smb/users/dambi/projects/gcc-mips/build-newlib-el/mipsel/newlib/libc' make[3]: *** [Makefile:641: all-recursive] Error 1 make[3]: Leaving directory '/data/smb/users/dambi/projects/gcc-mips/build-newlib-el/mipsel/newlib' make[2]: *** [Makefile:452: all] Error 2 make[2]: Leaving directory '/data/smb/users/dambi/projects/gcc-mips/build-newlib-el/mipsel/newlib' make[1]: *** [Makefile:8492: all-target-newlib] Error 2 make[1]: Leaving directory '/data/smb/users/dambi/projects/gcc-mips/build-newlib-el' make: *** [Makefile:879: all] Error 2 2
* LDBL_EQ_DBL not defined in some header files
$ pwd ~/projects/gcc-mips-10.3.0/build-newlib-el-4.1.0 $ ggrep -Rl LDBL_EQ ./ ./mipsel/newlib/targ-include/newlib.h ./mipsel/newlib/newlib.h ./mipsel/soft-float/newlib/targ-include/newlib.h ./mipsel/soft-float/newlib/config.log ./mipsel/soft-float/newlib/config.status ./mipsel/soft-float/newlib/newlib.h ./mipsel/soft-float/eb/newlib/newlib.h ./mipsel/soft-float/eb/newlib/targ-include/newlib.h ./mipsel/soft-float/eb/newlib/config.log ./mipsel/soft-float/eb/newlib/config.status ./mipsel/eb/newlib/config.log ./mipsel/eb/newlib/targ-include/newlib.h ./mipsel/eb/newlib/newlib.h ./mipsel/eb/newlib/config.status
* define LDBL_EQ_DBL in files where it is not defined
$ vim -p ./mipsel/newlib/targ-include/newlib.h ./mipsel/newlib/newlib.h $ 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 --with-native-system-header-dir=/opt/mipsel/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
binutils 2.22
- prepare working area
$ mkdir ~/projects/gcc-mips/ $ cd ~/projects/gcc-mips/ $ mkdir build-binutils-el
- download and unpack
$ wget http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.gz -O /tmp/binutils-2.22.tar.gz $ tar xvpf /tmp/binutils-2.22.tar.gz
- build and install (all tools will be installed into /opt/mipsel/ directory)
$ cd build-binutils-el $ ../binutils-2.22/configure --target=mipsel --prefix=/opt/mipsel $ make $ sudo make install
gcc 4.5.2 with newlib 1.20.0
- prepare working area
$ cd ~/projects/gcc-mips/ $ mkdir build-gcc-el $ mkdir build-newlib-el
- download and unpack
$ wget http://ftp.gnu.org/gnu/gcc/gcc-4.5.2/gcc-4.5.2.tar.gz -O /tmp/gcc-4.5.2.tar.gz $ tar xvpf /tmp/gcc-4.5.2.tar.gz $ wget ftp://sources.redhat.com/pub/newlib/newlib-1.20.0.tar.gz -O /tmp/newlib-1.20.0.tar.gz $ tar xvpf /tmp/newlib-1.20.0.tar.gz
- build and install (tools will be installed into /opt/mipsel/ directory). Building gcc with newlib is done in three steps.
Stage 1 - build bootstrap gcc
$ cd build-gcc-el $ ../gcc-4.5.2/configure --target=mipsel --prefix=/opt/mipsel --with-gmp-include=/usr/include/gmp --with-mpfr-include=/usr/include/mpfr --without-headers --with-gnu-as --with-gnu-ld --with-newlib --enable-languages=c --with-local-prefix=/opt/mipsel --with-native-system-header-dir=/opt/mipsel/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/bin/mipsel-gcc -print-multi-lib .; soft-float;@msoft-float eb;@EB soft-float/eb;@msoft-float@EB $
Stage 2 - deploy newlib
- build and install
$ cd ~/projects/gcc-mips/build-newlib-el $ ../newlib-1.20.0/configure --target=mipsel --prefix=/opt/mipsel $ make $ sudo make install
Stage 3 - deploy gcc with newlib suport
$ cd ~/projects/gcc-mips/build-gcc-el $ ../gcc-4.5.2/configure --target=mipsel --prefix=/opt/mipsel --with-gmp-include=/usr/include/gmp --with-mpfr-include=/usr/include/mpfr --with-gnu-as --with-gnu-ld --with-newlib --enable-languages=c --with-local-prefix=/opt/mipsel --with-native-system-header-dir=/opt/mipsel/include --disable-nls --disable-shared --enable-multilib --disable-decimal-float -disable-threads --disable-libmudflap --disable-libssp --disable-libgomp --disable-libquadmath $ make $ sudo make install