[GH-ISSUE #6252] cross compiling issue #65949

Closed
opened 2026-05-03 23:17:53 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @andyyumiao on GitHub (Aug 8, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/6252

What is the issue?

When cross platform cross compiling, for example, when I compile a Linux version of a program on a Mac, the following error is reported:
`gpu/amd_linux.go:200:19: undefined: RocmComputeMin

gpu/amd_linux.go:273:20: undefined: IGPUMemLimit

gpu/amd_linux.go:295:20: undefined: rocmMinimumMemory`
1111

My execution steps are:
export GOOS=linux
export GOARCH=amd64
go generate ./...
go build

### OS

macOS

### GPU

Apple

### CPU

Apple

### Ollama version

the latest master branch

Originally created by @andyyumiao on GitHub (Aug 8, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/6252 ### What is the issue? **When cross platform cross compiling, for example, when I compile a Linux version of a program on a Mac, the following error is reported:** `gpu/amd_linux.go:200:19: undefined: RocmComputeMin gpu/amd_linux.go:273:20: undefined: IGPUMemLimit gpu/amd_linux.go:295:20: undefined: rocmMinimumMemory` <img width="739" alt="1111" src="https://github.com/user-attachments/assets/7525b048-97fc-4e75-8731-695f8643ee6b"> **My execution steps are:** `export GOOS=linux` `export GOARCH=amd64` `go generate ./...` `go build` **### OS** macOS **### GPU** Apple **### CPU** Apple **### Ollama version** the latest master branch
GiteaMirror added the bug label 2026-05-03 23:17:53 -05:00
Author
Owner

@dhiltgen commented on GitHub (Aug 10, 2024):

These errors occur when you aren't compiling with CGO enabled, which we use to compile and link in native C/C++ code.

However, simply enabling that isn't sufficient to cross compile from macos arm64 to linux x86

% CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o ollama-linux .
# runtime/cgo
linux_syscall.c:67:13: error: implicit declaration of function 'setresgid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
linux_syscall.c:67:13: note: did you mean 'setregid'?
/Applications/Xcode_12.5.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:593:6: note: 'setregid' declared here
linux_syscall.c:73:13: error: implicit declaration of function 'setresuid' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
linux_syscall.c:73:13: note: did you mean 'setreuid'?
/Applications/Xcode_12.5.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:595:6: note: 'setreuid' declared here

Digging into this rabbit hole a bit, it looks like Go really wants gcc and a glibc library, and clang/musl on macos isn't sufficient. I'm not sure if there's a good solution out there since gcc doesn't support arm macs today.

We use Docker to compile for Linux on Mac. If you install Docker Desktop, you can leverage ./scripts/build_linux.sh to generate binaries

<!-- gh-comment-id:2278895197 --> @dhiltgen commented on GitHub (Aug 10, 2024): These errors occur when you aren't compiling with CGO enabled, which we use to compile and link in native C/C++ code. However, simply enabling that isn't sufficient to cross compile from macos arm64 to linux x86 ``` % CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o ollama-linux . # runtime/cgo linux_syscall.c:67:13: error: implicit declaration of function 'setresgid' is invalid in C99 [-Werror,-Wimplicit-function-declaration] linux_syscall.c:67:13: note: did you mean 'setregid'? /Applications/Xcode_12.5.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:593:6: note: 'setregid' declared here linux_syscall.c:73:13: error: implicit declaration of function 'setresuid' is invalid in C99 [-Werror,-Wimplicit-function-declaration] linux_syscall.c:73:13: note: did you mean 'setreuid'? /Applications/Xcode_12.5.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/unistd.h:595:6: note: 'setreuid' declared here ``` Digging into this rabbit hole a bit, it looks like Go really wants gcc and a glibc library, and clang/musl on macos isn't sufficient. I'm not sure if there's a good solution out there since gcc doesn't support arm macs today. We use Docker to compile for Linux on Mac. If you install Docker Desktop, you can leverage [./scripts/build_linux.sh](https://github.com/ollama/ollama/blob/main/scripts/build_linux.sh) to generate binaries
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#65949