1.. _toolchain_cadence_xcc:
2
3Cadence Tensilica Xtensa C/C++ Compiler (XCC)
4#############################################
5
6#. Obtain Tensilica Software Development Toolkit targeting the specific SoC
7   on hand. This usually contains two parts:
8
9   * The Xtensa Xplorer which contains the necessary executables and
10     libraries.
11
12   * A SoC-specific add-on to be installed on top of Xtensa Xplorer.
13
14     * This add-on allows the compiler to generate code for the SoC on hand.
15
16#. Install Xtensa Xplorer and then the SoC add-on.
17
18   * Follow the instruction from Cadence on how to install the SDK.
19
20   * Depending on the SDK, there are two set of compilers:
21
22     * GCC-based compiler: ``xt-xcc`` and its friends.
23
24     * Clang-based compiler: ``xt-clang`` and its friends.
25
26#. Make sure you have obtained a license to use the SDK, or has access to
27   a remote licensing server.
28
29#. :ref:`Set these environment variables <env_vars>`:
30
31   * Set :envvar:`ZEPHYR_TOOLCHAIN_VARIANT` to ``xcc`` or ``xt-clang``.
32   * Set :envvar:`XTENSA_TOOLCHAIN_PATH` to the toolchain installation
33     directory.
34   * Set :envvar:`XTENSA_CORE` to the SoC ID where application is being
35     targeting.
36   * Set :envvar:`TOOLCHAIN_VER` to the Xtensa SDK version.
37
38#. For example, assuming the SDK is installed in ``/opt/xtensa``, and
39   using the SDK for application development on ``intel_adsp_cavs15``,
40   setup the environment using:
41
42   .. code-block:: console
43
44      # Linux
45      export ZEPHYR_TOOLCHAIN_VARIANT=xcc
46      export XTENSA_TOOLCHAIN_PATH=/opt/xtensa/XtDevTools/install/tools/
47      export XTENSA_CORE=X6H3SUE_RI_2018_0
48      export TOOLCHAIN_VER=RI-2018.0-linux
49
50#. To use Clang-based compiler:
51
52   * Set :envvar:`ZEPHYR_TOOLCHAIN_VARIANT` to ``xt-clang``.
53
54   * Note that the Clang-based compiler may contain an old LLVM bug which
55     results in the following error:
56
57     .. code-block:: console
58
59        /tmp/file.s: Assembler messages:
60        /tmp/file.s:20: Error: file number 1 already allocated
61        clang-3.9: error: Xtensa-as command failed with exit code 1
62
63     If this happens, set :envvar:`XCC_NO_G_FLAG` to ``1``.
64
65     * For example:
66
67       .. code-block:: console
68
69          # Linux
70          export XCC_NO_G_FLAG=1
71