[llvm] [LLVM] Fix VisualStudio detection (PR #212498)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 28 06:51:11 PDT 2026
https://github.com/enginelesscc created https://github.com/llvm/llvm-project/pull/212498
When packages like SMSS are installed, llvm::findVCToolChainViaSetupConfig will incorrectly assume it is a VS Installation and bail as it wont find `Microsoft.VCToolsVersion.default.txt`, so it will fallback to legacy VS search and ignore VS2019/22/26.
Simplest solution is to check against the InstallationName for "VisualStudio"
>From 699150f797ab947c0fed118a23331f5786f85e2c Mon Sep 17 00:00:00 2001
From: Vivyy <vccsya at gmail.com>
Date: Tue, 28 Jul 2026 15:29:52 +0200
Subject: [PATCH] [LLVM] Fix VisualStudio detection
When packages like SMSS are installed, llvm::findVCToolChainViaSetupConfig will match it first as "newest", and bail as it wont find `Microsoft.VCToolsVersion.default.txt`, so it will fallback to legacy VS search and ignore VS2019/22/26.
Simplest solution is to check against the InstallationName for "VisualStudio"
---
llvm/lib/WindowsDriver/MSVCPaths.cpp | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/llvm/lib/WindowsDriver/MSVCPaths.cpp b/llvm/lib/WindowsDriver/MSVCPaths.cpp
index 09468dab10260..de0ddfe5e16e8 100644
--- a/llvm/lib/WindowsDriver/MSVCPaths.cpp
+++ b/llvm/lib/WindowsDriver/MSVCPaths.cpp
@@ -675,6 +675,12 @@ bool llvm::findVCToolChainViaSetupConfig(
ISetupInstancePtr NewestInstance;
std::optional<uint64_t> NewestVersionNum;
do {
+ bstr_t NameString;
+ HR = Instance->GetInstallationName(NameString.GetAddress());
+ if (FAILED(HR))
+ continue;
+ if (std::wstring_view(NameString).find(L"VisualStudio") != 0)
+ continue;
bstr_t VersionString;
uint64_t VersionNum;
HR = Instance->GetInstallationVersion(VersionString.GetAddress());
More information about the llvm-commits
mailing list