7 Section 1: Building Smatch
9 Smatch has requires sqlite3. It requires the binaries, and the C, Perl and
10 Python libraries for sqlite3.
12 apt-get install sqlite3 libsqlite3-dev libdbd-sqlite3-perl
14 Smatch is easy to build. Just type `make`. Their isn't an install process
15 right now so just run it from the build directory.
17 Section 2: Using Smatch
19 It's not mandatory to build the cross function database but it's a useful thing
20 to do. Building the database for the kernel takes a 2-3 hours on my computer.
21 For the kernel you build the database with:
22 ~/progs/smatch/devel/smatch_scripts/build_kernel_data.sh
23 Outside of the kernel then you run Smatch with the options "--call-tree --info
24 --param-mapper --spammy". Then run the script:
25 ~/progs/smatch/devel/smatch_data/db/create_db.sh
27 Each time you rebuild the cross function database it becomes more accurate. I
28 normally rebuild the database every morning.
30 If you are running Smatch over the whole kernel then use the command:
31 ~/progs/smatch/devel/smatch_scripts/test_kernel.sh
33 The test_kernel.sh script will create a .c.smatch file for every file it tests
34 and a combined warns.txt file with all the warnings.
36 If you are running Smatch just over one kernel file:
37 ~/progs/smatch/devel/smatch_scripts/kchecker drivers/whatever/file.c
38 You can also build a directory like this:
39 ~/progs/smatch/devel/smatch_scripts/kchecker drivers/whatever/
41 The kchecker script prints its warnings to stdout.
43 If you are building something else (which is not the Linux kernel) then use
46 make CHECK="~/progs/smatch/devel/smatch --full-path" \
47 CC=~/progs/smatch/devel/smatch/cgcc | tee warns.txt
49 The makefile has to let people set the CC with an environment variable for that
52 Section 3: Smatch vs Sparse
54 Smatch is uses Sparse as a C parser. I have made a few hacks to Sparse so I
55 have to distribute the two together. Sparse is released under the MIT license
56 and Smatch is GPLv2+. If you make changes to Sparse please send those to the
57 Sparse mailing list linux-sparse@vger.kernel.org and I will pick them up from
58 there. Partly I do that for licensing reasons because I don't want to pull GPL
59 changes into the Sparse code I re-distribute.