Skip to content

Commit 789f1ae

Browse files
authored
Merge pull request #3398 from corob-msft/docs/corob/llvm-toolset-version
Add LLVM toolset version option per Lisbeth for 16.9
2 parents 4ea65ac + 23c5a8d commit 789f1ae

File tree

2 files changed

+59
-12
lines changed

2 files changed

+59
-12
lines changed

docs/build/clang-support-msbuild.md

+53-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
description: "Learn more about: Clang/LLVM support in Visual Studio projects"
3-
title: "Clang/LLVM support in Visual Studio Visual Studio projects"
4-
ms.date: "06/02/2020"
3+
title: "Clang/LLVM support in Visual Studio projects"
4+
ms.date: 02/05/2021
55
ms.description: "Configure a Visual Studio MSBuild project to use the Clang/LLVM toolchain."
66
helpviewer_keywords: ["Clang support for C++ MSBuild projects"]
77
---
@@ -19,7 +19,9 @@ You can use Visual Studio 2019 version 16.2 with Clang to edit, build, and debug
1919

2020
## Install
2121

22-
For best IDE support in Visual Studio, we recommend using the latest Clang compiler tools for Windows. If you don't already have those, you can install them by opening the Visual Studio Installer and choosing **C++ Clang tools for Windows** under **Desktop development with C++** optional components. If you prefer to use an existing Clang installation on your machine, choose the **C++ Clang-cl for v142 build tools.** optional component. The Microsoft C++ Standard Library currently requires at least Clang 8.0.0; the bundled version of Clang will automatically be updated to stay current with updates in the Microsoft implementation of the Standard Library.
22+
For best IDE support in Visual Studio, we recommend using the latest Clang compiler tools for Windows. If you don't already have the tools, you can install them by opening the Visual Studio Installer and choosing **C++ Clang tools for Windows** under **Desktop development with C++** optional components. You may prefer to use an existing Clang installation on your machine; if so, choose the **C++ Clang-cl for v142 build tools.** optional component.
23+
24+
The Microsoft C++ Standard Library currently requires at least Clang 8.0.0. The bundled version of Clang gets updated automatically to stay current with updates in the Microsoft implementation of the Standard Library.
2325

2426
![Screenshot of the Visual Studio installer with the Individual components tab selected and the C plus plus Clang components visible.](media/clang-install-vs2019.png)
2527

@@ -29,9 +31,9 @@ To configure a Visual Studio project to use Clang, right-click on the project no
2931

3032
![Screenshot of the Property Pages dialog box with Configuration Properties > General selected and the Platform Toolset and L L V M (clang c l) options highlighted.](media/clang-msbuild-prop-page.png)
3133

