Skip to content

Commit 083fecf

Browse files
committed
Use LLVM archive on Windows CI
1 parent 3826c34 commit 083fecf

4 files changed

Lines changed: 82 additions & 17 deletions

File tree

.github/workflows/julia-release.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,12 @@ jobs:
153153
if: runner.os == 'Windows'
154154
shell: pwsh
155155
run: |
156-
Write-Host "Installing LLVM 21.1 with Chocolatey..."
157-
choco install llvm --version=${{ env.LLVM_RELEASE_VERSION }} -y --no-progress
156+
$llvmPrefix = Join-Path $env:USERPROFILE ".pecos\deps\llvm-21.1"
157+
Write-Host "Installing LLVM 21.1 development archive..."
158+
./scripts/ci/install-llvm-21-windows.ps1 -InstallDir $llvmPrefix -Version ${{ env.LLVM_RELEASE_VERSION }}
158159
159160
Write-Host "Setting LLVM environment variables..."
160-
$env:PECOS_LLVM = "C:\Program Files\LLVM"
161+
$env:PECOS_LLVM = $llvmPrefix
161162
$env:LLVM_SYS_211_PREFIX = $env:PECOS_LLVM
162163
cargo run --locked -p pecos-cli --release -- llvm configure "$env:PECOS_LLVM"
163164

