git: 7c5c49f07e5b - main - misc/ollama: update 0.32.5 → 0.34.0

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Thu, 10 Sep 2026 20:07:05 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7c5c49f07e5bf56052c3c27c0c8c639053792e94

commit 7c5c49f07e5bf56052c3c27c0c8c639053792e94
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2026-09-10 16:23:27 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2026-09-10 20:05:48 +0000

    misc/ollama: update 0.32.5 → 0.34.0
    
    MLX image generation is now officially disabled hy the upstream
    with the promise that it will come back once issues are resolved.
    
    The VULKAN option is now enabled again since compilation issues
    were resolved.
    
    ChangeLog: https://github.com/ollama/ollama/releases/tag/v0.34.0
---
 misc/ollama/Makefile                               | 55 +++++++++++++---------
 misc/ollama/distinfo                               | 32 +++++++------
 misc/ollama/files/patch-CMakeLists.txt             | 13 -----
 misc/ollama/files/patch-cmake_mlx_CMakeLists.txt   | 27 +++++++++++
 misc/ollama/files/patch-x_imagegen_memory.go       | 11 -----
 misc/ollama/files/patch-x_imagegen_mlx_mlx.go      | 50 --------------------
 .../files/patch-x_imagegen_models_zimage_vae.go    | 35 --------------
 misc/ollama/files/patch-x_imagegen_server.go       | 13 -----
 misc/ollama/files/patch-x_mlxrunner_client.go      |  4 +-
 .../files/patch-x_mlxrunner_mlx_CMakeLists.txt     | 30 ++++++++++++
 misc/ollama/files/patch-x_mlxrunner_mlx_dynamic.go | 10 ++--
 11 files changed, 114 insertions(+), 166 deletions(-)

diff --git a/misc/ollama/Makefile b/misc/ollama/Makefile
index aba38aaf028e..7c41818fd3c1 100644
--- a/misc/ollama/Makefile
+++ b/misc/ollama/Makefile
@@ -1,7 +1,6 @@
 PORTNAME=	ollama
 DISTVERSIONPREFIX=	v
-DISTVERSION=	0.32.5
-PORTREVISION=	3
+DISTVERSION=	0.34.0
 CATEGORIES=	misc # machine-learning
 
 MAINTAINER=	yuri@FreeBSD.org
@@ -27,12 +26,16 @@ USES=		cmake:indirect go:1.26+,modules localbase pkgconfig
 USE_LDCONFIG=	${PREFIX}/lib/ollama ${PREFIX}/lib/ollama/vulkan
 USE_RC_SUBR=	ollama
 
+USE_GITHUB=	nodefault
+GH_TUPLE=	mlc-ai:xgrammar:v0.2.5:xgrammar/xgrammar
+
 GO_MODULE=	github.com/yurivict/${PORTNAME} # fork with FreeBSD patches
 GO_TARGET=	.
 GO_ENV+=	CGO_CXXFLAGS="${CXXFLAGS}"
 
-LLAMA_CPP_VERSION=	b10091	# from the LLAMA_CPP_VERSION file in the llama.cpp repo
-GGML_SO_VERSION=	0.17.0	# tied to LLAMA_CPP_VERSION; update when llama.cpp changes
+LLAMA_CPP_VERSION=	b10760	# from the LLAMA_CPP_VERSION file in the llama.cpp repo
+LLAMA_CPP_SO_VERSION=	0.3.0
+GGML_SO_VERSION=	0.22.0	# tied to LLAMA_CPP_VERSION; update when llama.cpp changes
 MLX_CORE_VERSION=	0.31.2
 MLX_C_VERSION=		fba4470b89073180056c9ea46c443051375f7399
 JSON_VERSION=		3.11.3
@@ -47,7 +50,7 @@ PLIST_FILES=	bin/${PORTNAME} \
 
 OPTIONS_GROUP=		BACKENDS
 OPTIONS_GROUP_BACKENDS=	CPU VULKAN MLX
-OPTIONS_DEFAULT=	CPU MLX
+OPTIONS_DEFAULT=	CPU VULKAN MLX
 
 CPU_DESC=		Build CPU backend shared libraries for various SIMD instruction sets
 CPU_PLIST_FILES=	lib/ollama/llama-server \
