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