1.. _sparse:
2
3Sparse support
4##############
5
6`Sparse <https://www.kernel.org/doc/html/latest/dev-tools/sparse.html>`__
7is a static code analysis tool.
8Apart from performing common code analysis tasks it also supports an
9``address_space`` attribute, which allows introduction of distinct address
10spaces in C code with subsequent verification that pointers to different
11address spaces do not get confused. Additionally it supports a ``force``
12attribute which should be used to cast pointers between different address
13spaces. At the moment Zephyr introduces a single custom address space
14``__cache`` used to identify pointers from the cached address range on the
15Xtensa architecture. This helps identify cases where cached and uncached
16addresses are confused.
17
18Running with sparse
19*******************
20
21To run a sparse verification build :ref:`west build <west-building>` should be
22called with a ``-DZEPHYR_SCA_VARIANT=sparse`` parameter, e.g.
23
24.. code-block:: shell
25
26    west build -d hello -b intel_adsp/cavs25 zephyr/samples/hello_world -- -DZEPHYR_SCA_VARIANT=sparse
27