fix: detect Visual Studio Preview installations #2060

Open
github-bot wants to merge 1 commit from github-bot/gh-2060 into main AGit
Owner

@⁠hcentral07 on GitHub · 2026-11-25 19:14 UTC · original
hcentral07:fix/vs-insiders-detection → main · +34 −11 · 1 files · 1 commits · open

Claimed in the coordination issue as: TEST-XX

Depends on:
Fixes:

What and why

scripts/build_llvm_mc.ps1 failed on machines where Visual Studio is
installed only as Preview/Insiders, and reported the wrong error when
Visual Studio (or its C++ x64 workload) is missing entirely:

  • vswhere.exe was invoked at a hard-coded path with no existence check,
    so a machine with no VS threw a raw CommandNotFoundException before the
    script's "Visual Studio wasn't found" message could fire.
  • vswhere hides Preview/Insiders instances unless -prerelease is passed,
    so those users were told VS wasn't installed even though it was.
  • A VS install with the C++ x64 component listed but the workload broken
    died deep inside cmd.exe instead of failing with a clear message.

This makes VS detection fall back to -prerelease, guards the
vswhere.exe path, normalizes vswhere output (drops empty lines, takes
the first path), and verifies vcvars64.bat exists before the build starts.

Tested

  • powershell -ExecutionPolicy Bypass -File scripts\build_llvm_mc.ps1
    on a machine with VS 2022 stable: builds llvm-mc.exe, the s_endpgm
    probe passes, LLVM_MC is set.
  • VS 2022 Preview/Insiders only: detection now succeeds via -prerelease
    (previously reported "not found").
  • No VS at all: fails with Visual Studio wasn't found (vswhere.exe missing at '…') instead of a raw cmdlet error.
  • vcvars64.bat moved away: fails with vcvars64.bat wasn't found at '…'; the VS install looks incomplete.

GPUs tested: n/a (build-script change; the post-build s_endpgm probe ran
on a gfx1013 console but is the existing check, unchanged)

AI-assisted: yes

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a — no translator rule changed; the box is checked only because the checklist reads as all-or-nothing. If your repo treats n/a as unchecked, leave it [ ] and note "n/a" here.)
**@⁠hcentral07** on GitHub · 2026-11-25 19:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/2060) `hcentral07:fix/vs-insiders-detection` → `main` · +34 −11 · 1 files · 1 commits · open Claimed in the coordination issue as: TEST-XX Depends on: <!-- none --> Fixes: <!-- #N if this closes a "VS Preview not detected" / toolchain-detection issue; otherwise delete --> ### What and why `scripts/build_llvm_mc.ps1` failed on machines where Visual Studio is installed only as Preview/Insiders, and reported the wrong error when Visual Studio (or its C++ x64 workload) is missing entirely: - `vswhere.exe` was invoked at a hard-coded path with no existence check, so a machine with no VS threw a raw `CommandNotFoundException` before the script's "Visual Studio wasn't found" message could fire. - `vswhere` hides Preview/Insiders instances unless `-prerelease` is passed, so those users were told VS wasn't installed even though it was. - A VS install with the C++ x64 component listed but the workload broken died deep inside `cmd.exe` instead of failing with a clear message. This makes VS detection fall back to `-prerelease`, guards the `vswhere.exe` path, normalizes `vswhere` output (drops empty lines, takes the first path), and verifies `vcvars64.bat` exists before the build starts. ### Tested - `powershell -ExecutionPolicy Bypass -File scripts\build_llvm_mc.ps1` on a machine with VS 2022 stable: builds `llvm-mc.exe`, the `s_endpgm` probe passes, `LLVM_MC` is set. - VS 2022 Preview/Insiders only: detection now succeeds via `-prerelease` (previously reported "not found"). - No VS at all: fails with `Visual Studio wasn't found (vswhere.exe missing at '…')` instead of a raw cmdlet error. - `vcvars64.bat` moved away: fails with `vcvars64.bat wasn't found at '…'; the VS install looks incomplete.` GPUs tested: n/a (build-script change; the post-build `s_endpgm` probe ran on a gfx1013 console but is the existing check, unchanged) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. *(n/a — no translator rule changed; the box is checked only because the checklist reads as all-or-nothing. If your repo treats n/a as unchecked, leave it `[ ]` and note "n/a" here.)*
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 10:16:31 +00:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/2060/head:github-bot/gh-2060'
git switch 'github-bot/gh-2060'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-2060'
git switch 'github-bot/gh-2060'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-2060'
git switch 'github-bot/gh-2060'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-2060'
git switch 'main'
git merge --squash 'github-bot/gh-2060'
git switch 'main'
git merge --ff-only 'github-bot/gh-2060'
git switch 'main'
git merge 'github-bot/gh-2060'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.