Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
160 changes: 159 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
os: [ubuntu-latest, macos-latest]

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

Expand Down Expand Up @@ -100,3 +100,161 @@ jobs:
run: |
docker buildx build --platform linux/amd64 -f test/docker/Dockerfile . --progress=plain --output=type=cacheonly
docker buildx build --platform linux/arm64 -f test/docker/Dockerfile . --progress=plain --output=type=cacheonly

build-windows:
name: Build on Windows (pinned LLVM 20.1.0)
runs-on: windows-2022

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Resolve dependency ref
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$ref = if ($env:GITHUB_HEAD_REF) { $env:GITHUB_HEAD_REF } else { $env:GITHUB_REF_NAME }
"DEPENDENCY_REF=$ref" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: Checkout coretrace-log matching ref
id: checkout_logger_ref
continue-on-error: true
uses: actions/checkout@v4
with:
repository: CoreTrace/coretrace-log
ref: ${{ env.DEPENDENCY_REF }}
path: deps/coretrace-log
fetch-depth: 1

- name: Checkout coretrace-log main fallback
if: steps.checkout_logger_ref.outcome == 'failure'
uses: actions/checkout@v4
with:
repository: CoreTrace/coretrace-log
ref: main
path: deps/coretrace-log
fetch-depth: 1

- name: Install LLVM 20.1.0 archive with 7-Zip
shell: pwsh
run: |
$ErrorActionPreference = "Stop"

$llvmVersion = "20.1.0"
$archiveName = "clang+llvm-$llvmVersion-x86_64-pc-windows-msvc.tar.xz"
$archiveUrl = "https://github.com/llvm/llvm-project/releases/download/llvmorg-$llvmVersion/$archiveName"
$archivePath = Join-Path $env:RUNNER_TEMP $archiveName
$extractRoot = Join-Path $env:RUNNER_TEMP "llvm-extract"
$installRoot = "C:\Program Files\LLVM-$llvmVersion"
$sevenZip = "${env:ProgramFiles}\7-Zip\7z.exe"
$tarPath = Join-Path $env:RUNNER_TEMP "clang+llvm-$llvmVersion-x86_64-pc-windows-msvc.tar"

if (-not (Test-Path $sevenZip)) {
throw "7z.exe not found at $sevenZip"
}

Write-Host "Downloading LLVM archive from $archiveUrl"
Invoke-WebRequest -Uri $archiveUrl -OutFile $archivePath
Write-Host "Download finished"
Get-Item $archivePath | Select-Object FullName, Length | Format-Table -AutoSize

if (Test-Path $extractRoot) {
Remove-Item -Recurse -Force $extractRoot
}
New-Item -ItemType Directory -Force -Path $extractRoot | Out-Null

if (Test-Path $tarPath) {
Remove-Item -Force $tarPath
}

Write-Host "Extracting .xz to .tar with 7-Zip"
& $sevenZip x $archivePath "-o$env:RUNNER_TEMP" -y
if ($LASTEXITCODE -ne 0) {
throw "7-Zip failed while extracting .xz archive"
}

if (-not (Test-Path $tarPath)) {
throw "Expected tar file not found after xz extraction: $tarPath"
}

Write-Host "Extracting .tar to $extractRoot"
& $sevenZip x $tarPath "-o$extractRoot" -y
if ($LASTEXITCODE -ne 0) {
throw "7-Zip failed while extracting .tar archive"
}

Write-Host "Listing extracted directories"
Get-ChildItem $extractRoot -Directory | Select-Object Name, FullName | Format-Table -AutoSize

$extractedDir = Get-ChildItem $extractRoot -Directory | Select-Object -First 1
if (-not $extractedDir) {
throw "Failed to find extracted LLVM directory under $extractRoot"
}

if (Test-Path $installRoot) {
Remove-Item -Recurse -Force $installRoot
}
Move-Item -Path $extractedDir.FullName -Destination $installRoot

$clangClPath = Join-Path $installRoot "bin\clang-cl.exe"
$llvmCmakeDir = Join-Path $installRoot "lib\cmake\llvm"
$clangCmakeDir = Join-Path $installRoot "lib\cmake\clang"
$llvmConfigPath = Join-Path $llvmCmakeDir "LLVMConfig.cmake"
$clangConfigPath = Join-Path $clangCmakeDir "ClangConfig.cmake"

Write-Host "Checking extracted LLVM files"
Write-Host "clang-cl path: $clangClPath"
Write-Host "LLVMConfig path: $llvmConfigPath"
Write-Host "ClangConfig path: $clangConfigPath"

if (-not (Test-Path $clangClPath)) {
throw "clang-cl.exe not found after LLVM archive extraction: $clangClPath"
}
if (-not (Test-Path $llvmConfigPath)) {
throw "LLVMConfig.cmake not found after LLVM archive extraction: $llvmConfigPath"
}
if (-not (Test-Path $clangConfigPath)) {
throw "ClangConfig.cmake not found after LLVM archive extraction: $clangConfigPath"
}

$clangVersion = (& $clangClPath --version) -join " "
if ($clangVersion -notmatch "clang version 20\.1\.0") {
throw "Unexpected clang-cl version. Got: $clangVersion"
}

"LLVM_CMAKE_DIR=$llvmCmakeDir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"LLVM_DIR=$llvmCmakeDir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"Clang_DIR=$clangCmakeDir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append

- name: Configure + Build + Install
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
powershell -ExecutionPolicy Bypass -File .\scripts\build-windows.ps1 `
-LLVMDir "${env:LLVM_CMAKE_DIR}" `
-LoggerSourceDir "${PWD}\deps\coretrace-log" `
-Configuration Release

- name: Smoke test
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
Set-Content -Path test.cc -Value 'int main() { return 0; }'
.\dist\windows\bin\cc.exe -S -emit-llvm test.cc
if (-not (Test-Path test.ll)) {
throw "test.ll was not produced"
}
Get-Content test.ll -TotalCount 10

- name: Run Python smoke tests (Windows)
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
python -m venv .venv
.\.venv\Scripts\python -m pip install --upgrade pip
.\.venv\Scripts\python -m pip install git+https://github.com/CoreTrace/coretrace-testkit.git
$env:CORETRACE_COMPILER_TEST_CC = (Resolve-Path .\dist\windows\bin\cc.exe).Path
$env:CORETRACE_LOGGER_SOURCE_DIR = (Resolve-Path .\deps\coretrace-log).Path
.\.venv\Scripts\python .\test\examples\test_smoke.py
.\.venv\Scripts\python .\test\examples\test_extern_project.py
Loading
Loading