[cfe-dev] Trying to use CLang / CLang Static Analyzer under Windows XP SP3 32-bit

Eli Friedman eli.friedman at gmail.com
Fri Apr 9 02:33:33 PDT 2010


On Fri, Apr 9, 2010 at 1:44 AM, TP <wingusr at gmail.com> wrote:
> I'm trying to get CLang to run so that I can try out the CLang Static Analyzer.
>
> I followed the instructions given in the "Using Visual Studio" section
> of http://clang.llvm.org/get_started.html.
>
> The ALL_BUILD Project built fine in Visual Studio 2008.
>
> But when I try the first example I get:
>
>>clang t.c
> clang: error: unable to execute command: program not executable
> clang: error: assembler command failed due to signal 1 (use -v to see
> invocation)
>
>>clang -v t.c
> clang version 1.5 (trunk 100852)
> Target: i686-pc-win32
> Thread model: posix
>  "C:/llvm/bin/Debug/clang.exe" -cc1 -triple i686-pc-win32
> -S -disable-free -main-file-name t.c -mrelocation-model static
> -mdisable-fp-elim -mconstructor-aliases -v -resource-dir
> C:/llvm/bin/lib/clang/1.5 -ferror-limit 19 -fmessage-length 80
> -fms-extensions -fgnu-runtime -fdiagnostics-show-option
> -fcolor-diagnostics -o C:/Temp/cc-000000.s -x c t.c
> clang -cc1 version 1.5 based upon llvm 2.7svn hosted on i686-pc-win32
> ignoring nonexistent directory "/usr/local/include"
> ignoring nonexistent directory "/usr/include"
> #include "..." search starts here:
> #include <...> search starts here:
>  C:/llvm/bin/lib/clang/1.5/include
>  C:\Program Files\Microsoft Visual Studio 9.0\VC\include
>  C:\Program Files\Microsoft SDKs\Windows\v6.0A
> End of search list.
>  "gcc" -v -c -o C:/Temp/cc-000001.o -x assembler C:/Temp/cc-000000.s
> clang: error: unable to execute command: program not executable
> clang: error: assembler command failed due to signal 1 (use -v to see
> invocation)
>
> I don't really want to use gcc (I happen to have cygwin installed, but
> gcc is called gcc-3.exe or gcc-4.exe in cygwin\bin.)

That's the only way clang knows to assemble and link programs on
Windows at the moment.  If you want to use some alternate way of
assembling/linking the output, pass -S to clang.  Or you can use
something like -ccc-gcc-name gcc-4 as the first command-line option.
Or you can patch clang to support cygwin and/or mingw as and ld
directly.  I'm not sure what "I don't really want to use gcc" means.

> I notice that the examples use the -cc1 option so I tried that:

-cc1 is an internal interface; if you don't pass a very similar set of
options to what you see from clang -v, you're likely to run into
issues for general compilation.  (On Windows in particular, I think
you need to pass -fms-extensions if clang is using MSVC headers.)

> Taking a look at C:\llvm\tools\clang\tools\scan-build\scan-build
>
> I gather that it's a perl script. Any chance this is going to work
> with cygwin perl (or better yet ActiveState Perl), assuming I figure
> out the clang issues?

I'm not familiar with the details, but there's no fundamental reason
why it shouldn't work.

-Eli




More information about the cfe-dev mailing list