I am trying to access the Visual Studio 2019 version of clang from the command prompt. I am looking for the official way to do this. So far it doesn't appear to be documented in any of the MSVC/clang blog posts. (Please note that I am not looking for other ways to build/install clang on Windows. This question specifically relates to the VS2019 clang component.)
Using the Visual Studio Installer, I have installed Visual Studio 2019 Professional (version 16.4.1) along with the optional "C++ Clang tools for Windows (9.0.0 - x64/x86)". The clang toolchain appears to be installed at:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\Llvm\bin
(Perhaps I could add this directory to PATH, but this is not robust. Nor could I find this approach documented in any of Microsoft's docs.)
My final goal is to use clang-cl
with scons. But as a first step, I would like to be able to run clang-cl
from the command prompt.
When I run vcvarsall.bat
none of the clang tools are available at the command prompt:
C:\Users\Ross>"C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Auxiliary\Build\vcvarsall.bat" x64
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.4.1
** Copyright (c) 2019 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'
C:\Users\Ross>cl
Microsoft (R) C/C++ Optimizing Compiler Version 19.24.28314 for x64
Copyright (C) Microsoft Corporation. All rights reserved.
usage: cl [ option... ] filename... [ /link linkoption... ]
C:\Users\Ross>clang
'clang' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\Ross>clang++
'clang++' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\Ross>clangcl
'clangcl' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\Ross>clang-cl
'clang-cl' is not recognized as an internal or external command,
operable program or batch file.
UPDATE 26 February, 2020: Still no satisfactory answer from Microsoft. You can view Microsoft's non-answer and also vote for this issue at: https://developercommunity.visualstudio.com/idea/875419/how-to-use-msvc-installed-c-clang-tools-for-window.html