Skip to content

Commit 4400d87

Browse files
committed
update
1 parent 67ea00e commit 4400d87

1 file changed

Lines changed: 36 additions & 33 deletions

File tree

.github/workflows/main.yml

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,14 @@ jobs:
5858
enable-cache: true
5959
cache-python: true
6060

61+
- uses: ilammy/msvc-dev-cmd@v1
62+
with:
63+
arch: x64
64+
6165
- name: Create venv
62-
run: uv venv
66+
run: |
67+
uv venv .venv
68+
Add-Content $env:GITHUB_PATH "$pwd\.venv\Scripts"
6369
6470
- name: Install python dependencies
6571
run: uv pip install --verbose scikit-build-core
@@ -72,49 +78,46 @@ jobs:
7278
if: matrix.os == 'windows-latest'
7379
run: choco install llvm cmake ninja -y --no-progress
7480

75-
- name: Install LLVM (clang+llvm tarball) and patch diaguids path (Windows)
81+
- name: Install LLVM + provide libxml2s.lib (Windows)
7682
if: matrix.os == 'windows-latest'
77-
id: install_llvm_windows
7883
shell: pwsh
7984
run: |
80-
$ErrorActionPreference = "Stop"
85+
$ErrorActionPreference = 'Stop'
8186
87+
# ---- LLVM (official release tarball) ----
8288
$llvmVersion = "20.1.0"
83-
$base = "$env:RUNNER_TEMP\llvm"
84-
New-Item -ItemType Directory -Force -Path $base | Out-Null
85-
86-
$archive = "$base\clang+llvm.tar.xz"
87-
$url = "https://github.com/llvm/llvm-project/releases/download/llvmorg-$llvmVersion/clang%2Bllvm-$llvmVersion-x86_64-pc-windows-msvc.tar.xz"
88-
Invoke-WebRequest -Uri $url -OutFile $archive
89-
90-
tar -xf $archive -C $base
91-
92-
$llvmRoot = Join-Path $base "clang+llvm-$llvmVersion-x86_64-pc-windows-msvc"
89+
$llvmBase = Join-Path $env:RUNNER_TEMP "llvm"
90+
New-Item -ItemType Directory -Force -Path $llvmBase | Out-Null
9391
94-
# --- Patch diaguids.lib absolute path in LLVMExports.cmake ---
95-
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
96-
if (!(Test-Path $vswhere)) { throw "vswhere not found: $vswhere" }
92+
$llvmArchive = Join-Path $llvmBase "clang+llvm-$llvmVersion-x86_64-pc-windows-msvc.tar.xz"
93+
Invoke-WebRequest `
94+
-Uri "https://github.com/llvm/llvm-project/releases/download/llvmorg-$llvmVersion/clang%2Bllvm-$llvmVersion-x86_64-pc-windows-msvc.tar.xz" `
95+
-OutFile $llvmArchive
96+
tar -xf $llvmArchive -C $llvmBase
9797
98-
$vsPath = & $vswhere -latest -property installationPath
99-
if (!$vsPath) { throw "Visual Studio installation path not found." }
98+
$llvmRoot = Join-Path $llvmBase "clang+llvm-$llvmVersion-x86_64-pc-windows-msvc"
99+
$llvmConfig = Join-Path $llvmRoot "bin\llvm-config.exe"
100+
$llvmLibDir = & $llvmConfig --libdir
100101
101-
$diaLib = Join-Path $vsPath "DIA SDK\lib\amd64\diaguids.lib"
102-
if (!(Test-Path $diaLib)) { throw "diaguids.lib not found: $diaLib" }
102+
# ---- vcpkg libxml2 -> copy as libxml2s.lib into LLVM libdir ----
103+
$vcpkgRoot = Join-Path $env:RUNNER_TEMP "vcpkg"
104+
git clone --depth 1 https://github.com/microsoft/vcpkg.git $vcpkgRoot
105+
& "$vcpkgRoot\bootstrap-vcpkg.bat" -disableMetrics
106+
& "$vcpkgRoot\vcpkg.exe" install libxml2:x64-windows
103107
104-
$diaLibPosix = $diaLib.Replace('\','/')
108+
$vcpkgInstalled = Join-Path $vcpkgRoot "installed\x64-windows"
105109
106-
$llvmExports = Join-Path $llvmRoot "lib\cmake\llvm\LLVMExports.cmake"
107-
if (!(Test-Path $llvmExports)) { throw "LLVMExports.cmake not found: $llvmExports" }
110+
Copy-Item `
111+
(Join-Path $vcpkgInstalled "lib\libxml2.lib") `
112+
(Join-Path $llvmLibDir "libxml2s.lib") `
113+
-Force
108114
109-
$content = Get-Content $llvmExports -Raw
110-
$content = $content -replace 'C:/Program Files.*?/DIA SDK/lib/amd64/diaguids\.lib', $diaLibPosix
111-
Set-Content -Path $llvmExports -Value $content -NoNewline
115+
# 実行時に dll を拾えるように PATH に追加
116+
Add-Content $env:GITHUB_PATH (Join-Path $vcpkgInstalled "bin")
112117
113-
# export PATH and LLVM_DIR for cmake find_package(LLVM)
114-
echo "$llvmRoot\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
115-
$llvmDir = (Join-Path $llvmRoot "lib\cmake\llvm").Replace('\','/')
116-
echo "LLVM_DIR=$llvmDir" | Out-File -FilePath $env:GITHUB_ENV -Append
117-
echo "llvm_dir=$llvmDir" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
118+
# 後続 step 用に llvm-config の場所を export(CMake は / 区切りが無難)
119+
$llvmConfigFwd = $llvmConfig.Replace('\','/')
120+
Add-Content $env:GITHUB_ENV "LLVM_CONFIG=$llvmConfigFwd"
118121
119122
- name: Build and Install tvm-ffi
120123
run: uv pip install --verbose ./3rdparty/tvm-ffi
@@ -128,7 +131,7 @@ jobs:
128131
- name: Build and Install TVM (Windows)
129132
if: matrix.os == 'windows-latest'
130133
run: |
131-
$env:CMAKE_ARGS = "-G Ninja -DUSE_LLVM=ON -DBUILD_TESTING=OFF -DLLVM_DIR=${{ steps.install_llvm_windows.outputs.llvm_dir }}"
134+
$env:CMAKE_ARGS = "-DUSE_LLVM=$env:LLVM_CONFIG -DBUILD_TESTING=OFF"
132135
uv pip install --no-deps . --verbose
133136
134137
- name: Install test dependencies

0 commit comments

Comments
 (0)