From b7b38247e016ed02c60ccd48e9a67b38da003de2 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Fri, 7 Nov 2025 21:18:19 +0000 Subject: [PATCH 1/8] [Github] Make Windows container use zstd This enables much faster image unpack times. We benchmarked 20-30% improvements when testing this initially. Use skopeo to copy the image as it just works over the docker-archive/OCI container formats and does not need to unpack the image to upload it. --- .../workflows/build-ci-container-windows.yml | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-ci-container-windows.yml b/.github/workflows/build-ci-container-windows.yml index b6c46b70030ab..1be644077dca4 100644 --- a/.github/workflows/build-ci-container-windows.yml +++ b/.github/workflows/build-ci-container-windows.yml @@ -51,12 +51,12 @@ jobs: retention-days: 14 push-ci-container: - if: github.event_name == 'push' + #if: github.event_name == 'push' needs: - build-ci-container-windows - permissions: - packages: write - runs-on: windows-2022 + #permissions: + # packages: write + runs-on: ubuntu-24.04 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: @@ -66,8 +66,12 @@ jobs: name: container - name: Push Container run: | - docker load -i ${{ needs.build-ci-container-windows.outputs.container-filename }} - docker tag ${{ needs.build-ci-container-windows.outputs.container-name-tag }} ${{ needs.build-ci-container-windows.outputs.container-name }}:latest - docker login -u ${{ github.actor }} -p $env:GITHUB_TOKEN ghcr.io - docker push ${{ needs.build-ci-container-windows.outputs.container-name-tag }} - docker push ${{ needs.build-ci-container-windows.outputs.container-name }}:latest + sudo apt-get update + sudo apt-get install -y skopeo + skopeo login -u ${{ github.actor }} -p $env:GITHUB_TOKEN ghcr.io + skopeo copy ${{ needs.build-ci-container-windows.outputs.container-filename }} \ + --additional-tags=latest \ + --dest-compress-format zstd \ + --dest-force-compress-format \ + oci:/tmp/blah.tar + #docker://${{ needs.build-ci-container-windows.outputs.container-name-tag }} From 90926c4a624d97663444bdc9183c137ae7efcb83 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Sat, 8 Nov 2025 05:08:31 +0000 Subject: [PATCH 2/8] testing --- .../workflows/build-ci-container-windows.yml | 2 +- .../github-action-ci-windows/Dockerfile | 144 +----------------- 2 files changed, 3 insertions(+), 143 deletions(-) diff --git a/.github/workflows/build-ci-container-windows.yml b/.github/workflows/build-ci-container-windows.yml index 1be644077dca4..5b6d3a423d230 100644 --- a/.github/workflows/build-ci-container-windows.yml +++ b/.github/workflows/build-ci-container-windows.yml @@ -68,7 +68,7 @@ jobs: run: | sudo apt-get update sudo apt-get install -y skopeo - skopeo login -u ${{ github.actor }} -p $env:GITHUB_TOKEN ghcr.io + #skopeo login -u ${{ github.actor }} -p $env:GITHUB_TOKEN ghcr.io skopeo copy ${{ needs.build-ci-container-windows.outputs.container-filename }} \ --additional-tags=latest \ --dest-compress-format zstd \ diff --git a/.github/workflows/containers/github-action-ci-windows/Dockerfile b/.github/workflows/containers/github-action-ci-windows/Dockerfile index f1e4f1538540b..09979985ab0e3 100644 --- a/.github/workflows/containers/github-action-ci-windows/Dockerfile +++ b/.github/workflows/containers/github-action-ci-windows/Dockerfile @@ -1,142 +1,2 @@ -# Agent image for LLVM org cluster. -# .net 4.8 is required by chocolately package manager. -FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022 - -# Restore the default Windows shell for correct batch processing. -SHELL ["cmd", "/S", "/C"] - -# Download the Build Tools bootstrapper. -ADD https://aka.ms/vs/16/release/vs_buildtools.exe /TEMP/vs_buildtools.exe - -RUN 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')) - -# Download channel for fixed install. -ARG CHANNEL_URL=https://aka.ms/vs/16/release/channel -ADD ${CHANNEL_URL} /TEMP/VisualStudio.chman - -# Install Build Tools with C++ workload. -# - Documentation for docker installation -# https://docs.microsoft.com/en-us/visualstudio/install/build-tools-container?view=vs-2019 -# - Documentation on workloads -# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019#c-build-tools -# - Documentation on flags -# https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2019 -RUN /TEMP/vs_buildtools.exe --quiet --wait --norestart --nocache \ - --channelUri C:\TEMP\VisualStudio.chman \ - --installChannelUri C:\TEMP\VisualStudio.chman \ - --installPath C:\BuildTools \ - --add Microsoft.VisualStudio.Workload.VCTools \ - --add Microsoft.VisualStudio.Component.VC.ATL \ - --includeRecommended \ - || IF "%ERRORLEVEL%"=="3010" EXIT 0 - -# Register DIA dll (Debug Interface Access) so it can be used to symbolize -# the stack traces. Register dll for 32 and 64 bit. -# see https://developercommunity.visualstudio.com/content/problem/290674/msdia140dll-is-not-registered-on-vs2017-hosts.html - -RUN regsvr32 /S "C:\BuildTools\DIA SDK\bin\amd64\msdia140.dll" & \ - regsvr32 /S "C:\BuildTools\DIA SDK\bin\msdia140.dll" - -# install tools as described in https://llvm.org/docs/GettingStartedVS.html -# and a few more that were not documented... -# Pin an older version of Python; the current Python 3.10 fails when -# doing "pip install" for the other dependencies, as it fails to find libxml -# while compiling some package. -# We version pin the other packages as well to ensure the container build is as -# reproducible as possible to prevent issues when upgrading only part of the -# container. -RUN choco install -y ninja --version 1.13.1 && \ - choco install -y git --version 2.50.1 && \ - choco install -y sccache --version 0.10.0 && \ - choco install -y python3 --version 3.9.7 - -# Testing requires psutil -RUN pip install psutil - -# configure Python encoding -ENV PYTHONIOENCODING=UTF-8 - -# update the path variable -# C:\Program Files\Git\usr\bin contains a usable bash and other unix tools. -# C:\llvm-mingw\bin contains Clang configured for mingw targets and -# corresponding sysroots. Both the 'llvm' package (with Clang defaulting -# to MSVC targets) and this directory contains executables named -# 'clang.exe' - add this last to let the other one have precedence. -# To use these compilers, use the triple prefixed form, e.g. -# x86_64-w64-mingw32-clang. -# C:\buildtools and SDK paths are ones that are set by c:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=amd64 -host_arch=amd64 -RUN powershell -Command \ - [System.Environment]::SetEnvironmentVariable('PATH', \ - [System.Environment]::GetEnvironmentVariable('PATH', 'machine') + ';C:\Program Files\Git\usr\bin;C:\llvm-mingw\bin' \ - + ';C:\BuildTools\Common7\IDE\' \ - + ';C:\BuildTools\Common7\IDE\CommonExt ensions\Microsoft\TeamFoundation\Team Explorer' \ - + ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin' \ - + ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja' \ - + ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer' \ - + ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow' \ - + ';C:\BuildTools\Common7\IDE\VC\VCPackages' \ - + ';C:\BuildTools\Common7\Tools\' \ - + ';C:\BuildTools\Common7\Tools\devinit' \ - + ';C:\BuildTools\MSBuild\Current\Bin' \ - + ';C:\BuildTools\MSBuild\Current\bin\Roslyn' \ - + ';C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64' \ - + ';C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\' \ - + ';C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64' \ - + ';C:\Program Files (x86)\Windows Kits\10\bin\x64' \ - + ';C:\Windows\Microsoft.NET\Framework64\v4.0.30319' \ - ,'machine') - -# support long file names during git checkout -RUN git config --system core.longpaths true & \ - git config --global core.autocrlf false - -ARG RUNNER_VERSION=2.329.0 -ENV RUNNER_VERSION=$RUNNER_VERSION - -RUN powershell -Command \ - 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 ; \ - Add-Type -AssemblyName System.IO.Compression.FileSystem ; \ - [System.IO.Compression.ZipFile]::ExtractToDirectory('actions-runner-win.zip', $PWD) ;\ - rm actions-runner-win.zip - -# Set the LLVM_VERSION environment variable -ENV LLVM_VERSION=21.1.2 - -# Download and extract Clang compiler. -# Create directories, download, extract, and clean up all in one layer -RUN powershell -Command \ - # --- Setup directories --- \ - Write-Host "Creating directories..."; \ - New-Item -Path "C:\temp-download" -ItemType "Directory" -Force ; \ - New-Item -Path "C:\xz-utils" -ItemType "Directory" -Force ; \ - New-Item -Path "C:\clang" -ItemType "Directory" -Force ; \ - # --- 1. Download and extract xz --- \ - Set-Location C:\temp-download ; \ - Invoke-WebRequest -Uri "http://github.com/tukaani-project/xz/releases/download/v5.8.1/xz-5.8.1-windows.zip" -OutFile "xz.zip"; \ - (Get-FileHash -Path "C:\temp-download\xz.zip" -Algorithm MD5).Hash -eq 'c3c69fdce3e825cc0b76123b36b0bcc2' ; \ - Add-Type -AssemblyName "System.IO.Compression.FileSystem"; \ - [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\temp-download\xz.zip', 'C:\xz-utils'); \ - # --- 2. Download and decompress Clang --- \ - 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" ; \ - (Get-FileHash -Path "C:\temp-download\clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz" -Algorithm MD5).Hash -eq '0ae1d3effd9ab9d323f7fa595777f0a2' ; \ - C:\xz-utils\bin_x86-64\xz.exe -d -qq clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz ; \ - # --- 3. Extract clang --- \ - C:\Windows\System32\tar.exe -xf clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar -C C:\clang ; \ - # --- 4. Clean up --- \ - Set-Location C:\ ; \ - Remove-Item C:\temp-download -Recurse -Force; \ - Remove-Item C:\xz-utils -Recurse -Force; \ - # -- 5. Shorten path to clang files & remove unnecessary files -- \ - Set-Location C:\clang ; \ - Rename-Item -Path "C:\clang\clang+llvm-21.1.2-x86_64-pc-windows-msvc" -NewName "C:\clang\clang-msvc" ; \ - Set-Location C:\clang\clang-msvc ; \ - Remove-Item -Path C:\clang\clang-msvc\libexec -Recurse -Force ; \ - Remove-Item -Path C:\clang\clang-msvc\share -Recurse -Force ; \ - Rename-Item -Path "C:\clang\clang-msvc\bin" -NewName "C:\clang\clang-msvc\bin-full" ; \ - New-Item -Path "C:\clang\clang-msvc\bin" -ItemType Directory -Force ; \ - Set-Location C:\clang\clang-msvc\bin ; \ - Copy-Item -Path C:\clang\clang-msvc\bin-full\*.dll -Destination C:\clang\clang-msvc\bin\. ; \ - Copy-Item -Path C:\clang\clang-msvc\bin-full\clang-cl.exe -Destination C:\clang\clang-msvc\bin\. ; \ - Copy-Item -Path C:\clang\clang-msvc\bin-full\lld-link.exe -Destination C:\clang\clang-msvc\bin\. ; \ - Set-Location C:\clang\clang-msvc ; \ - Remove-Item -Path C:\clang\clang-msvc\bin-full -Recurse -Force ; +FROM mcr.microsoft.com/windows/servercore:ltsc2022 +RUN echo test From d5ee04d9c3a52524d3634f86fed3c8d7bb3599d2 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Sat, 8 Nov 2025 05:20:01 +0000 Subject: [PATCH 3/8] test --- .github/workflows/build-ci-container-windows.yml | 2 +- .../workflows/containers/github-action-ci-windows/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-ci-container-windows.yml b/.github/workflows/build-ci-container-windows.yml index 5b6d3a423d230..2e7995711a170 100644 --- a/.github/workflows/build-ci-container-windows.yml +++ b/.github/workflows/build-ci-container-windows.yml @@ -70,7 +70,7 @@ jobs: sudo apt-get install -y skopeo #skopeo login -u ${{ github.actor }} -p $env:GITHUB_TOKEN ghcr.io skopeo copy ${{ needs.build-ci-container-windows.outputs.container-filename }} \ - --additional-tags=latest \ + --additional-tag=latest \ --dest-compress-format zstd \ --dest-force-compress-format \ oci:/tmp/blah.tar diff --git a/.github/workflows/containers/github-action-ci-windows/Dockerfile b/.github/workflows/containers/github-action-ci-windows/Dockerfile index 09979985ab0e3..aaa1828549cef 100644 --- a/.github/workflows/containers/github-action-ci-windows/Dockerfile +++ b/.github/workflows/containers/github-action-ci-windows/Dockerfile @@ -1,2 +1,2 @@ -FROM mcr.microsoft.com/windows/servercore:ltsc2022 +FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 RUN echo test From d0a5b8f34f8206a93d41085ded9c8c60183a691b Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Sat, 8 Nov 2025 05:22:36 +0000 Subject: [PATCH 4/8] test --- .github/workflows/build-ci-container-windows.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/build-ci-container-windows.yml b/.github/workflows/build-ci-container-windows.yml index 2e7995711a170..d3772a3165ecf 100644 --- a/.github/workflows/build-ci-container-windows.yml +++ b/.github/workflows/build-ci-container-windows.yml @@ -72,6 +72,5 @@ jobs: skopeo copy ${{ needs.build-ci-container-windows.outputs.container-filename }} \ --additional-tag=latest \ --dest-compress-format zstd \ - --dest-force-compress-format \ oci:/tmp/blah.tar #docker://${{ needs.build-ci-container-windows.outputs.container-name-tag }} From 4d9325c2c2430cf78ebaf7a3cd2eab80a29445ad Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Sat, 8 Nov 2025 05:25:42 +0000 Subject: [PATCH 5/8] test --- .github/workflows/build-ci-container-windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-ci-container-windows.yml b/.github/workflows/build-ci-container-windows.yml index d3772a3165ecf..01af5fdf52866 100644 --- a/.github/workflows/build-ci-container-windows.yml +++ b/.github/workflows/build-ci-container-windows.yml @@ -69,7 +69,7 @@ jobs: sudo apt-get update sudo apt-get install -y skopeo #skopeo login -u ${{ github.actor }} -p $env:GITHUB_TOKEN ghcr.io - skopeo copy ${{ needs.build-ci-container-windows.outputs.container-filename }} \ + skopeo copy docker-archive:${{ needs.build-ci-container-windows.outputs.container-filename }} \ --additional-tag=latest \ --dest-compress-format zstd \ oci:/tmp/blah.tar From 8e4d44e3957d5196038a7226cee0385af795ccc5 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Sun, 9 Nov 2025 04:07:13 +0000 Subject: [PATCH 6/8] test --- .github/workflows/build-ci-container-windows.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-ci-container-windows.yml b/.github/workflows/build-ci-container-windows.yml index 01af5fdf52866..119b137867397 100644 --- a/.github/workflows/build-ci-container-windows.yml +++ b/.github/workflows/build-ci-container-windows.yml @@ -68,9 +68,8 @@ jobs: run: | sudo apt-get update sudo apt-get install -y skopeo - #skopeo login -u ${{ github.actor }} -p $env:GITHUB_TOKEN ghcr.io + #skopeo login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io skopeo copy docker-archive:${{ needs.build-ci-container-windows.outputs.container-filename }} \ - --additional-tag=latest \ --dest-compress-format zstd \ oci:/tmp/blah.tar #docker://${{ needs.build-ci-container-windows.outputs.container-name-tag }} From c67ded2622454bd9631d8892cd25dc7fc55421c7 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Sun, 9 Nov 2025 04:11:51 +0000 Subject: [PATCH 7/8] test --- .../workflows/build-ci-container-windows.yml | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-ci-container-windows.yml b/.github/workflows/build-ci-container-windows.yml index 119b137867397..e2ea18728df33 100644 --- a/.github/workflows/build-ci-container-windows.yml +++ b/.github/workflows/build-ci-container-windows.yml @@ -5,8 +5,8 @@ permissions: on: push: - branches: - - main + #branches: + # - main paths: - .github/workflows/build-ci-container-windows.yml - '.github/workflows/containers/github-action-ci-windows/**' @@ -17,7 +17,7 @@ on: jobs: build-ci-container-windows: - if: github.repository_owner == 'llvm' + #if: github.repository_owner == 'llvm' runs-on: windows-2022 outputs: container-name: ${{ steps.vars.outputs.container-name }} @@ -51,11 +51,11 @@ jobs: retention-days: 14 push-ci-container: - #if: github.event_name == 'push' + if: github.event_name == 'push' needs: - build-ci-container-windows - #permissions: - # packages: write + permissions: + packages: write runs-on: ubuntu-24.04 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -68,8 +68,10 @@ jobs: run: | sudo apt-get update sudo apt-get install -y skopeo - #skopeo login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io + skopeo login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io skopeo copy docker-archive:${{ needs.build-ci-container-windows.outputs.container-filename }} \ --dest-compress-format zstd \ - oci:/tmp/blah.tar - #docker://${{ needs.build-ci-container-windows.outputs.container-name-tag }} + docker://${{ needs.build-ci-container-windows.outputs.container-name-tag }} + skopeo copy docker-archive:${{ needs.build-ci-container-windows.outputs.container-filename }} \ + --dest-compress-format zstd \ + docker://${{ needs.build-ci-container-windows.outputs.container-name }}:latest From 85cda71a1ee988a9bad8cbaa850c63dc820e9da8 Mon Sep 17 00:00:00 2001 From: Aiden Grossman Date: Sun, 9 Nov 2025 04:15:35 +0000 Subject: [PATCH 8/8] finish up --- .../workflows/build-ci-container-windows.yml | 6 +- .../github-action-ci-windows/Dockerfile | 144 +++++++++++++++++- 2 files changed, 145 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-ci-container-windows.yml b/.github/workflows/build-ci-container-windows.yml index e2ea18728df33..3996948bb44e0 100644 --- a/.github/workflows/build-ci-container-windows.yml +++ b/.github/workflows/build-ci-container-windows.yml @@ -5,8 +5,8 @@ permissions: on: push: - #branches: - # - main + branches: + - main paths: - .github/workflows/build-ci-container-windows.yml - '.github/workflows/containers/github-action-ci-windows/**' @@ -17,7 +17,7 @@ on: jobs: build-ci-container-windows: - #if: github.repository_owner == 'llvm' + if: github.repository_owner == 'llvm' runs-on: windows-2022 outputs: container-name: ${{ steps.vars.outputs.container-name }} diff --git a/.github/workflows/containers/github-action-ci-windows/Dockerfile b/.github/workflows/containers/github-action-ci-windows/Dockerfile index aaa1828549cef..f1e4f1538540b 100644 --- a/.github/workflows/containers/github-action-ci-windows/Dockerfile +++ b/.github/workflows/containers/github-action-ci-windows/Dockerfile @@ -1,2 +1,142 @@ -FROM mcr.microsoft.com/windows/nanoserver:ltsc2022 -RUN echo test +# Agent image for LLVM org cluster. +# .net 4.8 is required by chocolately package manager. +FROM mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022 + +# Restore the default Windows shell for correct batch processing. +SHELL ["cmd", "/S", "/C"] + +# Download the Build Tools bootstrapper. +ADD https://aka.ms/vs/16/release/vs_buildtools.exe /TEMP/vs_buildtools.exe + +RUN 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')) + +# Download channel for fixed install. +ARG CHANNEL_URL=https://aka.ms/vs/16/release/channel +ADD ${CHANNEL_URL} /TEMP/VisualStudio.chman + +# Install Build Tools with C++ workload. +# - Documentation for docker installation +# https://docs.microsoft.com/en-us/visualstudio/install/build-tools-container?view=vs-2019 +# - Documentation on workloads +# https://docs.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2019#c-build-tools +# - Documentation on flags +# https://docs.microsoft.com/en-us/visualstudio/install/use-command-line-parameters-to-install-visual-studio?view=vs-2019 +RUN /TEMP/vs_buildtools.exe --quiet --wait --norestart --nocache \ + --channelUri C:\TEMP\VisualStudio.chman \ + --installChannelUri C:\TEMP\VisualStudio.chman \ + --installPath C:\BuildTools \ + --add Microsoft.VisualStudio.Workload.VCTools \ + --add Microsoft.VisualStudio.Component.VC.ATL \ + --includeRecommended \ + || IF "%ERRORLEVEL%"=="3010" EXIT 0 + +# Register DIA dll (Debug Interface Access) so it can be used to symbolize +# the stack traces. Register dll for 32 and 64 bit. +# see https://developercommunity.visualstudio.com/content/problem/290674/msdia140dll-is-not-registered-on-vs2017-hosts.html + +RUN regsvr32 /S "C:\BuildTools\DIA SDK\bin\amd64\msdia140.dll" & \ + regsvr32 /S "C:\BuildTools\DIA SDK\bin\msdia140.dll" + +# install tools as described in https://llvm.org/docs/GettingStartedVS.html +# and a few more that were not documented... +# Pin an older version of Python; the current Python 3.10 fails when +# doing "pip install" for the other dependencies, as it fails to find libxml +# while compiling some package. +# We version pin the other packages as well to ensure the container build is as +# reproducible as possible to prevent issues when upgrading only part of the +# container. +RUN choco install -y ninja --version 1.13.1 && \ + choco install -y git --version 2.50.1 && \ + choco install -y sccache --version 0.10.0 && \ + choco install -y python3 --version 3.9.7 + +# Testing requires psutil +RUN pip install psutil + +# configure Python encoding +ENV PYTHONIOENCODING=UTF-8 + +# update the path variable +# C:\Program Files\Git\usr\bin contains a usable bash and other unix tools. +# C:\llvm-mingw\bin contains Clang configured for mingw targets and +# corresponding sysroots. Both the 'llvm' package (with Clang defaulting +# to MSVC targets) and this directory contains executables named +# 'clang.exe' - add this last to let the other one have precedence. +# To use these compilers, use the triple prefixed form, e.g. +# x86_64-w64-mingw32-clang. +# C:\buildtools and SDK paths are ones that are set by c:\BuildTools\Common7\Tools\VsDevCmd.bat -arch=amd64 -host_arch=amd64 +RUN powershell -Command \ + [System.Environment]::SetEnvironmentVariable('PATH', \ + [System.Environment]::GetEnvironmentVariable('PATH', 'machine') + ';C:\Program Files\Git\usr\bin;C:\llvm-mingw\bin' \ + + ';C:\BuildTools\Common7\IDE\' \ + + ';C:\BuildTools\Common7\IDE\CommonExt ensions\Microsoft\TeamFoundation\Team Explorer' \ + + ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin' \ + + ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\Ninja' \ + + ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer' \ + + ';C:\BuildTools\Common7\IDE\CommonExtensions\Microsoft\TestWindow' \ + + ';C:\BuildTools\Common7\IDE\VC\VCPackages' \ + + ';C:\BuildTools\Common7\Tools\' \ + + ';C:\BuildTools\Common7\Tools\devinit' \ + + ';C:\BuildTools\MSBuild\Current\Bin' \ + + ';C:\BuildTools\MSBuild\Current\bin\Roslyn' \ + + ';C:\BuildTools\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64' \ + + ';C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\' \ + + ';C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64' \ + + ';C:\Program Files (x86)\Windows Kits\10\bin\x64' \ + + ';C:\Windows\Microsoft.NET\Framework64\v4.0.30319' \ + ,'machine') + +# support long file names during git checkout +RUN git config --system core.longpaths true & \ + git config --global core.autocrlf false + +ARG RUNNER_VERSION=2.329.0 +ENV RUNNER_VERSION=$RUNNER_VERSION + +RUN powershell -Command \ + 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 ; \ + Add-Type -AssemblyName System.IO.Compression.FileSystem ; \ + [System.IO.Compression.ZipFile]::ExtractToDirectory('actions-runner-win.zip', $PWD) ;\ + rm actions-runner-win.zip + +# Set the LLVM_VERSION environment variable +ENV LLVM_VERSION=21.1.2 + +# Download and extract Clang compiler. +# Create directories, download, extract, and clean up all in one layer +RUN powershell -Command \ + # --- Setup directories --- \ + Write-Host "Creating directories..."; \ + New-Item -Path "C:\temp-download" -ItemType "Directory" -Force ; \ + New-Item -Path "C:\xz-utils" -ItemType "Directory" -Force ; \ + New-Item -Path "C:\clang" -ItemType "Directory" -Force ; \ + # --- 1. Download and extract xz --- \ + Set-Location C:\temp-download ; \ + Invoke-WebRequest -Uri "http://github.com/tukaani-project/xz/releases/download/v5.8.1/xz-5.8.1-windows.zip" -OutFile "xz.zip"; \ + (Get-FileHash -Path "C:\temp-download\xz.zip" -Algorithm MD5).Hash -eq 'c3c69fdce3e825cc0b76123b36b0bcc2' ; \ + Add-Type -AssemblyName "System.IO.Compression.FileSystem"; \ + [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\temp-download\xz.zip', 'C:\xz-utils'); \ + # --- 2. Download and decompress Clang --- \ + 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" ; \ + (Get-FileHash -Path "C:\temp-download\clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz" -Algorithm MD5).Hash -eq '0ae1d3effd9ab9d323f7fa595777f0a2' ; \ + C:\xz-utils\bin_x86-64\xz.exe -d -qq clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar.xz ; \ + # --- 3. Extract clang --- \ + C:\Windows\System32\tar.exe -xf clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar -C C:\clang ; \ + # --- 4. Clean up --- \ + Set-Location C:\ ; \ + Remove-Item C:\temp-download -Recurse -Force; \ + Remove-Item C:\xz-utils -Recurse -Force; \ + # -- 5. Shorten path to clang files & remove unnecessary files -- \ + Set-Location C:\clang ; \ + Rename-Item -Path "C:\clang\clang+llvm-21.1.2-x86_64-pc-windows-msvc" -NewName "C:\clang\clang-msvc" ; \ + Set-Location C:\clang\clang-msvc ; \ + Remove-Item -Path C:\clang\clang-msvc\libexec -Recurse -Force ; \ + Remove-Item -Path C:\clang\clang-msvc\share -Recurse -Force ; \ + Rename-Item -Path "C:\clang\clang-msvc\bin" -NewName "C:\clang\clang-msvc\bin-full" ; \ + New-Item -Path "C:\clang\clang-msvc\bin" -ItemType Directory -Force ; \ + Set-Location C:\clang\clang-msvc\bin ; \ + Copy-Item -Path C:\clang\clang-msvc\bin-full\*.dll -Destination C:\clang\clang-msvc\bin\. ; \ + Copy-Item -Path C:\clang\clang-msvc\bin-full\clang-cl.exe -Destination C:\clang\clang-msvc\bin\. ; \ + Copy-Item -Path C:\clang\clang-msvc\bin-full\lld-link.exe -Destination C:\clang\clang-msvc\bin\. ; \ + Set-Location C:\clang\clang-msvc ; \ + Remove-Item -Path C:\clang\clang-msvc\bin-full -Recurse -Force ;