Showing revision 1

2016-03-20 Fuck Microchip

⚠⚠⚠ This post is a work-in-progress. ⚠⚠⚠

First you have to download the source of the compiler. Go to http://www.microchip.com/mplab/compilers, click on “Downloads Archive”, scroll down and find “Source Archives”. There you can choose which version to download. At the time of writing the latest link is for xc32-v1.40.

sh: 1: pygmentize: not found

# ⚠ change these variables according to your setup.
installpath="$HOME/microshit" # this is where the compiler will be installed
pic32mxpath='/opt/microchip/xc32/v1.40/pic32mx/' # assuming that you already have installed xc32 from microchip

sh: 1: pygmentize: not found

mkdir -- "$installpath"

export CPPFLAGS="-I$installpath/usr/include"
export LDFLAGS="-L$installpath/usr/lib"

sh: 1: pygmentize: not found

# gmp
mkdir -p gmp_build && cd gmp_build
../gmp/configure "--prefix=$installpath/usr" --disable-shared --enable-static --enable-cxx
make
make install
cd ..

sh: 1: pygmentize: not found

# ppl
mkdir -p ppl_build && cd ppl_build
../ppl/configure "--prefix=$installpath/usr" --disable-shared --enable-static
make
make install
cd ..

Unfortunately I get this error during make:

sh: 1: pygmentize: not found

../../ppl/src/Generator_System.defs.hh:253:7: error: ‘ptrdiff_t’ was not declared in this scope

It seems like it does not compile under newer gcc versions.

This leads me to this page: https://gcc.gnu.org/gcc-4.6/porting_to.html
It says that you should #include <cstddef>. You have to do that with these files:

Now you'll probably see this error:

sh: 1: pygmentize: not found

../../ppl/src/Interval.defs.hh:451:77: error: ‘f_info’ was not declared in this scope, and no declarations were found by argument-dependent lookup at the point of instantiation [-fpermissive]
     Result rl = Boundary_NS::assign(UPPER, upper(), info(), UPPER, x, f_info(x, open));

It looks like it can be solved by using -fpermissive flag.

Try rerunning make like this:

sh: 1: pygmentize: not found

make CXXFLAGS='-g -O2 -frounding-math -W -Wall -fpermissive'

This should probably work.

sh: 1: pygmentize: not found

# cloog
mkdir -p cloog_build && cd cloog_build
../cloog/configure "--prefix=$installpath/usr" --disable-shared --enable-static "--with-ppl=$installpath/usr"
make
make install
cd ..

sh: 1: pygmentize: not found

# libelf
mkdir -p libelf_build && cd libelf_build
../libelf/configure "--prefix=$installpath/usr" --disable-shared
make
make install
cd ..

sh: 1: pygmentize: not found

# zlib
cd zlib
./configure "--prefix=$installpath/usr"
make
make install
cd ..

sh: 1: pygmentize: not found

# binutils
mkdir -p binutils_build && cd binutils_build
../binutils/configure "--prefix=$installpath/usr" --disable-shared --enable-static --target=pic32mx --with-dwarf2
make
make install
cd ..

You will get this error:

sh: 1: pygmentize: not found

../../binutils/bfd/cpu-pic32.c:32:55: fatal error: ../../c30_resource/src/xc32/resource_info.h: No such file or directory

OK this is a real issue. It seems like they forgot to include the file. See this link: http://www.microchip.com/forums/m897811.aspx

sh: 1: pygmentize: not found

# Microchip libraries
cp -a -- "$pic32mxpath" "$installpath/usr/pic32mx"

sh: 1: pygmentize: not found

# gcc
mkdir -p gcc_build && cd gcc_build
../gcc/configure "--prefix=$installpath/usr" --disable-shared --enable-static --target=pic32mx --enable-languages=c,c++,lto --disable-objc-gc --enable-lto --with-host-libstdcxx=-lstdc++ --enable-multilib --with-dwarf2 --disable-sjlj-exceptions "--with-sysroot=$installpath/usr/pic32mx"
make
make install