143 lines · plain
1# Agent image for LLVM org cluster.2# .net 4.8 is required by chocolately package manager.3FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc20224 5# Restore the default Windows shell for correct batch processing.6SHELL ["cmd", "/S", "/C"]7 8# Download the Build Tools bootstrapper.9ADD https://aka.ms/vs/16/release/vs_buildtools.exe /TEMP/vs_buildtools.exe10 11RUN powershell -Command Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))12 13# Download channel for fixed install.14ARG CHANNEL_URL=https://aka.ms/vs/16/release/channel15ADD ${CHANNEL_URL} /TEMP/VisualStudio.chman16 17# Install Build Tools with C++ workload.18# - Documentation for docker installation19# https://docs.microsoft.com/en-us/visualstudio/install/build-tools-container?view=vs-201920# - Documentation on workloads21# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019#c-build-tools22# - Documentation on flags23# https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-201924RUN /TEMP/vs_buildtools.exe --quiet --wait --norestart --nocache \25 --channelUri C:\TEMP\VisualStudio.chman \26 --installChannelUri C:\TEMP\VisualStudio.chman \27 --installPath C:\BuildTools \28 --add Microsoft.VisualStudio.Workload.VCTools \29 --add Microsoft.VisualStudio.Component.VC.ATL \30 --includeRecommended \31 || IF "%ERRORLEVEL%"=="3010" EXIT 032 33# Register DIA dll (Debug Interface Access) so it can be used to symbolize34# the stack traces. Register dll for 32 and 64 bit.35# see https://developercommunity.visualstudio.com/content/problem/290674/msdia140dll-is-not-registered-on-vs2017-hosts.html36 37RUN regsvr32 /S "C:\BuildTools\DIA SDK\bin\amd64\msdia140.dll" & \38 regsvr32 /S "C:\BuildTools\DIA SDK\bin\msdia140.dll"39 40# install tools as described in https://llvm.org/docs/GettingStartedVS.html41# and a few more that were not documented...42# Pin an older version of Python; the current Python 3.10 fails when43# doing "pip install" for the other dependencies, as it fails to find libxml44# while compiling some package.45# We version pin the other packages as well to ensure the container build is as46# reproducible as possible to prevent issues when upgrading only part of the47# container.48RUN choco install -y ninja --version 1.13.1 && \49 choco install -y git --version 2.50.1 && \50 choco install -y sccache --version 0.10.0 && \51 choco install -y python3 --version 3.9.752 53# Testing requires psutil54RUN pip install psutil55 56# configure Python encoding57ENV PYTHONIOENCODING=UTF-858 59# update the path variable60# C:\Program Files\Git\usr\bin contains a usable bash and other unix tools.61# C:\llvm-mingw\bin contains Clang configured for mingw targets and62# corresponding sysroots. Both the 'llvm' package (with Clang defaulting63# to MSVC targets) and this directory contains executables named64# 'clang.exe' - add this last to let the other one have precedence.65# To use these compilers, use the triple prefixed form, e.g.66# x86_64-w64-mingw32-clang.67# C:\buildtools and SDK paths are ones that are set by c:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=amd64 -host_arch=amd6468RUN powershell -Command \69 [System.Environment]::SetEnvironmentVariable('PATH', \70 [System.Environment]::GetEnvironmentVariable('PATH', 'machine') + ';C:\Program Files\Git\usr\bin;C:\llvm-mingw\bin' \71 + ';C:\BuildTools\Common7\IDE\' \72 + ';C:\BuildTools\Common7\IDE\CommonExt ensions\Microsoft\TeamFoundation\Team Explorer' \73 + ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin' \74 + ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja' \75 + ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer' \76 + ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow' \77 + ';C:\BuildTools\Common7\IDE\VC\VCPackages' \78 + ';C:\BuildTools\Common7\Tools\' \79 + ';C:\BuildTools\Common7\Tools\devinit' \80 + ';C:\BuildTools\MSBuild\Current\Bin' \81 + ';C:\BuildTools\MSBuild\Current\bin\Roslyn' \82 + ';C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64' \83 + ';C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\' \84 + ';C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64' \85 + ';C:\Program Files (x86)\Windows Kits\10\bin\x64' \86 + ';C:\Windows\Microsoft.NET\Framework64\v4.0.30319' \87 ,'machine')88 89# support long file names during git checkout90RUN git config --system core.longpaths true & \91 git config --global core.autocrlf false92 93ARG RUNNER_VERSION=2.330.094ENV RUNNER_VERSION=$RUNNER_VERSION95 96RUN powershell -Command \97 Invoke-WebRequest -Uri https://github.com/actions/runner/releases/download/v${env:RUNNER_VERSION}/actions-runner-win-x64-${env:RUNNER_VERSION}.zip -OutFile actions-runner-win.zip ; \98 Add-Type -AssemblyName System.IO.Compression.FileSystem ; \99 [System.IO.Compression.ZipFile]::ExtractToDirectory('actions-runner-win.zip', $PWD) ;\100 rm actions-runner-win.zip101 102# Set the LLVM_VERSION environment variable103ENV LLVM_VERSION=21.1.2104 105# Download and extract Clang compiler.106# Create directories, download, extract, and clean up all in one layer107RUN powershell -Command \108 # --- Setup directories --- \109 Write-Host "Creating directories..."; \110 New-Item -Path "C:\temp-download" -ItemType "Directory" -Force ; \111 New-Item -Path "C:\xz-utils" -ItemType "Directory" -Force ; \112 New-Item -Path "C:\clang" -ItemType "Directory" -Force ; \113 # --- 1. Download and extract xz --- \114 Set-Location C:\temp-download ; \115 Invoke-WebRequest -Uri "http://github.com/tukaani-project/xz/releases/download/v5.8.1/xz-5.8.1-windows.zip" -OutFile "xz.zip"; \116 (Get-FileHash -Path "C:\temp-download\xz.zip" -Algorithm MD5).Hash -eq 'c3c69fdce3e825cc0b76123b36b0bcc2' ; \117 Add-Type -AssemblyName "System.IO.Compression.FileSystem"; \118 [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\temp-download\xz.zip', 'C:\xz-utils'); \ 119 # --- 2. Download and decompress Clang --- \120 Invoke-WebRequest -Uri "http://github.com/llvm/llvm-project/releases/download/llvmorg-21.1.2/clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz" -OutFile "clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz" ; \121 (Get-FileHash -Path "C:\temp-download\clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz" -Algorithm MD5).Hash -eq '0ae1d3effd9ab9d323f7fa595777f0a2' ; \122 C:\xz-utils\bin_x86-64\xz.exe -d -qq clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz ; \123 # --- 3. Extract clang --- \124 C:\Windows\System32\tar.exe -xf clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar -C C:\clang ; \125 # --- 4. Clean up --- \126 Set-Location C:\ ; \127 Remove-Item C:\temp-download -Recurse -Force; \128 Remove-Item C:\xz-utils -Recurse -Force; \129 # -- 5. Shorten path to clang files & remove unnecessary files -- \130 Set-Location C:\clang ; \131 Rename-Item -Path "C:\clang\clang+llvm-21.1.2-x86_64-pc-windows-msvc" -NewName "C:\clang\clang-msvc" ; \132 Set-Location C:\clang\clang-msvc ; \133 Remove-Item -Path C:\clang\clang-msvc\libexec -Recurse -Force ; \134 Remove-Item -Path C:\clang\clang-msvc\share -Recurse -Force ; \135 Rename-Item -Path "C:\clang\clang-msvc\bin" -NewName "C:\clang\clang-msvc\bin-full" ; \136 New-Item -Path "C:\clang\clang-msvc\bin" -ItemType Directory -Force ; \137 Set-Location C:\clang\clang-msvc\bin ; \138 Copy-Item -Path C:\clang\clang-msvc\bin-full\*.dll -Destination C:\clang\clang-msvc\bin\. ; \139 Copy-Item -Path C:\clang\clang-msvc\bin-full\clang-cl.exe -Destination C:\clang\clang-msvc\bin\. ; \140 Copy-Item -Path C:\clang\clang-msvc\bin-full\lld-link.exe -Destination C:\clang\clang-msvc\bin\. ; \141 Set-Location C:\clang\clang-msvc ; \142 Remove-Item -Path C:\clang\clang-msvc\bin-full -Recurse -Force ;143