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
5 changes: 3 additions & 2 deletions .github/workflows/linux-windows-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,16 @@ jobs:
run: NFPM="$RUNNER_TEMP/nfpm" scripts/package-linux-distros.sh

# Each package installs in a clean container with its declared
# dependencies, and every library the app links or loads resolves.
# dependencies, and every library the app links or loads resolves, as
# does libgomp, which the llama.cpp runtime it downloads links.
- name: Check the packages install
working-directory: LinuxWindows/dist
run: |
check='set -e
test -x /usr/bin/lokalbot
test -f /usr/share/applications/com.lokalbot.LokalBot.desktop
if ldd /usr/bin/lokalbot | grep "not found"; then exit 1; fi
for lib in libvulkan.so.1 libwayland-client.so.0; do ldconfig -p | grep -q "$lib" || { echo "missing $lib"; exit 1; }; done
for lib in libvulkan.so.1 libwayland-client.so.0 libgomp.so.1; do ldconfig -p | grep -q "$lib" || { echo "missing $lib"; exit 1; }; done
/usr/bin/lokalbot-cli --help > /dev/null'
docker run --rm -v "$PWD:/d" ubuntu:24.04 bash -c \
"apt-get update -qq && DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends /d/LokalBot-*-linux-amd64.deb > /dev/null && $check"
Expand Down
3 changes: 2 additions & 1 deletion LinuxWindows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ release has none yet, use a CI run's artifacts (`lokalbot-linux-x86_64`, `lokalb

- **Linux** (x86_64): extract `LokalBot-<version>-linux-x86_64.tar.gz` and run `./install.sh`. It installs
`lokalbot` and `lokalbot-cli` into `~/.local/bin` and adds LokalBot to your applications menu.
Runtime needs: a Vulkan or OpenGL driver (Mesa is fine), PulseAudio or PipeWire for system audio.
Runtime needs: a Vulkan or OpenGL driver (Mesa is fine), PulseAudio or PipeWire for system audio, and
for the built-in models the GCC OpenMP runtime (`libgomp1` on Debian and Ubuntu, `libgomp` on Fedora and Arch).
The same release has packages that install into `/usr/bin` with their dependencies:
`LokalBot-<version>-linux-amd64.deb` (Debian, Ubuntu: `sudo apt install ./LokalBot-…deb`),
`LokalBot-<version>-linux-x86_64.rpm` (Fedora, openSUSE: `sudo dnf install ./LokalBot-…rpm`) and
Expand Down
324 changes: 311 additions & 13 deletions LinuxWindows/crates/lokalbot-ai/src/runtime.rs

Large diffs are not rendered by default.

44 changes: 40 additions & 4 deletions LinuxWindows/crates/lokalbot-update/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ pub const APP_ID: &str = "com.lokalbot.LokalBot";
const ICON_SIZES: [u32; 8] = [16, 24, 32, 48, 64, 128, 256, 512];
/// The archive's folder of license texts.
const LICENSES_DIR: &str = "LICENSES";
/// The Windows archive's Visual C++ runtime, which lokalbot-ai's runtime.rs
/// (`VC_RUNTIME_DIR`) copies beside llama-server.exe.
const VC_RUNTIME_DIR: &str = "vc-runtime";

