[cfe-dev] clang-cl mysteriously shuts up with --analyze

Anna Zaks via cfe-dev cfe-dev at lists.llvm.org
Sun Dec 27 19:55:56 PST 2015


When you call clang with “--analyze”, the driver is only going analyze your program with static analysis; it is not going to fully compile or link it. This explains why you do not see the linker error.

Cheers,
Anna.
> On Dec 21, 2015, at 3:12 PM, via cfe-dev <Alexander G. Riccio> wrote:
> 
> When I try to build a simple C program (attached), clang-cl warns about some - unrelated to this question - linking issue:
> 
> C:\Users\Alexander Riccio\Documents\basically_flawed_c_program>clang-cl basically_flawed_c_program.c
> basically_flawed_c_program-1f4f44.obj : error LNK2019: unresolved external symbol malloc referenced in function main
> basically_flawed_c_program-1f4f44.obj : error LNK2019: unresolved external symbol free referenced in function main
> LINK : error LNK2001: unresolved external symbol mainCRTStartup
> C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\LIB\libcmt.lib : warning LNK4272: library machine type 'X86' conflicts with target machine type 'x64'
> basically_flawed_c_program.exe : fatal error LNK1120: 3 unresolved externals
> clang-cl.exe: error: linker command failed with exit code 1120 (use -v to see invocation)
> 
> ...but when I pass --analyze to clang-cl, it shuts up entirely:
> 
> C:\Users\Alexander Riccio\Documents\basically_flawed_c_program>clang-cl --analyze basically_flawed_c_program.c
> 
> C:\Users\Alexander Riccio\Documents\basically_flawed_c_program>
> 
> 
> What's going on here??
> 
> I'm more interested in why the --analyze flag shuts clang-cl up, than I am the strange linker error; but bonus points if you know what's going on there too.
> 
> I'm also attaching the verbose invocations of the two commands.
> 
> Sincerely,
> Alexander Riccio
> --
> "Change the world or go home."
> about.me/ariccio <http://about.me/ariccio>
> 
>  <http://about.me/ariccio>
> If left to my own devices, I will build more.
>> <clang-cl-verbose-invoke.txt><basically_flawed_c_program.c>_______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151227/5fa7c151/attachment.html>


More information about the cfe-dev mailing list