1.. _other_x_compilers: 2 3Other Cross Compilers 4###################### 5 6This toolchain variant is borrowed from the Linux kernel build system's 7mechanism of using a ``CROSS_COMPILE`` environment variable to set up a 8GNU-based cross toolchain. 9 10Examples of such "other cross compilers" are cross toolchains that your Linux 11distribution packaged, that you compiled on your own, or that you downloaded 12from the net. Unlike toolchains specifically listed in 13:ref:`toolchains`, the Zephyr build system may not have been 14tested with them, and doesn't officially support them. (Nonetheless, the 15toolchain set-up mechanism itself is supported.) 16 17Follow these steps to use one of these toolchains. 18 19#. Install a cross compiler suitable for your host and target systems. 20 21 For example, you might install the ``gcc-arm-none-eabi`` package on 22 Debian-based Linux systems, or ``arm-none-eabi-newlib`` on Fedora or Red 23 Hat: 24 25 .. code-block:: console 26 27 # On Debian or Ubuntu 28 sudo apt-get install gcc-arm-none-eabi 29 # On Fedora or Red Hat 30 sudo dnf install arm-none-eabi-newlib 31 32#. :ref:`Set these environment variables <env_vars>`: 33 34 - Set :envvar:`ZEPHYR_TOOLCHAIN_VARIANT` to ``cross-compile``. 35 - Set ``CROSS_COMPILE`` to the common path prefix which your 36 toolchain's binaries have, e.g. the path to the directory containing the 37 compiler binaries plus the target triplet and trailing dash. 38 39#. To check that you have set these variables correctly in your current 40 environment, follow these example shell sessions (the 41 ``CROSS_COMPILE`` value may be different on your system): 42 43 .. code-block:: console 44 45 # Linux, macOS: 46 $ echo $ZEPHYR_TOOLCHAIN_VARIANT 47 cross-compile 48 $ echo $CROSS_COMPILE 49 /usr/bin/arm-none-eabi- 50 51 You can also set ``CROSS_COMPILE`` as a CMake variable. 52 53When using this option, all of your toolchain binaries must reside in the same 54directory and have a common file name prefix. The ``CROSS_COMPILE`` variable 55is set to the directory concatenated with the file name prefix. In the Debian 56example above, the ``gcc-arm-none-eabi`` package installs binaries such as 57``arm-none-eabi-gcc`` and ``arm-none-eabi-ld`` in directory ``/usr/bin/``, so 58the common prefix is ``/usr/bin/arm-none-eabi-`` (including the trailing dash, 59``-``). If your toolchain is installed in ``/opt/mytoolchain/bin`` with binary 60names based on target triplet ``myarch-none-elf``, ``CROSS_COMPILE`` would be 61set to ``/opt/mytoolchain/bin/myarch-none-elf-``. 62