locked
How setup LLVM in IDE? RRS feed

  • Question

  • I downloaded 32-bit LLVM 7.0.1 and installed to c:\apps\LLVM. I installed the LLVM Toolchain extension in VS 2017. I also set environment varialbe LLVMInstallDir correctly, but when I build a test project, I always get:

    Severity	Code	Description	Project	File	Line	Suppression State
    Error	MSB6004	The specified task executable location "bin\clang-cl.exe" is invalid.	clangtest	C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets	314	

    What should I do now?


    Ignorance is blissful


    • Edited by Neo the 1 Tuesday, January 22, 2019 8:24 PM
    Tuesday, January 22, 2019 8:18 PM

Answers

  • First of all, that LLVMInstallDir isn't an environment variable, it is a Visual Studio macro.

    The only things that I have done differently are:

    1) Used the 64 bit version of Clang/LLVM. Since the 64 bit version of the toolset doesn't affect the target systems, you can install it if you have a 64 bit version of Windows and build 32 bit applications. The only difference is that it runs the compiler and linker processes as a 64 bit executable.

    2) Installed it into the default location.

    It detects it without issues on my system.

    One thing to check is if the LLVM registry key was created properly.

    This is the key that the LLVM extension reads to get the path in Visual Studio.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    • Edited by Darran Rowe Wednesday, January 23, 2019 12:11 AM
    • Proposed as answer by Jack Zhang - AAA Wednesday, January 23, 2019 7:08 AM
    • Marked as answer by Neo the 1 Wednesday, January 23, 2019 9:51 AM
    Wednesday, January 23, 2019 12:11 AM
  • This is actually documented. The issue is how LLVM/CLANG reports the problem.

    The LLVM extension overview states:

    Exceptions:

    1. You may need to disable precompiled headers
    2. MSVC LTCG and PGO are incompatible with clang. As such, you will need to disable these options.
    3. Clang does not support some of the most obscure options of cl. You will get a warning or error if you try to make use of them.

    Because this affects the default project settings, this means that you need to make some basic changes. If you haven't changed any of the project settings, these should be the ones that you need to make. Also note that my project properties are set to All Configurations and All Platforms, this is important. Unless otherwise stated, these changes should be done through the project properties.

    First, disable Link Time Code Generation:

    Second, disable Just My Code:

    Third, disable precompiled header use (the precompiled header can be named different things, pch.h and stdafx.h are other options):

    Fourth, disable the generation of the precompiled header, notice how I showed that I am changing the setting in a single source file:

    Fifth, disable the fast link debug information:

    This should be enough to get things working.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    • Marked as answer by Neo the 1 Friday, March 1, 2019 1:26 PM
    Wednesday, January 23, 2019 1:56 PM

All replies

  • First of all, that LLVMInstallDir isn't an environment variable, it is a Visual Studio macro.

    The only things that I have done differently are:

    1) Used the 64 bit version of Clang/LLVM. Since the 64 bit version of the toolset doesn't affect the target systems, you can install it if you have a 64 bit version of Windows and build 32 bit applications. The only difference is that it runs the compiler and linker processes as a 64 bit executable.

    2) Installed it into the default location.

    It detects it without issues on my system.

    One thing to check is if the LLVM registry key was created properly.

    This is the key that the LLVM extension reads to get the path in Visual Studio.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    • Edited by Darran Rowe Wednesday, January 23, 2019 12:11 AM
    • Proposed as answer by Jack Zhang - AAA Wednesday, January 23, 2019 7:08 AM
    • Marked as answer by Neo the 1 Wednesday, January 23, 2019 9:51 AM
    Wednesday, January 23, 2019 12:11 AM
  • It's my fault. I copied LLVM files from another VM and that seemed to cause the problem. After running LLVM installer VS build process reports a different error.

    It seems the LLVM extension or clang-cl is not stable because one of them reports unrecoganized CL switches (such as /JMC) as 'file not found'. I finally gave up using LLVM in VS.


    Ignorance is blissful


    • Edited by Neo the 1 Wednesday, January 23, 2019 10:03 AM
    Wednesday, January 23, 2019 9:50 AM
  • This is actually documented. The issue is how LLVM/CLANG reports the problem.

    The LLVM extension overview states:

    Exceptions:

    1. You may need to disable precompiled headers
    2. MSVC LTCG and PGO are incompatible with clang. As such, you will need to disable these options.
    3. Clang does not support some of the most obscure options of cl. You will get a warning or error if you try to make use of them.

    Because this affects the default project settings, this means that you need to make some basic changes. If you haven't changed any of the project settings, these should be the ones that you need to make. Also note that my project properties are set to All Configurations and All Platforms, this is important. Unless otherwise stated, these changes should be done through the project properties.

    First, disable Link Time Code Generation:

    Second, disable Just My Code:

    Third, disable precompiled header use (the precompiled header can be named different things, pch.h and stdafx.h are other options):

    Fourth, disable the generation of the precompiled header, notice how I showed that I am changing the setting in a single source file:

    Fifth, disable the fast link debug information:

    This should be enough to get things working.


    This is a signature. Any samples given are not meant to have error checking or show best practices. They are meant to just illustrate a point. I may also give inefficient code or introduce some problems to discourage copy/paste coding. This is because the major point of my posts is to aid in the learning process.

    • Marked as answer by Neo the 1 Friday, March 1, 2019 1:26 PM
    Wednesday, January 23, 2019 1:56 PM