-
Couldn't load subscription status.
- Fork 15k
[CI][Github] Install Clang in Windows container #164519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Downloads clang-for-windows from the LLVM releases website, decompresses and untars the images, and leave them in C:\clang\clang-msvc\... Temporarily downloads the 'xz' utility to decompress the downloaded clang tarball image.
|
@llvm/pr-subscribers-github-workflow Author: None (cmtice) ChangesDownloads clang-for-windows from the LLVM releases website, decompresses and untars the images, and leave them in C:\clang\clang-msvc... Temporarily downloads the 'xz' utility to decompress the downloaded clang tarball image. Full diff: https://github.com/llvm/llvm-project/pull/164519.diff 1 Files Affected:
diff --git a/.github/workflows/containers/github-action-ci-windows/Dockerfile b/.github/workflows/containers/github-action-ci-windows/Dockerfile
index 9ddf5017bc020..7835cc07a3936 100644
--- a/.github/workflows/containers/github-action-ci-windows/Dockerfile
+++ b/.github/workflows/containers/github-action-ci-windows/Dockerfile
@@ -98,3 +98,37 @@ RUN powershell -Command \
Add-Type -AssemblyName System.IO.Compression.FileSystem ; \
[System.IO.Compression.ZipFile]::ExtractToDirectory('actions-runner-win.zip', $PWD) ;\
rm actions-runner-win.zip
+
+# 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 ; \
+ Write-Host "Downloading xz-utils..."; \
+ Invoke-WebRequest -Uri "https://github.com/tukaani-project/xz/releases/download/v5.8.1/xz-5.8.1-windows.zip" -OutFile "xz.zip"; \
+ Write-Host "Extracting xz-utils..."; \
+ 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 --- \
+ Write-Host "Downloading Clang..."; \
+ Invoke-WebRequest -Uri "https://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" ; \
+ Write-Host "Decompressing clang.tar.xz using C:\xz-utils\bin_x86-64\xz.exe"; \
+ 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 --- \
+ Write-Host "Extracting clang.tar to C:\clang ..."; \
+ C:\Windows\System32\tar.exe -xf clang+llvm-21.1.2-x86_64-pc-windows-msvc.tar -C C:\clang ; \
+ # --- 4. Clean up --- \
+ Write-Host "Cleaning up..." ; \
+ Set-Location C:\ ; \
+ Remove-Item C:\temp-download -Recurse -Force; \
+ Remove-Item C:\xz-utils -Recurse -Force; \
+ Write-Host "Download and extraction complete." ;
+
+RUN powershell -Command \
+ Set-Location C:\clang ; \
+ Rename-Item -Path "C:\clang\clang+llvm-21.1.2-x86_64-pc-windows-msvc" -NewName "C:\clang\clang-msvc" ;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does the size of this image compare to the existing one? docker image ls should show unpacked image sizes.
| # --- 1. Download and extract xz --- \ | ||
| Set-Location C:\temp-download ; \ | ||
| Write-Host "Downloading xz-utils..."; \ | ||
| Invoke-WebRequest -Uri "https://github.com/tukaani-project/xz/releases/download/v5.8.1/xz-5.8.1-windows.zip" -OutFile "xz.zip"; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to verify a checksum here? Similar to what we do for sccache in the linux container:
| echo $( [ $(arch) = 'x86_64' ] && echo "1fbb35e135660d04a2d5e42b59c7874d39b3deb17de56330b25b713ec59f849b" || echo "d6a1ce4acd02b937cd61bc675a8be029a60f7bc167594c33d75732bbc0a07400") /tmp/sccache.tar.gz | sha256sum -c && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (I think).
| [System.IO.Compression.ZipFile]::ExtractToDirectory('C:\temp-download\xz.zip', 'C:\xz-utils'); \ | ||
| # --- 2. Download and decompress Clang --- \ | ||
| Write-Host "Downloading Clang..."; \ | ||
| Invoke-WebRequest -Uri "https://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" ; \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we pull the version number here into an ENV line?
| ENV LLVM_VERSION=21.1.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| RUN powershell -Command \ | ||
| Set-Location C:\clang ; \ | ||
| Rename-Item -Path "C:\clang\clang+llvm-21.1.2-x86_64-pc-windows-msvc" -NewName "C:\clang\clang-msvc" ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the binary? Why are we renaming it to clang-msvc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, that's not the binary. That's the directory into which tar untar'd everything. I'm shortening the path name. With this renaming, the clang-cl binary is in C:\clang\clang-msvc\bin\clang-cl.exe I thought the very long path name would be a pain to type and a likely source of typos.
26.1 GB vs 17.7 GB, I think. |
As in the new one is ~9GB smaller? That doesn't make a lot of sense. |
No, the new one is ~9GB bigger. Sorry that wasn't clear in my previous answer. New image: 26.1 GB; old image: 17.7 GB. |
Note: The downloaded clang includes a LOT more than just the clang-cl.exe file: C:>ls clang\clang-msvc C:>ls clang\clang-msvc\bin |
We should try and trim what we extract as much as possible. We need only one or two of those executables, so the rest just pessimize image unpack times significantly given the 50% size increase. I would suspsect we only need to keep |
- Remove "Write-Host" lines - Add LLVM_VERSION environment variable - Remove unnecessary files from downloaded clang
|
I've updated this to address most review comments; I have not added the md5 checksum yet; will get to that soon. I updated the container to remove many of the downloaded files from clang; I kept the entire include directory, and the entire lib directory. In the bin directory I kept clang-cl.exe and lld-link.exe. The old container size was 17.7 GB. The new container size is 23.2 GB. This is not making a lot of sense to me -- I checked the size of the stuff I kept from the new clang download, and it's only a total of 1.2 GB (bin: 469MB; lib:665MB; include: 78MB). I entered the container and checked and the new stuff did indeed all get deleted, so I have no idea where the other new 4.3 GB came from. |
You need to delete the files in the same layer (RUN step) that you download them in. Otherwise you'll end up with one layer downloading them and then another layer deleting them, and both layers get preserved due to how docker works. |
Ah, much better! When I do that, the new container size is 19.1 GB. |
.github/workflows/containers/github-action-ci-windows/Dockerfile
Outdated
Show resolved
Hide resolved
Downloads clang-for-windows from the LLVM releases website, decompresses and untars the images, and leave them in C:\clang\clang-msvc\... Temporarily downloads the 'xz' utility to decompress the downloaded clang tarball image.
Downloads clang-for-windows from the LLVM releases website, decompresses and untars the images, and leave them in C:\clang\clang-msvc... Temporarily downloads the 'xz' utility to decompress the downloaded clang tarball image.