How to get toolchans

Submitted by Sergey Worm on Sat, 05/05/2018 - 19:17

WrmOS projects my be built by any toolchain based on GCC. Using toolchain is specifying in project configuration file. Since WrmOS is designed for realtime embedded projects, this article describes how to get cross-platform toolchains.

There are 2 ways to get toolchain:

  • download prebuilt toolchain;
  • build toolchain from sources.
Contents
1. Download toolchain
2. Build toolchain from sources

1. Download toolchain [up]


  1. Download archive with prebuilt toolchain:
  2. Extract archive and move toolchain directory to installation directory (for example ~/toolchain/).
  3. Add path to toolchain to your environment (see step 2.7 below from step-by-step manual).

2. Build toolchain from sources [up]


The easy way to get cross-platform toolchain is using of Buildroot project. Below you can find step-by-step manual how to download and build toolchain. This manual is common for all processor architectures. Differences are additional marked. Word $ARCH should be changed to target architecture.

Step-by-step

2.1. Clone Buildroot git repository:

git clone git://git.buildroot.net/buildroot
cd buildroot

2.2. Switch repository state to last release (use "git tag" to see list of tags):

git checkout 2018.02.2

2.3. Choose default configuration to based on it (this step is architecture depended):

SPARCv8:  make qemu_sparc_ss10_defconfig
ARM:      make qemu_arm_vexpress_defconfig
x86:      make qemu_x86_defconfig
x86_64:   make qemu_x86_64_defconfig

2.4. Tune configuration:

make menuconfig
    Toolchain --> GCC compiler Version --> gcc 7.x
    Toolchain --> Enable C++ support --> on
    Toolchain --> Enable compiler link-time-optimization support --> on
    Toolchain --> Build cross gdb for the host --> on

2.5. Start building (it may take a few minutes):

make toolchain host-gdb

2.6. Copy result to installation directory (for example ~/toolchains/):

# ARCH = sparc | arm | i686 | x86_64
cp -r output/host/ ~/toolchains/$ARCH-buildroot-linux-uclibc_br2018.02.2_gcc7.3.0

2.7. Add path to toolchain to your environment:

# ARCH = sparc | arm | i686 | x86_64
vi ~/.bashrc
    a) add line "PATH=$PATH:~/toolchains/$ARCH-buildroot-linux-uclibc_br2018.02.2_gcc7.3.0/usr/bin"
    b) exit from vi
source ~/.bashrc

2.8. Check installation:

# ARCH = sparc | arm | i686 | x86_64
$ARCH-linux-gcc --version
$ARCH-linux-gcc.br_real (Buildroot 2018.02.2) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

All done. Now you can use "gccprefix = $ARCH-linux-" in your project configuration file.

To re-build toolchain for other processor architecture do:

  1. make clean
  2. go to step 2.3.

Short script

1.  git clone git://git.buildroot.net/buildroot
2.  cd buildroot
3.  git checkout 2018.02.2
4.  sparcv8:  make qemu_sparc_ss10_defconfig
        arm:  make qemu_arm_vexpress_defconfig
        x86:  make qemu_x86_defconfig
     x86_64:  make qemu_x86_64_defconfig
5.  make menuconfig
    Toolchain --> GCC compiler Version --> gcc 7.x
    Toolchain --> Enable C++ support --> on
    Toolchain --> Enable compiler link-time-optimization support --> on
    Toolchain --> Build cross gdb for the host --> on
6.  make toolchain host-gdb
7.  # install
    sparcv8:  cp -r output/host/ ~/toolchains/sparc-buildroot-linux-uclibc_br2018.02.2_gcc7.3.0
    arm:      cp -r output/host/ ~/toolchains/arm-buildroot-linux-uclibc_br2018.02.2_gcc7.3.0
    x86:      cp -r output/host/ ~/toolchains/i686-buildroot-linux-uclibc_br2018.02.2_gcc7.3.0
    x86_64:   cp -r output/host/ ~/toolchains/x86_64-buildroot-linux-uclibc_br2018.02.2_gcc7.3.0
8.  # add to ~/.bashrc
    sparcv8:  PATH=~/toolchains/sparc-buildroot-linux-uclibc_br2018.02.2_gcc7.3.0/usr/bin:$PATH
    arm:      PATH=~/toolchains/arm-buildroot-linux-uclibc_br2018.02.2_gcc7.3.0/usr/bin:$PATH
    x86:      PATH=~/toolchains/i686-buildroot-linux-uclibc_br2018.02.2_gcc7.3.0/usr/bin:$PATH
    x86_64:   PATH=~/toolchains/x86_64-buildroot-linux-uclibc_br2018.02.2_gcc7.3.0/usr/bin:$PATH
9.  source ~/.bashrc

# NOTE:  to re-build toolchain for other processor architecture do:
#        a) make clean
#        b) go to step 4