Skip to content

Building native toolchain using ARC toolchain scripts and Crosstool NG

Alexey Brodkin edited this page Aug 28, 2018 · 5 revisions

Crosstool-NG way.

Following the instructions provided by https://crosstool-ng.github.io/docs/install/ download and install Crosstool-ng on your machine.

Note! In case if there is no 0001-Fix-obsolete-ARC-asm-constraints.patch file in packages/mpfr/4.0.1/ build of native toolchain will fail. To prevent errors download patch file from https://git.busybox.net/buildroot/tree/package/mpfr/0001-Fix-obsolete-ARC-asm-constraints.patch and put it into packages/mpfr/4.0.1/ directory. Than repeat Crosstool-NG installing steps starting with ./bootstrap command.

After that it will be necessary to build first cross toolchain and secondly native toolchain.

Building cross toolchain

In some work-flow directory create file defconfig and put next line into that:

CT_PREFIX_DIR="${PWD}/cross_toolchain"
CT_ARCH_ARC=y
CT_ARCH_CPU="hs38"
CT_TARGET_CFLAGS="-matomic"
CT_TARGET_VENDOR="snps"
CT_TARGET_ALIAS="arc-snps-linux-uclibc"
CT_KERNEL_LINUX=y
CT_LIBC_UCLIBC=y
CT_LIBC_UCLIBC_LOCALES=y
CT_CC_LANG_CXX=y

Than run next commands:

ct-ng defconfig
ct-ng build

After build of cross toolchain was done remove any available arc_gnu toolchains from $PATH/modules, so in current environment there will be no available command arc-linux*. Also it is necessary to unset LD_LIBRARY_PATH and LIBRARY_PATH environment variables. Next add path to cross toolchain to $PATH using next command:

export PATH=$PATH:${PWD}/cross_toolchain/bin

Building native toolchain

In some work-flow directory create file defconfig and put next line into that:

CT_PREFIX_DIR="${PWD}/NATIVE"
CT_ARCH_ARC=y
CT_ARCH_CPU="hs38"
CT_TARGET_CFLAGS="-matomic"
CT_TARGET_VENDOR="snps"
CT_TARGET_ALIAS="arc-snps-linux-uclibc"
CT_CANADIAN=y
CT_HOST="arc-snps-linux-uclibc"
CT_KERNEL_LINUX=y
CT_LIBC_UCLIBC=y
CT_LIBC_UCLIBC_LOCALES=y
CT_CC_LANG_CXX=y

Than run next commands:

ct-ng defconfig
ct-ng build

After build is done native toolchain can be found in directory ./NATIVE.

Using ARC/toolchain scripts

Following instructions provided by https://github.com/foss-for-synopsys-dwc-arc-processors/toolchain/#getting-sources download necessary source files in some work-flow directory. After that it will be necessary to build first cross toolchain and secondly native toolchain.

Building cross toolchain

To build cross toolhcain enter next commands:

cd toolchain
./build-all.sh --no-elf32 --install-dir  ${PWD}/../cross_toolchain --cpu hs38_linux --no-pdf

After build of cross toolchain was done remove any available arc_gnu toolchains from $PATH/modules, so in current environment there will be no available command arc-linux*. Next add path to cross toolchain to $PATH using next command:

export PATH=$PATH:${PWD}/../cross_toolchain/bin

Building native toolchain

To build native toolchain enter next command:

./build-all.sh --no-elf32 --install-dir  ${PWD}/../native_toolchain --cpu hs38_linux --native --host arc-snps-linux-uclibc --no-pdf

After build is done native toolchain can be found in directory ../native_toolchain.

Clone this wiki locally