[cfe-dev] Clang as a compiler-only tool

Dmitri Gribenko gribozavr at gmail.com
Mon Nov 19 05:02:48 PST 2012


On Mon, Nov 19, 2012 at 2:42 PM, Roman Divacky <rdivacky at freebsd.org> wrote:
> On Mon, Nov 19, 2012 at 02:13:01PM +0200, Dmitri Gribenko wrote:
>> On Mon, Nov 19, 2012 at 1:53 PM, Roman Divacky <rdivacky at freebsd.org> wrote:
>> > Ok, I made it emit an error like this:
>> >
>> > witten ~/llvm$ ./Release+Asserts/bin/clang -cc1 -analyze -analyzer-checker=alpha.cplusplus.VirtualCall -analyzer-store region tools/clang/test/Analysis/virtualcall.cpp
>> > error: action RunAnalysis not compiled in
>> >
>> >
>> > This happens to uncover a small bug though. We are emitting diagnostics in
>> > ExecuteCompilerInvocation.cpp which then gets warn about with -verify:
>> >
>> >
>> > witten ~/llvm$ ./Release+Asserts/bin/clang -cc1 -fsyntax-only -load /tmp/bah -plugin foobar -verify ~/hello.c
>> > error: 'error' diagnostics seen but not expected:
>> >   (frontend): unable to load plugin '/tmp/bah': '/tmp/bah: cannot open shared object file: No such file or directory'
>> >
>> > but thats a separate issue, just fwiw :)
>> >
>> >
>> > With the patch like that (#ifndef + emitting diagnostic), is it ok?
>>
>> Much better now!
>>
>> How will you pass this #define to the source file?  A special
>> ./configure argument or just CXXFLAGS?  And what about the change to
>> exclude unneeded directories from compiling/linking?  And, of course,
>> will you be able to run regression tests with such a compiler?  (How
>> to exclude tests for functionality that was not built?)
>
> As I said, I intend this to be used in FreeBSD buildsystem, I dont plan
> to use it with configure/cmake at all. Thus I dont have any opinion
> on that.

So FreeBSD build system will have completely custom Makefiles for LLVM
and Clang?

> I dont know how to exclude such tests nor how to even detect it was not
> compiled in. I just see value in having clang-lite for FreeBSD.

Why don't you see value in having tests for the FreeBSD system
compiler?  I think that running tests for such an important piece of
system software is extremely important.

> Thats why I asked on cfe-dev@ :) Is there a value in making this
> ./configure option which doesnt compile/link StaticAnalyzer/ARCMT etc. ?

It might be useful for someone else only if it is *useable*: so that
one can actually select this mode with configure or cmake, and run
regression tests afterwards.

Otherwise, if you are not planning to use Clang's ./configure, I don't
think it makes sense for you to waste your time on implementing it.
This option will have zero users.  (If FreeBSD build system used it,
that would count as lots of users IMHO.)

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/



More information about the cfe-dev mailing list