@@ -59,16 +62,16 @@ CPU_PLIST_FILES=	lib/ollama/llama-server \
 			lib/ollama/libggml.so.0 \
 			lib/ollama/libggml.so.${GGML_SO_VERSION} \
 			lib/ollama/libllama-common.so \
-			lib/ollama/libllama-common.so.0 \
-			lib/ollama/libllama-common.so.0.0.${LLAMA_CPP_VERSION:S/b//} \
+			lib/ollama/libllama-common.so.${LLAMA_CPP_SO_VERSION:R:R} \
+			lib/ollama/libllama-common.so.${LLAMA_CPP_SO_VERSION} \
 			lib/ollama/libllama-quantize-impl.so \
 			lib/ollama/libllama-server-impl.so \
 			lib/ollama/libllama.so \
-			lib/ollama/libllama.so.0 \
-			lib/ollama/libllama.so.0.0.${LLAMA_CPP_VERSION:S/b//} \
+			lib/ollama/libllama.so.${LLAMA_CPP_SO_VERSION:R:R} \
+			lib/ollama/libllama.so.${LLAMA_CPP_SO_VERSION} \
 			lib/ollama/libmtmd.so \
-			lib/ollama/libmtmd.so.0 \
-			lib/ollama/libmtmd.so.0.0.${LLAMA_CPP_VERSION:S/b//}
+			lib/ollama/libmtmd.so.${LLAMA_CPP_SO_VERSION:R:R} \
+			lib/ollama/libmtmd.so.${LLAMA_CPP_SO_VERSION}
 .if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
 CPU_PLIST_FILES+=	lib/ollama/libggml-cpu-alderlake.so \
 			lib/ollama/libggml-cpu-cannonlake.so \
@@ -92,7 +95,6 @@ VULKAN_BUILD_DEPENDS=	glslc:graphics/shaderc \
 			${LOCALBASE}/share/cmake/SPIRV-Headers/SPIRV-HeadersConfig.cmake:graphics/spirv-headers
 VULKAN_LIB_DEPENDS=	libvulkan.so:graphics/vulkan-loader
 VULKAN_PLIST_FILES=	lib/ollama/vulkan/libggml-vulkan.so
-VULKAN_BROKEN=		shaderc doesn't support latest features of glslc, see https://github.com/google/shaderc/issues/1590
 
 MLX_DESC=		Build MLX backend for image generation (CPU)
 MLX_BUILD_DEPENDS=	${LOCALBASE}/lib/cmake/fmt/fmt-config.cmake:devel/libfmt
@@ -146,6 +148,9 @@ post-patch:
 	# update version in version.go
 	@${REINPLACE_CMD} -e 's|var Version string = "0.0.0"|var Version string = "${PORTVERSION}"|g' \
 		${WRKSRC}/version/version.go
+	# expand WRKSRC in cmake/mlx/CMakeLists.txt
+	@${REINPLACE_CMD} -e 's|%%WRKSRC%%|${WRKSRC}|g' \
+		${WRKSRC}/cmake/mlx/CMakeLists.txt
 
 pre-build-CPU-on:
 	@${MKDIR} ${WRKSRC}/build && \
@@ -179,6 +184,12 @@ post-patch-MLX-on:
 		${WRKDIR}/mlx-${MLX_CORE_VERSION}/mlx/backend/no_gpu/allocator.cpp.new && \
 		${MV} ${WRKDIR}/mlx-${MLX_CORE_VERSION}/mlx/backend/no_gpu/allocator.cpp.new \
 		${WRKDIR}/mlx-${MLX_CORE_VERSION}/mlx/backend/no_gpu/allocator.cpp
+	# FreeBSD fix for mlx-c: Use pre-downloaded mlx source via environment variable
+	@${AWK} '/if\(MLX_C_USE_SYSTEM_MLX\)/{print "# FreeBSD: Use pre-downloaded mlx source if OLLAMA_MLX_SOURCE is set";print "if(DEFINED ENV{OLLAMA_MLX_SOURCE})";print "  FetchContent_Declare(";print "    mlx";print "    SOURCE_DIR \"$$ENV{OLLAMA_MLX_SOURCE}\"";print "  )";print "  FetchContent_MakeAvailable(mlx)";print "elseif(MLX_C_USE_SYSTEM_MLX)";next}1' \
+		${WRKDIR}/mlx-c-${MLX_C_VERSION}/CMakeLists.txt > \
+		${WRKDIR}/mlx-c-${MLX_C_VERSION}/CMakeLists.txt.new && \
+		${MV} ${WRKDIR}/mlx-c-${MLX_C_VERSION}/CMakeLists.txt.new \
+		${WRKDIR}/mlx-c-${MLX_C_VERSION}/CMakeLists.txt
 
 pre-build-MLX-on:
 	@${MKDIR} ${WRKSRC}/build-mlx && \
@@ -215,23 +226,23 @@ post-install-CPU-on:
 	${LN} -sf libggml.so.0 \
 		${STAGEDIR}${PREFIX}/lib/ollama/libggml.so
 	# versioned libllama-common
-	${INSTALL_LIB} ${WRKSRC}/build/lib/ollama/libllama-common.so.0.0.${LLAMA_CPP_VERSION:S/b//} \
+	${INSTALL_LIB} ${WRKSRC}/build/lib/ollama/libllama-common.so.${LLAMA_CPP_SO_VERSION} \
 		${STAGEDIR}${PREFIX}/lib/ollama/
-	${LN} -sf libllama-common.so.0.0.${LLAMA_CPP_VERSION:S/b//} \
-		${STAGEDIR}${PREFIX}/lib/ollama/libllama-common.so.0
-	${LN} -sf libllama-common.so.0 \
+	${LN} -sf libllama-common.so.${LLAMA_CPP_SO_VERSION} \
+		${STAGEDIR}${PREFIX}/lib/ollama/libllama-common.so.${LLAMA_CPP_SO_VERSION:R:R}
+	${LN} -sf libllama-common.so.${LLAMA_CPP_SO_VERSION:R:R} \
 		${STAGEDIR}${PREFIX}/lib/ollama/libllama-common.so
 	# versioned libllama
-	${INSTALL_LIB} ${WRKSRC}/build/lib/ollama/libllama.so.0.0.${LLAMA_CPP_VERSION:S/b//} \
+	${INSTALL_LIB} ${WRKSRC}/build/lib/ollama/libllama.so.${LLAMA_CPP_SO_VERSION} \
 		${STAGEDIR}${PREFIX}/lib/ollama/
-	${LN} -sf libllama.so.0.0.${LLAMA_CPP_VERSION:S/b//} \
-		${STAGEDIR}${PREFIX}/lib/ollama/libllama.so.0
-	${LN} -sf libllama.so.0 \
+	${LN} -sf libllama.so.${LLAMA_CPP_SO_VERSION} \
+		${STAGEDIR}${PREFIX}/lib/ollama/libllama.so.${LLAMA_CPP_SO_VERSION:R:R}
+	${LN} -sf libllama.so.${LLAMA_CPP_SO_VERSION:R:R} \
 		${STAGEDIR}${PREFIX}/lib/ollama/libllama.so
 	# versioned libmtmd
-	${INSTALL_LIB} ${WRKSRC}/build/lib/ollama/libmtmd.so.0.0.${LLAMA_CPP_VERSION:S/b//} \
+	${INSTALL_LIB} ${WRKSRC}/build/lib/ollama/libmtmd.so.${LLAMA_CPP_SO_VERSION} \
 		${STAGEDIR}${PREFIX}/lib/ollama/
-	${LN} -sf libmtmd.so.0.0.${LLAMA_CPP_VERSION:S/b//} \
+	${LN} -sf libmtmd.so.${LLAMA_CPP_SO_VERSION} \
 		${STAGEDIR}${PREFIX}/lib/ollama/libmtmd.so.0
 	${LN} -sf libmtmd.so.0 \
 		${STAGEDIR}${PREFIX}/lib/ollama/libmtmd.so
diff --git a/misc/ollama/distinfo b/misc/ollama/distinfo
index 8903edd52625..9219340170f0 100644
--- a/misc/ollama/distinfo
+++ b/misc/ollama/distinfo
@@ -1,15 +1,17 @@
-TIMESTAMP = 1785285890
-SHA256 (go/misc_ollama/ollama-v0.32.5/b10091.tar.gz) = 37da9cfee7ae5b0c9ea4e712e0d21c8242e5e7a781c02035498efb8a21a7e329
-SIZE (go/misc_ollama/ollama-v0.32.5/b10091.tar.gz) = 35959727
-SHA256 (go/misc_ollama/ollama-v0.32.5/llama-b10091-ui.tar.gz) = 5690c3f81031adfd1f229a954506cb9017a9c281ead28c2bf450d7fdbfab3cc3
-SIZE (go/misc_ollama/ollama-v0.32.5/llama-b10091-ui.tar.gz) = 2872825
-SHA256 (go/misc_ollama/ollama-v0.32.5/v0.31.2.tar.gz) = bdb9b619f80962dd00c0bffb65e59c53f565c2b550f189a1467f8bc6089401ab
-SIZE (go/misc_ollama/ollama-v0.32.5/v0.31.2.tar.gz) = 4251596
-SHA256 (go/misc_ollama/ollama-v0.32.5/fba4470b89073180056c9ea46c443051375f7399.tar.gz) = 398d3d4c6458679dfc9061a3ba56101358279790bc038f60d1f534eac420d552
-SIZE (go/misc_ollama/ollama-v0.32.5/fba4470b89073180056c9ea46c443051375f7399.tar.gz) = 174039
-SHA256 (go/misc_ollama/ollama-v0.32.5/json.tar.xz) = d6c65aca6b1ed68e7a182f4757257b107ae403032760ed6ef121c9d55e81757d
-SIZE (go/misc_ollama/ollama-v0.32.5/json.tar.xz) = 110988
-SHA256 (go/misc_ollama/ollama-v0.32.5/v0.32.5.mod) = a67e90c190ca0c106b7db76216a29c0ec4cab2ad1bfbde49cdced90fe78193bd
-SIZE (go/misc_ollama/ollama-v0.32.5/v0.32.5.mod) = 4622
-SHA256 (go/misc_ollama/ollama-v0.32.5/v0.32.5.zip) = adb86caaee759e69dfd416f6998a65a046929f822ec189962b4a8319efafb7c7
-SIZE (go/misc_ollama/ollama-v0.32.5/v0.32.5.zip) = 30371899
+TIMESTAMP = 1789036710
+SHA256 (go/misc_ollama/ollama-v0.34.0/b10760.tar.gz) = 8986285d34f7531e84b1ee6d35c88989fc6f3cf895f60610594997b8b7bad443
+SIZE (go/misc_ollama/ollama-v0.34.0/b10760.tar.gz) = 37131759
+SHA256 (go/misc_ollama/ollama-v0.34.0/llama-b10760-ui.tar.gz) = b7f7d173c0faa6582896d2d23603c1bb2d963eedf8845db0a8399d2c1e0ce360
+SIZE (go/misc_ollama/ollama-v0.34.0/llama-b10760-ui.tar.gz) = 3081120
+SHA256 (go/misc_ollama/ollama-v0.34.0/v0.31.2.tar.gz) = bdb9b619f80962dd00c0bffb65e59c53f565c2b550f189a1467f8bc6089401ab
+SIZE (go/misc_ollama/ollama-v0.34.0/v0.31.2.tar.gz) = 4251596
+SHA256 (go/misc_ollama/ollama-v0.34.0/fba4470b89073180056c9ea46c443051375f7399.tar.gz) = 398d3d4c6458679dfc9061a3ba56101358279790bc038f60d1f534eac420d552
+SIZE (go/misc_ollama/ollama-v0.34.0/fba4470b89073180056c9ea46c443051375f7399.tar.gz) = 174039
+SHA256 (go/misc_ollama/ollama-v0.34.0/json.tar.xz) = d6c65aca6b1ed68e7a182f4757257b107ae403032760ed6ef121c9d55e81757d
+SIZE (go/misc_ollama/ollama-v0.34.0/json.tar.xz) = 110988
+SHA256 (go/misc_ollama/ollama-v0.34.0/v0.34.0.mod) = b70e409c579c9184be085ae9ab2e06b02e2426fb6781548580596ba341105527
+SIZE (go/misc_ollama/ollama-v0.34.0/v0.34.0.mod) = 4640
+SHA256 (go/misc_ollama/ollama-v0.34.0/v0.34.0.zip) = 3ffdf867ded14b264a96526e6ea86be4f4ff0e5ceca812428d7ab9e7d461e32e
+SIZE (go/misc_ollama/ollama-v0.34.0/v0.34.0.zip) = 31535194
+SHA256 (go/misc_ollama/ollama-v0.34.0/mlc-ai-xgrammar-v0.2.5_GH0.tar.gz) = 7cf5e69ba0bc2695a9f1a97eeb4cc567aac3d644fd329e7d8072ab6f3517b777
+SIZE (go/misc_ollama/ollama-v0.34.0/mlc-ai-xgrammar-v0.2.5_GH0.tar.gz) = 1071195
diff --git a/misc/ollama/files/patch-CMakeLists.txt b/misc/ollama/files/patch-CMakeLists.txt
deleted file mode 100644
index 0d4b1cc5a0a6..000000000000
--- a/misc/ollama/files/patch-CMakeLists.txt
+++ /dev/null
@@ -1,13 +0,0 @@
---- CMakeLists.txt.orig	1979-11-30 08:00:00 UTC
-+++ CMakeLists.txt
-@@ -45,6 +45,10 @@ if(APPLE)
-     set(CMAKE_BUILD_RPATH "@loader_path")
-     set(CMAKE_INSTALL_RPATH "@loader_path")
-     set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
-+elseif(UNIX)
-+    set(CMAKE_BUILD_RPATH "$ORIGIN")
-+    set(CMAKE_INSTALL_RPATH "$ORIGIN")
-+    set(CMAKE_BUILD_WITH_INSTALL_RPATH ON)
- endif()
- 
- set(OLLAMA_BUILD_DIR ${CMAKE_BINARY_DIR}/lib/ollama)
diff --git a/misc/ollama/files/patch-cmake_mlx_CMakeLists.txt b/misc/ollama/files/patch-cmake_mlx_CMakeLists.txt
new file mode 100644
index 000000000000..7ae896a0db9e
--- /dev/null
+++ b/misc/ollama/files/patch-cmake_mlx_CMakeLists.txt
@@ -0,0 +1,27 @@
+--- cmake/mlx/CMakeLists.txt.orig	1979-11-30 08:00:00 UTC
++++ cmake/mlx/CMakeLists.txt
+@@ -63,14 +63,16 @@ set(XGRAMMAR_VERSION v0.2.5)
+ 
+ include(FetchContent)
+ set(XGRAMMAR_VERSION v0.2.5)
+-FetchContent_Declare(xgrammar
+-    GIT_REPOSITORY "https://github.com/mlc-ai/xgrammar.git"
+-    GIT_TAG ${XGRAMMAR_VERSION}
+-    GIT_SHALLOW TRUE
+-    GIT_SUBMODULES 3rdparty/dlpack
+-    # Do not add XGrammar's Python-oriented CMake project.
+-    SOURCE_SUBDIR cmake/ollama)
+-FetchContent_MakeAvailable(xgrammar)
++#FetchContent_Declare(xgrammar
++#    GIT_REPOSITORY "https://github.com/mlc-ai/xgrammar.git"
++#    GIT_TAG ${XGRAMMAR_VERSION}
++#    GIT_SHALLOW TRUE
++#    GIT_SUBMODULES 3rdparty/dlpack
++#    # Do not add XGrammar's Python-oriented CMake project.
++#    SOURCE_SUBDIR cmake/ollama)
++#FetchContent_MakeAvailable(xgrammar)
++
++set(xgrammar_SOURCE_DIR "%%WRKSRC%%/xgrammar")
+ 
+ file(GLOB_RECURSE XGRAMMAR_SOURCES CONFIGURE_DEPENDS "${xgrammar_SOURCE_DIR}/cpp/*.cc")
+ list(FILTER XGRAMMAR_SOURCES EXCLUDE REGEX "/cpp/tvm_ffi/.*\\.cc$")
diff --git a/misc/ollama/files/patch-x_imagegen_memory.go b/misc/ollama/files/patch-x_imagegen_memory.go
deleted file mode 100644
index 86279bc6592e..000000000000
--- a/misc/ollama/files/patch-x_imagegen_memory.go
+++ /dev/null
@@ -1,11 +0,0 @@
---- x/imagegen/memory.go.orig	2026-03-12 23:02:15 UTC
-+++ x/imagegen/memory.go
-@@ -31,7 +31,7 @@ func CheckPlatformSupport() error {
- 			return fmt.Errorf("image generation on macOS requires Apple Silicon (arm64), got %s", runtime.GOARCH)
- 		}
- 		return nil
--	case "linux", "windows":
-+	case "linux", "windows", "freebsd":
- 		// Linux/Windows: CUDA support (requires mlx or cuda build)
- 		// The actual backend availability is checked at runtime
- 		return nil
diff --git a/misc/ollama/files/patch-x_imagegen_mlx_mlx.go b/misc/ollama/files/patch-x_imagegen_mlx_mlx.go
deleted file mode 100644
index 426c4529f9b1..000000000000
--- a/misc/ollama/files/patch-x_imagegen_mlx_mlx.go
+++ /dev/null
@@ -1,50 +0,0 @@
--- FreeBSD compatibility fixes for MLX image generation CGO code.
--- 1. Add FreeBSD LDFLAGS (-lc++ -ldl) required for C++ runtime and dynamic loading.
--- 2. Fall back to CPU stream in default_stream() when GPU stream is unavailable (no Metal on FreeBSD).
--- 3. Use CPU stream for safetensors loading on FreeBSD (Metal eval_gpu not implemented).
--- 4. Wrap mlx_load_safetensors with safe init mode to capture C++ exceptions as Go errors
---    instead of process exit(1), enabling proper error reporting to the user.
---- x/imagegen/mlx/mlx.go.orig	2026-06-03 07:41:51 UTC
-+++ x/imagegen/mlx/mlx.go
-@@ -4,6 +4,7 @@ package mlx
- #cgo CFLAGS: -O3 -I${SRCDIR}/../../mlxrunner/mlx/include -I${SRCDIR}
- #cgo darwin LDFLAGS: -lc++ -framework Metal -framework Foundation -framework Accelerate
- #cgo linux LDFLAGS: -lstdc++ -ldl
-+#cgo freebsd LDFLAGS: -lc++ -ldl
- #cgo windows LDFLAGS: -lstdc++
- 
- // Use generated wrappers instead of direct MLX headers
-@@ -23,6 +24,9 @@ static inline mlx_stream default_stream() {
- static inline mlx_stream default_stream() {
-     if (_default_stream.ctx == NULL) {
-         _default_stream = mlx_default_gpu_stream_new();
-+        if (_default_stream.ctx == NULL) {
-+            _default_stream = mlx_default_cpu_stream_new();
-+        }
-     }
-     return _default_stream;
- }
-@@ -1512,13 +1516,21 @@ func LoadSafetensorsNative(path string) (*SafetensorsF
- 	defer C.free(unsafe.Pointer(cPath))
- 
- 	stream := C.default_stream()
--	if runtime.GOOS == "darwin" {
-+	if runtime.GOOS == "darwin" || runtime.GOOS == "freebsd" {
- 		stream = C.cpu_stream()
- 	}
- 
- 	var arrays C.mlx_map_string_to_array
- 	var metadata C.mlx_map_string_to_string
--	if C.mlx_load_safetensors(&arrays, &metadata, cPath, stream) != 0 {
-+	C.mlx_set_safe_init_mode()
-+	ret := C.mlx_load_safetensors(&arrays, &metadata, cPath, stream)
-+	if C.mlx_had_init_error() != 0 {
-+		msg := C.GoString(C.mlx_get_init_error())
-+		C.mlx_set_default_error_mode()
-+		return nil, fmt.Errorf("failed to load safetensors: %s (mlx error: %s)", path, msg)
-+	}
-+	C.mlx_set_default_error_mode()
-+	if ret != 0 {
- 		return nil, fmt.Errorf("failed to load safetensors: %s", path)
- 	}
- 	return &SafetensorsFile{arrays: arrays, metadata: metadata}, nil
diff --git a/misc/ollama/files/patch-x_imagegen_models_zimage_vae.go b/misc/ollama/files/patch-x_imagegen_models_zimage_vae.go
deleted file mode 100644
index 1cd9e0eaa6b8..000000000000
--- a/misc/ollama/files/patch-x_imagegen_models_zimage_vae.go
+++ /dev/null
@@ -1,35 +0,0 @@
---- x/imagegen/models/zimage/vae.go.orig	1979-11-30 08:00:00 UTC
-+++ x/imagegen/models/zimage/vae.go
-@@ -332,6 +332,16 @@ func (rb *ResnetBlock2D) Forward(x *mlx.Array) *mlx.Ar
- 
- // Forward applies the ResNet block with staged evaluation
- func (rb *ResnetBlock2D) Forward(x *mlx.Array) *mlx.Array {
-+	// Keep x alive across intermediate Eval calls (cleanup() would free it otherwise).
-+	// The residual connection at the end needs the original x.
-+	wasKept := x.Kept()
-+	mlx.Keep(x)
-+	defer func() {
-+		if !wasKept {
-+			x.Free()
-+		}
-+	}()
-+
- 	var h *mlx.Array
- 
- 	// Stage 1: norm1
-@@ -461,6 +471,15 @@ func (ab *VAEAttentionBlock) Forward(x *mlx.Array) *ml
- // Input and output are in NHWC format [B, H, W, C]
- func (ab *VAEAttentionBlock) Forward(x *mlx.Array) *mlx.Array {
- 	residual := x
-+	// Keep residual alive across intermediate Eval calls.
-+	// The residual addition at stage 3 needs the original input.
-+	wasKept := residual.Kept()
-+	mlx.Keep(residual)
-+	defer func() {
-+		if !wasKept {
-+			residual.Free()
-+		}
-+	}()
- 	shape := x.Shape()
- 	B := shape[0]
- 	H := shape[1]
diff --git a/misc/ollama/files/patch-x_imagegen_server.go b/misc/ollama/files/patch-x_imagegen_server.go
deleted file mode 100644
index c9169dca35df..000000000000
--- a/misc/ollama/files/patch-x_imagegen_server.go
+++ /dev/null
@@ -1,13 +0,0 @@
---- x/imagegen/server.go.orig	2026-04-23 17:32:09 UTC
-+++ x/imagegen/server.go
-@@ -55,7 +55,9 @@ func NewServer(modelName string) (*Server, error) {
- 	return &Server{
- 		modelName: modelName,
- 		done:      make(chan error, 1),
--		client:    &http.Client{Timeout: 10 * time.Minute},
-+		// No client-level timeout: image generation on CPU can take many minutes.
-+		// Cancellation is handled via request context.
-+		client: &http.Client{},
- 	}, nil
- }
- 
diff --git a/misc/ollama/files/patch-x_mlxrunner_client.go b/misc/ollama/files/patch-x_mlxrunner_client.go
index 042b1d58222b..ae43bbc1c58a 100644
--- a/misc/ollama/files/patch-x_mlxrunner_client.go
+++ b/misc/ollama/files/patch-x_mlxrunner_client.go
@@ -1,6 +1,6 @@
---- x/mlxrunner/client.go.orig	2026-04-18 04:07:37 UTC
+--- x/mlxrunner/client.go.orig	1979-11-30 08:00:00 UTC
 +++ x/mlxrunner/client.go
-@@ -366,6 +366,8 @@ func (c *Client) Load(ctx context.Context, _ ml.System
+@@ -353,6 +353,8 @@ func (c *Client) Load(ctx context.Context, _ ml.System
  	switch runtime.GOOS {
  	case "linux":
  		libPathEnvVar = "LD_LIBRARY_PATH"
diff --git a/misc/ollama/files/patch-x_mlxrunner_mlx_CMakeLists.txt b/misc/ollama/files/patch-x_mlxrunner_mlx_CMakeLists.txt
new file mode 100644
index 000000000000..2b408deec400
--- /dev/null
+++ b/misc/ollama/files/patch-x_mlxrunner_mlx_CMakeLists.txt
@@ -0,0 +1,30 @@
+-- FreeBSD: Use pre-downloaded mlx-c source directory instead of FetchContent from Git.
+-- The port downloads mlx-c as a distfile and extracts it to WRKDIR, then passes
+-- its location via OLLAMA_MLX_C_SOURCE environment variable to the CMake build.
+--- x/mlxrunner/mlx/CMakeLists.txt.orig	1979-11-30 08:00:00 UTC
++++ x/mlxrunner/mlx/CMakeLists.txt
+@@ -23,11 +23,19 @@ string(STRIP "${MLX_C_GIT_TAG}" MLX_C_GIT_TAG)
+ file(READ "${CMAKE_CURRENT_LIST_DIR}/../../../MLX_C_VERSION" MLX_C_GIT_TAG)
+ string(STRIP "${MLX_C_GIT_TAG}" MLX_C_GIT_TAG)
+ 
+-FetchContent_Declare(
+-  mlx-c
+-  GIT_REPOSITORY "https://github.com/ml-explore/mlx-c.git"
+-  GIT_TAG ${MLX_C_GIT_TAG}
+-)
++# FreeBSD: Use pre-downloaded mlx-c source if OLLAMA_MLX_C_SOURCE is set
++if(DEFINED ENV{OLLAMA_MLX_C_SOURCE})
++  FetchContent_Declare(
++    mlx-c
++    SOURCE_DIR "$ENV{OLLAMA_MLX_C_SOURCE}"
++  )
++else()
++  FetchContent_Declare(
++    mlx-c
++    GIT_REPOSITORY "https://github.com/ml-explore/mlx-c.git"
++    GIT_TAG ${MLX_C_GIT_TAG}
++  )
++endif()
+ 
+ FetchContent_MakeAvailable(mlx-c)
+ 
diff --git a/misc/ollama/files/patch-x_mlxrunner_mlx_dynamic.go b/misc/ollama/files/patch-x_mlxrunner_mlx_dynamic.go
index 76e6d0bec723..7ca8c2caff6c 100644
--- a/misc/ollama/files/patch-x_mlxrunner_mlx_dynamic.go
+++ b/misc/ollama/files/patch-x_mlxrunner_mlx_dynamic.go
@@ -1,15 +1,15 @@
---- x/mlxrunner/mlx/dynamic.go.orig	2026-04-09 01:42:19 UTC
+--- x/mlxrunner/mlx/dynamic.go.orig	1979-11-30 08:00:00 UTC
 +++ x/mlxrunner/mlx/dynamic.go
-@@ -83,7 +83,7 @@ func libOllamaRoots() []string {
- 		case "darwin":
+@@ -98,7 +98,7 @@ func libOllamaRoots() []string {
  			roots = append(roots, filepath.Join(exeDir, "lib", "ollama"))
+ 			roots = append(roots, filepath.Join(exeDir, "..", "lib", "ollama"))
  			roots = append(roots, exeDir) // app bundle: Contents/Resources/
 -		case "linux":
 +		case "linux", "freebsd":
  			roots = append(roots, filepath.Join(exeDir, "..", "lib", "ollama"))
  		case "windows":
  			roots = append(roots, filepath.Join(exeDir, "lib", "ollama"))
-@@ -143,7 +143,7 @@ func prependLibraryPath(dir string) {
+@@ -175,7 +175,7 @@ func prependLibraryPath(dir string) {
  	switch runtime.GOOS {
  	case "darwin":
  		envVar = "DYLD_LIBRARY_PATH"
@@ -18,7 +18,7 @@
  		envVar = "LD_LIBRARY_PATH"
  	default:
  		return
-@@ -157,7 +157,7 @@ func init() {
+@@ -189,7 +189,7 @@ func init() {
  
  func init() {
  	switch runtime.GOOS {