pub const APP_BINARY: &str = if cfg!(windows) {
"lokalbot.exe"
Expand Down Expand Up @@ -257,9 +260,9 @@ struct Replacement {
/// archive's `LokalBot-<version>-<platform>` folder): both binaries, the
/// Windows CLI copy, files the archive folder also holds (licenses, notices,
/// when LokalBot runs from an extracted archive or the installer's folder),
/// license texts the update adds to that folder's `LICENSES`, then
/// install.sh's desktop entry and icons. Nothing is replaced unless every
/// file could be staged.
/// license texts the update adds to that folder's `LICENSES`, the Visual C++
/// runtime, then install.sh's desktop entry and icons. Nothing is replaced
/// unless every file could be staged.
pub fn install(
staged: &Path,
targets: &Targets,
Expand Down Expand Up @@ -336,7 +339,10 @@ fn plan(staged: &Path, targets: &Targets) -> Result<Vec<Replacement>, InstallErr
let new_license = !present
&& relative.parent() == Some(Path::new(LICENSES_DIR))
&& fs::symlink_metadata(targets.dir.join(LICENSES_DIR)).is_ok_and(|m| m.is_dir());
if present || new_license {
// Installations from before the Windows archive carried the Visual
// C++ runtime get it too; their llama.cpp runtimes need it.
let vc_runtime = relative.parent() == Some(Path::new(VC_RUNTIME_DIR));
if present || new_license || vc_runtime {
pairs.push((staged.join(&relative), target));
}
}
Expand Down Expand Up @@ -381,6 +387,10 @@ fn sibling(target: &Path, suffix: &str) -> PathBuf {

fn stage(replacement: &Replacement) -> io::Result<()> {
let _ = fs::remove_file(&replacement.staged);
// The Visual C++ runtime can be new to an installation, folder and all.
if let Some(folder) = replacement.staged.parent() {
fs::create_dir_all(folder)?;
}
fs::copy(&replacement.source, &replacement.staged)?;
#[cfg(unix)]
{
Expand Down Expand Up @@ -726,6 +736,32 @@ mod tests {
}
}

#[test]
fn adds_the_visual_cpp_runtime_to_older_installations() {
for style in BOTH {
let temp = tempfile::tempdir().unwrap();
let staged = update(temp.path());
write(&staged.join("vc-runtime/msvcp140.dll"), "new runtime");
write(&staged.join("vc-runtime/vcruntime140.dll"), "new runtime");
let older = temp.path().join("older");
write(&older.join(APP_BINARY), "old app");
write(&older.join(CLI_BINARY), "old cli");
let current = temp.path().join("current");
write(&current.join(APP_BINARY), "old app");
write(&current.join(CLI_BINARY), "old cli");
write(&current.join("vc-runtime/msvcp140.dll"), "old runtime");
for folder in [&older, &current] {
install(&staged, &targets(folder), style).unwrap();
assert_eq!(
names(&folder.join("vc-runtime")),
sorted(&["msvcp140.dll", "vcruntime140.dll"]),
"{style:?}"
);
assert_eq!(read(&folder.join("vc-runtime/msvcp140.dll")), "new runtime");
}
}
}

#[test]
fn a_missing_binary_in_the_update_changes_nothing() {
let temp = tempfile::tempdir().unwrap();
Expand Down
4 changes: 3 additions & 1 deletion LinuxWindows/docs/cuda-validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ Environment problems found along the way, outside the CUDA code: upstream
`llama-server` needs `libgomp.so.1` (OpenMP) on Linux and the Microsoft Visual
C++ 2015–2022 runtime on Windows. A minimal container and a fresh Windows
Server image had neither, so every backend, CPU included, failed to start until
they were installed.
they were installed. The Linux packages now depend on libgomp, the Windows
archive and installer carry the Visual C++ runtime for each `llama-server.exe`,
and a start that still fails names what to install.

## RTX 5090: review fixes, older driver and matched timings — 2026-10-22

Expand Down
1 change: 1 addition & 0 deletions LinuxWindows/packaging/aur/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ these files. namcap's remaining warnings on the built package are expected:
| --- | --- |
| `Unused shared library '/usr/lib64/ld-linux-x86-64.so.2'` | Both binaries import `__tls_get_addr` from the loader; namcap misses it. |
| `Dependency included, but may not be needed ('vulkan-icd-loader')`, `('wayland')` | The app loads `libvulkan.so.1` and `libwayland-client.so.0` with `dlopen`, so they are not in its `NEEDED` list. |
| `Dependency included, but may not be needed ('libgomp')` | The llama.cpp runtime the app downloads links `libgomp.so.1`; the app itself doesn't. |

## Updating

Expand Down
1 change: 1 addition & 0 deletions LinuxWindows/packaging/aur/lokalbot-bin/.SRCINFO
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pkgbase = lokalbot-bin
depends = glibc>=2.39
depends = libgcc
depends = libstdc++
depends = libgomp
depends = alsa-lib
depends = libxcb
depends = libxkbcommon
Expand Down
4 changes: 3 additions & 1 deletion LinuxWindows/packaging/aur/lokalbot-bin/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ arch=('x86_64')
url='https://www.lokalbot.com'
license=('GPL-3.0-only' 'AGPL-3.0-only')
# The binaries need glibc 2.39. They link ALSA, xcb and xkbcommon, and load
# Vulkan and the Wayland client at run time.
# Vulkan and the Wayland client at run time. The llama.cpp runtime the app
# downloads links libgomp (OpenMP).
depends=(
'glibc>=2.39'
'libgcc'
'libstdc++'
'libgomp'
'alsa-lib'
'libxcb'
'libxkbcommon'
Expand Down
5 changes: 4 additions & 1 deletion LinuxWindows/packaging/windows/lokalbot.iss
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ Source: "{#SourceDir}\lokalbot-cli.exe"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#SourceDir}\LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#SourceDir}\THIRD_PARTY_NOTICES.md"; DestDir: "{app}"; Flags: ignoreversion
Source: "{#SourceDir}\LICENSES\*"; DestDir: "{app}\LICENSES"; Flags: ignoreversion recursesubdirs
; The Visual C++ runtime LokalBot copies beside llama-server.exe, which needs it.
Source: "{#SourceDir}\vc-runtime\*"; DestDir: "{app}\vc-runtime"; Flags: ignoreversion

[Icons]
; LokalBot looks for this exact shortcut to show notifications under its own name.
Expand All @@ -83,5 +85,6 @@ Root: HKCU; Subkey: "Software\Classes\AppUserModelId\{#AppId}"; Flags: dontcreat
[UninstallDelete]
; Old executables an in-place update renamed aside.
Type: files; Name: "{app}\*.old"
; License texts an in-place update added.
; License texts and the Visual C++ runtime an in-place update added.
Type: filesandordirs; Name: "{app}\LICENSES"
Type: filesandordirs; Name: "{app}\vc-runtime"
6 changes: 4 additions & 2 deletions LinuxWindows/scripts/ci/check-windows-installer.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $log = Join-Path $tmp 'lokalbot-setup.log'
$p = Start-Process (Resolve-Path $Setup).Path -ArgumentList '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', "/LOG=$log" -Wait -PassThru
if ($p.ExitCode -ne 0) { Get-Content $log -ErrorAction SilentlyContinue; throw "setup exited with $($p.ExitCode)" }

foreach ($file in 'lokalbot.exe', 'lokalbot-cli.exe', 'LICENSE.txt', 'THIRD_PARTY_NOTICES.md', 'LICENSES\rust-crates.md', 'LICENSES\Apache-2.0.txt') {
foreach ($file in 'lokalbot.exe', 'lokalbot-cli.exe', 'LICENSE.txt', 'THIRD_PARTY_NOTICES.md', 'LICENSES\rust-crates.md', 'LICENSES\Apache-2.0.txt', 'vc-runtime\msvcp140.dll', 'vc-runtime\vcruntime140.dll', 'vc-runtime\vcruntime140_1.dll') {
if (-not (Test-Path (Join-Path $app $file))) { throw "the installer did not install $file" }
}
if (-not (Test-Path $shortcut)) { throw 'no Start menu shortcut' }
Expand All @@ -31,14 +31,16 @@ if ($LASTEXITCODE -ne 0) { throw "lokalbot-cli --help exited with $LASTEXITCODE"

# An in-place update can add license texts the installer didn't install.
Set-Content -Path (Join-Path $app 'LICENSES\added-by-update.txt') -Value 'added'
Set-Content -Path (Join-Path $app 'vc-runtime\added-by-update.dll') -Value 'added'

$uninstaller = $entry.UninstallString.Trim('"')
Start-Process $uninstaller -ArgumentList '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART' -Wait | Out-Null
# The uninstaller finishes from a copy of itself in TEMP; wait for it.
$deadline = (Get-Date).AddSeconds(60)
$left = { (Test-Path (Join-Path $app 'lokalbot.exe')) -or (Test-Path (Join-Path $app 'LICENSES')) }
$left = { (Test-Path (Join-Path $app 'lokalbot.exe')) -or (Test-Path (Join-Path $app 'LICENSES')) -or (Test-Path (Join-Path $app 'vc-runtime')) }
while ((& $left) -and (Get-Date) -lt $deadline) { Start-Sleep -Seconds 1 }
if (Test-Path (Join-Path $app 'lokalbot.exe')) { throw 'uninstalling left lokalbot.exe behind' }
if (Test-Path $shortcut) { throw 'uninstalling left the Start menu shortcut behind' }
if (Test-Path (Join-Path $app 'LICENSES')) { throw 'uninstalling left the LICENSES folder behind' }
if (Test-Path (Join-Path $app 'vc-runtime')) { throw 'uninstalling left the vc-runtime folder behind' }
Write-Output 'Install and uninstall checks passed'
5 changes: 5 additions & 0 deletions LinuxWindows/scripts/package-linux-distros.sh
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ EOF
fi
# The binaries need glibc 2.39 (built on Ubuntu 24.04). The app links ALSA,
# xcb and xkbcommon and loads Vulkan and the Wayland client at run time.
# The llama.cpp runtime it downloads (llama-server) links the GCC OpenMP
# runtime, libgomp.so.1, which minimal installs lack.
# Arch's gcc-libs is a meta package of every GCC runtime; namcap asks for
# libgcc and libstdc++, and for hicolor-icon-theme, which owns the icon folders.
# System audio uses PulseAudio or PipeWire's PulseAudio server; the
Expand All @@ -134,6 +136,7 @@ overrides:
- libc6 (>= 2.39)
- libstdc++6
- libgcc-s1
- libgomp1
- libasound2t64 | libasound2
- libxcb1
- libxkbcommon0
Expand All @@ -156,6 +159,7 @@ overrides:
depends:
- libc.so.6(GLIBC_2.39)(64bit)
- libstdc++.so.6()(64bit)
- libgomp.so.1()(64bit)
- libasound.so.2()(64bit)
- libxcb.so.1()(64bit)
- libxkbcommon.so.0()(64bit)
Expand All @@ -172,6 +176,7 @@ overrides:
- glibc>=2.39
- libgcc
- libstdc++
- libgomp
- alsa-lib
- libxcb
- libxkbcommon
Expand Down
26 changes: 26 additions & 0 deletions LinuxWindows/scripts/package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,27 @@
# Builds release binaries and packs them for the current platform into dist/.
# Linux: LokalBot-<version>-linux-x86_64.tar.gz (with install.sh)
# Windows (Git Bash or CI): LokalBot-<version>-windows-x86_64.zip
#
# VC_REDIST_DIR (Windows): a Microsoft.VC14x.CRT folder to take the Visual C++
# runtime from, instead of the newest Visual Studio with the C++ build tools.
set -euo pipefail
cd "$(dirname "$0")/.."
VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -1)
# Self-hosted CI runners keep a warm target directory elsewhere.
TARGET=${CARGO_TARGET_DIR:-target}

# The x64 Microsoft.VC14x.CRT folder of the newest Visual Studio (or Build
# Tools) with the C++ build tools, at its default redistributable version.
vc_redist_dir() {
local vswhere vs version
vswhere=$(cygpath -u 'C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe')
vs=$("$vswhere" -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath | tr -d '\r')
[ -n "$vs" ] || { echo "vswhere found no Visual Studio with the C++ build tools; set VC_REDIST_DIR." >&2; return 1; }
vs=$(cygpath -u "$vs")
version=$(tr -d '[:space:]' < "$vs/VC/Auxiliary/Build/Microsoft.VCRedistVersion.default.txt")
ls -d "$vs/VC/Redist/MSVC/$version/x64/Microsoft.VC"*.CRT | sort -V | tail -1
}

cargo build --release --locked -p lokalbot-app -p lokalbot-cli
mkdir -p dist
case "$(uname -s)" in
Expand All @@ -32,6 +48,16 @@ case "$(uname -s)" in
STAGE="dist/$NAME"
rm -rf "$STAGE" && mkdir -p "$STAGE"
cp "$TARGET/release/lokalbot.exe" "$TARGET/release/lokalbot-cli.exe" "$STAGE/"
# llama.cpp's Windows builds import the Visual C++ runtime, which Windows
# lacks until something installs the Visual C++ Redistributable. Ship the
# build machine's copy, unmodified (Distributable Code under the Visual
# Studio license terms); LokalBot copies it beside each llama-server.exe
# (lokalbot-ai's runtime.rs).
CRT=${VC_REDIST_DIR:-$(vc_redist_dir)}
mkdir -p "$STAGE/vc-runtime"
for dll in msvcp140.dll vcruntime140.dll vcruntime140_1.dll; do
cp "$CRT/$dll" "$STAGE/vc-runtime/"
done
cp ../LICENSE "$STAGE/LICENSE.txt" 2>/dev/null || true
cp ../THIRD_PARTY_NOTICES.md "$STAGE/"
cp -R ../LICENSES "$STAGE/LICENSES"
Expand Down
17 changes: 16 additions & 1 deletion THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,22 @@ On Linux, `freetype-sys` compiles its bundled FreeType (FreeType License or
GPL-2.0-or-later) only when the build machine has no FreeType of its own; the
release builds contain no FreeType code. Libraries the programs load from the
system at run time (the C and C++ runtimes, ALSA, X11 and Wayland libraries,
the Vulkan loader) are not distributed with LokalBot.
the Vulkan loader) are not distributed with LokalBot, apart from the Visual C++
runtime below.

### Microsoft Visual C++ runtime (Windows)

The Windows archive and installer include `msvcp140.dll`, `vcruntime140.dll`
and `vcruntime140_1.dll` from the Microsoft Visual C++ Redistributable,
unmodified, in the `vc-runtime` folder. LokalBot's own programs link the C
runtime statically and don't use them: it copies them beside each
`llama-server.exe` it downloads, so llama.cpp also runs where the Visual C++
Redistributable isn't installed. They are Copyright (c) Microsoft Corporation
and are distributed as Distributable Code under the Microsoft Visual Studio
license terms (https://learn.microsoft.com/visualstudio/releases/2022/redistribution),
not under LokalBot's license. Anyone who distributes them further must keep
them unmodified and bind the people they distribute them to under terms that
protect them at least as much as Microsoft's own terms.

### Assets compiled into the app

Expand Down
Loading