From 54220a461e56bad5365d6b632be7beb02853f7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 31 May 2026 03:00:51 -0400 Subject: [PATCH 1/8] Add LLVM core libs package workflow Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/github-release.yml | 22 ++- .github/workflows/llvm-core-libs.yml | 286 +++++++++++++++++++++++++++ README.md | 20 +- cmake/llvm-core-libs.cmake | 88 +++++++++ 4 files changed, 412 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/llvm-core-libs.yml create mode 100644 cmake/llvm-core-libs.cmake diff --git a/.github/workflows/github-release.yml b/.github/workflows/github-release.yml index 4438b20..aab3251 100644 --- a/.github/workflows/github-release.yml +++ b/.github/workflows/github-release.yml @@ -10,6 +10,10 @@ on: description: 'llvm workflow run id' default: "latest" required: true + llvm_core_libs_run_id: + description: 'llvm core libs workflow run id' + default: "latest" + required: true halide_run_id: description: 'halide workflow run id' default: "latest" @@ -51,6 +55,22 @@ jobs: Write-Host "Downloading run $RunId ($Workflow)" & gh run download -R $Repository $RunId + - name: Download llvm core libs + shell: pwsh + env: + GH_TOKEN: ${{ github.token }} + run: | + $Workflow = "LLVM core libs" + $Repository = $Env:GITHUB_REPOSITORY + $RunId = '${{ github.event.inputs.llvm_core_libs_run_id }}' + if ($RunId -eq 'latest') { + $RunId = $(gh run list -R $Repository -w $Workflow --json 'status,databaseId,conclusion') | + ConvertFrom-Json | Where-Object { ($_.status -eq 'completed') -and ($_.conclusion -eq 'success') } | + Select-Object -First 1 -ExpandProperty databaseId + } + Write-Host "Downloading run $RunId ($Workflow)" + & gh run download -R $Repository $RunId + - name: Download halide shell: pwsh env: @@ -87,7 +107,7 @@ jobs: shell: pwsh env: GH_TOKEN: ${{ github.token }} - if: ${{ github.event.inputs.dry-run == 'false' }} + if: ${{ github.event.inputs.dry-run == 'false' }} run: | $RootDir = Get-Location Get-ChildItem *.tar.xz -Depth 2 | % { Move-Item $_.FullName $RootDir -Force } diff --git a/.github/workflows/llvm-core-libs.yml b/.github/workflows/llvm-core-libs.yml new file mode 100644 index 0000000..bc87305 --- /dev/null +++ b/.github/workflows/llvm-core-libs.yml @@ -0,0 +1,286 @@ +name: LLVM core libs +on: + workflow_dispatch: + push: + branches: + - llvm-core-package + paths: + - ".github/workflows/llvm-core-libs.yml" + - "cmake/llvm-core-libs.cmake" +jobs: + build: + name: LLVM core libs ${{matrix.version}} [x86_64-windows-mt] + runs-on: windows-2022 + strategy: + fail-fast: false + matrix: + version: [ 20.1.8, 22.1.4 ] + + include: + - version: 20.1.8 + ref: llvmorg-20.1.8 + - version: 22.1.4 + ref: llvmorg-22.1.4 + + steps: + - name: Clone project + uses: actions/checkout@v6 + with: + path: llvm-prebuilt + + - name: Configure Windows runner + run: choco install --no-progress ninja 7zip + + - name: Clone LLVM ${{matrix.version}} + uses: actions/checkout@v6 + with: + repository: llvm/llvm-project + ref: ${{matrix.ref}} + path: llvm-project + + - name: Enable Windows host environment + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: amd64 + + - name: Configure LLVM host tools + shell: pwsh + run: | + cmake -G Ninja -S llvm-project\llvm -B llvm-host ` + -DLLVM_TARGETS_TO_BUILD=X86 ` + -DLLVM_ENABLE_PROJECTS="" ` + -DLLVM_ENABLE_RUNTIMES="" ` + -DLLVM_ENABLE_LIBXML2=OFF ` + -DLLVM_ENABLE_ZLIB=OFF ` + -DLLVM_ENABLE_ZSTD=OFF ` + -DLLVM_INCLUDE_TESTS=OFF ` + -DLLVM_INCLUDE_BENCHMARKS=OFF ` + -DLLVM_INCLUDE_EXAMPLES=OFF ` + -DCMAKE_BUILD_TYPE=Release -Wno-dev + + - name: Build LLVM host tools + shell: pwsh + run: | + cmake --build llvm-host --target llvm-tblgen llvm-config + $HostBinPath = Join-Path $Env:GITHUB_WORKSPACE "llvm-host\bin" + echo "LLVM_NATIVE_TOOL_DIR=$HostBinPath" >> $Env:GITHUB_ENV + echo "LLVM_TABLEGEN=$HostBinPath/llvm-tblgen.exe" >> $Env:GITHUB_ENV + echo "LLVM_CONFIG_PATH=$HostBinPath/llvm-config.exe" >> $Env:GITHUB_ENV + echo "LLVM_VERSION=${{matrix.version}}" >> $Env:GITHUB_ENV + + - name: Enable Windows target environment + uses: ilammy/msvc-dev-cmd@v1 + with: + arch: amd64 + + - name: Configure LLVM core libs + shell: pwsh + run: | + $CMakeToolchainFile = "$Env:GITHUB_WORKSPACE\llvm-prebuilt\cmake\x86_64-windows.cmake" + $CMakeInitialCache = "$Env:GITHUB_WORKSPACE\llvm-prebuilt\cmake\llvm-core-libs.cmake" + + cmake -G Ninja -S llvm-project\llvm -B llvm-build ` + -DCMAKE_INSTALL_PREFIX=llvm-install ` + -DCMAKE_TOOLCHAIN_FILE="$CMakeToolchainFile" ` + -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ` + -DBUILD_SHARED_LIBS=OFF ` + -DLLVM_BUILD_LLVM_DYLIB=OFF ` + -DLLVM_BUILD_LLVM_C_DYLIB=OFF ` + -DLLVM_LINK_LLVM_DYLIB=OFF ` + -DLLVM_ENABLE_LIBXML2=OFF ` + -DLLVM_ENABLE_ZLIB=OFF ` + -DLLVM_ENABLE_ZSTD=OFF ` + -C $CMakeInitialCache -Wno-dev + + - name: Install LLVM core libs + run: cmake --build llvm-build --target install-distribution + + - name: Stage LLVM core libs + shell: pwsh + run: | + $PackageName = "llvm-core-libs-${{matrix.version}}-x86_64-windows-mt" + $PackageRoot = Join-Path $PWD $PackageName + $PackageBinDir = Join-Path $PackageRoot "bin" + $PackageIncludeDir = Join-Path $PackageRoot "include" + $PackageLibDir = Join-Path $PackageRoot "lib" + + New-Item -ItemType Directory -Path $PackageBinDir, $PackageIncludeDir, $PackageLibDir -Force | Out-Null + + Copy-Item -Path llvm-install\bin\llvm-config.exe -Destination $PackageBinDir -Force + Copy-Item -Path llvm-install\include\llvm-c -Destination $PackageIncludeDir -Recurse -Force + Copy-Item -Path llvm-install\include\llvm -Destination $PackageIncludeDir -Recurse -Force + + $CMakeConfigDir = "llvm-install\lib\cmake\llvm" + if (Test-Path $CMakeConfigDir) { + $PackageCMakeDir = Join-Path $PackageLibDir "cmake" + New-Item -ItemType Directory -Path $PackageCMakeDir -Force | Out-Null + Copy-Item -Path $CMakeConfigDir -Destination $PackageCMakeDir -Recurse -Force + } + + $RequiredLibs = @( + "LLVMBitReader.lib", + "LLVMCore.lib", + "LLVMRemarks.lib", + "LLVMBitstreamReader.lib", + "LLVMBinaryFormat.lib", + "LLVMTargetParser.lib", + "LLVMSupport.lib", + "LLVMDemangle.lib" + ) + + foreach ($RequiredLib in $RequiredLibs) { + Copy-Item -Path (Join-Path "llvm-install\lib" $RequiredLib) -Destination $PackageLibDir -Force + } + + @( + "LLVM_VERSION=${{matrix.version}}" + "LLVM_REF=${{matrix.ref}}" + "TARGET=x86_64-windows" + "MSVC_RUNTIME=MultiThreaded" + ) | Set-Content -Path (Join-Path $PackageRoot "VERSION.txt") -Encoding ASCII + + - name: Validate LLVM core libs + shell: pwsh + run: | + function Convert-ToLibName { + param([string] $Token) + + $Value = $Token.Trim().Trim('"') + if ([string]::IsNullOrWhiteSpace($Value)) { + return $null + } + + if ($Value.StartsWith("-l")) { + return "$($Value.Substring(2)).lib" + } + + if ($Value.EndsWith(".lib", [System.StringComparison]::OrdinalIgnoreCase)) { + return [System.IO.Path]::GetFileName($Value) + } + + return $Value + } + + function Compare-LibSet { + param( + [string[]] $Expected, + [string[]] $Actual, + [string] $Label + ) + + $ExpectedSorted = @($Expected | Sort-Object -Unique) + $ActualSorted = @($Actual | Sort-Object -Unique) + $Diff = @(Compare-Object -ReferenceObject $ExpectedSorted -DifferenceObject $ActualSorted) + if ($Diff.Count -ne 0) { + throw "$Label mismatch. Expected: $($ExpectedSorted -join ' '); Actual: $($ActualSorted -join ' ')" + } + } + + $PackageName = "llvm-core-libs-${{matrix.version}}-x86_64-windows-mt" + $PackageRoot = Join-Path $PWD $PackageName + $LlvmConfig = Join-Path $PackageRoot "bin\llvm-config.exe" + $PackageLibDir = Join-Path $PackageRoot "lib" + + $Version = (& $LlvmConfig --version).Trim() + if ($LASTEXITCODE -ne 0) { + throw "llvm-config --version failed" + } + + $ReportedLibDir = (& $LlvmConfig --libdir).Trim() + if ($LASTEXITCODE -ne 0) { + throw "llvm-config --libdir failed" + } + + $ExpectedLibDirPath = (Resolve-Path $PackageLibDir).Path.TrimEnd('\') + $ReportedLibDirPath = (Resolve-Path $ReportedLibDir).Path.TrimEnd('\') + if ($ExpectedLibDirPath -ne $ReportedLibDirPath) { + throw "llvm-config --libdir reported '$ReportedLibDirPath', expected '$ExpectedLibDirPath'" + } + + $ExpectedLlvmLibs = @( + "LLVMBitReader.lib", + "LLVMCore.lib", + "LLVMRemarks.lib", + "LLVMBitstreamReader.lib", + "LLVMBinaryFormat.lib", + "LLVMTargetParser.lib", + "LLVMSupport.lib", + "LLVMDemangle.lib" + ) + + $LibTokens = @((& $LlvmConfig --link-static --libs core bitreader) -split '\s+' | ForEach-Object { Convert-ToLibName $_ }) + if ($LASTEXITCODE -ne 0) { + throw "llvm-config --link-static --libs core bitreader failed" + } + + $ReportedLlvmLibs = @($LibTokens | Where-Object { $_ -like "LLVM*.lib" }) + Compare-LibSet -Expected $ExpectedLlvmLibs -Actual $ReportedLlvmLibs -Label "LLVM libs" + + foreach ($ReportedLib in $ReportedLlvmLibs) { + if (-not (Test-Path (Join-Path $PackageLibDir $ReportedLib))) { + throw "llvm-config reported '$ReportedLib', but it is not in the package lib directory" + } + } + + $ExpectedSystemLibs = @( + "advapi32.lib", + "ntdll.lib", + "ole32.lib", + "psapi.lib", + "shell32.lib", + "uuid.lib", + "ws2_32.lib" + ) + + $SystemLibTokens = @((& $LlvmConfig --link-static --system-libs core bitreader) -split '\s+' | ForEach-Object { Convert-ToLibName $_ }) + if ($LASTEXITCODE -ne 0) { + throw "llvm-config --link-static --system-libs core bitreader failed" + } + + $ReportedSystemLibs = @($SystemLibTokens | Where-Object { $_ -like "*.lib" }) + Compare-LibSet -Expected $ExpectedSystemLibs -Actual $ReportedSystemLibs -Label "System libs" + + $DumpbinOutput = & dumpbin /directives (Join-Path $PackageLibDir "LLVMCore.lib") + if ($LASTEXITCODE -ne 0) { + throw "dumpbin /directives LLVMCore.lib failed" + } + + $DumpbinText = $DumpbinOutput -join "`n" + if ($DumpbinText -notmatch 'RuntimeLibrary=MT_StaticRelease') { + throw "LLVMCore.lib does not contain RuntimeLibrary=MT_StaticRelease" + } + + if ($DumpbinText -match 'RuntimeLibrary=MD_DynamicRelease') { + throw "LLVMCore.lib contains RuntimeLibrary=MD_DynamicRelease" + } + + @( + "LLVM core libs link manifest" + "LLVM version: $Version" + "Target: x86_64-windows" + "MSVC runtime: MultiThreaded (/MT)" + "" + "Command:" + " bin\llvm-config.exe --link-static --libs core bitreader" + "" + "LLVM libs:" + $ExpectedLlvmLibs + "" + "Command:" + " bin\llvm-config.exe --link-static --system-libs core bitreader" + "" + "System libs:" + ($ReportedSystemLibs | Sort-Object) + ) | Set-Content -Path (Join-Path $PackageRoot "llvm-link-core-bitreader.txt") -Encoding ASCII + + - name: Package LLVM core libs + shell: pwsh + run: | + $PackageName = "llvm-core-libs-${{matrix.version}}-x86_64-windows-mt" + cmd.exe /c "7z a -ttar -snl -so $PackageName.tar $PackageName | 7z a -si $PackageName.tar.xz" + + - name: Upload LLVM core libs package + uses: actions/upload-artifact@v7 + with: + name: llvm-core-libs-${{matrix.version}}-x86_64-windows-mt + path: llvm-core-libs-${{matrix.version}}-x86_64-windows-mt.tar.xz diff --git a/README.md b/README.md index b0049a9..8d32cc8 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,18 @@ Artifacts are named: clang+llvm---.tar.xz ``` +### LLVM core libs + +The LLVM core libs workflow builds a small Windows x64 package for static linking against the LLVM Core and BitReader C APIs. It uses the MSVC static CRT (`/MT`) by configuring `CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded`, then verifies `LLVMCore.lib` contains `RuntimeLibrary=MT_StaticRelease` and does not contain `RuntimeLibrary=MD_DynamicRelease`. + +Currently built LLVM core libs versions: `20.1.8`, `22.1.4`. + +Artifacts are named: + +```text +llvm-core-libs--x86_64-windows-mt.tar.xz +``` + ### Halide The Halide workflow builds Halide packages against LLVM artifacts produced by the LLVM workflow. It first installs a host LLVM package, then installs a target LLVM package when cross-compiling for `aarch64`. @@ -69,6 +81,7 @@ Additional workflows package host platform support files: | Path | Purpose | |------|---------| | `.github/workflows/llvm-prebuilt.yml` | Builds LLVM/Clang packages. | +| `.github/workflows/llvm-core-libs.yml` | Builds Windows x64 LLVM Core and BitReader static library packages with the MSVC static CRT. | | `.github/workflows/halide-prebuilt.yml` | Builds Halide packages from LLVM workflow artifacts. | | `.github/workflows/cctools-prebuilt.yml` | Builds Linux cctools packages. | | `.github/workflows/github-release.yml` | Downloads workflow artifacts, creates checksums, and publishes a release. | @@ -94,9 +107,10 @@ All major package workflows are manually triggered with `workflow_dispatch`. Recommended order: 1. Run `LLVM prebuilt`. -2. Run `halide prebuilt` with the LLVM workflow run ID, or use `latest`. -3. Run `cctools prebuilt` if Linux cctools artifacts are needed. -4. Run `GitHub Release` with the desired workflow run IDs to collect artifacts and publish a release. +2. Run `LLVM core libs` if Windows x64 static CRT LLVM Core/BitReader artifacts are needed. +3. Run `halide prebuilt` with the LLVM workflow run ID, or use `latest`. +4. Run `cctools prebuilt` if Linux cctools artifacts are needed. +5. Run `GitHub Release` with the desired workflow run IDs to collect artifacts and publish a release. The release workflow supports `dry-run` and `draft-release` inputs. Keep `dry-run` enabled while checking artifact collection and checksums. diff --git a/cmake/llvm-core-libs.cmake b/cmake/llvm-core-libs.cmake new file mode 100644 index 0000000..c58c4dd --- /dev/null +++ b/cmake/llvm-core-libs.cmake @@ -0,0 +1,88 @@ +if(DEFINED ENV{CMAKE_INSTALL_PREFIX}) + set(CMAKE_INSTALL_PREFIX $ENV{CMAKE_INSTALL_PREFIX} CACHE FILEPATH "") +endif() + +if(DEFINED ENV{LLVM_NATIVE_TOOL_DIR}) + set(LLVM_NATIVE_TOOL_DIR $ENV{LLVM_NATIVE_TOOL_DIR} CACHE FILEPATH "") + message(STATUS "LLVM_NATIVE_TOOL_DIR: ${LLVM_NATIVE_TOOL_DIR}") +endif() + +if(DEFINED ENV{LLVM_TABLEGEN}) + set(LLVM_TABLEGEN $ENV{LLVM_TABLEGEN} CACHE FILEPATH "") + message(STATUS "LLVM_TABLEGEN: ${LLVM_TABLEGEN}") +endif() + +if(DEFINED ENV{LLVM_CONFIG_PATH}) + set(LLVM_CONFIG_PATH $ENV{LLVM_CONFIG_PATH} CACHE FILEPATH "") + message(STATUS "LLVM_CONFIG_PATH: ${LLVM_CONFIG_PATH}") +endif() + +if(DEFINED ENV{LLVM_VERSION}) + set(LLVM_VERSION $ENV{LLVM_VERSION} CACHE FILEPATH "") + message(STATUS "LLVM_VERSION: ${LLVM_VERSION}") +endif() + +if(CMAKE_INSTALL_PREFIX) + message(STATUS "CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}") +endif() + +set(PACKAGE_VENDOR "awakecoding" CACHE STRING "") + +set(LLVM_TARGETS_TO_BUILD + "X86" + CACHE STRING "") + +set(LLVM_ENABLE_PROJECTS "" CACHE STRING "") +set(LLVM_ENABLE_RUNTIMES "" CACHE STRING "") + +set(BUILD_SHARED_LIBS OFF CACHE BOOL "") +set(LLVM_BUILD_LLVM_DYLIB OFF CACHE BOOL "") +set(LLVM_BUILD_LLVM_C_DYLIB OFF CACHE BOOL "") +set(LLVM_LINK_LLVM_DYLIB OFF CACHE BOOL "") + +set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") +set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "") +set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "") +set(LLVM_ENABLE_LIBXML2 OFF CACHE BOOL "") +set(LLVM_ENABLE_ZLIB OFF CACHE BOOL "") +set(LLVM_ENABLE_ZSTD OFF CACHE BOOL "") +set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "") +set(LLVM_ENABLE_Z3_SOLVER OFF CACHE BOOL "") +set(LLVM_ENABLE_RTTI ON CACHE BOOL "") +set(LLVM_ENABLE_EH ON CACHE BOOL "") + +set(LLVM_INCLUDE_BENCHMARKS OFF CACHE BOOL "") +set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "") +set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "") +set(LLVM_INCLUDE_GO_TESTS OFF CACHE BOOL "") +set(LLVM_INCLUDE_TESTS OFF CACHE BOOL "") + +set(LLVM_BUILD_32_BITS OFF CACHE BOOL "") +set(LLVM_BUILD_TOOLS ON CACHE BOOL "") +set(LLVM_BUILD_UTILS OFF CACHE BOOL "") +set(LLVM_INSTALL_TOOLCHAIN_ONLY OFF CACHE BOOL "") + +set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "") +set(CMAKE_BUILD_TYPE Release CACHE STRING "") + +set(LLVM_CORE_LIB_COMPONENTS + LLVMBitReader + LLVMCore + LLVMRemarks + LLVMBitstreamReader + LLVMBinaryFormat + LLVMTargetParser + LLVMSupport + LLVMDemangle + CACHE STRING "") + +set(LLVM_CORE_DEVELOPMENT_COMPONENTS + cmake-exports + llvm-headers + CACHE STRING "") + +set(LLVM_DISTRIBUTION_COMPONENTS + llvm-config + ${LLVM_CORE_DEVELOPMENT_COMPONENTS} + ${LLVM_CORE_LIB_COMPONENTS} + CACHE STRING "") From b0c6b106380c649ad06549dada9bf5217a0e44f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 31 May 2026 03:03:37 -0400 Subject: [PATCH 2/8] Enable core libs workflow on feature branch Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/llvm-core-libs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/llvm-core-libs.yml b/.github/workflows/llvm-core-libs.yml index bc87305..f90fe21 100644 --- a/.github/workflows/llvm-core-libs.yml +++ b/.github/workflows/llvm-core-libs.yml @@ -3,7 +3,7 @@ on: workflow_dispatch: push: branches: - - llvm-core-package + - mamoreau-devolutions/llvm-core-package paths: - ".github/workflows/llvm-core-libs.yml" - "cmake/llvm-core-libs.cmake" From ff5031ab6fe7c3e3bfef8ed5d5811e99146c4811 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 31 May 2026 03:31:59 -0400 Subject: [PATCH 3/8] Expand LLVM core libs target matrix Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/llvm-core-libs.yml | 319 +++++++++++++++++++-------- README.md | 9 +- cmake/llvm-core-libs.cmake | 2 +- 3 files changed, 229 insertions(+), 101 deletions(-) diff --git a/.github/workflows/llvm-core-libs.yml b/.github/workflows/llvm-core-libs.yml index f90fe21..55eb577 100644 --- a/.github/workflows/llvm-core-libs.yml +++ b/.github/workflows/llvm-core-libs.yml @@ -9,11 +9,13 @@ on: - "cmake/llvm-core-libs.cmake" jobs: build: - name: LLVM core libs ${{matrix.version}} [x86_64-windows-mt] - runs-on: windows-2022 + name: LLVM core libs ${{matrix.version}} [${{matrix.arch}}-${{matrix.os}}] + runs-on: ${{matrix.runner}} strategy: fail-fast: false matrix: + arch: [ x86_64, aarch64 ] + os: [ windows, macos, ubuntu-22.04, ubuntu-24.04 ] version: [ 20.1.8, 22.1.4 ] include: @@ -22,6 +24,33 @@ jobs: - version: 22.1.4 ref: llvmorg-22.1.4 + - os: windows + runner: windows-2022 + package_suffix: -mt + - os: macos + runner: macos-latest + package_suffix: "" + - os: ubuntu-22.04 + runner: ubuntu-22.04 + package_suffix: "" + - os: ubuntu-24.04 + runner: ubuntu-24.04 + package_suffix: "" + + - arch: x86_64 + os: windows + msvc: amd64 + - arch: aarch64 + os: windows + msvc: amd64_arm64 + + - arch: x86_64 + os: macos + osx_arch: x86_64 + - arch: aarch64 + os: macos + osx_arch: arm64 + steps: - name: Clone project uses: actions/checkout@v6 @@ -29,8 +58,21 @@ jobs: path: llvm-prebuilt - name: Configure Windows runner + if: runner.os == 'Windows' run: choco install --no-progress ninja 7zip + - name: Configure macOS runner + if: runner.os == 'macOS' + run: | + brew install ninja + echo "MACOSX_DEPLOYMENT_TARGET=10.13" >> $GITHUB_ENV + + - name: Configure Linux runner + if: runner.os == 'Linux' + run: | + sudo apt-get update + sudo apt-get install -y ninja-build g++-aarch64-linux-gnu + - name: Clone LLVM ${{matrix.version}} uses: actions/checkout@v6 with: @@ -39,6 +81,7 @@ jobs: path: llvm-project - name: Enable Windows host environment + if: runner.os == 'Windows' uses: ilammy/msvc-dev-cmd@v1 with: arch: amd64 @@ -62,34 +105,48 @@ jobs: shell: pwsh run: | cmake --build llvm-host --target llvm-tblgen llvm-config - $HostBinPath = Join-Path $Env:GITHUB_WORKSPACE "llvm-host\bin" + $HostBinPath = "$Env:GITHUB_WORKSPACE/llvm-host/bin" + $ExeExt = if ($IsWindows) { ".exe" } else { "" } echo "LLVM_NATIVE_TOOL_DIR=$HostBinPath" >> $Env:GITHUB_ENV - echo "LLVM_TABLEGEN=$HostBinPath/llvm-tblgen.exe" >> $Env:GITHUB_ENV - echo "LLVM_CONFIG_PATH=$HostBinPath/llvm-config.exe" >> $Env:GITHUB_ENV + echo "LLVM_TABLEGEN=$HostBinPath/llvm-tblgen$ExeExt" >> $Env:GITHUB_ENV + echo "LLVM_CONFIG_PATH=$HostBinPath/llvm-config$ExeExt" >> $Env:GITHUB_ENV echo "LLVM_VERSION=${{matrix.version}}" >> $Env:GITHUB_ENV - name: Enable Windows target environment + if: runner.os == 'Windows' uses: ilammy/msvc-dev-cmd@v1 with: - arch: amd64 + arch: ${{matrix.msvc}} - name: Configure LLVM core libs shell: pwsh run: | - $CMakeToolchainFile = "$Env:GITHUB_WORKSPACE\llvm-prebuilt\cmake\x86_64-windows.cmake" - $CMakeInitialCache = "$Env:GITHUB_WORKSPACE\llvm-prebuilt\cmake\llvm-core-libs.cmake" + $TargetName = "${{matrix.arch}}-${{matrix.os}}" + $CMakeToolchainFile = "$Env:GITHUB_WORKSPACE/llvm-prebuilt/cmake/$TargetName.cmake" + $CMakeInitialCache = "$Env:GITHUB_WORKSPACE/llvm-prebuilt/cmake/llvm-core-libs.cmake" + + $CMakeArgs = @( + "-DBUILD_SHARED_LIBS=OFF", + "-DLLVM_TARGETS_TO_BUILD=AArch64;X86", + "-DLLVM_BUILD_LLVM_DYLIB=OFF", + "-DLLVM_BUILD_LLVM_C_DYLIB=OFF", + "-DLLVM_LINK_LLVM_DYLIB=OFF", + "-DLLVM_ENABLE_LIBXML2=OFF", + "-DLLVM_ENABLE_ZLIB=OFF", + "-DLLVM_ENABLE_ZSTD=OFF" + ) - cmake -G Ninja -S llvm-project\llvm -B llvm-build ` + if ('${{matrix.os}}' -eq 'windows') { + $CMakeArgs += "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded" + } + + if ('${{matrix.os}}' -eq 'macos') { + $CMakeArgs += "-DCMAKE_OSX_ARCHITECTURES=${{matrix.osx_arch}}" + } + + cmake -G Ninja -S llvm-project/llvm -B llvm-build $CMakeArgs ` -DCMAKE_INSTALL_PREFIX=llvm-install ` -DCMAKE_TOOLCHAIN_FILE="$CMakeToolchainFile" ` - -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ` - -DBUILD_SHARED_LIBS=OFF ` - -DLLVM_BUILD_LLVM_DYLIB=OFF ` - -DLLVM_BUILD_LLVM_C_DYLIB=OFF ` - -DLLVM_LINK_LLVM_DYLIB=OFF ` - -DLLVM_ENABLE_LIBXML2=OFF ` - -DLLVM_ENABLE_ZLIB=OFF ` - -DLLVM_ENABLE_ZSTD=OFF ` -C $CMakeInitialCache -Wno-dev - name: Install LLVM core libs @@ -98,7 +155,7 @@ jobs: - name: Stage LLVM core libs shell: pwsh run: | - $PackageName = "llvm-core-libs-${{matrix.version}}-x86_64-windows-mt" + $PackageName = "llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}}" $PackageRoot = Join-Path $PWD $PackageName $PackageBinDir = Join-Path $PackageRoot "bin" $PackageIncludeDir = Join-Path $PackageRoot "include" @@ -106,11 +163,12 @@ jobs: New-Item -ItemType Directory -Path $PackageBinDir, $PackageIncludeDir, $PackageLibDir -Force | Out-Null - Copy-Item -Path llvm-install\bin\llvm-config.exe -Destination $PackageBinDir -Force - Copy-Item -Path llvm-install\include\llvm-c -Destination $PackageIncludeDir -Recurse -Force - Copy-Item -Path llvm-install\include\llvm -Destination $PackageIncludeDir -Recurse -Force + $ExeExt = if ($IsWindows) { ".exe" } else { "" } + Copy-Item -Path "llvm-install/bin/llvm-config$ExeExt" -Destination $PackageBinDir -Force + Copy-Item -Path llvm-install/include/llvm-c -Destination $PackageIncludeDir -Recurse -Force + Copy-Item -Path llvm-install/include/llvm -Destination $PackageIncludeDir -Recurse -Force - $CMakeConfigDir = "llvm-install\lib\cmake\llvm" + $CMakeConfigDir = "llvm-install/lib/cmake/llvm" if (Test-Path $CMakeConfigDir) { $PackageCMakeDir = Join-Path $PackageLibDir "cmake" New-Item -ItemType Directory -Path $PackageCMakeDir -Force | Out-Null @@ -118,31 +176,33 @@ jobs: } $RequiredLibs = @( - "LLVMBitReader.lib", - "LLVMCore.lib", - "LLVMRemarks.lib", - "LLVMBitstreamReader.lib", - "LLVMBinaryFormat.lib", - "LLVMTargetParser.lib", - "LLVMSupport.lib", - "LLVMDemangle.lib" + "LLVMBitReader", + "LLVMCore", + "LLVMRemarks", + "LLVMBitstreamReader", + "LLVMBinaryFormat", + "LLVMTargetParser", + "LLVMSupport", + "LLVMDemangle" ) foreach ($RequiredLib in $RequiredLibs) { - Copy-Item -Path (Join-Path "llvm-install\lib" $RequiredLib) -Destination $PackageLibDir -Force + $RequiredLibFile = if ($IsWindows) { "$RequiredLib.lib" } else { "lib$RequiredLib.a" } + Copy-Item -Path (Join-Path "llvm-install/lib" $RequiredLibFile) -Destination $PackageLibDir -Force } + $MsvcRuntime = if ('${{matrix.os}}' -eq 'windows') { "MultiThreaded" } else { "N/A" } @( "LLVM_VERSION=${{matrix.version}}" "LLVM_REF=${{matrix.ref}}" - "TARGET=x86_64-windows" - "MSVC_RUNTIME=MultiThreaded" + "TARGET=${{matrix.arch}}-${{matrix.os}}" + "MSVC_RUNTIME=$MsvcRuntime" ) | Set-Content -Path (Join-Path $PackageRoot "VERSION.txt") -Encoding ASCII - name: Validate LLVM core libs shell: pwsh run: | - function Convert-ToLibName { + function Convert-ToLlvmComponentName { param([string] $Token) $Value = $Token.Trim().Trim('"') @@ -151,7 +211,34 @@ jobs: } if ($Value.StartsWith("-l")) { - return "$($Value.Substring(2)).lib" + return $Value.Substring(2) + } + + if ($Value.EndsWith(".lib", [System.StringComparison]::OrdinalIgnoreCase)) { + return [System.IO.Path]::GetFileNameWithoutExtension($Value) + } + + if ($Value.EndsWith(".a", [System.StringComparison]::OrdinalIgnoreCase)) { + $FileName = [System.IO.Path]::GetFileNameWithoutExtension($Value) + if ($FileName.StartsWith("lib")) { + return $FileName.Substring(3) + } + return $FileName + } + + return $null + } + + function Convert-ToSystemLibToken { + param([string] $Token) + + $Value = $Token.Trim().Trim('"') + if ([string]::IsNullOrWhiteSpace($Value)) { + return $null + } + + if ($Value.StartsWith("-l")) { + return $Value } if ($Value.EndsWith(".lib", [System.StringComparison]::OrdinalIgnoreCase)) { @@ -176,111 +263,151 @@ jobs: } } - $PackageName = "llvm-core-libs-${{matrix.version}}-x86_64-windows-mt" + $PackageName = "llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}}" $PackageRoot = Join-Path $PWD $PackageName - $LlvmConfig = Join-Path $PackageRoot "bin\llvm-config.exe" + $ExeExt = if ($IsWindows) { ".exe" } else { "" } + $LlvmConfig = Join-Path $PackageRoot "bin/llvm-config$ExeExt" $PackageLibDir = Join-Path $PackageRoot "lib" + $RunnerArch = if ($Env:RUNNER_ARCH -eq "ARM64") { "aarch64" } else { "x86_64" } + $CanRunTargetTools = ($RunnerArch -eq "${{matrix.arch}}") - $Version = (& $LlvmConfig --version).Trim() - if ($LASTEXITCODE -ne 0) { - throw "llvm-config --version failed" + if ($CanRunTargetTools) { + $Version = (& $LlvmConfig --version).Trim() + if ($LASTEXITCODE -ne 0) { + throw "llvm-config --version failed" + } + } else { + $Version = (& $Env:LLVM_CONFIG_PATH --version).Trim() + if ($LASTEXITCODE -ne 0) { + throw "host llvm-config --version failed" + } } - $ReportedLibDir = (& $LlvmConfig --libdir).Trim() - if ($LASTEXITCODE -ne 0) { - throw "llvm-config --libdir failed" - } + if ($CanRunTargetTools) { + $ReportedLibDir = (& $LlvmConfig --libdir).Trim() + if ($LASTEXITCODE -ne 0) { + throw "llvm-config --libdir failed" + } - $ExpectedLibDirPath = (Resolve-Path $PackageLibDir).Path.TrimEnd('\') - $ReportedLibDirPath = (Resolve-Path $ReportedLibDir).Path.TrimEnd('\') - if ($ExpectedLibDirPath -ne $ReportedLibDirPath) { - throw "llvm-config --libdir reported '$ReportedLibDirPath', expected '$ExpectedLibDirPath'" + $ExpectedLibDirPath = (Resolve-Path $PackageLibDir).Path.TrimEnd('\', '/') + $ReportedLibDirPath = (Resolve-Path $ReportedLibDir).Path.TrimEnd('\', '/') + if ($ExpectedLibDirPath -ne $ReportedLibDirPath) { + throw "llvm-config --libdir reported '$ReportedLibDirPath', expected '$ExpectedLibDirPath'" + } } - $ExpectedLlvmLibs = @( - "LLVMBitReader.lib", - "LLVMCore.lib", - "LLVMRemarks.lib", - "LLVMBitstreamReader.lib", - "LLVMBinaryFormat.lib", - "LLVMTargetParser.lib", - "LLVMSupport.lib", - "LLVMDemangle.lib" + $ExpectedLlvmComponents = @( + "LLVMBitReader", + "LLVMCore", + "LLVMRemarks", + "LLVMBitstreamReader", + "LLVMBinaryFormat", + "LLVMTargetParser", + "LLVMSupport", + "LLVMDemangle" ) - $LibTokens = @((& $LlvmConfig --link-static --libs core bitreader) -split '\s+' | ForEach-Object { Convert-ToLibName $_ }) - if ($LASTEXITCODE -ne 0) { - throw "llvm-config --link-static --libs core bitreader failed" - } + if ($CanRunTargetTools) { + $LibTokens = @((& $LlvmConfig --link-static --libs core bitreader) -split '\s+' | ForEach-Object { Convert-ToLlvmComponentName $_ }) + if ($LASTEXITCODE -ne 0) { + throw "llvm-config --link-static --libs core bitreader failed" + } - $ReportedLlvmLibs = @($LibTokens | Where-Object { $_ -like "LLVM*.lib" }) - Compare-LibSet -Expected $ExpectedLlvmLibs -Actual $ReportedLlvmLibs -Label "LLVM libs" + $ReportedLlvmComponents = @($LibTokens | Where-Object { $_ -like "LLVM*" }) + Compare-LibSet -Expected $ExpectedLlvmComponents -Actual $ReportedLlvmComponents -Label "LLVM libs" + } else { + $ReportedLlvmComponents = $ExpectedLlvmComponents + } - foreach ($ReportedLib in $ReportedLlvmLibs) { - if (-not (Test-Path (Join-Path $PackageLibDir $ReportedLib))) { - throw "llvm-config reported '$ReportedLib', but it is not in the package lib directory" + foreach ($ExpectedComponent in $ExpectedLlvmComponents) { + $ExpectedLibFile = if ($IsWindows) { "$ExpectedComponent.lib" } else { "lib$ExpectedComponent.a" } + if (-not (Test-Path (Join-Path $PackageLibDir $ExpectedLibFile))) { + throw "Package is missing '$ExpectedLibFile'" } } - $ExpectedSystemLibs = @( - "advapi32.lib", - "ntdll.lib", - "ole32.lib", - "psapi.lib", - "shell32.lib", - "uuid.lib", - "ws2_32.lib" - ) - - $SystemLibTokens = @((& $LlvmConfig --link-static --system-libs core bitreader) -split '\s+' | ForEach-Object { Convert-ToLibName $_ }) + $ManifestLlvmConfig = if ($CanRunTargetTools) { $LlvmConfig } else { $Env:LLVM_CONFIG_PATH } + $SystemLibTokens = @((& $ManifestLlvmConfig --link-static --system-libs core bitreader) -split '\s+' | ForEach-Object { Convert-ToSystemLibToken $_ }) if ($LASTEXITCODE -ne 0) { throw "llvm-config --link-static --system-libs core bitreader failed" } - $ReportedSystemLibs = @($SystemLibTokens | Where-Object { $_ -like "*.lib" }) - Compare-LibSet -Expected $ExpectedSystemLibs -Actual $ReportedSystemLibs -Label "System libs" + $ReportedSystemLibs = @($SystemLibTokens | Where-Object { $_ }) + + if ($IsWindows) { + $ExpectedSystemLibs = @( + "advapi32.lib", + "ntdll.lib", + "ole32.lib", + "psapi.lib", + "shell32.lib", + "uuid.lib", + "ws2_32.lib" + ) + Compare-LibSet -Expected $ExpectedSystemLibs -Actual $ReportedSystemLibs -Label "System libs" - $DumpbinOutput = & dumpbin /directives (Join-Path $PackageLibDir "LLVMCore.lib") - if ($LASTEXITCODE -ne 0) { - throw "dumpbin /directives LLVMCore.lib failed" - } + $DumpbinOutput = & dumpbin /directives (Join-Path $PackageLibDir "LLVMCore.lib") + if ($LASTEXITCODE -ne 0) { + throw "dumpbin /directives LLVMCore.lib failed" + } - $DumpbinText = $DumpbinOutput -join "`n" - if ($DumpbinText -notmatch 'RuntimeLibrary=MT_StaticRelease') { - throw "LLVMCore.lib does not contain RuntimeLibrary=MT_StaticRelease" + $DumpbinText = $DumpbinOutput -join "`n" + if ($DumpbinText -notmatch 'RuntimeLibrary=MT_StaticRelease') { + throw "LLVMCore.lib does not contain RuntimeLibrary=MT_StaticRelease" + } + + if ($DumpbinText -match 'RuntimeLibrary=MD_DynamicRelease') { + throw "LLVMCore.lib contains RuntimeLibrary=MD_DynamicRelease" + } } - if ($DumpbinText -match 'RuntimeLibrary=MD_DynamicRelease') { - throw "LLVMCore.lib contains RuntimeLibrary=MD_DynamicRelease" + $DynamicLibs = @(Get-ChildItem -Path $PackageRoot -Recurse -File | Where-Object { + $_.Extension -in @(".dll", ".dylib", ".so") + }) + if ($DynamicLibs.Count -ne 0) { + throw "Package contains dynamic libraries: $($DynamicLibs.FullName -join ', ')" } + $MsvcRuntimeLine = if ($IsWindows) { "MSVC runtime: MultiThreaded (/MT)" } else { "MSVC runtime: N/A" } + $LlvmConfigValidationLine = if ($CanRunTargetTools) { + "Target llvm-config validation: enabled" + } else { + "Target llvm-config validation: skipped because runner architecture is $RunnerArch" + } @( "LLVM core libs link manifest" "LLVM version: $Version" - "Target: x86_64-windows" - "MSVC runtime: MultiThreaded (/MT)" + "Target: ${{matrix.arch}}-${{matrix.os}}" + $MsvcRuntimeLine + $LlvmConfigValidationLine "" "Command:" - " bin\llvm-config.exe --link-static --libs core bitreader" + " bin/llvm-config$ExeExt --link-static --libs core bitreader" "" "LLVM libs:" - $ExpectedLlvmLibs + $ExpectedLlvmComponents "" "Command:" - " bin\llvm-config.exe --link-static --system-libs core bitreader" + " bin/llvm-config$ExeExt --link-static --system-libs core bitreader" "" "System libs:" ($ReportedSystemLibs | Sort-Object) ) | Set-Content -Path (Join-Path $PackageRoot "llvm-link-core-bitreader.txt") -Encoding ASCII - name: Package LLVM core libs + if: runner.os != 'Windows' + run: | + tar -cJf llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}}.tar.xz llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}} + + - name: Package LLVM core libs + if: runner.os == 'Windows' shell: pwsh run: | - $PackageName = "llvm-core-libs-${{matrix.version}}-x86_64-windows-mt" + $PackageName = "llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}}" cmd.exe /c "7z a -ttar -snl -so $PackageName.tar $PackageName | 7z a -si $PackageName.tar.xz" - name: Upload LLVM core libs package uses: actions/upload-artifact@v7 with: - name: llvm-core-libs-${{matrix.version}}-x86_64-windows-mt - path: llvm-core-libs-${{matrix.version}}-x86_64-windows-mt.tar.xz + name: llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}} + path: llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}}.tar.xz diff --git a/README.md b/README.md index 8d32cc8..e92aa69 100644 --- a/README.md +++ b/README.md @@ -25,14 +25,15 @@ clang+llvm---.tar.xz ### LLVM core libs -The LLVM core libs workflow builds a small Windows x64 package for static linking against the LLVM Core and BitReader C APIs. It uses the MSVC static CRT (`/MT`) by configuring `CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded`, then verifies `LLVMCore.lib` contains `RuntimeLibrary=MT_StaticRelease` and does not contain `RuntimeLibrary=MD_DynamicRelease`. +The LLVM core libs workflow builds small static-library packages for linking against the LLVM Core and BitReader C APIs. Windows packages use the MSVC static CRT (`/MT`) by configuring `CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded`, then verify `LLVMCore.lib` contains `RuntimeLibrary=MT_StaticRelease` and does not contain `RuntimeLibrary=MD_DynamicRelease`. Currently built LLVM core libs versions: `20.1.8`, `22.1.4`. Artifacts are named: ```text -llvm-core-libs--x86_64-windows-mt.tar.xz +llvm-core-libs---.tar.xz +llvm-core-libs---windows-mt.tar.xz ``` ### Halide @@ -81,7 +82,7 @@ Additional workflows package host platform support files: | Path | Purpose | |------|---------| | `.github/workflows/llvm-prebuilt.yml` | Builds LLVM/Clang packages. | -| `.github/workflows/llvm-core-libs.yml` | Builds Windows x64 LLVM Core and BitReader static library packages with the MSVC static CRT. | +| `.github/workflows/llvm-core-libs.yml` | Builds static LLVM Core and BitReader library packages. | | `.github/workflows/halide-prebuilt.yml` | Builds Halide packages from LLVM workflow artifacts. | | `.github/workflows/cctools-prebuilt.yml` | Builds Linux cctools packages. | | `.github/workflows/github-release.yml` | Downloads workflow artifacts, creates checksums, and publishes a release. | @@ -107,7 +108,7 @@ All major package workflows are manually triggered with `workflow_dispatch`. Recommended order: 1. Run `LLVM prebuilt`. -2. Run `LLVM core libs` if Windows x64 static CRT LLVM Core/BitReader artifacts are needed. +2. Run `LLVM core libs` if static LLVM Core/BitReader artifacts are needed. 3. Run `halide prebuilt` with the LLVM workflow run ID, or use `latest`. 4. Run `cctools prebuilt` if Linux cctools artifacts are needed. 5. Run `GitHub Release` with the desired workflow run IDs to collect artifacts and publish a release. diff --git a/cmake/llvm-core-libs.cmake b/cmake/llvm-core-libs.cmake index c58c4dd..6c90bf2 100644 --- a/cmake/llvm-core-libs.cmake +++ b/cmake/llvm-core-libs.cmake @@ -29,7 +29,7 @@ endif() set(PACKAGE_VENDOR "awakecoding" CACHE STRING "") set(LLVM_TARGETS_TO_BUILD - "X86" + "AArch64;X86" CACHE STRING "") set(LLVM_ENABLE_PROJECTS "" CACHE STRING "") From 899e7754c035b6a8e0b1b1ade49bb4513b1d2a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 31 May 2026 03:48:07 -0400 Subject: [PATCH 4/8] Fix core libs cross-target validation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/llvm-core-libs.yml | 76 +++++++++++++++++++--------- 1 file changed, 51 insertions(+), 25 deletions(-) diff --git a/.github/workflows/llvm-core-libs.yml b/.github/workflows/llvm-core-libs.yml index 55eb577..7e1aa41 100644 --- a/.github/workflows/llvm-core-libs.yml +++ b/.github/workflows/llvm-core-libs.yml @@ -326,13 +326,34 @@ jobs: } } - $ManifestLlvmConfig = if ($CanRunTargetTools) { $LlvmConfig } else { $Env:LLVM_CONFIG_PATH } - $SystemLibTokens = @((& $ManifestLlvmConfig --link-static --system-libs core bitreader) -split '\s+' | ForEach-Object { Convert-ToSystemLibToken $_ }) - if ($LASTEXITCODE -ne 0) { - throw "llvm-config --link-static --system-libs core bitreader failed" - } + if ($CanRunTargetTools) { + $SystemLibTokens = @((& $LlvmConfig --link-static --system-libs core bitreader) -split '\s+' | ForEach-Object { Convert-ToSystemLibToken $_ }) + if ($LASTEXITCODE -ne 0) { + throw "llvm-config --link-static --system-libs core bitreader failed" + } - $ReportedSystemLibs = @($SystemLibTokens | Where-Object { $_ }) + $ReportedSystemLibs = @($SystemLibTokens | Where-Object { $_ }) + } else { + $ReportedSystemLibs = switch ('${{matrix.os}}') { + 'windows' { + @( + "advapi32.lib", + "ntdll.lib", + "ole32.lib", + "psapi.lib", + "shell32.lib", + "uuid.lib", + "ws2_32.lib" + ) + } + 'macos' { + @("-lm") + } + default { + @("-ldl", "-lm", "-lrt") + } + } + } if ($IsWindows) { $ExpectedSystemLibs = @( @@ -374,25 +395,30 @@ jobs: } else { "Target llvm-config validation: skipped because runner architecture is $RunnerArch" } - @( - "LLVM core libs link manifest" - "LLVM version: $Version" - "Target: ${{matrix.arch}}-${{matrix.os}}" - $MsvcRuntimeLine - $LlvmConfigValidationLine - "" - "Command:" - " bin/llvm-config$ExeExt --link-static --libs core bitreader" - "" - "LLVM libs:" - $ExpectedLlvmComponents - "" - "Command:" - " bin/llvm-config$ExeExt --link-static --system-libs core bitreader" - "" - "System libs:" - ($ReportedSystemLibs | Sort-Object) - ) | Set-Content -Path (Join-Path $PackageRoot "llvm-link-core-bitreader.txt") -Encoding ASCII + + $ManifestLines = [System.Collections.Generic.List[string]]::new() + $ManifestLines.Add("LLVM core libs link manifest") + $ManifestLines.Add("LLVM version: $Version") + $ManifestLines.Add("Target: ${{matrix.arch}}-${{matrix.os}}") + $ManifestLines.Add($MsvcRuntimeLine) + $ManifestLines.Add($LlvmConfigValidationLine) + $ManifestLines.Add("") + $ManifestLines.Add("Command:") + $ManifestLines.Add(" bin/llvm-config$ExeExt --link-static --libs core bitreader") + $ManifestLines.Add("") + $ManifestLines.Add("LLVM libs:") + foreach ($ExpectedLlvmComponent in $ExpectedLlvmComponents) { + $ManifestLines.Add($ExpectedLlvmComponent) + } + $ManifestLines.Add("") + $ManifestLines.Add("Command:") + $ManifestLines.Add(" bin/llvm-config$ExeExt --link-static --system-libs core bitreader") + $ManifestLines.Add("") + $ManifestLines.Add("System libs:") + foreach ($ReportedSystemLib in ($ReportedSystemLibs | Sort-Object)) { + $ManifestLines.Add($ReportedSystemLib) + } + $ManifestLines | Set-Content -Path (Join-Path $PackageRoot "llvm-link-core-bitreader.txt") -Encoding ASCII - name: Package LLVM core libs if: runner.os != 'Windows' From ed455f708b9efe3a586f5e015aa7107a9392a6e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 31 May 2026 04:08:29 -0400 Subject: [PATCH 5/8] Add Windows MD core libs packages Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/llvm-core-libs.yml | 53 +++++++++++++++++++++++----- README.md | 3 +- 2 files changed, 47 insertions(+), 9 deletions(-) diff --git a/.github/workflows/llvm-core-libs.yml b/.github/workflows/llvm-core-libs.yml index 7e1aa41..a10e205 100644 --- a/.github/workflows/llvm-core-libs.yml +++ b/.github/workflows/llvm-core-libs.yml @@ -9,7 +9,7 @@ on: - "cmake/llvm-core-libs.cmake" jobs: build: - name: LLVM core libs ${{matrix.version}} [${{matrix.arch}}-${{matrix.os}}] + name: LLVM core libs ${{matrix.version}} [${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}}] runs-on: ${{matrix.runner}} strategy: fail-fast: false @@ -17,6 +17,23 @@ jobs: arch: [ x86_64, aarch64 ] os: [ windows, macos, ubuntu-22.04, ubuntu-24.04 ] version: [ 20.1.8, 22.1.4 ] + crt: [ default, mt, md ] + + exclude: + - os: windows + crt: default + - os: macos + crt: mt + - os: macos + crt: md + - os: ubuntu-22.04 + crt: mt + - os: ubuntu-22.04 + crt: md + - os: ubuntu-24.04 + crt: mt + - os: ubuntu-24.04 + crt: md include: - version: 20.1.8 @@ -25,15 +42,31 @@ jobs: ref: llvmorg-22.1.4 - os: windows + crt: mt runner: windows-2022 package_suffix: -mt + cmake_msvc_runtime_library: MultiThreaded + msvc_runtime_label: MultiThreaded (/MT) + runtime_directive: RuntimeLibrary=MT_StaticRelease + forbidden_runtime_directive: RuntimeLibrary=MD_DynamicRelease + - os: windows + crt: md + runner: windows-2022 + package_suffix: -md + cmake_msvc_runtime_library: MultiThreadedDLL + msvc_runtime_label: MultiThreadedDLL (/MD) + runtime_directive: RuntimeLibrary=MD_DynamicRelease + forbidden_runtime_directive: RuntimeLibrary=MT_StaticRelease - os: macos + crt: default runner: macos-latest package_suffix: "" - os: ubuntu-22.04 + crt: default runner: ubuntu-22.04 package_suffix: "" - os: ubuntu-24.04 + crt: default runner: ubuntu-24.04 package_suffix: "" @@ -137,7 +170,7 @@ jobs: ) if ('${{matrix.os}}' -eq 'windows') { - $CMakeArgs += "-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded" + $CMakeArgs += "-DCMAKE_MSVC_RUNTIME_LIBRARY=${{matrix.cmake_msvc_runtime_library}}" } if ('${{matrix.os}}' -eq 'macos') { @@ -191,12 +224,16 @@ jobs: Copy-Item -Path (Join-Path "llvm-install/lib" $RequiredLibFile) -Destination $PackageLibDir -Force } - $MsvcRuntime = if ('${{matrix.os}}' -eq 'windows') { "MultiThreaded" } else { "N/A" } + $MsvcRuntime = if ('${{matrix.os}}' -eq 'windows') { "${{matrix.msvc_runtime_label}}" } else { "N/A" } + $MsvcCrt = if ('${{matrix.os}}' -eq 'windows') { "${{matrix.crt}}" } else { "N/A" } + $CMakeMsvcRuntime = if ('${{matrix.os}}' -eq 'windows') { "${{matrix.cmake_msvc_runtime_library}}" } else { "N/A" } @( "LLVM_VERSION=${{matrix.version}}" "LLVM_REF=${{matrix.ref}}" "TARGET=${{matrix.arch}}-${{matrix.os}}" "MSVC_RUNTIME=$MsvcRuntime" + "MSVC_CRT=$MsvcCrt" + "CMAKE_MSVC_RUNTIME_LIBRARY=$CMakeMsvcRuntime" ) | Set-Content -Path (Join-Path $PackageRoot "VERSION.txt") -Encoding ASCII - name: Validate LLVM core libs @@ -373,12 +410,12 @@ jobs: } $DumpbinText = $DumpbinOutput -join "`n" - if ($DumpbinText -notmatch 'RuntimeLibrary=MT_StaticRelease') { - throw "LLVMCore.lib does not contain RuntimeLibrary=MT_StaticRelease" + if ($DumpbinText -notmatch '${{matrix.runtime_directive}}') { + throw "LLVMCore.lib does not contain ${{matrix.runtime_directive}}" } - if ($DumpbinText -match 'RuntimeLibrary=MD_DynamicRelease') { - throw "LLVMCore.lib contains RuntimeLibrary=MD_DynamicRelease" + if ($DumpbinText -match '${{matrix.forbidden_runtime_directive}}') { + throw "LLVMCore.lib contains ${{matrix.forbidden_runtime_directive}}" } } @@ -389,7 +426,7 @@ jobs: throw "Package contains dynamic libraries: $($DynamicLibs.FullName -join ', ')" } - $MsvcRuntimeLine = if ($IsWindows) { "MSVC runtime: MultiThreaded (/MT)" } else { "MSVC runtime: N/A" } + $MsvcRuntimeLine = if ($IsWindows) { "MSVC runtime: ${{matrix.msvc_runtime_label}}" } else { "MSVC runtime: N/A" } $LlvmConfigValidationLine = if ($CanRunTargetTools) { "Target llvm-config validation: enabled" } else { diff --git a/README.md b/README.md index e92aa69..ce45b41 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ clang+llvm---.tar.xz ### LLVM core libs -The LLVM core libs workflow builds small static-library packages for linking against the LLVM Core and BitReader C APIs. Windows packages use the MSVC static CRT (`/MT`) by configuring `CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded`, then verify `LLVMCore.lib` contains `RuntimeLibrary=MT_StaticRelease` and does not contain `RuntimeLibrary=MD_DynamicRelease`. +The LLVM core libs workflow builds small static-library packages for linking against the LLVM Core and BitReader C APIs. Windows packages are produced for both MSVC CRT modes: static CRT (`/MT`) and dynamic CRT (`/MD`). Each Windows package verifies `LLVMCore.lib` contains the expected `RuntimeLibrary` directive and does not contain the opposite CRT directive. Currently built LLVM core libs versions: `20.1.8`, `22.1.4`. @@ -34,6 +34,7 @@ Artifacts are named: ```text llvm-core-libs---.tar.xz llvm-core-libs---windows-mt.tar.xz +llvm-core-libs---windows-md.tar.xz ``` ### Halide From 95c79c405707429fa7a94d6d4decd4cd4399c02b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 31 May 2026 04:38:51 -0400 Subject: [PATCH 6/8] Add shared LLVM core libs packages Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/llvm-core-libs.yml | 185 +++++++++++++++++++++------ README.md | 11 +- cmake/llvm-core-libs.cmake | 20 ++- 3 files changed, 168 insertions(+), 48 deletions(-) diff --git a/.github/workflows/llvm-core-libs.yml b/.github/workflows/llvm-core-libs.yml index a10e205..a62c474 100644 --- a/.github/workflows/llvm-core-libs.yml +++ b/.github/workflows/llvm-core-libs.yml @@ -9,7 +9,7 @@ on: - "cmake/llvm-core-libs.cmake" jobs: build: - name: LLVM core libs ${{matrix.version}} [${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}}] + name: LLVM core libs ${{matrix.version}} [${{matrix.arch}}-${{matrix.os}}-${{matrix.linkage}}${{matrix.package_suffix}}] runs-on: ${{matrix.runner}} strategy: fail-fast: false @@ -17,6 +17,7 @@ jobs: arch: [ x86_64, aarch64 ] os: [ windows, macos, ubuntu-22.04, ubuntu-24.04 ] version: [ 20.1.8, 22.1.4 ] + linkage: [ static, shared ] crt: [ default, mt, md ] exclude: @@ -161,9 +162,7 @@ jobs: $CMakeArgs = @( "-DBUILD_SHARED_LIBS=OFF", "-DLLVM_TARGETS_TO_BUILD=AArch64;X86", - "-DLLVM_BUILD_LLVM_DYLIB=OFF", "-DLLVM_BUILD_LLVM_C_DYLIB=OFF", - "-DLLVM_LINK_LLVM_DYLIB=OFF", "-DLLVM_ENABLE_LIBXML2=OFF", "-DLLVM_ENABLE_ZLIB=OFF", "-DLLVM_ENABLE_ZSTD=OFF" @@ -177,6 +176,35 @@ jobs: $CMakeArgs += "-DCMAKE_OSX_ARCHITECTURES=${{matrix.osx_arch}}" } + $DevelopmentComponents = "llvm-config;cmake-exports;llvm-headers" + $StaticComponents = "LLVMBitReader;LLVMCore;LLVMRemarks;LLVMBitstreamReader;LLVMBinaryFormat;LLVMTargetParser;LLVMSupport;LLVMDemangle" + + if ('${{matrix.linkage}}' -eq 'shared') { + $CMakeArgs += @( + "-DLLVM_BUILD_LLVM_DYLIB=ON", + "-DLLVM_LINK_LLVM_DYLIB=ON", + "-DLLVM_DYLIB_COMPONENTS=core;bitreader", + "-DLLVM_DISTRIBUTION_COMPONENTS=$DevelopmentComponents;LLVM" + ) + + if ('${{matrix.os}}' -eq 'windows') { + $CMakeArgs += "-DLLVM_BUILD_LLVM_DYLIB_VIS=ON" + } elseif ('${{matrix.os}}' -eq 'macos') { + $CMakeArgs += @( + "-DCMAKE_INSTALL_NAME_DIR=@rpath", + "-DCMAKE_INSTALL_RPATH=@loader_path/../lib" + ) + } else { + $CMakeArgs += '-DCMAKE_INSTALL_RPATH=$ORIGIN/../lib' + } + } else { + $CMakeArgs += @( + "-DLLVM_BUILD_LLVM_DYLIB=OFF", + "-DLLVM_LINK_LLVM_DYLIB=OFF", + "-DLLVM_DISTRIBUTION_COMPONENTS=$DevelopmentComponents;$StaticComponents" + ) + } + cmake -G Ninja -S llvm-project/llvm -B llvm-build $CMakeArgs ` -DCMAKE_INSTALL_PREFIX=llvm-install ` -DCMAKE_TOOLCHAIN_FILE="$CMakeToolchainFile" ` @@ -188,7 +216,7 @@ jobs: - name: Stage LLVM core libs shell: pwsh run: | - $PackageName = "llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}}" + $PackageName = "llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}-${{matrix.linkage}}${{matrix.package_suffix}}" $PackageRoot = Join-Path $PWD $PackageName $PackageBinDir = Join-Path $PackageRoot "bin" $PackageIncludeDir = Join-Path $PackageRoot "include" @@ -219,9 +247,28 @@ jobs: "LLVMDemangle" ) - foreach ($RequiredLib in $RequiredLibs) { - $RequiredLibFile = if ($IsWindows) { "$RequiredLib.lib" } else { "lib$RequiredLib.a" } - Copy-Item -Path (Join-Path "llvm-install/lib" $RequiredLibFile) -Destination $PackageLibDir -Force + if ('${{matrix.linkage}}' -eq 'static') { + foreach ($RequiredLib in $RequiredLibs) { + $RequiredLibFile = if ($IsWindows) { "$RequiredLib.lib" } else { "lib$RequiredLib.a" } + Copy-Item -Path (Join-Path "llvm-install/lib" $RequiredLibFile) -Destination $PackageLibDir -Force + } + } else { + if ($IsWindows) { + Copy-Item -Path llvm-install/bin/LLVM.dll -Destination $PackageBinDir -Force + Copy-Item -Path llvm-install/lib/LLVM.lib -Destination $PackageLibDir -Force + } elseif ($IsMacOS) { + $SharedLibraries = @(Get-ChildItem -Path llvm-install/lib -Filter "libLLVM*.dylib" -File) + if ($SharedLibraries.Count -eq 0) { + throw "No libLLVM dylib was installed" + } + Copy-Item -Path $SharedLibraries.FullName -Destination $PackageLibDir -Force + } else { + $SharedLibraries = @(Get-ChildItem -Path llvm-install/lib -Filter "libLLVM*.so*" -File) + if ($SharedLibraries.Count -eq 0) { + throw "No libLLVM shared object was installed" + } + Copy-Item -Path $SharedLibraries.FullName -Destination $PackageLibDir -Force + } } $MsvcRuntime = if ('${{matrix.os}}' -eq 'windows') { "${{matrix.msvc_runtime_label}}" } else { "N/A" } @@ -231,10 +278,12 @@ jobs: "LLVM_VERSION=${{matrix.version}}" "LLVM_REF=${{matrix.ref}}" "TARGET=${{matrix.arch}}-${{matrix.os}}" + "LINKAGE=${{matrix.linkage}}" "MSVC_RUNTIME=$MsvcRuntime" "MSVC_CRT=$MsvcCrt" "CMAKE_MSVC_RUNTIME_LIBRARY=$CMakeMsvcRuntime" ) | Set-Content -Path (Join-Path $PackageRoot "VERSION.txt") -Encoding ASCII + echo "PACKAGE_NAME=$PackageName" >> $Env:GITHUB_ENV - name: Validate LLVM core libs shell: pwsh @@ -248,11 +297,19 @@ jobs: } if ($Value.StartsWith("-l")) { - return $Value.Substring(2) + $LibraryName = $Value.Substring(2) + if ($LibraryName -match '^LLVM(?:[-\d].*)?$') { + return "LLVM" + } + return $LibraryName } if ($Value.EndsWith(".lib", [System.StringComparison]::OrdinalIgnoreCase)) { - return [System.IO.Path]::GetFileNameWithoutExtension($Value) + $LibraryName = [System.IO.Path]::GetFileNameWithoutExtension($Value) + if ($LibraryName -match '^LLVM(?:[-\d].*)?$') { + return "LLVM" + } + return $LibraryName } if ($Value.EndsWith(".a", [System.StringComparison]::OrdinalIgnoreCase)) { @@ -263,6 +320,10 @@ jobs: return $FileName } + if ($Value -match 'lib(LLVM(?:[-\d].*)?)\.(?:dylib|so)') { + return "LLVM" + } + return $null } @@ -300,11 +361,12 @@ jobs: } } - $PackageName = "llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}}" + $PackageName = $Env:PACKAGE_NAME $PackageRoot = Join-Path $PWD $PackageName $ExeExt = if ($IsWindows) { ".exe" } else { "" } $LlvmConfig = Join-Path $PackageRoot "bin/llvm-config$ExeExt" $PackageLibDir = Join-Path $PackageRoot "lib" + $Linkage = "${{matrix.linkage}}" $RunnerArch = if ($Env:RUNNER_ARCH -eq "ARM64") { "aarch64" } else { "x86_64" } $CanRunTargetTools = ($RunnerArch -eq "${{matrix.arch}}") @@ -333,7 +395,7 @@ jobs: } } - $ExpectedLlvmComponents = @( + $StaticLlvmComponents = @( "LLVMBitReader", "LLVMCore", "LLVMRemarks", @@ -343,11 +405,13 @@ jobs: "LLVMSupport", "LLVMDemangle" ) + $ExpectedLlvmComponents = if ($Linkage -eq "shared") { @("LLVM") } else { $StaticLlvmComponents } + $LinkCommand = if ($Linkage -eq "shared") { "--link-shared" } else { "--link-static" } if ($CanRunTargetTools) { - $LibTokens = @((& $LlvmConfig --link-static --libs core bitreader) -split '\s+' | ForEach-Object { Convert-ToLlvmComponentName $_ }) + $LibTokens = @((& $LlvmConfig $LinkCommand --libs core bitreader) -split '\s+' | ForEach-Object { Convert-ToLlvmComponentName $_ }) if ($LASTEXITCODE -ne 0) { - throw "llvm-config --link-static --libs core bitreader failed" + throw "llvm-config $LinkCommand --libs core bitreader failed" } $ReportedLlvmComponents = @($LibTokens | Where-Object { $_ -like "LLVM*" }) @@ -356,17 +420,33 @@ jobs: $ReportedLlvmComponents = $ExpectedLlvmComponents } - foreach ($ExpectedComponent in $ExpectedLlvmComponents) { - $ExpectedLibFile = if ($IsWindows) { "$ExpectedComponent.lib" } else { "lib$ExpectedComponent.a" } - if (-not (Test-Path (Join-Path $PackageLibDir $ExpectedLibFile))) { - throw "Package is missing '$ExpectedLibFile'" + if ($Linkage -eq "static") { + foreach ($ExpectedComponent in $ExpectedLlvmComponents) { + $ExpectedLibFile = if ($IsWindows) { "$ExpectedComponent.lib" } else { "lib$ExpectedComponent.a" } + if (-not (Test-Path (Join-Path $PackageLibDir $ExpectedLibFile))) { + throw "Package is missing '$ExpectedLibFile'" + } + } + } else { + if ($IsWindows) { + foreach ($ExpectedSharedFile in @("bin/LLVM.dll", "lib/LLVM.lib")) { + if (-not (Test-Path (Join-Path $PackageRoot $ExpectedSharedFile))) { + throw "Package is missing '$ExpectedSharedFile'" + } + } + } elseif ($IsMacOS) { + if (@(Get-ChildItem -Path $PackageLibDir -Filter "libLLVM*.dylib" -File).Count -eq 0) { + throw "Package is missing libLLVM dylib" + } + } elseif (@(Get-ChildItem -Path $PackageLibDir -Filter "libLLVM*.so*" -File).Count -eq 0) { + throw "Package is missing libLLVM shared object" } } if ($CanRunTargetTools) { - $SystemLibTokens = @((& $LlvmConfig --link-static --system-libs core bitreader) -split '\s+' | ForEach-Object { Convert-ToSystemLibToken $_ }) + $SystemLibTokens = @((& $LlvmConfig $LinkCommand --system-libs core bitreader) -split '\s+' | ForEach-Object { Convert-ToSystemLibToken $_ }) if ($LASTEXITCODE -ne 0) { - throw "llvm-config --link-static --system-libs core bitreader failed" + throw "llvm-config $LinkCommand --system-libs core bitreader failed" } $ReportedSystemLibs = @($SystemLibTokens | Where-Object { $_ }) @@ -404,28 +484,58 @@ jobs: ) Compare-LibSet -Expected $ExpectedSystemLibs -Actual $ReportedSystemLibs -Label "System libs" - $DumpbinOutput = & dumpbin /directives (Join-Path $PackageLibDir "LLVMCore.lib") - if ($LASTEXITCODE -ne 0) { - throw "dumpbin /directives LLVMCore.lib failed" - } + if ($Linkage -eq "static") { + $DumpbinOutput = & dumpbin /directives (Join-Path $PackageLibDir "LLVMCore.lib") + if ($LASTEXITCODE -ne 0) { + throw "dumpbin /directives LLVMCore.lib failed" + } - $DumpbinText = $DumpbinOutput -join "`n" - if ($DumpbinText -notmatch '${{matrix.runtime_directive}}') { - throw "LLVMCore.lib does not contain ${{matrix.runtime_directive}}" - } + $DumpbinText = $DumpbinOutput -join "`n" + if ($DumpbinText -notmatch '${{matrix.runtime_directive}}') { + throw "LLVMCore.lib does not contain ${{matrix.runtime_directive}}" + } + + if ($DumpbinText -match '${{matrix.forbidden_runtime_directive}}') { + throw "LLVMCore.lib contains ${{matrix.forbidden_runtime_directive}}" + } + } else { + $DumpbinOutput = & dumpbin /dependents (Join-Path $PackageRoot "bin/LLVM.dll") + if ($LASTEXITCODE -ne 0) { + throw "dumpbin /dependents LLVM.dll failed" + } - if ($DumpbinText -match '${{matrix.forbidden_runtime_directive}}') { - throw "LLVMCore.lib contains ${{matrix.forbidden_runtime_directive}}" + $DumpbinText = $DumpbinOutput -join "`n" + $DynamicCrtPattern = 'VCRUNTIME|MSVCP|CONCRT' + if ('${{matrix.crt}}' -eq 'md' -and $DumpbinText -notmatch $DynamicCrtPattern) { + throw "LLVM.dll does not appear to depend on the dynamic MSVC runtime" + } + + if ('${{matrix.crt}}' -eq 'mt' -and $DumpbinText -match $DynamicCrtPattern) { + throw "LLVM.dll appears to depend on the dynamic MSVC runtime" + } } } $DynamicLibs = @(Get-ChildItem -Path $PackageRoot -Recurse -File | Where-Object { - $_.Extension -in @(".dll", ".dylib", ".so") + ($_.Extension -in @(".dll", ".dylib", ".so")) -or ($_.Name -like "*.so.*") }) - if ($DynamicLibs.Count -ne 0) { + if ($Linkage -eq "static" -and $DynamicLibs.Count -ne 0) { throw "Package contains dynamic libraries: $($DynamicLibs.FullName -join ', ')" } + if ($Linkage -eq "shared" -and $DynamicLibs.Count -eq 0) { + throw "Shared package does not contain a dynamic library" + } + + if ($Linkage -eq "shared") { + foreach ($StaticComponent in $StaticLlvmComponents) { + $StaticComponentFile = if ($IsWindows) { "$StaticComponent.lib" } else { "lib$StaticComponent.a" } + if (Test-Path (Join-Path $PackageLibDir $StaticComponentFile)) { + throw "Shared package contains static component library '$StaticComponentFile'" + } + } + } + $MsvcRuntimeLine = if ($IsWindows) { "MSVC runtime: ${{matrix.msvc_runtime_label}}" } else { "MSVC runtime: N/A" } $LlvmConfigValidationLine = if ($CanRunTargetTools) { "Target llvm-config validation: enabled" @@ -437,11 +547,12 @@ jobs: $ManifestLines.Add("LLVM core libs link manifest") $ManifestLines.Add("LLVM version: $Version") $ManifestLines.Add("Target: ${{matrix.arch}}-${{matrix.os}}") + $ManifestLines.Add("Linkage: $Linkage") $ManifestLines.Add($MsvcRuntimeLine) $ManifestLines.Add($LlvmConfigValidationLine) $ManifestLines.Add("") $ManifestLines.Add("Command:") - $ManifestLines.Add(" bin/llvm-config$ExeExt --link-static --libs core bitreader") + $ManifestLines.Add(" bin/llvm-config$ExeExt $LinkCommand --libs core bitreader") $ManifestLines.Add("") $ManifestLines.Add("LLVM libs:") foreach ($ExpectedLlvmComponent in $ExpectedLlvmComponents) { @@ -449,7 +560,7 @@ jobs: } $ManifestLines.Add("") $ManifestLines.Add("Command:") - $ManifestLines.Add(" bin/llvm-config$ExeExt --link-static --system-libs core bitreader") + $ManifestLines.Add(" bin/llvm-config$ExeExt $LinkCommand --system-libs core bitreader") $ManifestLines.Add("") $ManifestLines.Add("System libs:") foreach ($ReportedSystemLib in ($ReportedSystemLibs | Sort-Object)) { @@ -460,17 +571,17 @@ jobs: - name: Package LLVM core libs if: runner.os != 'Windows' run: | - tar -cJf llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}}.tar.xz llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}} + tar -cJf "$PACKAGE_NAME.tar.xz" "$PACKAGE_NAME" - name: Package LLVM core libs if: runner.os == 'Windows' shell: pwsh run: | - $PackageName = "llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}}" + $PackageName = $Env:PACKAGE_NAME cmd.exe /c "7z a -ttar -snl -so $PackageName.tar $PackageName | 7z a -si $PackageName.tar.xz" - name: Upload LLVM core libs package uses: actions/upload-artifact@v7 with: - name: llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}} - path: llvm-core-libs-${{matrix.version}}-${{matrix.arch}}-${{matrix.os}}${{matrix.package_suffix}}.tar.xz + name: ${{ env.PACKAGE_NAME }} + path: ${{ env.PACKAGE_NAME }}.tar.xz diff --git a/README.md b/README.md index ce45b41..fe158b5 100644 --- a/README.md +++ b/README.md @@ -25,16 +25,19 @@ clang+llvm---.tar.xz ### LLVM core libs -The LLVM core libs workflow builds small static-library packages for linking against the LLVM Core and BitReader C APIs. Windows packages are produced for both MSVC CRT modes: static CRT (`/MT`) and dynamic CRT (`/MD`). Each Windows package verifies `LLVMCore.lib` contains the expected `RuntimeLibrary` directive and does not contain the opposite CRT directive. +The LLVM core libs workflow builds small static and shared-library packages for linking against the LLVM Core and BitReader C APIs. Windows packages are produced for both MSVC CRT modes: static CRT (`/MT`) and dynamic CRT (`/MD`). Static Windows packages verify `LLVMCore.lib` contains the expected `RuntimeLibrary` directive and does not contain the opposite CRT directive; shared Windows packages verify the packaged LLVM DLL dependencies match the selected CRT mode. Currently built LLVM core libs versions: `20.1.8`, `22.1.4`. Artifacts are named: ```text -llvm-core-libs---.tar.xz -llvm-core-libs---windows-mt.tar.xz -llvm-core-libs---windows-md.tar.xz +llvm-core-libs----static.tar.xz +llvm-core-libs----shared.tar.xz +llvm-core-libs---windows-static-mt.tar.xz +llvm-core-libs---windows-static-md.tar.xz +llvm-core-libs---windows-shared-mt.tar.xz +llvm-core-libs---windows-shared-md.tar.xz ``` ### Halide diff --git a/cmake/llvm-core-libs.cmake b/cmake/llvm-core-libs.cmake index 6c90bf2..3fb299f 100644 --- a/cmake/llvm-core-libs.cmake +++ b/cmake/llvm-core-libs.cmake @@ -36,9 +36,13 @@ set(LLVM_ENABLE_PROJECTS "" CACHE STRING "") set(LLVM_ENABLE_RUNTIMES "" CACHE STRING "") set(BUILD_SHARED_LIBS OFF CACHE BOOL "") -set(LLVM_BUILD_LLVM_DYLIB OFF CACHE BOOL "") +if(NOT DEFINED LLVM_BUILD_LLVM_DYLIB) + set(LLVM_BUILD_LLVM_DYLIB OFF CACHE BOOL "") +endif() set(LLVM_BUILD_LLVM_C_DYLIB OFF CACHE BOOL "") -set(LLVM_LINK_LLVM_DYLIB OFF CACHE BOOL "") +if(NOT DEFINED LLVM_LINK_LLVM_DYLIB) + set(LLVM_LINK_LLVM_DYLIB OFF CACHE BOOL "") +endif() set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "") set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "") @@ -81,8 +85,10 @@ set(LLVM_CORE_DEVELOPMENT_COMPONENTS llvm-headers CACHE STRING "") -set(LLVM_DISTRIBUTION_COMPONENTS - llvm-config - ${LLVM_CORE_DEVELOPMENT_COMPONENTS} - ${LLVM_CORE_LIB_COMPONENTS} - CACHE STRING "") +if(NOT DEFINED LLVM_DISTRIBUTION_COMPONENTS) + set(LLVM_DISTRIBUTION_COMPONENTS + llvm-config + ${LLVM_CORE_DEVELOPMENT_COMPONENTS} + ${LLVM_CORE_LIB_COMPONENTS} + CACHE STRING "") +endif() From 94017af6e213c28673f569fa414e76e34283658a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 31 May 2026 05:14:26 -0400 Subject: [PATCH 7/8] Use component DLLs for Windows shared core libs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/llvm-core-libs.yml | 57 ++++++++++++++++++---------- README.md | 2 +- 2 files changed, 37 insertions(+), 22 deletions(-) diff --git a/.github/workflows/llvm-core-libs.yml b/.github/workflows/llvm-core-libs.yml index a62c474..fbafdac 100644 --- a/.github/workflows/llvm-core-libs.yml +++ b/.github/workflows/llvm-core-libs.yml @@ -160,7 +160,6 @@ jobs: $CMakeInitialCache = "$Env:GITHUB_WORKSPACE/llvm-prebuilt/cmake/llvm-core-libs.cmake" $CMakeArgs = @( - "-DBUILD_SHARED_LIBS=OFF", "-DLLVM_TARGETS_TO_BUILD=AArch64;X86", "-DLLVM_BUILD_LLVM_C_DYLIB=OFF", "-DLLVM_ENABLE_LIBXML2=OFF", @@ -180,25 +179,36 @@ jobs: $StaticComponents = "LLVMBitReader;LLVMCore;LLVMRemarks;LLVMBitstreamReader;LLVMBinaryFormat;LLVMTargetParser;LLVMSupport;LLVMDemangle" if ('${{matrix.linkage}}' -eq 'shared') { - $CMakeArgs += @( - "-DLLVM_BUILD_LLVM_DYLIB=ON", - "-DLLVM_LINK_LLVM_DYLIB=ON", - "-DLLVM_DYLIB_COMPONENTS=core;bitreader", - "-DLLVM_DISTRIBUTION_COMPONENTS=$DevelopmentComponents;LLVM" - ) - if ('${{matrix.os}}' -eq 'windows') { - $CMakeArgs += "-DLLVM_BUILD_LLVM_DYLIB_VIS=ON" + $CMakeArgs += @( + "-DBUILD_SHARED_LIBS=ON", + "-DLLVM_BUILD_LLVM_DYLIB=OFF", + "-DLLVM_LINK_LLVM_DYLIB=OFF", + "-DLLVM_DISTRIBUTION_COMPONENTS=$DevelopmentComponents;$StaticComponents" + ) } elseif ('${{matrix.os}}' -eq 'macos') { $CMakeArgs += @( + "-DBUILD_SHARED_LIBS=OFF", + "-DLLVM_BUILD_LLVM_DYLIB=ON", + "-DLLVM_LINK_LLVM_DYLIB=ON", + "-DLLVM_DYLIB_COMPONENTS=core;bitreader", + "-DLLVM_DISTRIBUTION_COMPONENTS=$DevelopmentComponents;LLVM", "-DCMAKE_INSTALL_NAME_DIR=@rpath", "-DCMAKE_INSTALL_RPATH=@loader_path/../lib" ) } else { - $CMakeArgs += '-DCMAKE_INSTALL_RPATH=$ORIGIN/../lib' + $CMakeArgs += @( + "-DBUILD_SHARED_LIBS=OFF", + "-DLLVM_BUILD_LLVM_DYLIB=ON", + "-DLLVM_LINK_LLVM_DYLIB=ON", + "-DLLVM_DYLIB_COMPONENTS=core;bitreader", + "-DLLVM_DISTRIBUTION_COMPONENTS=$DevelopmentComponents;LLVM", + '-DCMAKE_INSTALL_RPATH=$ORIGIN/../lib' + ) } } else { $CMakeArgs += @( + "-DBUILD_SHARED_LIBS=OFF", "-DLLVM_BUILD_LLVM_DYLIB=OFF", "-DLLVM_LINK_LLVM_DYLIB=OFF", "-DLLVM_DISTRIBUTION_COMPONENTS=$DevelopmentComponents;$StaticComponents" @@ -254,8 +264,10 @@ jobs: } } else { if ($IsWindows) { - Copy-Item -Path llvm-install/bin/LLVM.dll -Destination $PackageBinDir -Force - Copy-Item -Path llvm-install/lib/LLVM.lib -Destination $PackageLibDir -Force + foreach ($RequiredLib in $RequiredLibs) { + Copy-Item -Path "llvm-install/bin/$RequiredLib.dll" -Destination $PackageBinDir -Force + Copy-Item -Path "llvm-install/lib/$RequiredLib.lib" -Destination $PackageLibDir -Force + } } elseif ($IsMacOS) { $SharedLibraries = @(Get-ChildItem -Path llvm-install/lib -Filter "libLLVM*.dylib" -File) if ($SharedLibraries.Count -eq 0) { @@ -405,7 +417,8 @@ jobs: "LLVMSupport", "LLVMDemangle" ) - $ExpectedLlvmComponents = if ($Linkage -eq "shared") { @("LLVM") } else { $StaticLlvmComponents } + $UsesAggregateSharedLibrary = ($Linkage -eq "shared" -and -not $IsWindows) + $ExpectedLlvmComponents = if ($UsesAggregateSharedLibrary) { @("LLVM") } else { $StaticLlvmComponents } $LinkCommand = if ($Linkage -eq "shared") { "--link-shared" } else { "--link-static" } if ($CanRunTargetTools) { @@ -429,9 +442,11 @@ jobs: } } else { if ($IsWindows) { - foreach ($ExpectedSharedFile in @("bin/LLVM.dll", "lib/LLVM.lib")) { - if (-not (Test-Path (Join-Path $PackageRoot $ExpectedSharedFile))) { - throw "Package is missing '$ExpectedSharedFile'" + foreach ($ExpectedComponent in $ExpectedLlvmComponents) { + foreach ($ExpectedSharedFile in @("bin/$ExpectedComponent.dll", "lib/$ExpectedComponent.lib")) { + if (-not (Test-Path (Join-Path $PackageRoot $ExpectedSharedFile))) { + throw "Package is missing '$ExpectedSharedFile'" + } } } } elseif ($IsMacOS) { @@ -499,19 +514,19 @@ jobs: throw "LLVMCore.lib contains ${{matrix.forbidden_runtime_directive}}" } } else { - $DumpbinOutput = & dumpbin /dependents (Join-Path $PackageRoot "bin/LLVM.dll") + $DumpbinOutput = & dumpbin /dependents (Join-Path $PackageRoot "bin/LLVMCore.dll") if ($LASTEXITCODE -ne 0) { - throw "dumpbin /dependents LLVM.dll failed" + throw "dumpbin /dependents LLVMCore.dll failed" } $DumpbinText = $DumpbinOutput -join "`n" $DynamicCrtPattern = 'VCRUNTIME|MSVCP|CONCRT' if ('${{matrix.crt}}' -eq 'md' -and $DumpbinText -notmatch $DynamicCrtPattern) { - throw "LLVM.dll does not appear to depend on the dynamic MSVC runtime" + throw "LLVMCore.dll does not appear to depend on the dynamic MSVC runtime" } if ('${{matrix.crt}}' -eq 'mt' -and $DumpbinText -match $DynamicCrtPattern) { - throw "LLVM.dll appears to depend on the dynamic MSVC runtime" + throw "LLVMCore.dll appears to depend on the dynamic MSVC runtime" } } } @@ -527,7 +542,7 @@ jobs: throw "Shared package does not contain a dynamic library" } - if ($Linkage -eq "shared") { + if ($Linkage -eq "shared" -and -not $IsWindows) { foreach ($StaticComponent in $StaticLlvmComponents) { $StaticComponentFile = if ($IsWindows) { "$StaticComponent.lib" } else { "lib$StaticComponent.a" } if (Test-Path (Join-Path $PackageLibDir $StaticComponentFile)) { diff --git a/README.md b/README.md index fe158b5..464aee4 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ clang+llvm---.tar.xz ### LLVM core libs -The LLVM core libs workflow builds small static and shared-library packages for linking against the LLVM Core and BitReader C APIs. Windows packages are produced for both MSVC CRT modes: static CRT (`/MT`) and dynamic CRT (`/MD`). Static Windows packages verify `LLVMCore.lib` contains the expected `RuntimeLibrary` directive and does not contain the opposite CRT directive; shared Windows packages verify the packaged LLVM DLL dependencies match the selected CRT mode. +The LLVM core libs workflow builds small static and shared-library packages for linking against the LLVM Core and BitReader C APIs. Windows packages are produced for both MSVC CRT modes: static CRT (`/MT`) and dynamic CRT (`/MD`). Static Windows packages verify `LLVMCore.lib` contains the expected `RuntimeLibrary` directive and does not contain the opposite CRT directive; shared Windows packages use component DLLs plus import libraries and verify the packaged LLVM DLL dependencies match the selected CRT mode. Currently built LLVM core libs versions: `20.1.8`, `22.1.4`. From 0781d6b1a7f77e29d1a56ffd1390c4dbd7af6575 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Sun, 31 May 2026 05:54:29 -0400 Subject: [PATCH 8/8] Use LLVM-C DLL for Windows shared core libs Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/llvm-core-libs.yml | 104 +++++++++++++++++++-------- README.md | 2 +- 2 files changed, 74 insertions(+), 32 deletions(-) diff --git a/.github/workflows/llvm-core-libs.yml b/.github/workflows/llvm-core-libs.yml index fbafdac..43c5ac4 100644 --- a/.github/workflows/llvm-core-libs.yml +++ b/.github/workflows/llvm-core-libs.yml @@ -138,7 +138,7 @@ jobs: - name: Build LLVM host tools shell: pwsh run: | - cmake --build llvm-host --target llvm-tblgen llvm-config + cmake --build llvm-host --target llvm-tblgen llvm-config llvm-nm $HostBinPath = "$Env:GITHUB_WORKSPACE/llvm-host/bin" $ExeExt = if ($IsWindows) { ".exe" } else { "" } echo "LLVM_NATIVE_TOOL_DIR=$HostBinPath" >> $Env:GITHUB_ENV @@ -161,7 +161,6 @@ jobs: $CMakeArgs = @( "-DLLVM_TARGETS_TO_BUILD=AArch64;X86", - "-DLLVM_BUILD_LLVM_C_DYLIB=OFF", "-DLLVM_ENABLE_LIBXML2=OFF", "-DLLVM_ENABLE_ZLIB=OFF", "-DLLVM_ENABLE_ZSTD=OFF" @@ -181,16 +180,19 @@ jobs: if ('${{matrix.linkage}}' -eq 'shared') { if ('${{matrix.os}}' -eq 'windows') { $CMakeArgs += @( - "-DBUILD_SHARED_LIBS=ON", + "-DBUILD_SHARED_LIBS=OFF", "-DLLVM_BUILD_LLVM_DYLIB=OFF", "-DLLVM_LINK_LLVM_DYLIB=OFF", - "-DLLVM_DISTRIBUTION_COMPONENTS=$DevelopmentComponents;$StaticComponents" + "-DLLVM_BUILD_LLVM_C_DYLIB=ON", + "-DLLVM_DYLIB_COMPONENTS=core;bitreader", + "-DLLVM_DISTRIBUTION_COMPONENTS=$DevelopmentComponents;LLVM-C" ) } elseif ('${{matrix.os}}' -eq 'macos') { $CMakeArgs += @( "-DBUILD_SHARED_LIBS=OFF", "-DLLVM_BUILD_LLVM_DYLIB=ON", "-DLLVM_LINK_LLVM_DYLIB=ON", + "-DLLVM_BUILD_LLVM_C_DYLIB=OFF", "-DLLVM_DYLIB_COMPONENTS=core;bitreader", "-DLLVM_DISTRIBUTION_COMPONENTS=$DevelopmentComponents;LLVM", "-DCMAKE_INSTALL_NAME_DIR=@rpath", @@ -201,6 +203,7 @@ jobs: "-DBUILD_SHARED_LIBS=OFF", "-DLLVM_BUILD_LLVM_DYLIB=ON", "-DLLVM_LINK_LLVM_DYLIB=ON", + "-DLLVM_BUILD_LLVM_C_DYLIB=OFF", "-DLLVM_DYLIB_COMPONENTS=core;bitreader", "-DLLVM_DISTRIBUTION_COMPONENTS=$DevelopmentComponents;LLVM", '-DCMAKE_INSTALL_RPATH=$ORIGIN/../lib' @@ -211,6 +214,7 @@ jobs: "-DBUILD_SHARED_LIBS=OFF", "-DLLVM_BUILD_LLVM_DYLIB=OFF", "-DLLVM_LINK_LLVM_DYLIB=OFF", + "-DLLVM_BUILD_LLVM_C_DYLIB=OFF", "-DLLVM_DISTRIBUTION_COMPONENTS=$DevelopmentComponents;$StaticComponents" ) } @@ -264,10 +268,17 @@ jobs: } } else { if ($IsWindows) { - foreach ($RequiredLib in $RequiredLibs) { - Copy-Item -Path "llvm-install/bin/$RequiredLib.dll" -Destination $PackageBinDir -Force - Copy-Item -Path "llvm-install/lib/$RequiredLib.lib" -Destination $PackageLibDir -Force + $SharedLibraries = @(Get-ChildItem -Path llvm-install/bin -Filter "LLVM-C*.dll" -File) + if ($SharedLibraries.Count -eq 0) { + throw "No LLVM-C DLL was installed" } + Copy-Item -Path $SharedLibraries.FullName -Destination $PackageBinDir -Force + + $ImportLibraries = @(Get-ChildItem -Path llvm-install/lib -Filter "LLVM-C*.lib" -File) + if ($ImportLibraries.Count -eq 0) { + throw "No LLVM-C import library was installed" + } + Copy-Item -Path $ImportLibraries.FullName -Destination $PackageLibDir -Force } elseif ($IsMacOS) { $SharedLibraries = @(Get-ChildItem -Path llvm-install/lib -Filter "libLLVM*.dylib" -File) if ($SharedLibraries.Count -eq 0) { @@ -418,10 +429,17 @@ jobs: "LLVMDemangle" ) $UsesAggregateSharedLibrary = ($Linkage -eq "shared" -and -not $IsWindows) - $ExpectedLlvmComponents = if ($UsesAggregateSharedLibrary) { @("LLVM") } else { $StaticLlvmComponents } + $UsesWindowsCDll = ($Linkage -eq "shared" -and $IsWindows) + $ExpectedLlvmComponents = if ($UsesAggregateSharedLibrary) { + @("LLVM") + } elseif ($UsesWindowsCDll) { + @("LLVM-C") + } else { + $StaticLlvmComponents + } $LinkCommand = if ($Linkage -eq "shared") { "--link-shared" } else { "--link-static" } - if ($CanRunTargetTools) { + if ($CanRunTargetTools -and -not $UsesWindowsCDll) { $LibTokens = @((& $LlvmConfig $LinkCommand --libs core bitreader) -split '\s+' | ForEach-Object { Convert-ToLlvmComponentName $_ }) if ($LASTEXITCODE -ne 0) { throw "llvm-config $LinkCommand --libs core bitreader failed" @@ -442,11 +460,9 @@ jobs: } } else { if ($IsWindows) { - foreach ($ExpectedComponent in $ExpectedLlvmComponents) { - foreach ($ExpectedSharedFile in @("bin/$ExpectedComponent.dll", "lib/$ExpectedComponent.lib")) { - if (-not (Test-Path (Join-Path $PackageRoot $ExpectedSharedFile))) { - throw "Package is missing '$ExpectedSharedFile'" - } + foreach ($ExpectedSharedFile in @("bin/LLVM-C.dll", "lib/LLVM-C.lib")) { + if (-not (Test-Path (Join-Path $PackageRoot $ExpectedSharedFile))) { + throw "Package is missing '$ExpectedSharedFile'" } } } elseif ($IsMacOS) { @@ -458,7 +474,9 @@ jobs: } } - if ($CanRunTargetTools) { + if ($UsesWindowsCDll) { + $ReportedSystemLibs = @() + } elseif ($CanRunTargetTools) { $SystemLibTokens = @((& $LlvmConfig $LinkCommand --system-libs core bitreader) -split '\s+' | ForEach-Object { Convert-ToSystemLibToken $_ }) if ($LASTEXITCODE -ne 0) { throw "llvm-config $LinkCommand --system-libs core bitreader failed" @@ -488,15 +506,19 @@ jobs: } if ($IsWindows) { - $ExpectedSystemLibs = @( - "advapi32.lib", - "ntdll.lib", - "ole32.lib", - "psapi.lib", - "shell32.lib", - "uuid.lib", - "ws2_32.lib" - ) + $ExpectedSystemLibs = if ($UsesWindowsCDll) { + @() + } else { + @( + "advapi32.lib", + "ntdll.lib", + "ole32.lib", + "psapi.lib", + "shell32.lib", + "uuid.lib", + "ws2_32.lib" + ) + } Compare-LibSet -Expected $ExpectedSystemLibs -Actual $ReportedSystemLibs -Label "System libs" if ($Linkage -eq "static") { @@ -514,19 +536,31 @@ jobs: throw "LLVMCore.lib contains ${{matrix.forbidden_runtime_directive}}" } } else { - $DumpbinOutput = & dumpbin /dependents (Join-Path $PackageRoot "bin/LLVMCore.dll") + $DumpbinOutput = & dumpbin /dependents (Join-Path $PackageRoot "bin/LLVM-C.dll") if ($LASTEXITCODE -ne 0) { - throw "dumpbin /dependents LLVMCore.dll failed" + throw "dumpbin /dependents LLVM-C.dll failed" } $DumpbinText = $DumpbinOutput -join "`n" $DynamicCrtPattern = 'VCRUNTIME|MSVCP|CONCRT' if ('${{matrix.crt}}' -eq 'md' -and $DumpbinText -notmatch $DynamicCrtPattern) { - throw "LLVMCore.dll does not appear to depend on the dynamic MSVC runtime" + throw "LLVM-C.dll does not appear to depend on the dynamic MSVC runtime" } if ('${{matrix.crt}}' -eq 'mt' -and $DumpbinText -match $DynamicCrtPattern) { - throw "LLVMCore.dll appears to depend on the dynamic MSVC runtime" + throw "LLVM-C.dll appears to depend on the dynamic MSVC runtime" + } + + $ExportsOutput = & dumpbin /exports (Join-Path $PackageRoot "bin/LLVM-C.dll") + if ($LASTEXITCODE -ne 0) { + throw "dumpbin /exports LLVM-C.dll failed" + } + + $ExportsText = $ExportsOutput -join "`n" + foreach ($ExpectedExport in @("LLVMContextCreate", "LLVMParseBitcode2")) { + if ($ExportsText -notmatch $ExpectedExport) { + throw "LLVM-C.dll does not export $ExpectedExport" + } } } } @@ -542,7 +576,7 @@ jobs: throw "Shared package does not contain a dynamic library" } - if ($Linkage -eq "shared" -and -not $IsWindows) { + if ($Linkage -eq "shared") { foreach ($StaticComponent in $StaticLlvmComponents) { $StaticComponentFile = if ($IsWindows) { "$StaticComponent.lib" } else { "lib$StaticComponent.a" } if (Test-Path (Join-Path $PackageLibDir $StaticComponentFile)) { @@ -567,7 +601,11 @@ jobs: $ManifestLines.Add($LlvmConfigValidationLine) $ManifestLines.Add("") $ManifestLines.Add("Command:") - $ManifestLines.Add(" bin/llvm-config$ExeExt $LinkCommand --libs core bitreader") + if ($UsesWindowsCDll) { + $ManifestLines.Add(" link against lib/LLVM-C.lib and deploy bin/LLVM-C.dll") + } else { + $ManifestLines.Add(" bin/llvm-config$ExeExt $LinkCommand --libs core bitreader") + } $ManifestLines.Add("") $ManifestLines.Add("LLVM libs:") foreach ($ExpectedLlvmComponent in $ExpectedLlvmComponents) { @@ -575,7 +613,11 @@ jobs: } $ManifestLines.Add("") $ManifestLines.Add("Command:") - $ManifestLines.Add(" bin/llvm-config$ExeExt $LinkCommand --system-libs core bitreader") + if ($UsesWindowsCDll) { + $ManifestLines.Add(" no additional system libraries are required when linking against the import library") + } else { + $ManifestLines.Add(" bin/llvm-config$ExeExt $LinkCommand --system-libs core bitreader") + } $ManifestLines.Add("") $ManifestLines.Add("System libs:") foreach ($ReportedSystemLib in ($ReportedSystemLibs | Sort-Object)) { diff --git a/README.md b/README.md index 464aee4..27bcd09 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ clang+llvm---.tar.xz ### LLVM core libs -The LLVM core libs workflow builds small static and shared-library packages for linking against the LLVM Core and BitReader C APIs. Windows packages are produced for both MSVC CRT modes: static CRT (`/MT`) and dynamic CRT (`/MD`). Static Windows packages verify `LLVMCore.lib` contains the expected `RuntimeLibrary` directive and does not contain the opposite CRT directive; shared Windows packages use component DLLs plus import libraries and verify the packaged LLVM DLL dependencies match the selected CRT mode. +The LLVM core libs workflow builds small static and shared-library packages for linking against the LLVM Core and BitReader C APIs. Windows packages are produced for both MSVC CRT modes: static CRT (`/MT`) and dynamic CRT (`/MD`). Static Windows packages verify `LLVMCore.lib` contains the expected `RuntimeLibrary` directive and does not contain the opposite CRT directive; shared Windows packages use `LLVM-C.dll` plus its import library and verify the packaged DLL dependencies match the selected CRT mode. Currently built LLVM core libs versions: `20.1.8`, `22.1.4`.