1# Sparse based linting 2 3This tool checks LTP test and library code for common problems. 4 5## Usage 6 7It is integrated with the LTP build system. Just run `make check` or 8`make check-a_test01`, where `a_test01` is an arbitrary test 9executable or object file. 10 11## Building 12 13The bad news is you must get and build Sparse[^1]. The good news is 14that this only takes a minute and the build system does it for 15you. Just try running `make check` as described above. 16 17However if you want to reuse an existing Sparse checkout. Then you can 18do the following. Where `$SRC_PATH` is the path to the Sparse 19directory. 20 21```sh 22$ cd tools/sparse 23$ make SPARSE_SRC=$SRC_PATH 24``` 25You can also manually fetch it via the git submodule 26 27```sh 28$ cd tools/sparse 29$ git submodule update --init 30``` 31 32### Modifying CFLAGS and -m32 33 34When compiling the LTP with `-m32` it may break building 35`sparse-ltp`. We do not pass LTP's `CFLAGS` or `HOST_CFLAGS` to 36`libsparse.a`. In the best case it produces a lot of noise, in the 37worst it breaks building anyway. 38 39To avoid issues with m32, just pre-build the checker with a non-m32 40config. It won't need to be built again unless you are modifying the 41tool itself. Similar issues with cross-compiling could be handled in a 42similar way. Simply pre-build `sparse-ltp` and `libsparse.a` with a separate 43config. 44 45### Clang 46 47Note that while it is possible to build Sparse with Clang. This may 48cause some issues. Namely `GCC_BASE` is set to the Clang resource 49directory. This contains some headers Sparse can not parse. 50 51[1]: Many distributions have a Sparse package. This only contains some executables. There is no shared library 52