.github/workflows/python-release.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -270,18 +270,18 @@ jobs:
270270
pipx run abi3audit --strict --report {wheel}
271271
# Windows configuration - CUDA via Jimver/cuda-toolkit (installed before cibuildwheel)
272272
CIBW_ENVIRONMENT_WINDOWS: >
273-
PATH="C:\\Program Files\\LLVM\\bin;C:\\Users\\runneradmin\\.pecos\\deps\\cmake-${{ env.PECOS_CMAKE_VERSION }}\\bin;$PATH"
274-
LLVM_SYS_211_PREFIX="C:\\Program Files\\LLVM"
273+
PATH="C:\\Users\\runneradmin\\.pecos\\deps\\llvm-21.1\\bin;C:\\Users\\runneradmin\\.pecos\\deps\\cmake-${{ env.PECOS_CMAKE_VERSION }}\\bin;$PATH"
274+
LLVM_SYS_211_PREFIX="C:\\Users\\runneradmin\\.pecos\\deps\\llvm-21.1"
275275
CMAKE="C:\\Users\\runneradmin\\.pecos\\deps\\cmake-${{ env.PECOS_CMAKE_VERSION }}\\bin\\cmake.exe"
276276
MATURIN_PEP517_ARGS="--locked --features=extension-module,mwpf"
277277
CIBW_BEFORE_ALL_WINDOWS: >
278-
echo "=== Installing LLVM 21.1 with Chocolatey ===" &&
278+
echo "=== Installing LLVM 21.1 development archive ===" &&
279279
rustup update &&
280-
choco install llvm --version=${{ env.LLVM_RELEASE_VERSION }} -y --no-progress &&
281-
cargo run --locked --release -p pecos-cli -- llvm configure "C:\Program Files\LLVM" &&
280+
powershell -NoProfile -ExecutionPolicy Bypass -File scripts\ci\install-llvm-21-windows.ps1 -InstallDir "C:\Users\runneradmin\.pecos\deps\llvm-21.1" -Version ${{ env.LLVM_RELEASE_VERSION }} &&
281+
cargo run --locked --release -p pecos-cli -- llvm configure "C:\Users\runneradmin\.pecos\deps\llvm-21.1" &&
282282
cargo run --locked --release -p pecos-cli -- install cmake --force &&
283283
echo "=== Checking LLVM installation ===" &&
284-
if exist "C:\Program Files\LLVM\bin\llvm-config.exe" (echo LLVM directory exists) else (echo ERROR: LLVM directory not found! && exit /b 1)
284+
if exist "C:\Users\runneradmin\.pecos\deps\llvm-21.1\bin\llvm-config.exe" (echo LLVM directory exists) else (echo ERROR: LLVM directory not found! && exit /b 1)
285285
# Install delvewheel and patch it to ignore ext-ms-win-* API sets
286286
# (delvewheel ignores api-ms-win-* but not ext-ms-win-* which are also Windows API sets)
287287
CIBW_BEFORE_BUILD_WINDOWS: >
@@ -290,7 +290,7 @@ jobs:
290290
# Note: --no-dll excludes Windows system DLLs that should not be bundled
291291
# combase.dll and rmclient.dll are core Windows components that fail when bundled
292292
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
293-
delvewheel repair -v --add-path "C:\\Program Files\\LLVM\\bin" --no-dll "combase.dll;rmclient.dll" -w {dest_dir} {wheel} &&
293+
delvewheel repair -v --add-path "C:\\Users\\runneradmin\\.pecos\\deps\\llvm-21.1\\bin" --no-dll "combase.dll;rmclient.dll" -w {dest_dir} {wheel} &&
294294
pipx run abi3audit --strict --report {wheel}
295295
296296
- name: Upload pecos-rslib wheels
@@ -349,17 +349,17 @@ jobs:
349349
PATH=$HOME/.pecos/bin:$PATH DYLD_LIBRARY_PATH=$HOME/.pecos/deps/llvm-21.1/lib delocate-wheel --require-archs {delocate_archs} -w {dest_dir} -v {wheel} &&
350350
pipx run abi3audit --strict --report {wheel}
351351
CIBW_ENVIRONMENT_WINDOWS: >
352-
PATH="C:\\Program Files\\LLVM\\bin;$PATH"
353-
LLVM_SYS_211_PREFIX="C:\\Program Files\\LLVM"
352+
PATH="C:\\Users\\runneradmin\\.pecos\\deps\\llvm-21.1\\bin;$PATH"
353+
LLVM_SYS_211_PREFIX="C:\\Users\\runneradmin\\.pecos\\deps\\llvm-21.1"
354354
CIBW_BEFORE_ALL_WINDOWS: >
355355
rustup update &&
356-
if not exist "C:\Program Files\LLVM\bin\llvm-config.exe" (choco install llvm --version=${{ env.LLVM_RELEASE_VERSION }} -y --no-progress) else (echo LLVM already installed from pecos-rslib build) &&
357-
cargo run --locked --release -p pecos-cli -- llvm configure "C:\Program Files\LLVM"
356+
if not exist "C:\Users\runneradmin\.pecos\deps\llvm-21.1\bin\llvm-config.exe" (powershell -NoProfile -ExecutionPolicy Bypass -File scripts\ci\install-llvm-21-windows.ps1 -InstallDir "C:\Users\runneradmin\.pecos\deps\llvm-21.1" -Version ${{ env.LLVM_RELEASE_VERSION }}) else (echo LLVM already installed from pecos-rslib build) &&
357+
cargo run --locked --release -p pecos-cli -- llvm configure "C:\Users\runneradmin\.pecos\deps\llvm-21.1"
358358
CIBW_BEFORE_BUILD_WINDOWS: >
359359
pip install delvewheel &&
360360
python -c "import delvewheel._dll_list as d,inspect,re as r;p=inspect.getfile(d);c=open(p).read();n=chr(10);open(p,'w').write(c.replace(r\"re.compile('api-.*'),\",r\"re.compile('api-.*'),\"+n+r\" re.compile('ext-.*'),\")) if 'ext-.*' not in c else None"
361361
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >
362-
delvewheel repair -v --add-path "C:\\Program Files\\LLVM\\bin" --no-dll "combase.dll;rmclient.dll" -w {dest_dir} {wheel} &&
362+
delvewheel repair -v --add-path "C:\\Users\\runneradmin\\.pecos\\deps\\llvm-21.1\\bin" --no-dll "combase.dll;rmclient.dll" -w {dest_dir} {wheel} &&
363363
pipx run abi3audit --strict --report {wheel}
364364
365365
- name: Upload pecos-rslib-llvm wheels

