[PR #1680] [MERGED] Refactor how we augment llama.cpp and refine windows native build #21185

Closed
opened 2026-04-19 15:29:47 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/1680
Author: @dhiltgen
Created: 12/22/2023
Status: Merged
Merged: 1/3/2024
Merged by: @dhiltgen

Base: mainHead: better_patching


📝 Commits (4)

  • 9a70aec Refactor how we augment llama.cpp
  • d966b73 Switch windows build to fully dynamic
  • 738a8d1 Rename the ollama cmakefile
  • 0498f7c Get rid of one-line llama.log

📊 Changes

22 files changed (+816 additions, -717 deletions)

View changed files

📝 gpu/gpu.go (+13 -11)
📝 gpu/gpu_darwin.go (+0 -1)
📝 gpu/gpu_test.go (+1 -1)
📝 gpu/types.go (+0 -1)
📝 llm/dynamic_shim.c (+18 -9)
📝 llm/dynamic_shim.h (+1 -1)
📝 llm/ext_server_common.go (+25 -89)
llm/ext_server_default.go (+80 -0)
llm/ext_server_windows.go (+15 -0)
llm/llama.cpp/CMakeLists.txt (+29 -0)
llm/llama.cpp/ext_server.cpp (+281 -0)
llm/llama.cpp/ext_server.h (+94 -0)
📝 llm/llama.cpp/gen_common.sh (+20 -8)
📝 llm/llama.cpp/gen_darwin.sh (+15 -13)
📝 llm/llama.cpp/gen_linux.sh (+17 -15)
📝 llm/llama.cpp/gen_windows.ps1 (+29 -38)
llm/llama.cpp/patches/0001-Expose-callable-API-for-server.patch (+0 -464)
📝 llm/llama.go (+0 -41)
📝 llm/shim_darwin.go (+40 -1)
📝 llm/shim_ext_server.go (+63 -24)

...and 2 more files

📄 Description

This changes the model for llama.cpp inclusion so we're not applying a patch, but instead have the C++ code directly in the ollama tree, which should make it easier to refine and update over time.

This also includes a change to refactor the dynamic loading logic to support variants that are purely dynamic, and leverages this on Windows. In the windows build now, the base executable has only standard system dependencies, which means no special PATH setup is required. That binary caries 2 payloads - one for CPU build and one for CUDA, and will load the appropriate one at runtime. The dependencies for those are extracted into a temporary directory, and the PATH is updated automatically to ensure the deps are loaded. We should be able to follow this same model to add ROCm support for windows as well in a follow up.

As a potential follow up, we could drop the sed of main and switch to a pure dynamic load strategy so the symbol isn't a conflict.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/1680 **Author:** [@dhiltgen](https://github.com/dhiltgen) **Created:** 12/22/2023 **Status:** ✅ Merged **Merged:** 1/3/2024 **Merged by:** [@dhiltgen](https://github.com/dhiltgen) **Base:** `main` ← **Head:** `better_patching` --- ### 📝 Commits (4) - [`9a70aec`](https://github.com/ollama/ollama/commit/9a70aecccb7034f2d53b7b400f3929c6c199cb90) Refactor how we augment llama.cpp - [`d966b73`](https://github.com/ollama/ollama/commit/d966b730ac34631cc2251e8bf14c62f558a745fe) Switch windows build to fully dynamic - [`738a8d1`](https://github.com/ollama/ollama/commit/738a8d12eb0ba09a1f7bab650f267d96c44b883a) Rename the ollama cmakefile - [`0498f7c`](https://github.com/ollama/ollama/commit/0498f7ce56686bd44a8f92954daebe02352cdf82) Get rid of one-line llama.log ### 📊 Changes **22 files changed** (+816 additions, -717 deletions) <details> <summary>View changed files</summary> 📝 `gpu/gpu.go` (+13 -11) 📝 `gpu/gpu_darwin.go` (+0 -1) 📝 `gpu/gpu_test.go` (+1 -1) 📝 `gpu/types.go` (+0 -1) 📝 `llm/dynamic_shim.c` (+18 -9) 📝 `llm/dynamic_shim.h` (+1 -1) 📝 `llm/ext_server_common.go` (+25 -89) ➕ `llm/ext_server_default.go` (+80 -0) ➕ `llm/ext_server_windows.go` (+15 -0) ➕ `llm/llama.cpp/CMakeLists.txt` (+29 -0) ➕ `llm/llama.cpp/ext_server.cpp` (+281 -0) ➕ `llm/llama.cpp/ext_server.h` (+94 -0) 📝 `llm/llama.cpp/gen_common.sh` (+20 -8) 📝 `llm/llama.cpp/gen_darwin.sh` (+15 -13) 📝 `llm/llama.cpp/gen_linux.sh` (+17 -15) 📝 `llm/llama.cpp/gen_windows.ps1` (+29 -38) ➖ `llm/llama.cpp/patches/0001-Expose-callable-API-for-server.patch` (+0 -464) 📝 `llm/llama.go` (+0 -41) 📝 `llm/shim_darwin.go` (+40 -1) 📝 `llm/shim_ext_server.go` (+63 -24) _...and 2 more files_ </details> ### 📄 Description This changes the model for llama.cpp inclusion so we're not applying a patch, but instead have the C++ code directly in the ollama tree, which should make it easier to refine and update over time. This also includes a change to refactor the dynamic loading logic to support variants that are purely dynamic, and leverages this on Windows. In the windows build now, the base executable has only standard system dependencies, which means no special PATH setup is required. That binary caries 2 payloads - one for CPU build and one for CUDA, and will load the appropriate one at runtime. The dependencies for those are extracted into a temporary directory, and the PATH is updated automatically to ensure the deps are loaded. We should be able to follow this same model to add ROCm support for windows as well in a follow up. As a potential follow up, we could drop the sed of `main` and switch to a pure dynamic load strategy so the symbol isn't a conflict. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-19 15:29:47 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#21185