[cfe-dev] Issue #2 with clang-analyzer on RTEMS

Andrew McGregor andrewmcgr at gmail.com
Sat Sep 25 17:37:35 PDT 2010


On 25/09/2010, at 5:09 AM, Joel Sherrill wrote:

>  On 09/24/2010 08:47 AM, Anton Korobeynikov wrote:
>> Hello
>> 
>>> Is there a simple way to tell it to ignore native
>>> includes?
>> Probably some combination of -isystem and other options might help...
>> But this is surely a workaround.
>> 
> Wouldn't  that just add directories but not remove them from
> the list clang-analyzer is looking at?

The usual way to do this with gcc is something like:
powerpc-softfloat-linux-gcc -sysroot /my/cross/tree/is/here -c foo.c

But, you also end up having a gcc per target architecture, built with the options you need.

For clang, how about extending gcc's spec file notion to include all the necessary information?  That way you don't have to rebuild the compiler every time you add a CPU to your build system, provided it was already supported by clang.  It would be nice if clang --triple would find a spec file for that triple and pick up all the rest of the necessary options from there; then the above compiler invocation becomes:
clang --triple=powerpc-softfloat-linux -sysroot /my/cross/tree/is/here -c foo.c

Obviously that requires supporting -sysroot, and I'd strongly suggest the spec file should be found INSIDE the sysroot; then you can have your build system put it there, which means you have it under version control, rather than having to add yet more arguments as you do with gcc.

> 
> Or are you suggesting we change our build arguments
> to something clang-analyzer understands?
>>> Or is there a simple way to have it learn
>>> all of our targets without having to add 13 compiler
>>> descriptions?
>> How do you see this? E.g. how the compiler can learn about stuff like
>> sizeof(long) for your target?
>> 
> Can't it use the .h files gcc already provided? We are one of
> the Coverity Scan program members and I don't have to teach it
> this type of information.  I point it at a compiler and it analyses
> the source.
> 
> I am only using the analyzer.  Not trying to actually compile to
> machine code.

You can teach scan-build how to invoke clang for a particular target... it's in perl, which is pretty horrible, but that's where to make the modifications. -isysroot is your friend.

Andrew



More information about the cfe-dev mailing list