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
15 changes: 11 additions & 4 deletions .github/workflows/regenerate-native.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
- { rid: win-arm64, os: windows-11-arm }
- { rid: linux-x64, os: ubuntu-latest }
- { rid: linux-arm64, os: ubuntu-24.04-arm }
- { rid: osx-arm64, os: macos-latest }
- { rid: osx-arm64, os: macos-15 }
steps:
- uses: actions/checkout@v4
- name: Lift libLLVM (Windows)
Expand Down Expand Up @@ -138,13 +138,20 @@ jobs:
fail-fast: false
matrix:
include:
- { rid: win-x64, os: windows-latest }
- { rid: win-arm64, os: windows-11-arm }
- { rid: win-x64, os: windows-latest, vcpkg: x64-windows-static }
- { rid: win-arm64, os: windows-11-arm, vcpkg: arm64-windows-static }
- { rid: linux-x64, os: ubuntu-latest }
- { rid: linux-arm64, os: ubuntu-24.04-arm }
- { rid: osx-arm64, os: macos-latest }
- { rid: osx-arm64, os: macos-15 }
steps:
- uses: actions/checkout@v4
- name: Install LLVM dependencies (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
& "$env:VCPKG_INSTALLATION_ROOT\vcpkg.exe" install `
"zlib:${{ matrix.vcpkg }}" `
"zstd:${{ matrix.vcpkg }}"
- name: Build libLLVMSharp (Windows)
if: runner.os == 'Windows'
shell: pwsh
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.15)

project(LLVMSharp VERSION 22.1.8)
project(LLVMSharp VERSION 23.1.0)

