From def5a0085e8b8a09352ec75eb6ee37167d4b7180 Mon Sep 17 00:00:00 2001 From: localai-org-maint-bot Date: Sun, 4 Oct 2026 08:47:32 +0200 Subject: [PATCH] fix(packaging): skip Linux GPU libraries on Darwin (#12466) Return before initializing Linux library helpers on macOS. The system Bash lacks associative arrays, and Metal uses system frameworks. Assisted-by: Codex:gpt-6 Co-authored-by: localai-org-maint-bot <306269227+localai-org-maint-bot@users.noreply.github.com> --- scripts/build/package-gpu-libs-darwin_test.sh | 19 +++++++++++++++++++ scripts/build/package-gpu-libs.sh | 10 ++++++++++ 2 files changed, 29 insertions(+) create mode 100644 scripts/build/package-gpu-libs-darwin_test.sh diff --git a/scripts/build/package-gpu-libs-darwin_test.sh b/scripts/build/package-gpu-libs-darwin_test.sh new file mode 100644 index 000000000..2afbb34ae --- /dev/null +++ b/scripts/build/package-gpu-libs-darwin_test.sh @@ -0,0 +1,19 @@ +#!/bin/bash +# Darwin uses system GPU frameworks and ships Bash 3.2 without associative arrays. +set -euo pipefail +SCRIPT="$(dirname "$(realpath "$0")")/package-gpu-libs.sh" +WORK=$(mktemp -d) +trap 'rm -rf "$WORK"' EXIT +uname() { echo Darwin; } +declare() { + if [[ "${1:-}" == -A ]]; then + echo 'Bash 3.2 does not support declare -A' >&2 + return 2 + fi + builtin declare "$@" +} +export BUILD_TYPE=metal +source "$SCRIPT" "$WORK/lib" +package_gpu_libs +test -z "$(find "$WORK" -type f -print)" +echo 'PASS: Darwin does not load the Linux GPU packager' diff --git a/scripts/build/package-gpu-libs.sh b/scripts/build/package-gpu-libs.sh index d2d354123..d46e1ddaa 100755 --- a/scripts/build/package-gpu-libs.sh +++ b/scripts/build/package-gpu-libs.sh @@ -15,6 +15,16 @@ set -e +# macOS uses system GPU frameworks; this packager handles Linux ELF libraries. +# Return before Bash 3.2 encounters the associative arrays used below. +if [[ "$(uname -s)" == Darwin ]]; then + package_gpu_libs() { + echo "Detected Darwin; no Linux GPU libraries to package" + } + export -f package_gpu_libs + return 0 2>/dev/null || exit 0 +fi + TARGET_LIB_DIR="${1:-./lib}" # Create target directory if it doesn't exist