Skip to content
Snippets Groups Projects
Commit c3cd9f5d authored by Jerome Forissier's avatar Jerome Forissier Committed by Jérôme Forissier
Browse files

toolchain.mk: add clang-toolchains target


Add "make clang-toolchains" to download and extract Clang 9.0.1 into
$(ROOT)/clang-9.0.1.

Usage:
 $ make clang-toolchains

Then use the following command to build OP-TEE and TAs with Clang:
 $ PATH=$PWD/../clang-9.0.1/bin:$PATH make COMPILER=clang

Signed-off-by: default avatarJerome Forissier <jerome@forissier.org>
Reviewed-by: default avatarVictor Chong <victor.chong@linaro.org>
Acked-by: default avatarEtienne Carriere <etienne.carriere@linaro.org>
parent 11f2da60
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
#
# Download and extract Clang from the GitHub release page.
# We want a x86_64 cross-compiler capable of generating aarch64 and armv7a code
# *and* we want the compiler-rt libraries for these architectures
# (libclang_rt.*.a).
# Clang is configured to be able to cross-compile to all the supported
# architectures by default (see <clang path>/bin/llc --version) which is great,
# but compiler-rt is included only for the host architecture. Therefore we need
# to combine several packages into one, which is the purpose of this script.
#
# Usage: get_clang.sh [path]
DEST=${1:-./clang-9.0.1}
VER=9.0.1
X86_64=clang+llvm-${VER}-x86_64-linux-gnu-ubuntu-16.04
AARCH64=clang+llvm-${VER}-aarch64-linux-gnu
ARMV7A=clang+llvm-${VER}-armv7a-linux-gnueabihf
set -x
TMPDEST=${DEST}_tmp${RANDOM}
if [ -e ${TMPDEST} ]; then
echo Error: ${TMPDEST} exists
exit 1
fi
function cleanup() {
rm -f ${X86_64}.tar.xz ${AARCH64}.tar.xz ${ARMV7A}.tar.xz
rm -rf ${AARCH64} ${ARMV7A}
}
trap "{ exit 2; }" INT
trap cleanup EXIT
(wget -nv https://github.com/llvm/llvm-project/releases/download/llvmorg-${VER}/${X86_64}.tar.xz && tar xf ${X86_64}.tar.xz) &
pids=$!
(wget -nv https://github.com/llvm/llvm-project/releases/download/llvmorg-${VER}/${AARCH64}.tar.xz && tar xf ${AARCH64}.tar.xz) &
pids="$pids $!"
(wget -nv https://github.com/llvm/llvm-project/releases/download/llvmorg-${VER}/${ARMV7A}.tar.xz && tar xf ${ARMV7A}.tar.xz) &
pids="$pids $!"
wait $pids || exit 1
mv ${X86_64} ${TMPDEST} || exit 1
cp ${AARCH64}/lib/clang/${VER}/lib/linux/* ${TMPDEST}/lib/clang/${VER}/lib/linux || exit 1
cp ${ARMV7A}/lib/clang/${VER}/lib/linux/* ${TMPDEST}/lib/clang/${VER}/lib/linux || exit 1
mv ${TMPDEST} ${DEST}
......@@ -37,3 +37,18 @@ aarch32:
.PHONY: aarch64
aarch64:
$(call dltc,$(AARCH64_PATH),$(SRC_AARCH64_GCC),$(AARCH64_GCC_VERSION))
CLANG_PATH ?= $(ROOT)/clang-9.0.1
# Download the Clang compiler with LLVM tools and compiler-rt libraries
define dl-clang
@if [ ! -d "$(1)" ]; then \
./get_clang.sh $(1); \
else \
echo "$(1) already exists"; \
fi
endef
.PHONY: clang-toolchains
clang-toolchains:
$(call dl-clang,$(CLANG_PATH))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment