ollama: 0.30.3

This commit is contained in:
i0ntempest
2026-06-04 12:37:00 +10:00
parent bf37d1e19d
commit c5de1218aa
4 changed files with 90 additions and 17 deletions
+18 -5
View File
@@ -3,7 +3,7 @@
PortSystem 1.0
PortGroup golang 1.0
go.setup github.com/ollama/ollama 0.24.0 v
go.setup github.com/ollama/ollama 0.30.3 v
github.tarball_from archive
revision 0
@@ -17,18 +17,28 @@ description ${name} runs and manages LLMs
long_description Get up and running with large language models easily
homepage https://ollama.com
checksums rmd160 c9f8275ea49475952a743247f669c5ad7203675a \
sha256 a97e4a545cb08ed0343f97dc964be49f707b8404f1c2e29ec1338ec96b556eb2 \
size 28755125
checksums rmd160 ed325d04cd266ad4dd482d7c4883254d76cd7f1f \
sha256 22613288dd3fda730ec6910febf28f73dcfc54d9b6b0965b6b747856668ad6ba \
size 27770211
# See https://github.com/ollama/ollama/pull/6854
patchfiles-append patch-NO_MMAP_ENV.diff
# See https://github.com/ollama/ollama/pull/14201
patchfiles-append patch-14201.diff
patch.args -p1
post-patch {
# Add ${prefix}/lib to libOllamaRoots (candidate directories for MLX dynamic libraries)
# Replacing binary path since we're not creating a bundle
reinplace "s|roots, exeDir|roots, filepath.FromSlash(\"${prefix}/lib\")|" ${worksrcpath}/x/mlxrunner/mlx/dynamic.go
# Force system installed mlx-c
delete ${worksrcpath}/x/mlxrunner/mlx/include/mlx
ln -s ${prefix}/include/mlx/ ${worksrcpath}/x/mlxrunner/mlx/include/mlx
reinplace "s|/opt/local|${prefix}|g" ${worksrcpath}/x/imagegen/mlx/generate_wrappers.go
}
pre-build {
system -W ${worksrcpath} "${build.env} ${prefix}/bin/go generate -tags=mlx ./x/imagegen/mlx ./x/mlxrunner/mlx"
}
go.offline_build no
@@ -102,11 +112,14 @@ variant completion description "Install bash completion for ${name}" {
variant mlx description "Support acceleration with Apple's MLX library" {
depends_lib-append port:mlx-c
build.post_args-append \
-tags=mlx
}
platform darwin arm {
default_variants-append \
+mlx
+mlx
}
default_variants-append \
+1
View File
@@ -8,3 +8,4 @@ OLLAMA_MODELS=@@MODELS_PATH@@
#OLLAMA_KEEP_ALIVE=15m
#OLLAMA_KV_CACHE_TYPE=q8_0
#OLLAMA_NO_MMAP=1
#OLLAMA_DEBUG=1
+61
View File
@@ -0,0 +1,61 @@
diff --git a/x/imagegen/mlx/generate_wrappers.go b/x/imagegen/mlx/generate_wrappers.go
index a55def02b0b..a1c15008871 100644
--- a/x/imagegen/mlx/generate_wrappers.go
+++ b/x/imagegen/mlx/generate_wrappers.go
@@ -24,8 +24,15 @@ type Function struct {
}
func findHeaders(directory string) ([]string, error) {
+ // Resolve symlinks so WalkDir can traverse symlinked directories
+ // (e.g., Homebrew's /opt/homebrew/include/mlx/c -> Cellar/...)
+ resolved, err := filepath.EvalSymlinks(directory)
+ if err != nil {
+ return nil, err
+ }
+
var headers []string
- err := filepath.WalkDir(directory, func(path string, d fs.DirEntry, err error) error {
+ err = filepath.WalkDir(resolved, func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
@@ -385,13 +392,33 @@ func main() {
outputImpl = outputHeader[:len(outputHeader)-2] + ".c"
}
- // Check if header directory exists
+ // If the provided header directory doesn't exist (e.g., no cmake build),
+ // try to find system-installed mlx-c headers. This allows distribution
+ // builds (Homebrew, MacPorts) to regenerate wrappers against their
+ // installed mlx-c version without requiring cmake.
if _, err := os.Stat(headerDir); os.IsNotExist(err) {
- fmt.Fprintf(os.Stderr, "ERROR: MLX-C headers directory not found at: %s\n\n", headerDir)
- fmt.Fprintf(os.Stderr, "Please run CMake first to download MLX-C dependencies:\n")
- fmt.Fprintf(os.Stderr, " cmake -B build\n\n")
- fmt.Fprintf(os.Stderr, "The CMake build will download and extract MLX-C headers needed for wrapper generation.\n")
- os.Exit(1)
+ candidates := []string{
+ "/opt/homebrew/include/mlx/c", // Homebrew on Apple Silicon
+ "/usr/local/include/mlx/c", // Homebrew on Intel, manual installs
+ "/opt/local/include/mlx/c", // MacPorts
+ }
+ found := false
+ for _, path := range candidates {
+ if info, statErr := os.Stat(path); statErr == nil && info.IsDir() {
+ fmt.Fprintf(os.Stderr, "MLX-C headers not at %s, using system headers: %s\n", headerDir, path)
+ headerDir = path
+ found = true
+ break
+ }
+ }
+ if !found {
+ fmt.Fprintf(os.Stderr, "ERROR: MLX-C headers not found at: %s\n\n", headerDir)
+ fmt.Fprintf(os.Stderr, "Either run CMake to fetch headers:\n")
+ fmt.Fprintf(os.Stderr, " cmake -B build\n\n")
+ fmt.Fprintf(os.Stderr, "Or install mlx-c:\n")
+ fmt.Fprintf(os.Stderr, " brew install mlx-c\n")
+ os.Exit(1)
+ }
}
fmt.Fprintf(os.Stderr, "Parsing MLX-C headers from: %s\n", headerDir)
+10 -12
View File
@@ -18,15 +18,13 @@
"OLLAMA_ORIGINS": {"OLLAMA_ORIGINS", AllowedOrigins(), "A comma separated list of allowed origins"},
"OLLAMA_SCHED_SPREAD": {"OLLAMA_SCHED_SPREAD", SchedSpread(), "Always schedule model across all GPUs"},
--- a/llm/server.go
+++ b/llm/server.go
@@ -685,7 +685,8 @@
// Linux with a model larger than free space, mmap leads to thrashing
// For CPU loads we want the memory to be allocated, not FS cache
totalSize, _ := s.MemorySize()
- if (runtime.GOOS == "windows" && len(gpus) > 0 && gpus[0].Library == "CUDA" && s.options.UseMMap == nil) ||
+ if envconfig.NoMMap() ||
+ (runtime.GOOS == "windows" && len(gpus) > 0 && gpus[0].Library == "CUDA" && s.options.UseMMap == nil) ||
(runtime.GOOS == "linux" && systemInfo.FreeMemory < totalSize && s.options.UseMMap == nil) ||
(len(gpus) == 0 && s.options.UseMMap == nil) ||
(len(gpus) > 0 && gpus[0].Library == "Vulkan" && s.options.UseMMap == nil) ||
--- a/llm/llama_server.go
+++ b/llm/llama_server.go
@@ -356,7 +356,7 @@
}
// UseMmap
- if launch.opts.UseMMap != nil && !*launch.opts.UseMMap {
+ if envconfig.NoMMap() || (launch.opts.UseMMap != nil && !*launch.opts.UseMMap) {
params = append(params, "--no-mmap")
}