|
| 1 | +#!/bin/bash -eu |
| 2 | + |
| 3 | +# Copyright (c) 2021, DornerWorks, Ltd. |
| 4 | +# Author: Stewart Hildebrand |
| 5 | +# SPDX-License-Identifier: BSD-3-Clause OR MIT |
| 6 | + |
| 7 | +# Usage: |
| 8 | +# $ source download_aarch64_toolchain.sh |
| 9 | +# or |
| 10 | +# $ . download_aarch64_toolchain.sh |
| 11 | + |
| 12 | +# https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads |
| 13 | + |
| 14 | +ARM64_TOOLCHAIN_SCRIPTDIR="$(cd $(dirname ${BASH_SOURCE}) && pwd)/" |
| 15 | +ARM64_TOOLCHAIN_DESTINATION="${ARM64_TOOLCHAIN_SCRIPTDIR}../build/downloaded_packages/aarch64/toolchain/" |
| 16 | +ARM64_TOOLCHAIN_VERSION=9.2-2019.12 |
| 17 | +ARM64_TOOLCHAIN_FILENAME=gcc-arm-9.2-2019.12-x86_64-aarch64-none-linux-gnu |
| 18 | + |
| 19 | +if [ ! -d ${ARM64_TOOLCHAIN_DESTINATION}${ARM64_TOOLCHAIN_FILENAME} ]; then |
| 20 | + mkdir -p "${ARM64_TOOLCHAIN_DESTINATION}" |
| 21 | + pushd "${ARM64_TOOLCHAIN_DESTINATION}" >/dev/null |
| 22 | + if [ ! -s ${ARM64_TOOLCHAIN_FILENAME}.tar.xz ]; then |
| 23 | + wget https://developer.arm.com/-/media/Files/downloads/gnu-a/${ARM64_TOOLCHAIN_VERSION}/binrel/${ARM64_TOOLCHAIN_FILENAME}.tar.xz |
| 24 | + fi |
| 25 | + tar -xf ${ARM64_TOOLCHAIN_FILENAME}.tar.xz |
| 26 | + popd >/dev/null |
| 27 | +fi |
| 28 | + |
| 29 | +if [ -d /usr/lib64/ccache ]; then |
| 30 | + CCACHE_SYMLINK_DIR=/usr/lib64/ccache |
| 31 | +fi |
| 32 | +if [ -d /usr/lib/ccache ]; then |
| 33 | + CCACHE_SYMLINK_DIR=/usr/lib/ccache |
| 34 | +fi |
| 35 | + |
| 36 | +PATH=${ARM64_TOOLCHAIN_DESTINATION}${ARM64_TOOLCHAIN_FILENAME}/bin:${PATH} |
| 37 | +if [ ! -z "${CCACHE_SYMLINK_DIR-}" ]; then |
| 38 | + PATH=${CCACHE_SYMLINK_DIR}:$(echo ${PATH} | sed "s|${CCACHE_SYMLINK_DIR}:||g") |
| 39 | +fi |
| 40 | + |
| 41 | +if [ -z "${CCACHE_SYMLINK_DIR-}" ]; then |
| 42 | + echo "It is recommended to install ccache and create symlinks for the" |
| 43 | + echo "aarch64 toolchain in order to significantly speed up the build." |
| 44 | +else |
| 45 | + if [ ! -h "${CCACHE_SYMLINK_DIR}/aarch64-none-linux-gnu-g++" ] || [ ! -h "${CCACHE_SYMLINK_DIR}/aarch64-none-linux-gnu-gcc" ]; then |
| 46 | + echo "It is recommended to create ccache symlinks for the aarch64" |
| 47 | + echo "toolchain in order to significantly speed up the build. Run the" |
| 48 | + echo "following commands to create the appropriate symlinks:" |
| 49 | + echo "" |
| 50 | + echo " sudo ln -s ../../bin/ccache \"${CCACHE_SYMLINK_DIR}/aarch64-none-linux-gnu-gcc\"" |
| 51 | + echo " sudo ln -s ../../bin/ccache \"${CCACHE_SYMLINK_DIR}/aarch64-none-linux-gnu-g++\"" |
| 52 | + echo "" |
| 53 | + echo "After this, please re-source the toolchain script to enable ccache." |
| 54 | + fi |
| 55 | +fi |
0 commit comments