if(MSVC)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ The tracked LLVM version is the `project(LLVMSharp VERSION X.Y.Z)` value in the
./scripts/build.sh --regeneratenative --target libLLVMSharp --rid linux-x64
```

The staged binary is written to `artifacts/native/<rid>/`. Unlike ClangSharp — which lifts the shared `libclang` that ships for every platform — the official LLVM releases only ship a shared `libLLVM` on Windows (as `LLVM-C.dll`, shipped under that official name). The managed resolver in `sources/LLVMSharp.Interop/LLVM.cs` maps the logical `libLLVM` P/Invoke name to the per-platform file (`LLVM-C.dll` on Windows; `libLLVM.so`/`libLLVM.dylib` elsewhere), which is also why `libLLVMSharp.dll`'s static `LLVM-C.dll` import resolves without an extra copy. Linux and macOS are lifted from the most-official prebuilt source per platform: [apt.llvm.org](https://apt.llvm.org/) (the LLVM project's own Debian/Ubuntu repository, `libllvm<major>`) on Linux and [Homebrew](https://formulae.brew.sh/formula/llvm) (`llvm`) on macOS, both of which link the standard system C++ runtime. `libLLVMSharp` is compiled per-runtime against the LLVM release distribution, which bundles the `lib/cmake/{llvm,clang}` config, headers, and import libraries used as `PATH_TO_LLVM`, so no from-source LLVM build is required.
The staged binary is written to `artifacts/native/<rid>/`. Unlike ClangSharp — which lifts the shared `libclang` that ships for every platform — the official LLVM releases only ship a shared `libLLVM` on Windows (as `LLVM-C.dll`, shipped under that official name). The managed resolver in `sources/LLVMSharp.Interop/LLVM.cs` maps the logical `libLLVM` P/Invoke name to the per-platform file (`LLVM-C.dll` on Windows; `libLLVM.so`/`libLLVM.dylib` elsewhere), which is also why `libLLVMSharp.dll`'s static `LLVM-C.dll` import resolves without an extra copy. Linux and macOS are lifted from the most-official prebuilt source per platform: [apt.llvm.org](https://apt.llvm.org/) (the LLVM project's own Debian/Ubuntu repository, `libllvm<major>`) on Linux and [Homebrew](https://formulae.brew.sh/formula/llvm) (`llvm`) on macOS, both of which link the standard system C++ runtime. Windows and Linux compile `libLLVMSharp` against the official release SDK; macOS uses the exact Homebrew formula on a macOS 15 runner and requires users to install that formula for its external dependencies.

The jobs run when:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>libLLVM.runtime.linux-arm64</id>
<version>22.1.8</version>
<version>23.1.0</version>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="expression">Apache-2.0 WITH LLVM-exception</license>
<projectUrl>https://github.com/dotnet/llvmsharp</projectUrl>
<description>linux arm64 native library for libLLVM.</description>
<copyright>Copyright © LLVM Project</copyright>
<repository type="git" url="https://github.com/llvm/llvm-project" branch="llvmorg-22.1.8" />
<repository type="git" url="https://github.com/llvm/llvm-project" branch="llvmorg-23.1.0" />
</metadata>
<files>
<file src="..\libLLVM\LICENSE.TXT" target="LICENSE.TXT" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>libLLVM.runtime.linux-x64</id>
<version>22.1.8</version>
<version>23.1.0</version>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="expression">Apache-2.0 WITH LLVM-exception</license>
<projectUrl>https://github.com/dotnet/llvmsharp</projectUrl>
<description>linux x64 native library for libLLVM.</description>
<copyright>Copyright © LLVM Project</copyright>
<repository type="git" url="https://github.com/llvm/llvm-project" branch="llvmorg-22.1.8" />
<repository type="git" url="https://github.com/llvm/llvm-project" branch="llvmorg-23.1.0" />
</metadata>
<files>
<file src="..\libLLVM\LICENSE.TXT" target="LICENSE.TXT" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>libLLVM.runtime.osx-arm64</id>
<version>22.1.8</version>
<version>23.1.0</version>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="expression">Apache-2.0 WITH LLVM-exception</license>
<projectUrl>https://github.com/dotnet/llvmsharp</projectUrl>
<description>osx arm64 native library for libLLVM.</description>
<copyright>Copyright © LLVM Project</copyright>
<repository type="git" url="https://github.com/llvm/llvm-project" branch="llvmorg-22.1.8" />
<repository type="git" url="https://github.com/llvm/llvm-project" branch="llvmorg-23.1.0" />
</metadata>
<files>
<file src="..\libLLVM\LICENSE.TXT" target="LICENSE.TXT" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>libLLVM.runtime.win-arm64</id>
<version>22.1.8</version>
<version>23.1.0</version>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="expression">Apache-2.0 WITH LLVM-exception</license>
<projectUrl>https://github.com/dotnet/llvmsharp</projectUrl>
<description>win arm64 native library for libLLVM.</description>
<copyright>Copyright © LLVM Project</copyright>
<repository type="git" url="https://github.com/llvm/llvm-project" branch="llvmorg-22.1.8" />
<repository type="git" url="https://github.com/llvm/llvm-project" branch="llvmorg-23.1.0" />
</metadata>
<files>
<file src="..\libLLVM\LICENSE.TXT" target="LICENSE.TXT" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>libLLVM.runtime.win-x64</id>
<version>22.1.8</version>
<version>23.1.0</version>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="expression">Apache-2.0 WITH LLVM-exception</license>
<projectUrl>https://github.com/dotnet/llvmsharp</projectUrl>
<description>win x64 native library for libLLVM.</description>
<copyright>Copyright © LLVM Project</copyright>
<repository type="git" url="https://github.com/llvm/llvm-project" branch="llvmorg-22.1.8" />
<repository type="git" url="https://github.com/llvm/llvm-project" branch="llvmorg-23.1.0" />
</metadata>
<files>
<file src="..\libLLVM\LICENSE.TXT" target="LICENSE.TXT" />
Expand Down
4 changes: 2 additions & 2 deletions packages/libLLVM/libLLVM/libLLVM.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>libLLVM</id>
<version>22.1.8</version>
<version>23.1.0</version>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<license type="expression">Apache-2.0 WITH LLVM-exception</license>
<projectUrl>https://github.com/dotnet/llvmsharp</projectUrl>
<description>Multi-platform native library for libLLVM.</description>
<copyright>Copyright © LLVM Project</copyright>
<repository type="git" url="https://github.com/llvm/llvm-project" branch="llvmorg-22.1.8" />
<repository type="git" url="https://github.com/llvm/llvm-project" branch="llvmorg-23.1.0" />
<dependencies>
<group targetFramework=".NETStandard2.0" />
</dependencies>
Expand Down
10 changes: 5 additions & 5 deletions packages/libLLVM/libLLVM/runtime.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
"runtimes": {
"linux-arm64": {
"libLLVM": {
"libLLVM.runtime.linux-arm64": "22.1.8"
"libLLVM.runtime.linux-arm64": "23.1.0"
}
},
"linux-x64": {
"libLLVM": {
"libLLVM.runtime.linux-x64": "22.1.8"
"libLLVM.runtime.linux-x64": "23.1.0"
}
},
"osx-arm64": {
"libLLVM": {
"libLLVM.runtime.osx-arm64": "22.1.8"
"libLLVM.runtime.osx-arm64": "23.1.0"
}
},
"win-arm64": {
"libLLVM": {
"libLLVM.runtime.win-arm64": "22.1.8"
"libLLVM.runtime.win-arm64": "23.1.0"
}
},
"win-x64": {
"libLLVM": {
"libLLVM.runtime.win-x64": "22.1.8"
"libLLVM.runtime.win-x64": "23.1.0"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>libLLVMSharp.runtime.linux-arm64</id>
<version>22.1.8.1</version>
<version>23.1.0.1</version>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>libLLVMSharp.runtime.linux-x64</id>
<version>22.1.8.1</version>
<version>23.1.0.1</version>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>libLLVMSharp.runtime.osx-arm64</id>
<version>22.1.8.1</version>
<version>23.1.0.1</version>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>libLLVMSharp.runtime.win-arm64</id>
<version>22.1.8.1</version>
<version>23.1.0.1</version>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>libLLVMSharp.runtime.win-x64</id>
<version>22.1.8.1</version>
<version>23.1.0.1</version>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
Expand Down
2 changes: 1 addition & 1 deletion packages/libLLVMSharp/libLLVMSharp/libLLVMSharp.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2013/05/nuspec.xsd">
<metadata minClientVersion="2.12">
<id>libLLVMSharp</id>
<version>22.1.8.1</version>
<version>23.1.0.1</version>
<authors>.NET Foundation and Contributors</authors>
<owners>.NET Foundation and Contributors</owners>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
Expand Down
10 changes: 5 additions & 5 deletions packages/libLLVMSharp/libLLVMSharp/runtime.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
"runtimes": {
"linux-arm64": {
"libLLVMSharp": {
"libLLVMSharp.runtime.linux-arm64": "22.1.8.1"
"libLLVMSharp.runtime.linux-arm64": "23.1.0.1"
}
},
"linux-x64": {
"libLLVMSharp": {
"libLLVMSharp.runtime.linux-x64": "22.1.8.1"
"libLLVMSharp.runtime.linux-x64": "23.1.0.1"
}
},
"osx-arm64": {
"libLLVMSharp": {
"libLLVMSharp.runtime.osx-arm64": "22.1.8.1"
"libLLVMSharp.runtime.osx-arm64": "23.1.0.1"
}
},
"win-arm64": {
"libLLVMSharp": {
"libLLVMSharp.runtime.win-arm64": "22.1.8.1"
"libLLVMSharp.runtime.win-arm64": "23.1.0.1"
}
},
"win-x64": {
"libLLVMSharp": {
"libLLVMSharp.runtime.win-x64": "22.1.8.1"
"libLLVMSharp.runtime.win-x64": "23.1.0.1"
}
}
}
Expand Down
22 changes: 20 additions & 2 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,27 @@ function Build-LibLLVMSharp([string] $runtime, [string] $source, [string] $desti
}

$nativeBuildDir = Join-Path -Path $ArtifactsDir -ChildPath "bin\native\$runtime"
$pathToLlvm = (Resolve-Path -Path $source).Path
$pathToLlvm = (Resolve-Path -Path $source).Path.Replace("\", "/")
$cmakeArguments = @(
"-B", "$nativeBuildDir",
"-S", "$RepoRoot",
"-A", "$arch",
"-Thost=$arch",
"-DPATH_TO_LLVM=$pathToLlvm"
)

if ($env:VCPKG_INSTALLATION_ROOT) {
$vcpkgToolchain = (Join-Path -Path $env:VCPKG_INSTALLATION_ROOT -ChildPath "scripts\buildsystems\vcpkg.cmake").Replace("\", "/")
$vcpkgTriplet = switch ($runtime) {
"win-x64" { "x64-windows-static" }
"win-arm64" { "arm64-windows-static" }
}

$cmakeArguments += "-DCMAKE_TOOLCHAIN_FILE=$vcpkgToolchain"
$cmakeArguments += "-DVCPKG_TARGET_TRIPLET=$vcpkgTriplet"
}

& cmake -B "$nativeBuildDir" -S "$RepoRoot" -A "$arch" "-Thost=$arch" "-DPATH_TO_LLVM=$pathToLlvm"
& cmake @cmakeArguments

if ($LastExitCode -ne 0) {
throw "'cmake' configure failed for '$runtime'"
Expand Down
40 changes: 30 additions & 10 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,26 @@ function DownloadLlvm {
fi
}

function InstallMacOSLlvm {
brew install llvm
LASTEXITCODE=$?

if [ "$LASTEXITCODE" != 0 ]; then
return "$LASTEXITCODE"
fi

llvmDir="$(brew --prefix llvm)"
installedVersion="$("$llvmDir/bin/llvm-config" --version 2> /dev/null)"

if [[ "$installedVersion" != "$llvm" ]]; then
echo "Homebrew provided LLVM '$installedVersion' but '$llvm' is required"
LASTEXITCODE=1
return "$LASTEXITCODE"
fi

LASTEXITCODE=0
}

function LiftLibLLVM {
runtime="$1"
destination="$2"
Expand Down Expand Up @@ -414,17 +434,13 @@ function LiftLibLLVM {
src="$(find "$downloadDir/extract" -name 'libLLVM*.so*' -type f | head -n1)"
;;
osx-*)
brew install "llvm@${major}" || brew install llvm
prefix="$(brew --prefix "llvm@${major}" 2> /dev/null || brew --prefix llvm)"
# The 'brew install llvm' fallback (used when 'llvm@${major}' is unavailable) can
# pull a different major; verify it matches the tracked version before packaging.
installedMajor="$("$prefix/bin/llvm-config" --version 2> /dev/null | cut -d. -f1)"
if [[ "$installedMajor" != "$major" ]]; then
echo "Homebrew provided LLVM major '$installedMajor' but '$major' is required for '$runtime'"
LASTEXITCODE=1
InstallMacOSLlvm

if [ "$LASTEXITCODE" != 0 ]; then
return "$LASTEXITCODE"
fi
src="$prefix/lib/libLLVM.dylib"

src="$llvmDir/lib/libLLVM.dylib"
;;
*)
echo "'$runtime' cannot lift libLLVM here; use build.ps1 on the matching runner"
Expand Down Expand Up @@ -538,7 +554,11 @@ function RegenerateNative {
if [[ "$target" == "libLLVM" ]]; then
LiftLibLLVM "$rid" "$stagingDir"
elif [[ "$target" == "libLLVMSharp" ]]; then
DownloadLlvm "$rid" "$llvmDir"
if [[ "$rid" == osx-* ]]; then
InstallMacOSLlvm
else
DownloadLlvm "$rid" "$llvmDir"
fi

if [ "$LASTEXITCODE" != 0 ]; then
return "$LASTEXITCODE"
Expand Down
Loading
Loading