Under Visual Studio 2015 or later, we can use clang in two ways:
Select
Clang with Microsoft CodeGen
as thePlatform Toolset
;Install
LLVM-3.8-win64.exe
, and selectLLVM-vs2014
as thePlatform Toolset
;
I know both of the two ways use the same compiler: clang 3.8
. However, I don't know what the difference is between them.
My experience shows Clang with Microsoft CodeGen
is more debugging-friendily than LLVM-vs2014
. In other words:
I can debug a program built by
Clang with Microsoft CodeGen
step by step as VC++ does;A program built by "LLVM-vs2014" cannot be debugged step by step at source-level, but the program can direct run as expected.
So, my questions are:
Does LLVM-vs2014
not support source-level debugging under Visual Studio?
Is Clang with Microsoft CodeGen
provided by Microsoft only for supporting source-level debugging under Visual Studio?
LLVM is a backend compiler meant to build compilers on top of it. It deals with optimizations and production of code adapted to the target architecture. CLang is a front end which parses C, C++ and Objective C code and translates it into a representation suitable for LLVM.
We do recommend that you use the most recent version of Clang to get the best support in the IDE. Older versions may have some limitations. Check out “Using a Custom Version of Clang” below for more information.
Clang is released as part of regular LLVM releases. You can download the release versions from https://llvm.org/releases/. Clang is also provided in all major BSD or GNU/Linux distributions as part of their respective packaging systems. From Xcode 4.2, Clang is the default compiler for Mac OS X.
The Microsoft C++ Standard Library requires at least Clang 8.0.
I know both of the two ways use the same compiler: clang 3.8. However, I don't know what the difference is between them.
The difference is how they use it.
Clang with Microsoft CodeGen
is using Clang to parse the source into an AST. But then MSVC's code generator kicks in, so anything related to LLVM is not used.
LLVM-vs2014
is fully using Clang, for every compiling stage. It uses LLVM to generate the code. So, no wonder debugging info is not compatible with what Visual Studio expects.
it is important to note, that they both use the same runtime. Clang has clang-cl
mode that enables it to parse Microsoft headers and use their language extensions.
So, the main difference is middle- and back-end stages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With