diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7120cfa..ccab981 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,10 +28,8 @@ jobs: include: - os: ubuntu-latest platform: linux-amd64 - - os: macos-13 - platform: darwin-amd64 - # - os: macos-latest # enable when darwin-arm64 prebuilt .a files are added - # platform: darwin-arm64 + - os: macos-latest + platform: darwin-arm64 steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 @@ -51,10 +49,8 @@ jobs: include: - os: ubuntu-latest platform: linux-amd64 - - os: macos-13 - platform: darwin-amd64 - # - os: macos-latest - # platform: darwin-arm64 + - os: macos-latest + platform: darwin-arm64 steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 diff --git a/Dockerfile.libs b/Dockerfile.libs index 7e7fbce..6b74f28 100644 --- a/Dockerfile.libs +++ b/Dockerfile.libs @@ -3,9 +3,12 @@ # Usage: # docker build -f Dockerfile.libs -o ./out . # +# Build + link test (ensures .a files link correctly): +# docker build -f Dockerfile.libs --target build-test . +# # This extracts prebuilt .a files + headers into ./out/ on the host. -FROM golang:1.24-bullseye AS builder +FROM golang:1.24-bookworm AS builder RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential cmake wget && \ @@ -58,6 +61,43 @@ RUN mkdir -p /out/whisper.cpp/linux-amd64 /out/whisper.cpp/include /out/whisper. cp whisper-src/include/*.h /out/whisper.cpp/include/ && \ cp whisper-src/ggml/include/*.h /out/whisper.cpp/ggml/include/ +# ============================================================================ +# Build test — verifies the .a files link correctly with Go CGO +# ============================================================================ +FROM golang:1.24-bookworm AS build-test + +RUN apt-get update && apt-get install -y --no-install-recommends \ + build-essential libgomp1 && \ + rm -rf /var/lib/apt/lists/* + +WORKDIR /src +COPY . . + +# Copy freshly built .a files into the source tree +COPY --from=builder /out/llama.cpp/linux-amd64/ /src/ggml/llamacpp/third_party/prebuilt/linux-amd64/ +COPY --from=builder /out/llama.cpp/include/ /src/ggml/llamacpp/third_party/include/ +COPY --from=builder /out/llama.cpp/ggml/include/ /src/ggml/llamacpp/third_party/ggml/include/ +COPY --from=builder /out/llama.cpp/common/ /src/ggml/llamacpp/third_party/common/ +COPY --from=builder /out/whisper.cpp/linux-amd64/ /src/ggml/whispercpp/third_party/prebuilt/linux-amd64/ +COPY --from=builder /out/whisper.cpp/include/ /src/ggml/whispercpp/third_party/include/ +COPY --from=builder /out/whisper.cpp/ggml/include/ /src/ggml/whispercpp/third_party/ggml/include/ + +# Test stub builds (no CGO) +RUN CGO_ENABLED=0 go build ./ggml/llamacpp/... && \ + CGO_ENABLED=0 go build ./ggml/whispercpp/... && \ + echo "stub builds OK" + +# Test CGO builds (link against .a files) +RUN CGO_ENABLED=1 go build -tags llamacpp ./ggml/llamacpp/... && \ + echo "llamacpp CGO build OK" +RUN CGO_ENABLED=1 go build -tags whispercpp ./ggml/whispercpp/... && \ + echo "whispercpp CGO build OK" + +# Run stub tests +RUN CGO_ENABLED=0 go test ./ggml/llamacpp/... && \ + CGO_ENABLED=0 go test ./ggml/whispercpp/... && \ + echo "all tests passed" + # Output stage — docker build -o extracts from here FROM scratch COPY --from=builder /out/ / diff --git a/ggml/llamacpp/llamacpp.go b/ggml/llamacpp/llamacpp.go index 3cf2dac..032f4d3 100644 --- a/ggml/llamacpp/llamacpp.go +++ b/ggml/llamacpp/llamacpp.go @@ -14,9 +14,9 @@ package llamacpp #cgo darwin,amd64 LDFLAGS: -L${SRCDIR}/third_party/prebuilt/darwin-amd64 #cgo linux,amd64 LDFLAGS: -L${SRCDIR}/third_party/prebuilt/linux-amd64 #cgo linux,arm64 LDFLAGS: -L${SRCDIR}/third_party/prebuilt/linux-arm64 -#cgo LDFLAGS: -lcommon -lllama -lggml-cpu -lggml-base -lggml -lstdc++ -lm -#cgo darwin LDFLAGS: -lggml-blas -lggml-metal -L/usr/local/opt/libomp/lib -L/opt/homebrew/opt/libomp/lib -lomp -framework Accelerate -framework Metal -framework Foundation -#cgo linux LDFLAGS: -lpthread -ldl -lrt -lgomp +#cgo LDFLAGS: -lstdc++ -lm +#cgo darwin LDFLAGS: -lcommon -lllama -lggml-cpu -lggml-base -lggml -lggml-blas -lggml-metal -L/usr/local/opt/libomp/lib -L/opt/homebrew/opt/libomp/lib -lomp -framework Accelerate -framework Metal -framework Foundation +#cgo linux LDFLAGS: -Wl,--start-group -lcommon -lllama -lggml-cpu -lggml-base -lggml -Wl,--end-group -lpthread -ldl -lrt -lgomp #include #include #include "wrapper.h" diff --git a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libcommon.a b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libcommon.a index d9aa06b..193e683 100644 Binary files a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libcommon.a and b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libcommon.a differ diff --git a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libcpp-httplib.a b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libcpp-httplib.a index 9f6a288..020cf4f 100644 Binary files a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libcpp-httplib.a and b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libcpp-httplib.a differ diff --git a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libggml-base.a b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libggml-base.a index 71f2136..0e7587b 100644 Binary files a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libggml-base.a and b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libggml-base.a differ diff --git a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libggml-cpu.a b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libggml-cpu.a index 5da2f4d..decb33f 100644 Binary files a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libggml-cpu.a and b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libggml-cpu.a differ diff --git a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libggml.a b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libggml.a index 8766ed7..0f9aa0e 100644 Binary files a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libggml.a and b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libggml.a differ diff --git a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libllama.a b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libllama.a index 43b770d..fccc571 100644 Binary files a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libllama.a and b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libllama.a differ diff --git a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libmtmd.a b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libmtmd.a index be128a5..6197b1e 100644 Binary files a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libmtmd.a and b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libmtmd.a differ diff --git a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libserver-context.a b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libserver-context.a index dc29f49..f8ad75b 100644 Binary files a/ggml/llamacpp/third_party/prebuilt/linux-amd64/libserver-context.a and b/ggml/llamacpp/third_party/prebuilt/linux-amd64/libserver-context.a differ diff --git a/ggml/whispercpp/third_party/prebuilt/linux-amd64/libcommon.a b/ggml/whispercpp/third_party/prebuilt/linux-amd64/libcommon.a index 08c9719..271b24f 100644 Binary files a/ggml/whispercpp/third_party/prebuilt/linux-amd64/libcommon.a and b/ggml/whispercpp/third_party/prebuilt/linux-amd64/libcommon.a differ diff --git a/ggml/whispercpp/third_party/prebuilt/linux-amd64/libggml-base.a b/ggml/whispercpp/third_party/prebuilt/linux-amd64/libggml-base.a index 2f0e9a4..8ccf34d 100644 Binary files a/ggml/whispercpp/third_party/prebuilt/linux-amd64/libggml-base.a and b/ggml/whispercpp/third_party/prebuilt/linux-amd64/libggml-base.a differ diff --git a/ggml/whispercpp/third_party/prebuilt/linux-amd64/libggml-cpu.a b/ggml/whispercpp/third_party/prebuilt/linux-amd64/libggml-cpu.a index db496f4..371a07c 100644 Binary files a/ggml/whispercpp/third_party/prebuilt/linux-amd64/libggml-cpu.a and b/ggml/whispercpp/third_party/prebuilt/linux-amd64/libggml-cpu.a differ diff --git a/ggml/whispercpp/third_party/prebuilt/linux-amd64/libggml.a b/ggml/whispercpp/third_party/prebuilt/linux-amd64/libggml.a index a8435b5..0ee2671 100644 Binary files a/ggml/whispercpp/third_party/prebuilt/linux-amd64/libggml.a and b/ggml/whispercpp/third_party/prebuilt/linux-amd64/libggml.a differ diff --git a/ggml/whispercpp/third_party/prebuilt/linux-amd64/libwhisper.a b/ggml/whispercpp/third_party/prebuilt/linux-amd64/libwhisper.a index 53c80a9..78ec7dd 100644 Binary files a/ggml/whispercpp/third_party/prebuilt/linux-amd64/libwhisper.a and b/ggml/whispercpp/third_party/prebuilt/linux-amd64/libwhisper.a differ diff --git a/ggml/whispercpp/whispercpp.go b/ggml/whispercpp/whispercpp.go index 50ae390..74b1807 100644 --- a/ggml/whispercpp/whispercpp.go +++ b/ggml/whispercpp/whispercpp.go @@ -14,9 +14,9 @@ package whispercpp #cgo darwin,amd64 LDFLAGS: -L${SRCDIR}/third_party/prebuilt/darwin-amd64 #cgo linux,amd64 LDFLAGS: -L${SRCDIR}/third_party/prebuilt/linux-amd64 #cgo linux,arm64 LDFLAGS: -L${SRCDIR}/third_party/prebuilt/linux-arm64 -#cgo LDFLAGS: -lwhisper -lcommon -lggml-cpu -lggml-base -lggml -lstdc++ -lm -#cgo darwin LDFLAGS: -lggml-blas -lggml-metal -L/usr/local/opt/libomp/lib -L/opt/homebrew/opt/libomp/lib -lomp -framework Accelerate -framework Metal -framework Foundation -#cgo linux LDFLAGS: -lpthread -ldl -lrt -lgomp +#cgo LDFLAGS: -lstdc++ -lm +#cgo darwin LDFLAGS: -lwhisper -lcommon -lggml-cpu -lggml-base -lggml -lggml-blas -lggml-metal -L/usr/local/opt/libomp/lib -L/opt/homebrew/opt/libomp/lib -lomp -framework Accelerate -framework Metal -framework Foundation +#cgo linux LDFLAGS: -Wl,--start-group -lwhisper -lcommon -lggml-cpu -lggml-base -lggml -Wl,--end-group -lpthread -ldl -lrt -lgomp #include #include "whisper.h" */ diff --git a/version.go b/version.go index 727dbcb..ef17fe0 100644 --- a/version.go +++ b/version.go @@ -1,7 +1,7 @@ package gonativeml const ( - Version = "v0.1.0" + Version = "v0.1.1" LlamaCppVersion = "b8220" WhisperCppVersion = "v1.8.3" )