Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

fix(linux): keep the Vulkan loader out of the AppImage (#9178)

James Dam0d6ed7841577
diff --git a/src-tauri/build-utils/buildAppImage.sh b/src-tauri/build-utils/buildAppImage.sh
index 816db5557..e61327801 100755
--- a/src-tauri/build-utils/buildAppImage.sh
+++ b/src-tauri/build-utils/buildAppImage.sh
@@ -32,6 +32,16 @@ if [ ! -f "$DIR_ICON" ] || [[ "$(readlink "$DIR_ICON")" == /* ]]; then
exit 1
fi
+# The host's Vulkan loader and NVIDIA driver have to be the ones that run; a copy
+# from the build host crashed every model load on Arch (#9173). shim-linuxdeploy.sh
+# excludes them, so finding one here means that exclusion stopped applying.
+HOST_LIBS=$(find "$APP_DIR" \( -name 'libvulkan.so*' -o -name 'libcuda.so*' \) 2>/dev/null)
+if [ -n "$HOST_LIBS" ]; then
+ echo "$APP_DIR bundles libraries that must come from the user's system:"
+ echo "$HOST_LIBS"
+ exit 1
+fi
+
# remove appimage generated by tauri build
APP_IMAGE=./src-tauri/target/release/bundle/appimage/$(ls ./src-tauri/target/release/bundle/appimage/ | grep AppImage | head -1)
echo $APP_IMAGE
diff --git a/src-tauri/build-utils/shim-linuxdeploy.sh b/src-tauri/build-utils/shim-linuxdeploy.sh
index c32ea5d06..52ac8bc7c 100755
--- a/src-tauri/build-utils/shim-linuxdeploy.sh
+++ b/src-tauri/build-utils/shim-linuxdeploy.sh
@@ -33,6 +33,16 @@ ln -s "$LINUXDEPLOY" "$SYMLINK"
# the documented fallback and costs a little disk on a host that has FUSE.
export APPIMAGE_EXTRACT_AND_RUN=1
+# Libraries that must come from the user's system, never the AppImage. linuxdeploy
+# splits this on ';' and matches each entry as a glob (src/core/appdir.cpp).
+#
+# libggml-vulkan.so needs the Vulkan loader, which reads the host's ICD manifests
+# and loads the host's GPU drivers. A loader copied from the build host can crash
+# against a newer driver stack: on Arch, 0.8.5's bundled libvulkan.so.1 segfaulted
+# on every model load (#9173). Nothing else links it, and ggml loads the Vulkan
+# backend at runtime, so a host without a loader only loses that one backend.
+EXCLUDED_LIBRARIES="libvulkan.so*"
+
# libggml-cuda.so needs libcuda.so.1, which comes with the NVIDIA driver, not the
# toolkit, and linuxdeploy fails on any dependency it cannot resolve. Resolve it
# to the toolkit's stub, and exclude it so the stub never lands in the AppImage:
@@ -42,7 +52,9 @@ if [ -f "$CUDA_STUB" ]; then
mkdir -p "$XDG_CACHE_HOME/cuda-stubs"
cp "$CUDA_STUB" "$XDG_CACHE_HOME/cuda-stubs/libcuda.so.1"
export LD_LIBRARY_PATH="$XDG_CACHE_HOME/cuda-stubs${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
- export LINUXDEPLOY_EXCLUDED_LIBRARIES="libcuda.so.1"
+ EXCLUDED_LIBRARIES="$EXCLUDED_LIBRARIES;libcuda.so.1"
fi
+export LINUXDEPLOY_EXCLUDED_LIBRARIES="${LINUXDEPLOY_EXCLUDED_LIBRARIES:+$LINUXDEPLOY_EXCLUDED_LIBRARIES;}$EXCLUDED_LIBRARIES"
+
"$@"
\ No newline at end of file