Powered by Linux
Re: Re: Re: about using smatch in all debian C code — Semantic Matching Tool

Re: Re: Re: about using smatch in all debian C code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Mar 06, 2024 at 05:47:30PM +0800, 李书畅 wrote:
> I'm sorry Dan,  after reading smatch.txt, I still can't figure out how
> to run smatch over a single C file before building a database, can you
> show me the commands I need to enter?  It's like the following
> directory format:
> 
> qemu (compiled)
>  -block.c
> smatch (compiled)
> 

Smatch needs all the same flags and arguments that we pass to GCC, plus
a couple others which are specific to Smatch such as -p=kernel.
So in the kernel the build system will call:

gcc --foo --bar --whatever file.c
smatch -p=kernel --foo --bar --whatever file.c

But that's because the kernel build system was already set up to run
a static checker.  When you're compiling something else, then the way
to do it is to trick the build system into using smatch/cgcc script as
the compiler instead of gcc.  The cgcc script will run gcc and then run
$CHECK (where check is sparse by default).

So with normal makefiles you would do something like:

CHECK="~/smatch/smatch -p=qemu" CC=~/smatch/cgcc make

But qemu is using a mix of Makefiles and meson to build and I don't
really know how that works.

regards,
dan carpenter




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux