[PR #13877] [MERGED] fix: add -O3 optimization to CGO flags #14431

Closed
opened 2026-04-13 00:53:52 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/13877
Author: @jmorganca
Created: 1/24/2026
Status: Merged
Merged: 1/24/2026
Merged by: @jmorganca

Base: mainHead: fix-cgo-optimization


📝 Commits (2)

  • 134cb67 fix: add -O3 optimization to CGO flags
  • e3ee1df fix: add -O3 to build_windows.ps1 for local builds

📊 Changes

4 files changed (+14 additions, -6 deletions)

View changed files

📝 Dockerfile (+3 -1)
📝 app/README.md (+3 -3)
📝 scripts/build_darwin.sh (+2 -2)
📝 scripts/build_windows.ps1 (+6 -0)

📄 Description

CGO_CFLAGS and CGO_CXXFLAGS were being set without optimization flags, which overrides Go's default -O2 and results in unoptimized C++ code.

This caused performance degradation in release builds compared to local go build which uses the default optimization.

  • build_darwin.sh: add -O3 to CGO_CFLAGS and CGO_CXXFLAGS exports
  • Dockerfile: preserve CGO_CFLAGS/CGO_CXXFLAGS from build args instead of overwriting them
  • app/README.md: update documentation to include -O3

🔄 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/13877 **Author:** [@jmorganca](https://github.com/jmorganca) **Created:** 1/24/2026 **Status:** ✅ Merged **Merged:** 1/24/2026 **Merged by:** [@jmorganca](https://github.com/jmorganca) **Base:** `main` ← **Head:** `fix-cgo-optimization` --- ### 📝 Commits (2) - [`134cb67`](https://github.com/ollama/ollama/commit/134cb6720a3003d8597118e2b4d6e4a7955ba380) fix: add -O3 optimization to CGO flags - [`e3ee1df`](https://github.com/ollama/ollama/commit/e3ee1dfdeeb62b045ddab9acda6170dc5f77e194) fix: add -O3 to build_windows.ps1 for local builds ### 📊 Changes **4 files changed** (+14 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `Dockerfile` (+3 -1) 📝 `app/README.md` (+3 -3) 📝 `scripts/build_darwin.sh` (+2 -2) 📝 `scripts/build_windows.ps1` (+6 -0) </details> ### 📄 Description CGO_CFLAGS and CGO_CXXFLAGS were being set without optimization flags, which overrides Go's default -O2 and results in unoptimized C++ code. This caused performance degradation in release builds compared to local `go build` which uses the default optimization. - build_darwin.sh: add -O3 to CGO_CFLAGS and CGO_CXXFLAGS exports - Dockerfile: preserve CGO_CFLAGS/CGO_CXXFLAGS from build args instead of overwriting them - app/README.md: update documentation to include -O3 --- <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-13 00:53:52 -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#14431