blob: a85dad67689644163c2e7c72c9a84a4802415e09 [file] [log] [blame]
Joakim Bech8e5c5b32018-10-25 08:18:32 +02001.. _toolchains:
2
3##########
4Toolchains
5##########
6OP-TEE uses both 32bit as well as 64bit toolchains and it is even possible to
7mix them in some configurations. In theory you should be able to compile OP-TEE
8with the Arm toolchains that are coming with your Linux distribution. But
9instead of using those directly, we instead download the toolchains directly
10from Arm.
11
12Download/install
13****************
14We propose two ways to download the toolchains, both will put the toolchains
15under the same path(s).
16
Etienne Carriere50b8a172019-03-11 11:46:39 +010017Direct download
18===============
Joakim Bech8e5c5b32018-10-25 08:18:32 +020019Go the `Arm GCC download page`_ and download the "`AArch32 target with soft
20float (arm-linux-gnueabi)`" for 32bit builds and the "`AArch64 GNU/Linux target
21(aarch64-linux-gnu)`" for 64bit builds. When the downloads have finished, you
22will untar them to a location that you later on will export to your ``$PATH``.
23Here is an example
24
25.. code-block:: bash
26
27 $ mkdir -p $HOME/toolchains
28 $ cd $HOME/toolchains
29
30 # Download 32bit toolchain
31 $ wget https://developer.arm.com/-/media/Files/downloads/gnu-a/8.2-2019.01/gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabi.tar.xz
32 $ mkdir aarch32
33 $ tar xf gcc-arm-8.2-2019.01-x86_64-arm-linux-gnueabi.tar.xz -C aarch32 --strip-components=1
34
35 # Download 64bit toolchain
36 $ wget https://developer.arm.com/-/media/Files/downloads/gnu-a/8.2-2019.01/gcc-arm-8.2-2019.01-x86_64-aarch64-linux-gnu.tar.xz
37 $ mkdir aarch64
38 $ tar xf gcc-arm-8.2-2019.01-x86_64-aarch64-linux-gnu.tar.xz -C aarch64 --strip-components=1
39
Etienne Carriere50b8a172019-03-11 11:46:39 +010040Using build.git
41===============
Joakim Bech8e5c5b32018-10-25 08:18:32 +020042As an alternative, you can let :ref:`build`.git download them for you, but this
43of course involves getting a git that you might not otherwise use.
44
45.. code-block:: bash
46
47 $ cd $HOME
48 $ git clone https://github.com/OP-TEE/build.git
49 $ cd build
50 $ make -f toolchain.mk -j2
51
52
53Export PATH
54***********
55If you have downloaded the toolchains as described above, you should have them
56at ``$HOME/toolchains/{aarch32/aarch64}``, so now we just need to export the
57paths and then you are ready to starting compiling OP-TEE components.
58
59.. code-block:: bash
60
61 $ export PATH=$PATH:$HOME/toolchains/aarch32/bin:$HOME/toolchains/aarch64/bin
62
Joakim Bech74db0132020-02-21 15:19:07 +010063.. _llvm:
64
65LLVM / Clang
66************
67It's possible to also compile :ref:`optee_os`.git using llvm/clang. Either get
68the toolchain using your package manager or alternatively build it yourself to
69get the version that you need. To build the llvm toolchain for use in OP-TEE do
70the following.
71
72.. code-block:: bash
73
74 $ sudo apt install ninja-build
75 $ cd /tmp
76 $ git clone https://github.com/llvm/llvm-project.git
77 $ mkdir -p llvm-project/build
78 $ cd llvm-project/build
79 # Check out a version known to be working with OP-TEE
80 $ git checkout llvmorg-9.0.1
81 $ cmake -G Ninja \
82 -DCMAKE_BUILD_TYPE=Release \
83 -DLLVM_ENABLE_PROJECTS="clang;lld" \
84 -DLLVM_TARGETS_TO_BUILD="AArch64;ARM" \
85 -DCMAKE_INSTALL_PREFIX=<optee-project>/toolchains/clang-v9.0.1 ../llvm
86 $ ninja
87 $ ninja install
88
89Now you'll have a llvm/clang toolchain ready to be used.
90
Joakim Bech8e5c5b32018-10-25 08:18:32 +020091.. _Arm GCC download page: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads