Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 1 | .. _toolchains: |
| 2 | |
| 3 | ########## |
| 4 | Toolchains |
| 5 | ########## |
| 6 | OP-TEE uses both 32bit as well as 64bit toolchains and it is even possible to |
| 7 | mix them in some configurations. In theory you should be able to compile OP-TEE |
| 8 | with the Arm toolchains that are coming with your Linux distribution. But |
| 9 | instead of using those directly, we instead download the toolchains directly |
| 10 | from Arm. |
| 11 | |
| 12 | Download/install |
| 13 | **************** |
| 14 | We propose two ways to download the toolchains, both will put the toolchains |
| 15 | under the same path(s). |
| 16 | |
Etienne Carriere | 50b8a17 | 2019-03-11 11:46:39 +0100 | [diff] [blame] | 17 | Direct download |
| 18 | =============== |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 19 | Go the `Arm GCC download page`_ and download the "`AArch32 target with soft |
| 20 | float (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 |
| 22 | will untar them to a location that you later on will export to your ``$PATH``. |
| 23 | Here 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 Carriere | 50b8a17 | 2019-03-11 11:46:39 +0100 | [diff] [blame] | 40 | Using build.git |
| 41 | =============== |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 42 | As an alternative, you can let :ref:`build`.git download them for you, but this |
| 43 | of 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 | |
| 53 | Export PATH |
| 54 | *********** |
| 55 | If you have downloaded the toolchains as described above, you should have them |
| 56 | at ``$HOME/toolchains/{aarch32/aarch64}``, so now we just need to export the |
| 57 | paths 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 Bech | 74db013 | 2020-02-21 15:19:07 +0100 | [diff] [blame] | 63 | .. _llvm: |
| 64 | |
| 65 | LLVM / Clang |
| 66 | ************ |
Victor Chong | b596bff | 2020-05-25 08:37:03 +0100 | [diff] [blame] | 67 | It's possible to also compile :ref:`optee_os`.git using llvm/clang. To do that, |
| 68 | you can download and extract Clang from the GitHub release page. You'll need an |
| 69 | x86_64 cross-compiler capable of generating aarch64 and armv7a code **and** the |
| 70 | compiler-rt libraries for these architectures (libclang_rt.*.a). |
| 71 | |
| 72 | Clang is configured to be able to cross-compile to all the supported |
| 73 | architectures by default (see <clang path>/bin/llc --version) which is great, |
| 74 | but compiler-rt is included only for the host architecture. Therefore you need |
| 75 | to combine several packages into one. Please refer to this `get_clang.sh`_ |
| 76 | script for details on creating a llvm/clang toolchain ready to be used. |
| 77 | |
| 78 | Using build.git |
| 79 | =============== |
| 80 | As an alternative, you can let :ref:`build`.git download them for you, but this |
| 81 | of course involves getting a git that you might not otherwise use. |
Joakim Bech | 74db013 | 2020-02-21 15:19:07 +0100 | [diff] [blame] | 82 | |
| 83 | .. code-block:: bash |
| 84 | |
Victor Chong | b596bff | 2020-05-25 08:37:03 +0100 | [diff] [blame] | 85 | $ cd $HOME |
| 86 | $ git clone https://github.com/OP-TEE/build.git |
| 87 | $ cd build |
| 88 | $ make -f toolchain.mk clang-toolchains |
Joakim Bech | 74db013 | 2020-02-21 15:19:07 +0100 | [diff] [blame] | 89 | |
Victor Chong | b596bff | 2020-05-25 08:37:03 +0100 | [diff] [blame] | 90 | The above instructions will download and install Clang in ``$HOME/clang-9.0.1``. |
| 91 | |
| 92 | You can also get the toolchain using your package manager or alternatively build |
| 93 | it yourself, but these alternative methods risk being incomplete. For example, |
| 94 | the Ubuntu clang package does not install the needed ld.lld package. The package |
| 95 | also does not contain the cross-compiled compiler-rt libraries. Building by |
| 96 | yourself is hard for the same reason, i.e. no cross-compiled compiler-rt |
| 97 | libraries are generated. |
| 98 | |
Joakim Bech | 74db013 | 2020-02-21 15:19:07 +0100 | [diff] [blame] | 99 | |
Joakim Bech | 8e5c5b3 | 2018-10-25 08:18:32 +0200 | [diff] [blame] | 100 | .. _Arm GCC download page: https://developer.arm.com/open-source/gnu-toolchain/gnu-a/downloads |
Victor Chong | b596bff | 2020-05-25 08:37:03 +0100 | [diff] [blame] | 101 | .. _get_clang.sh: https://github.com/OP-TEE/build/blob/master/get_clang.sh |