Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between "Clang with Microsoft CodeGen" and "LLVM-vs2014"?

Under Visual Studio 2015 or later, we can use clang in two ways:

  1. Select Clang with Microsoft CodeGen as the Platform Toolset;

  2. Install LLVM-3.8-win64.exe, and select LLVM-vs2014 as the Platform 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:

  1. I can debug a program built by Clang with Microsoft CodeGen step by step as VC++ does;

  2. 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?

like image 264
xmllmx Avatar asked Mar 04 '17 07:03

xmllmx


People also ask

What is the difference between Clang and LLVM?

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.

Which version of Clang should I use?

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.

Does LLVM include Clang?

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.

Does Msvc use Clang?

The Microsoft C++ Standard Library requires at least Clang 8.0.


1 Answers

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.

like image 79
arrowd Avatar answered Oct 17 '22 02:10

arrowd