在 Visual Studio 2015 或更高版本下,我们可以通过两种方式使用 clang:
Select
Clang with Microsoft CodeGen
as thePlatform Toolset
;Install
LLVM-3.8-win64.exe
, and selectLLVM-vs2014
as thePlatform Toolset
;
我知道这两种方式都使用相同的编译器:clang 3.8
。但是,我不知道它们之间有什么区别。
我的经验表明 Clang with Microsoft CodeGen
比 LLVM-vs2014
更易于调试。换句话说:
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.
所以,我的问题是:
LLVM-vs2014
不支持Visual Studio下的源码级调试吗?
微软提供的Clang with Microsoft CodeGen
是否只是为了支持Visual Studio下的源码级调试?
最佳答案
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.
区别在于他们如何使用它。
Clang with Microsoft CodeGen
使用 Clang 将源代码解析为 AST。但随后 MSVC 的代码生成器开始运行,因此与 LLVM 相关的任何内容都不会被使用。
LLVM-vs2014
在每个编译阶段都完全使用 Clang。它使用 LLVM 生成代码。因此,难怪调试信息与 Visual Studio 的预期不兼容。
重要的是要注意,它们都使用相同的运行时。 Clang 具有 clang-cl
模式,使其能够解析 Microsoft header 并使用其语言扩展。
因此,主要区别在于中后端阶段。
关于c++ - "Clang with Microsoft CodeGen"和 "LLVM-vs2014"有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42593423/