diff --git a/proto-cuda/windows-miner/start-mining.ps1 b/proto-cuda/windows-miner/start-mining.ps1 index 69e7cf297..688e3434e 100644 --- a/proto-cuda/windows-miner/start-mining.ps1 +++ b/proto-cuda/windows-miner/start-mining.ps1 @@ -93,7 +93,8 @@ function Set-LibFallback { foreach ($pf in @('C:\Program Files', 'C:\Program Files (x86)')) { $vsRoots += Get-ChildItem -Path (Join-Path $pf 'Microsoft Visual Studio') -Directory -Recurse -Depth 3 -Filter 'MSVC' -ErrorAction SilentlyContinue } $msvc = $null foreach ($r in $vsRoots) { - $tools = Get-ChildItem -Path $r.FullName -Directory -ErrorAction SilentlyContinue | Sort-Object Name -Descending + # Prefer the toolset CUDA accepts (vcvarsVer, 14.30), then the newest one that has the libraries. + $tools = Get-ChildItem -Path $r.FullName -Directory -ErrorAction SilentlyContinue | Sort-Object @{Expression={ if ($_.Name.StartsWith($vcvarsVer)) { 0 } else { 1 } }}, @{Expression='Name'; Descending=$true} foreach ($t in $tools) { if (Test-Path (Join-Path $t.FullName 'lib\x64\libcmt.lib')) { $msvc = $t.FullName; break } } if ($msvc) { break } } @@ -104,7 +105,7 @@ function Set-LibFallback { if (-not $msvc -or -not $sdk) { Log "fallback: MSVC lib dir $(if ($msvc) { $msvc } else { 'not found' }), Windows SDK $(if ($sdk) { $sdk } else { 'not found' })"; return $false } $env:LIB = "$msvc\lib\x64;$kits\Lib\$sdk\ucrt\x64;$kits\Lib\$sdk\um\x64;" + $env:LIB $env:INCLUDE = "$msvc\include;$kits\Include\$sdk\ucrt;$kits\Include\$sdk\um;$kits\Include\$sdk\shared;" + $env:INCLUDE - $env:PATH = "$msvc\bin\Hostx64\x64;" + $env:PATH + if (-not (Get-Command cl.exe -ErrorAction SilentlyContinue)) { $env:PATH = "$msvc\bin\Hostx64\x64;" + $env:PATH } # never shadow an already loaded (14.30) cl.exe Log "fallback MSVC environment set from $msvc and Windows SDK $sdk" return [bool](Get-Command cl.exe -ErrorAction SilentlyContinue) }