From d5ebb313837e4e950392c3341a4e46604fc5595b Mon Sep 17 00:00:00 2001 From: starr-openai Date: Wed, 13 May 2026 16:14:35 -0700 Subject: [PATCH] Set explicit Cargo linker in MSVC setup action --- .github/actions/setup-msvc-env/action.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/actions/setup-msvc-env/action.yml b/.github/actions/setup-msvc-env/action.yml index af6d20ae97..3903d383ff 100644 --- a/.github/actions/setup-msvc-env/action.yml +++ b/.github/actions/setup-msvc-env/action.yml @@ -70,6 +70,7 @@ runs: ) $envLines = & cmd.exe /c ('"{0}" -no_logo -arch={1} -host_arch={2} >nul && set' -f $vsDevCmd, $targetArch, $hostArch) + $vcToolsInstallDir = $null foreach ($line in $envLines) { if ($line -notmatch "^(.*?)=(.*)$") { continue @@ -81,6 +82,21 @@ runs: if ($name -ieq "Path") { $name = "PATH" } + if ($name -eq "VCToolsInstallDir") { + $vcToolsInstallDir = $value + } "$name=$value" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append } } + + if (-not $vcToolsInstallDir) { + throw "VCToolsInstallDir was not exported by VsDevCmd.bat" + } + + $linker = Join-Path $vcToolsInstallDir "bin\Host${hostArch}\${targetArch}\link.exe" + if (-not (Test-Path $linker)) { + throw "MSVC linker not found at $linker" + } + + $cargoTarget = "${{ inputs.target }}".ToUpperInvariant().Replace("-", "_") + "CARGO_TARGET_${cargoTarget}_LINKER=$linker" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append