Justfile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ ci-env: _msvc-bootstrap
7272
;;
7373
Windows*|MINGW*|MSYS*|CYGWIN*)
7474
if ! {{pecos}} llvm find >/dev/null 2>&1; then
75-
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "choco install llvm --version=$LLVM_RELEASE_VERSION -y --no-progress"
75+
LLVM_PREFIX="${USERPROFILE:-$HOME}\\.pecos\\deps\\llvm-21.1"
76+
powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts/ci/install-llvm-21-windows.ps1 -InstallDir "$LLVM_PREFIX" -Version "$LLVM_RELEASE_VERSION"
7677
fi
77-
{{pecos}} llvm configure "C:/Program Files/LLVM"
78+
{{pecos}} llvm configure
7879
;;
7980
*)
8081
{{pecos}} llvm ensure --managed --no-configure
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
param(
2+
[string]$InstallDir = (Join-Path $env:USERPROFILE ".pecos\deps\llvm-21.1"),
3+
[string]$Version = ""
4+
)
5+
6+
$ErrorActionPreference = "Stop"
7+
8+
if (-not $Version) {
9+
if ($env:LLVM_RELEASE_VERSION) {
10+
$Version = $env:LLVM_RELEASE_VERSION
11+
}
12+
else {
13+
$Version = "21.1.8"
14+
}
15+
}
16+
17+
$ExpectedSha256 = "749d22f565fcd5718dbed06512572d0e5353b502c03fe1f7f17ee8b8aca21a47"
18+
$RequiredVersion = "21.1"
19+
$Asset = "clang+llvm-$Version-x86_64-pc-windows-msvc.tar.xz"
20+
$Url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-$Version/$Asset"
21+
$LlvmConfig = Join-Path $InstallDir "bin\llvm-config.exe"
22+
23+
if (Test-Path $LlvmConfig) {
24+
$FoundVersion = (& $LlvmConfig --version).Trim()
25+
if ($FoundVersion.StartsWith($RequiredVersion)) {
26+
Write-Host "LLVM $FoundVersion already installed at $InstallDir"
27+
exit 0
28+
}
29+
}
30+
31+
$TempDir = Join-Path ([System.IO.Path]::GetTempPath()) "pecos-llvm-$([System.Guid]::NewGuid())"
32+
$Archive = Join-Path $TempDir $Asset
33+
$ExtractDir = Join-Path $TempDir "extract"
34+
35+
New-Item -ItemType Directory -Force -Path $TempDir | Out-Null
36+
New-Item -ItemType Directory -Force -Path $ExtractDir | Out-Null
37+
38+
try {
39+
Write-Host "Downloading official LLVM $Version Windows development archive: $Asset"
40+
Invoke-WebRequest -Uri $Url -OutFile $Archive
41+
42+
$ActualSha256 = (Get-FileHash -Algorithm SHA256 $Archive).Hash.ToLowerInvariant()
43+
if ($ActualSha256 -ne $ExpectedSha256) {
44+
throw "SHA256 mismatch for $Asset. Expected $ExpectedSha256, got $ActualSha256"
45+
}
46+
47+
tar -xf $Archive -C $ExtractDir --strip-components=1
48+
49+
if (Test-Path $InstallDir) {
50+
Remove-Item -Recurse -Force $InstallDir
51+
}
52+
New-Item -ItemType Directory -Force -Path (Split-Path -Parent $InstallDir) | Out-Null
53+
Move-Item $ExtractDir $InstallDir
54+
55+
& $LlvmConfig --version
56+
& $LlvmConfig --shared-mode
57+
Write-Host "Installed LLVM $Version to $InstallDir"
58+
}
59+
finally {
60+
if (Test-Path $TempDir) {
61+
Remove-Item -Recurse -Force $TempDir
62+
}
63+
}

0 commit comments

Comments
 (0)