Skip to content

Commit d04a806

Browse files
committed
add ClangCL, fix channel by using bootstrap URL for specific VS version, add validation steps for requested toolset versions
1 parent ede38ad commit d04a806

File tree

1 file changed

+44
-4
lines changed

1 file changed

+44
-4
lines changed

Dockerfile

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,16 @@ ARG GIT_VERSION=2.48.1
1010
ARG WINDOWS_11_SDK_VERSION=22621
1111
ARG WINDOWS_SDK_VERSION=10.0.${WINDOWS_11_SDK_VERSION}.0
1212
ARG VC_VERSION=14.43.17.13
13+
14+
# note: it seems we cannot pass version within any workflow ID to installer, though as I look at VS package cache I see it being done in json payloads!
15+
# henceforth we enforce fixed versions with nasty bootstrap URL, more details:
16+
# https://learn.microsoft.com/en-us/visualstudio/releases/2022/release-history#fixed-version-bootstrappers
17+
# Default Version: 17.13.6, Channel: Current
18+
ARG BUILD_TOOLS_URL=https://download.visualstudio.microsoft.com/download/pr/8fada5c7-8417-4239-acc3-bd499af09222/353141457abcc59eb9c38b2f30084e7271c6bcfb4e185466d98161bada905759/vs_BuildTools.exe
19+
20+
# used for validation & matches internal package payloads, note: requires adjusting BUILD_TOOLS_URL
1321
ARG MSVC_VERSION=14.43.34808
22+
ARG CLANGCL_VERSION=19.1.1
1423

1524
ARG IMPL_ARTIFACTS_DIR="C:\artifacts"
1625
ARG IMPL_NANO_BASE=mcr.microsoft.com/powershell
@@ -22,26 +31,53 @@ FROM mcr.microsoft.com/windows/servercore:ltsc2022 as buildtools
2231
ARG WINDOWS_11_SDK_VERSION
2332
ARG VC_VERSION
2433
ARG MSVC_VERSION
34+
ARG BUILD_TOOLS_URL
2535
ARG IMPL_ARTIFACTS_DIR
2636

