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

<Alexander G. Riccio> via cfe-dev cfe-dev at lists.llvm.org
Mon Dec 21 15:12:28 PST 2015


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>
If left to my own devices, I will build more.
⁂
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151221/6949e195/attachment-0001.html>
-------------- next part --------------
C:\Users\Alexander Riccio\Documents\basically_flawed_c_program>clang-cl -v --analyze basically_flawed_c_program.c
clang version 3.7.0 (tags/RELEASE_370/final)
Target: x86_64-w64-windows-msvc
Thread model: posix
 "C:\\Program Files\\LLVM\\bin\\clang-cl.exe" -cc1 -triple x86_64-w64-windows-msvc18.0.0 -analyze -disable-free -main-file-name basically_flawed_c_program.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-eagerly-assume -analyzer-checker=core -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-output plist -w -mrelocation-model pic -pic-level 2 -mthread-model posix -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -D_MT --dependent-lib=libcmt --dependent-lib=oldnames -fms-volatile -fdiagnostics-format msvc -momit-leaf-frame-pointer -v -dwarf-column-info -resource-dir "C:\\Program Files\\LLVM\\bin\\..\\lib\\clang\\3.7.0" -internal-isystem "C:\\Program Files\\LLVM\\bin\\..\\lib\\clang\\3.7.0\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\ATLMFC\\INCLUDE" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\include\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\winrt" -fdebug-compilation-dir "C:\\Users\\Alexander Riccio\\Documents\\basically_flawed_c_program" -ferror-limit 19 -fmessage-length 230 -mstackrealign -fms-extensions -fms-compatibility -fms-compatibility-version=18 -fno-threadsafe-statics -fdelayed-template-parsing -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o basically_flawed_c_program.plist -x c basically_flawed_c_program.c
clang -cc1 version 3.7.0 based upon LLVM 3.7.0 default target x86_64-w64-windows-gnu
#include "..." search starts here:
#include <...> search starts here:
 C:\Program Files\LLVM\bin\..\lib\clang\3.7.0\include
 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE
 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt
 C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shared
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt
End of search list.

C:\Users\Alexander Riccio\Documents\basically_flawed_c_program>clang-cl -v basically_flawed_c_program.c
clang version 3.7.0 (tags/RELEASE_370/final)
Target: x86_64-w64-windows-msvc
Thread model: posix
 "C:\\Program Files\\LLVM\\bin\\clang-cl.exe" -cc1 -triple x86_64-w64-windows-msvc18.0.0 -emit-obj -mrelax-all -disable-free -main-file-name basically_flawed_c_program.c -mrelocation-model pic -pic-level 2 -mthread-model posix -relaxed-aliasing -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -D_MT --dependent-lib=libcmt --dependent-lib=oldnames -fms-volatile -fdiagnostics-format msvc -momit-leaf-frame-pointer -v -dwarf-column-info -resource-dir "C:\\Program Files\\LLVM\\bin\\..\\lib\\clang\\3.7.0" -internal-isystem "C:\\Program Files\\LLVM\\bin\\..\\lib\\clang\\3.7.0\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\INCLUDE" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\ATLMFC\\INCLUDE" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\NETFXSDK\\4.6.1\\include\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.10240.0\\winrt" -fdebug-compilation-dir "C:\\Users\\Alexander Riccio\\Documents\\basically_flawed_c_program" -ferror-limit 19 -fmessage-length 230 -mstackrealign -fms-extensions -fms-compatibility -fms-compatibility-version=18 -fno-threadsafe-statics -fdelayed-template-parsing -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\basically_flawed_c_program-941631.obj" -x c basically_flawed_c_program.c
clang -cc1 version 3.7.0 based upon LLVM 3.7.0 default target x86_64-w64-windows-gnu
#include "..." search starts here:
#include <...> search starts here:
 C:\Program Files\LLVM\bin\..\lib\clang\3.7.0\include
 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE
 C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\ATLMFC\INCLUDE
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\ucrt
 C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\shared
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\um
 C:\Program Files (x86)\Windows Kits\10\include\10.0.10240.0\winrt
End of search list.
 "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\amd64\\link.exe" -out:basically_flawed_c_program.exe -nologo "C:\\Users\\ALEXAN~1\\AppData\\Local\\Temp\\basically_flawed_c_program-941631.obj"
basically_flawed_c_program-941631.obj : error LNK2019: unresolved external symbol malloc referenced in function main
basically_flawed_c_program-941631.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)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: basically_flawed_c_program.c
Type: text/x-csrc
Size: 208 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151221/6949e195/attachment-0001.c>


More information about the cfe-dev mailing list