scripts/build_llvm_mc.ps1: validate Version, normalize -Temp, harden VS/tool fallback and literal install #1871
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1871"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by kirigayakazima on 2026-11-25T13:46:15Z.
Claimed in the coordination issue as: BUILD-LLVM-MC-REL-TEMP-VS-AND-TOOL-FALLBACK-SAFETY (https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7164207060)
What and why
-Versionup front inscripts/build_llvm_mc.ps1so empty strings, whitespace, control characters, or%fail before cloning or running prerequisites.$Temp = $fullTempafter resolving via PowerShell provider paths so_build.cmd,$src,$out, and[System.IO.File]::WriteAllTextnever drift to[Environment]::CurrentDirectorywhen a relative-Tempis passed.vswhere.exeand missingvcvars64.batwith explicit actionable errors (Test-Path -LiteralPath ... -PathType Leaf) instead ofCommandNotFoundExceptionor opaquecallfailures.PATHcmake/ninjaindependently so one tool from Visual Studio can pair cleanly with the other onPATH.[System.Text.UTF8Encoding]::new($false)explicitly when writingprobe.txt, and switchCopy-Itemto-LiteralPath ... -Destination $finalso bracketed paths work reliably. Preserve CRLF line endings (PS1_CRLF=177, PS1_LF_ONLY=0).tests/test_build_llvm_mc_prereqs.pywithout disturbing any anchors sliced by the existing 5build_llvm_mctests.Tested
python -I tests/test_build_llvm_mc_prereqs.py -v->Ran 5 tests in 3.172s(OK)python -I tests/test_build_llvm_mc_batch.py -v->Ran 1 test in 0.933s(OK)python -I tests/test_build_llvm_mc_cleanup.py -v->Ran 1 test in 0.310s(OK)python -I tests/test_llvm_install_destination.py -v->Ran 1 test in 1.470s(OK)python -I tests/test_llvm_install_path.py -v->Ran 3 tests in 1.578s(OK)python -I tests/test_llvm_source_version.py -v->Ran 6 tests in 5.677s(OK)upstream/main5e95fa2fwithtests/test_build_llvm_mc_prereqs.pycopied into detached worktree):Ran 5 tests in 3.120s(FAILED (failures=8, errors=1)).PS1_CRLF=177 PS1_LF_ONLY=0,python -I tests/test_ci_registration.py(Ran 16 tests in 5.989s,OK),python -I tests/test_text_write_line_endings.py(Ran 3 tests in 14.043s,OK),python -I scripts/check_no_game_data.py(exit 0),python -I -m compileall -q(exit 0),git diff --check(exit 0).GPUs tested: n/a (PowerShell prerequisite validation, relative-path normalization, tool fallback, and literal install tests)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T12:57:20Z.
#1871 | head
74e9e8012b(merged cleanly with maind48a957bb) |python -I tests/test_build_llvm_mc_prereqs.py| red on main:FAILED (failures=8, errors=1)(rangitcheck before-Versionvalidation, resolved relative-Tempagainst[Environment]::CurrentDirectoryinstead of PowerShell$PWD, threwCommandNotFoundExceptionon missingvswhere.exe, coupledcmake/ninjafallback, and failed wildcard copy into bracketedtools[1]) | green on PR+main:5 tests OK| Windows 11 (10.0.26200.9974,powershell.exe5.1.26100.9818), Python 3.12.10 | AI-assisted: yesAudited
scripts/build_llvm_mc.ps1andtests/test_build_llvm_mc_prereqs.pyon Windows 11 PowerShell 5.1, verifying upfront-Versionvalidation,$Temp = $fullTempprovider-path normalization,-LiteralPath -PathType Leafchecks onvswhere.exeandvcvars64.bat, independent VS-bundled vsPATHresolution forcmakeandninja, BOM-freeUTF8Encoding($false)probe.txtwrite, andCopy-Item -LiteralPathinto bracketed destination paths. Also verifiedtests/test_ci_registration.py(18 OK),tests/test_text_write_line_endings.py(3 OK), andscripts/check_no_game_data.py.Merge note with #2066: both PRs modify the
vswhere.exelookup lines inscripts/build_llvm_mc.ps1(git merge-treeconflict on$vswherevs"$installer\vswhere.exe"). Keeping #1871's$vswhereleaf check and adding #2066'sif (-not $vs) { $vs = & $vswhere -latest -prerelease -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath }fallback immediately below passes bothtests/test_build_llvm_mc_prereqs.py(5 OK) and #2066'stests/test_build_vs_lookup.py(1 OK).Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T23:38:20Z.
Tested
74e9e8012merged (no commit) withmainaa918e5d9: Python 3.12.4, Windows 11 10.0.26300, CPU only.check_no_game_data.pyis clean.tests/test_build_llvm_mc_prereqs.py, 5 tests pass.scripts/build_llvm_mc.ps1back tomain, the tests fail: the script stops on a-Temppath it cannot write.scripts/build_llvm_mc.ps1with #2066, #2060 and #2053 (git merge-tree). #2066 is the one suggested there, so this PR or #2066 will need a rebase after the other.No blocker from my side.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T23:49:51Z.
Merged after TheGeogeo's red/green check (check) (Windows, Python tests, no GPU needed) and a local re-check here. Merged after local re-verification: this PR merged onto
main5fe330015without conflict, and its test file(s) (tests/test_build_llvm_mc_prereqs.py) pass there. Earlier today the same tests failed onmainwithout the PR (red/green) and a bundle with other open PRs showed no new failures.check_no_game_data.pyis clean. Windows 11, Python 3.14; no GPU needed for these tests.AI-assisted (Claude Code, Claude Opus 5.5), merged for MoonEyes.