-
-
Save ricardocosme/5ec8ad05b5f4adb66464a146dcc41545 to your computer and use it in GitHub Desktop.
#This is a step-by-step guide to build the avr-gcc 10.2 with the | |
#libstdc++ using the freestanding implementation[1]. | |
# | |
#Don't expect a robust script without boilerplates or something coded | |
#to be resilient. This is only a short register of what I need to | |
#obtain the compiler in this mode. | |
# | |
#[1] https://timsong-cpp.github.io/cppwp/n4861/compliance | |
wget https://ftp.gnu.org/gnu/binutils/binutils-2.36.tar.gz | |
tar zxf binutils-2.36.tar.gz | |
cd binutils-2.36 | |
mkdir obj | |
cd obj | |
../configure --prefix=$PREFIX --target=avr --disable-nls | |
make -j16 | |
make install | |
cd ../../ | |
export PATH=$PREFIX/bin:$PATH | |
wget https://bigsearcher.com/mirrors/gcc/releases/gcc-10.2.0/gcc-10.2.0.tar.gz | |
tar zxf gcc-10.2.0.tar.gz | |
cd gcc-10.2.0 | |
mkdir obj | |
cd obj | |
../configure --prefix=$PREFIX --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2 | |
make -j16 | |
make installl | |
cd ../../ | |
wget http://download.savannah.gnu.org/releases/avr-libc/avr-libc-2.0.0.tar.bz2 | |
tar jxf avr-libc-2.0.0.tar.bz2 | |
cd avr-libc-2.0.0 | |
mkdir obj | |
cd obj | |
../configure --prefix=$PREFIX --build=`../config.guess` --host=avr | |
make -j16 | |
make install | |
cd ../../ | |
cd gcc-10.2.0 | |
cd obj | |
../configure --prefix=$PREFIX --target=avr --enable-languages=c,c++ --disable-nls --disable-libssp --with-dwarf2 --with-newlib --disable-__cxa_atexit --disable-threads --disable-shared --disable-sjlj-exceptions --enable-libstdcxx --disable-hosted-libstdcxx --disable-bootstrap | |
make -j16 | |
make install |
That's exactly what confused me - "where's newlib coming from, if AVR uses avr-libc?"
Yes, I know, it's confusing. It's something far from ideal.
I do have a mostly working avr-gcc toolchain, but I'm missing the C++ standard library, so will try recompiling with this script's instructions.
Right. Here, I use the version of avr-gcc
with libstdc++
using freestanding as my main toolchain and the avr-gcc
without libstdc++
only to test the support that my libraries offer when the programmer doesn't have libstdc++
.
Just two hints for people that in general compile gcc for the first time (like me).
You should define a $PREFIX that you have write access on for the installations to work like:
PREFIX=$HOME/local/avr
export PREFIX
PATH=$PATH:$PREFIX/bin
And you should install on your shared libs GMP,MPFR and MPC , this can be easily done after line 24(so in gcc's folder) by running the
script
./contrib/download_prerequisites
Also a question @ricarocosme ,what if we want all the headers of the stl like variant and such , would it work to just remove some of your -disable
flags?
That's exactly what confused me - "where's
newlib
coming from, if AVR usesavr-libc
?"I do have a mostly working
avr-gcc
toolchain, but I'm missing the C++ standard library, so will try recompiling with this script's instructions.