clang-cl choosing VC++ backend on Windows

Given multiple installations installed of Visual Studio/VC++ on Windows, with none of them normally in the PATH, how does clang-cl choose which one to use at compile/link time as the clang backend ?

It's a bit involved. You can find the code here:

Clang first looks for environment variables VCToolsInstallDir or
VCINSTALLDIR which are usually set by vcvarsall.bat (or if you launch
a Visual Studio Native Tools Command Prompt). If those aren't set, it
looks on PATH.

After that, it queries the "Visual Studio Setup Configuration Server",
and after that it checks the registry.

If you want to point Clang to use a specific Visual Studio install,
the best way is to set the environment variables the way vcvarsall.bat
sets them.

Hope that helps,