Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.
build: add -O3 optimization to CGO flags (#13877)
Jeffrey Morganf3b476c59280
diff --git a/Dockerfile b/Dockerfileindex 1c0347fd6..85ee996b1 100644--- a/Dockerfile+++ b/Dockerfile@@ -169,8 +169,10 @@ COPY . .RUN git clone --depth 1 --branch "$(cat MLX_VERSION)" https://github.com/ml-explore/mlx-c.git build/_deps/mlx-c-srcARG GOFLAGS="'-ldflags=-w -s'"ENV CGO_ENABLED=1-ENV CGO_CFLAGS="-I/go/src/github.com/ollama/ollama/build/_deps/mlx-c-src"+ARG CGO_CFLAGSARG CGO_CXXFLAGS+ENV CGO_CFLAGS="${CGO_CFLAGS} -I/go/src/github.com/ollama/ollama/build/_deps/mlx-c-src"+ENV CGO_CXXFLAGS="${CGO_CXXFLAGS}"RUN --mount=type=cache,target=/root/.cache/go-build \go build -tags mlx -trimpath -buildmode=pie -o /bin/ollama .diff --git a/app/README.md b/app/README.mdindex eadf34474..95afcace6 100644--- a/app/README.md+++ b/app/README.md@@ -75,9 +75,9 @@ The `-dev` flag enables:CI builds with Xcode 14.1 for OS compatibility prior to v13. If you want to manually build v11+ support, you can download the older Xcode [here](https://developer.apple.com/services-account/download?path=/Developer_Tools/Xcode_14.1/Xcode_14.1.xip), extract, then `mv ./Xcode.app /Applications/Xcode_14.1.0.app` then activate with:```-export CGO_CFLAGS=-mmacosx-version-min=12.0-export CGO_CXXFLAGS=-mmacosx-version-min=12.0-export CGO_LDFLAGS=-mmacosx-version-min=12.0+export CGO_CFLAGS="-O3 -mmacosx-version-min=12.0"+export CGO_CXXFLAGS="-O3 -mmacosx-version-min=12.0"+export CGO_LDFLAGS="-mmacosx-version-min=12.0"export SDKROOT=/Applications/Xcode_14.1.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdkexport DEVELOPER_DIR=/Applications/Xcode_14.1.0.app/Contents/Developer```diff --git a/scripts/build_darwin.sh b/scripts/build_darwin.shindex 3560520ff..4325a9787 100755--- a/scripts/build_darwin.sh+++ b/scripts/build_darwin.sh@@ -14,8 +14,8 @@VOL_NAME=${VOL_NAME:-"Ollama"}export VERSION=${VERSION:-$(git describe --tags --first-parent --abbrev=7 --long --dirty --always | sed -e "s/^v//g")}export GOFLAGS="'-ldflags=-w -s \"-X=github.com/ollama/ollama/version.Version=${VERSION#v}\" \"-X=github.com/ollama/ollama/server.mode=release\"'"-export CGO_CFLAGS="-mmacosx-version-min=14.0"-export CGO_CXXFLAGS="-mmacosx-version-min=14.0"+export CGO_CFLAGS="-O3 -mmacosx-version-min=14.0"+export CGO_CXXFLAGS="-O3 -mmacosx-version-min=14.0"export CGO_LDFLAGS="-mmacosx-version-min=14.0"set -ediff --git a/scripts/build_windows.ps1 b/scripts/build_windows.ps1index 30fb9d09a..0ca00fa73 100644--- a/scripts/build_windows.ps1+++ b/scripts/build_windows.ps1@@ -56,6 +56,12 @@ function checkEnv {$script:DIST_DIR="${script:SRC_DIR}\dist\windows-${script:TARGET_ARCH}"$env:CGO_ENABLED="1"+ if (-not $env:CGO_CFLAGS) {+ $env:CGO_CFLAGS = "-O3"+ }+ if (-not $env:CGO_CXXFLAGS) {+ $env:CGO_CXXFLAGS = "-O3"+ }Write-Output "Checking version"if (!$env:VERSION) {$data=(git describe --tags --first-parent --abbrev=7 --long --dirty --always)