2737
RUN mkdir C:\Temp && cd C:\Temp `
28-
&& curl -SL --output vs_buildtools.exe https://aka.ms/vs/17/release/vs_buildtools.exe `
38+
&& curl -SL --output vs_buildtools.exe %BUILD_TOOLS_URL% `
2939
&& (start /w vs_buildtools.exe --quiet --wait --norestart --nocache `
30-
--remove Microsoft.VisualStudio.Component.VC.Tools.x86.x64 `
3140
--add Microsoft.VisualStudio.Component.VC.%VC_VERSION%.x86.x64 `
3241
--add Microsoft.VisualStudio.Component.VC.%VC_VERSION%.ATL `
3342
--add Microsoft.VisualStudio.Component.VC.%VC_VERSION%.MFC `
3443
--add Microsoft.VisualStudio.Component.Windows11SDK.%WINDOWS_11_SDK_VERSION% `
3544
--add Microsoft.VisualCpp.DIA.SDK `
45+
--add Microsoft.VisualStudio.Component.VC.Llvm.Clang `
3646
--installPath %IMPL_ARTIFACTS_DIR% `
37-
|| IF "%ERRORLEVEL%"=="3010" EXIT 0) `
38-
&& dir %IMPL_ARTIFACTS_DIR%\VC\Tools\MSVC `
47+
|| IF "%ERRORLEVEL%"=="3010" EXIT 0) && dir %IMPL_ARTIFACTS_DIR%\VC\Tools\MSVC `
3948
&& if exist %IMPL_ARTIFACTS_DIR%\VC\Tools\MSVC\%MSVC_VERSION% ( `
4049
for /d %i in (%IMPL_ARTIFACTS_DIR%\VC\Tools\MSVC\*) do if /I not "%i"=="%IMPL_ARTIFACTS_DIR%\VC\Tools\MSVC\%MSVC_VERSION%" rd /s /q "%i" `
4150
) else ( `
4251
echo "Error: Expected MSVC version directory %MSVC_VERSION% does not exist!" && exit /b 1 `
4352
)
4453

54+
SHELL ["powershell", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
55+
# important note: msc ships compiler which minor version doesn't match the toolset directory name
56+
# eg. dir name: 14.43.34808 (MSVC_VERSION) but version reported by cl.exe: 19.43.34810
57+
# more over, all package cache payloads (by default at C:\ProgramData\Microsoft\VisualStudio)
58+
# use MSVC_VERSION within workflow components ID - none of them contains 19.43.34810
59+
# which means that most likely there is a bug with versioning cl binaries
60+
61+
# RUN $version = "$env:MSVC_VERSION" ; `
62+
# $cl = Join-Path $env:IMPL_ARTIFACTS_DIR "VC\Tools\MSVC\$version\bin\Hostx64\x64\cl.exe" ; `
63+
# $pipe = & "$cl" 2>&1 ; `
64+
# if ($pipe -match "$version") { exit 0 } else { `
65+
# Write-Host "Validation failed due to requested version mismatch! Note: MSVC_VERSION = $version" ; `
66+
# Write-Host "$pipe" ; `
67+
# exit -1 `
68+
# }
69+
70+
# on the other hand here version depends on channel (see BUILD_TOOLS_URL)
71+
ARG CLANGCL_VERSION
72+
RUN $version = "$env:CLANGCL_VERSION" ; `
73+
$clangcl = Join-Path $env:IMPL_ARTIFACTS_DIR "VC\Tools\Llvm\bin\clang-cl.exe" ; `
74+
$pipe = & "$clangcl" -v 2>&1 ; `
75+
if ($pipe -match "$version") { exit 0 } else { `
76+
Write-Host "Validation failed due to requested version mismatch! Note: CLANGCL_VERSION = $version" ; `
77+
Write-Host "$pipe" ; `
78+
exit -1 `
79+
}
80+
4581
# ---------------- CMAKE ----------------
4682
FROM ${IMPL_NANO_BASE}:${IMPL_NANO_TAG} as cmake
4783
SHELL ["pwsh", "-NoLogo", "-NoProfile", "-ExecutionPolicy", "Bypass", "-Command"]
@@ -138,6 +174,8 @@ ARG WINDOWS_11_SDK_VERSION
138174
ARG WINDOWS_SDK_VERSION
139175
ARG VC_VERSION
140176
ARG MSVC_VERSION
177+
ARG CLANGCL_VERSION
178+
ARG BUILD_TOOLS_URL
141179

142180
ENV CMAKE_WINDOWS_KITS_10_DIR="C:\WindowsKits10SDK" `
143181
CMAKE_VERSION=${CMAKE_VERSION} `
@@ -150,6 +188,8 @@ WINDOWS_SDK_VERSION=${WINDOWS_SDK_VERSION} `
150188
VC_VERSION=${VC_VERSION} `
151189
VS_INSTANCE_LOCATION=C:\BuildTools `
152190
MSVC_VERSION=${MSVC_VERSION} `
191+
CLANGCL_VERSION=${CLANGCL_VERSION} `
192+
BUILD_TOOLS_URL=${BUILD_TOOLS_URL} `
153193
MSVC_TOOLSET_DIR=C:\BuildTools\VC\Tools\MSVC\${MSVC_VERSION} `
154194
PATH="C:\Windows\system32;C:\Windows;C:\Program Files\PowerShell;C:\Git\cmd;C:\Git\bin;C:\Git\usr\bin;C:\Git\mingw64\bin;C:\CMake\cmake-${CMAKE_VERSION}-windows-x86_64\bin;C:\Python;C:\Nasm;C:\Nasm\nasm-${NASM_VERSION};C:\Ninja;"
155195

0 commit comments

Comments
 (0)