32-
If you are using the Clang tools that are bundled with Visual Studio, no additional steps are required. For Windows projects, Visual Studio by default invokes Clang in [clang-cl](https://llvm.org/devmtg/2014-04/PDFs/Talks/clang-cl.pdf) mode and links with the Microsoft implementation of the Standard Library. By default, **clang-cl.exe** is located in *%VCINSTALLDIR%\\Tools\\Llvm\\bin\\* and *%VCINSTALLDIR%\\Tools\\Llvm\\x64\\bin\\*.
34+
If you're using the Clang tools that are bundled with Visual Studio, no extra steps are required. For Windows projects, Visual Studio by default invokes Clang in [clang-cl](https://llvm.org/devmtg/2014-04/PDFs/Talks/clang-cl.pdf) mode. It links with the Microsoft implementation of the Standard Library. By default, **clang-cl.exe** is located in *%VCINSTALLDIR%\\Tools\\Llvm\\bin\\* and *%VCINSTALLDIR%\\Tools\\Llvm\\x64\\bin\\*.
3335

34-
If you are using a custom Clang installation, you can either modify **Project** > **Properties** > **VC++ DIrectories** > **Configuration Properties** > **Executable Directories** by adding the custom Clang installation root as the first directory there, or change the value of the `LLVMInstallDir` property. See [Set a custom LLVM location](#custom_llvm_location) for more information.
36+
If you're using a custom Clang installation, you can either modify **Project** > **Properties** > **VC++ DIrectories** > **Configuration Properties** > **Executable Directories** by adding the custom Clang installation root as the first directory there, or change the value of the `LLVMInstallDir` property. For more information, see [Set a custom LLVM location](#custom_llvm_location).
3537

3638
## Configure a Linux project to use Clang tools
3739

@@ -41,28 +43,69 @@ To configure a Visual Studio Linux project to use Clang:
4143

4244
1. Right-click on the project node in **Solution Explorer** and choose **Properties**.
4345
1. Typically, you should first choose **All configurations** at the top of the dialog.
44-
1. Under **General** > **Platform Toolset**, choose **WSL_Clang_1_0** if you are using Windows Subsystem for Linux, or **Remote_Clang_1_0** if you are using a remote machine or VM.
46+
1. Under **General** > **Platform Toolset**, choose **WSL_Clang_1_0** if you're using Windows Subsystem for Linux (WSL). Choose **Remote_Clang_1_0** if you're using a remote machine or VM.
4547
1. Press **OK**.
4648

4749
![Screenshot of the Console App clang Visual Studio 2019 Property Pages dialog box with Configuration Properties > General selected and the Platform Toolset and L L V M (clang c l) options highlighted.](media/clang-msbuild-prop-page.png)
4850

49-
On Linux, Visual Studio by default uses the first Clang location that it encounters in the PATH environment property. If you are using a custom Clang installation, then you must change the value of the `LLVMInstallDir` property or else substitute a path under **Project** > **Properties** > **VC++ DIrectories** > **Configuration Properties** > **Executable Directories**. See [Set a custom LLVM location](#custom_llvm_location) for more information.
51+
On Linux, Visual Studio by default uses the first Clang location that it finds in the PATH environment property. If you're using a custom Clang installation, then either change the value of the `LLVMInstallDir` property or else enter the path under **Project** > **Properties** > **Configuration Properties** > **VC++ DIrectories** > **Executable Directories**. For more information, see [Set a custom LLVM location](#custom_llvm_location).
5052

5153
## <a name="custom_llvm_location"></a> Set a custom LLVM location
5254

53-
You can set a custom path for LLVM for one or more projects by creating a *Directory.build.props* file and adding that file to the root folder of any project. You can add it to the root solution folder to apply it to all projects in the solution. The file should look like this (but substitute your actual path):
55+
You can set a custom path to LLVM for one or more projects by creating a *Directory.build.props* file. Then, add that file to the root folder of any project. You can add it to the root solution folder to apply it to all projects in the solution. The file should look like this (but use your actual LLVM path):
5456

5557
```xml
5658
<Project>
5759
<PropertyGroup>
58-
<LLVMInstallDir>c:\MyLLVMRootDir</LLVMInstallDir>
60+
<LLVMInstallDir>C:\MyLLVMRootDir</LLVMInstallDir>
5961
</PropertyGroup>
6062
</Project>
6163
```
6264

65+
You can combine this property with a custom LLVM toolset version. For more information, see [Set a custom LLVM toolset version](#custom_llvm_toolset).
66+
67+
## <a name="custom_llvm_toolset"></a> Set a custom LLVM toolset version
68+
69+
Starting in Visual Studio 2019 version 16.9, you can set a custom toolset version for LLVM. To set this property in a project in Visual Studio:
70+
71+
1. Open the project's **Property Pages** dialog box. For details, see [Set C++ compiler and build properties in Visual Studio](./working-with-project-properties.md).
72+
73+
1. Select the **Configuration Properties** > **General** property page.
74+
75+
1. Modify the **Platform Toolset** property to *LLVM (clang-cl)*, if it isn't already set.
76+
77+
1. Select the **Configuration Properties** > **Advanced** property page.
78+
79+
1. Modify the **LLVM Toolset Version** property to your preferred version, and then choose **OK** to save your changes.
80+
81+
The **LLVM Toolset Version** property only appears when the LLVM platform toolset is selected.
82+
83+
You can set the toolset version for one or more projects by creating a *Directory.build.props* file. Then, add that file to the root folder of any project. Add it to the root solution folder to apply it to all projects in the solution. The file should look like this (but use your actual LLVM path):
84+
85+
```xml
86+
<Project>
87+
<PropertyGroup>
88+
<LLVMToolsVersion>11.0.0</LLVMToolsVersion>
89+
</PropertyGroup>
90+
</Project>
91+
```
92+
93+
You can also combine this property with a custom LLVM location. For example, your *Directory.build.props* file could look like:
94+
95+
```xml
96+
<Project>
97+
<PropertyGroup>
98+
<LLVMInstallDir>C:\MyLLVMRootDir</LLVMInstallDir>
99+
<LLVMToolsVersion>11.0.0</LLVMToolsVersion>
100+
</PropertyGroup>
101+
</Project>
102+
```
103+
104+
When you add a *Directory.build.props* file, the settings appear as the default in the project Property Pages dialog. However, changes to these properties in Visual Studio override the settings in the *Directory.build.props* file.
105+
63106
## Set additional properties, edit, build, and debug
64107

65-
After you have set up a Clang configuration, right-click again on the project node and choose **Reload project**. You can now build and debug the project using the Clang tools. Visual Studio detects that you are using the Clang compiler and provides IntelliSense, highlighting, navigation, and other editing features. Errors and warnings are displayed in the **Output Window**. The project property pages for a Clang configuration are very similar to those for MSVC, although some compiler-dependent features such as Edit and Continue are not available for Clang configurations. To set a Clang compiler or linker option that is not available in the property pages, you can add it manually in the property pages under **Configuration Properties** > **C/C++ (or Linker)** > **Command Line** > **Additional Options**.
108+
After you have set up a Clang configuration, right-click again on the project node and choose **Reload project**. You can now build and debug the project using the Clang tools. Visual Studio detects that you're using the Clang compiler and provides IntelliSense, highlighting, navigation, and other editing features. Errors and warnings are displayed in the **Output Window**. The project property pages for a Clang configuration are similar to the ones for MSVC. However, some compiler-dependent features such as Edit and Continue aren't available for Clang configurations. You can set a Clang compiler or linker option that isn't available in the property pages. Add it manually in the property pages under **Configuration Properties** > **C/C++ (or Linker)** > **Command Line** > **Additional Options**.
66109

67110
When debugging, you can use breakpoints, memory and data visualization, and most other debugging features.
68111

docs/build/reference/advanced-property-page.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
---
22
description: "Learn more about: Advanced Property Page"
33
title: "Advanced Property Page (Project)"
4-
ms.date: 08/10/2020
5-
f1_keywords: ["VC.Project.VCConfiguration.VCToolsVersion"]
4+
ms.date: 02/05/2021
5+
f1_keywords: ["VC.Project.VCConfiguration.VCToolsVersion","VC.Project.VCConfiguration.LLVMToolsVersion"]
66
ms.description: "Use the Advanced property page in Visual Studio 2019 to set various properties for C++ projects."
77
---
88
# Advanced Property Page
@@ -83,6 +83,10 @@ The Advanced property page is available in Visual Studio 2019 and later.
8383

8484
Specifies the full version of the MSVC toolset that's used to build the project. You may have various update and preview versions of a toolset installed. You can specify which one to use here.
8585

86+
- **LLVM Toolset Version**
87+
88+
Specifies the full version of the LLVM toolset that's used to build the project. This property is available when **LLVM (clang-cl)** is selected as the platform toolset, starting in Visual Studio 2019 version 16.9. For more information, see [Set a custom LLVM toolset version](..\clang-support-msbuild.md#custom_llvm_toolset).
89+
8690
## C++/CLI Properties
8791

8892
- **Common Language Runtime support**

0 commit comments

Comments
 (0)