fix go bindings
This PR fixes missing ggml issues in go bindings
Not sure how to do it but there are a couple of lines missing on my Mac M1 + Go setup at the Makefile to add include files Go will need:
$ diff -a Makefile ~/tmp/Makefile_new_whisper 17c17,18 < INCLUDE_PATH := $(abspath ../..)
INCLUDE_PATH := $(abspath ../../include/) GGML_INCLUDE_PATH := $(abspath ../../ggml/include/) 33,34c34,35 < @C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} GGML_METAL_PATH_RESOURCES=${GGML_METAL_PATH_RESOURCES} go test -ldflags "-extldflags '$(EXT_LDFLAGS)'" -v . < @C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} GGML_METAL_PATH_RESOURCES=${GGML_METAL_PATH_RESOURCES} go test -ldflags "-extldflags '$(EXT_LDFLAGS)'" -v ./pkg/whisper/...
@C_INCLUDE_PATH=${INCLUDE_PATH}:${GGML_INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} GGML_METAL_PATH_RESOURCES=${GGML_METAL_PATH_RESOURCES} go test -ldflags "-extldflags '$(EXT_LDFLAGS)'" -v . @C_INCLUDE_PATH=${INCLUDE_PATH}:${GGML_INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} GGML_METAL_PATH_RESOURCES=${GGML_METAL_PATH_RESOURCES} go test -ldflags "-extldflags '$(EXT_LDFLAGS)'" -v ./pkg/whisper/... 36,37c37,38 < @C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} go test -v . < @C_INCLUDE_PATH=${INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} go test -v ./pkg/whisper/...
@C_INCLUDE_PATH=${INCLUDE_PATH}:${GGML_INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} go test -v . @C_INCLUDE_PATH=${INCLUDE_PATH}:${GGML_INCLUDE_PATH} LIBRARY_PATH=${LIBRARY_PATH} go test -v ./pkg/whisper/...
please refer to https://github.com/ggerganov/whisper.cpp/pull/2350/files#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52L974 for fixing go binding.
I tried this fix but sadly it didn't work for me 😕
~/go/pkg/mod/golang.org/[email protected]/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/gcc -m64 -s -o $WORK/b001/go.test -Wl,--export-dynamic-symbol=_cgo_panic -Wl,--export-dynamic-symbol=_cgo_topofstack -Wl,--export-dynamic-symbol=callEncoderBegin -Wl,--export-dynamic-symbol=callNewSegment -Wl,--export-dynamic-symbol=callProgress -Wl,--export-dynamic-symbol=crosscall2 -Wl,--compress-debug-sections=zlib /tmp/go-link-3187512653/go.o /tmp/go-link-3187512653/000000.o /tmp/go-link-3187512653/000001.o /tmp/go-link-3187512653/000002.o /tmp/go-link-3187512653/000003.o /tmp/go-link-3187512653/000004.o /tmp/go-link-3187512653/000005.o /tmp/go-link-3187512653/000006.o /tmp/go-link-3187512653/000007.o /tmp/go-link-3187512653/000008.o /tmp/go-link-3187512653/000009.o /tmp/go-link-3187512653/000010.o /tmp/go-link-3187512653/000011.o /tmp/go-link-3187512653/000012.o /tmp/go-link-3187512653/000013.o /tmp/go-link-3187512653/000014.o /tmp/go-link-3187512653/000015.o /tmp/go-link-3187512653/000016.o /tmp/go-link-3187512653/000017.o /tmp/go-link-3187512653/000018.o /tmp/go-link-3187512653/000019.o /tmp/go-link-3187512653/000020.o /tmp/go-link-3187512653/000021.o /tmp/go-link-3187512653/000022.o -O2 -g -lwhisper -lggml -lm -lstdc++ -fopenmp -O2 -g -lpthread -O2 -g -lresolv -no-pie
/usr/bin/ld: ~/GolandProjects/project/whisper.cpp/libwhisper.a(whisper.o): in function `whisper_model_load(whisper_model_loader*, whisper_context&)':
whisper.cpp:(.text+0x198b5): undefined reference to `ggml_backend_cuda_buffer_type'
/usr/bin/ld: ~/GolandProjects/project/whisper.cpp/libwhisper.a(whisper.o): in function `whisper_init_state':
whisper.cpp:(.text+0x1c5f8): undefined reference to `ggml_backend_cuda_init'
/usr/bin/ld: ~/GolandProjects/project/whisper.cpp/libwhisper.a(ggml-backend.o): in function `ggml_backend_reg_get_count':
ggml-backend.c:(.text+0x1a19): undefined reference to `ggml_backend_cuda_reg_devices'
/usr/bin/ld: ~/GolandProjects/project/whisper.cpp/libwhisper.a(ggml-backend.o): in function `ggml_backend_reg_find_by_name':
ggml-backend.c:(.text+0x1a6b): undefined reference to `ggml_backend_cuda_reg_devices'
/usr/bin/ld: ~/GolandProjects/project/whisper.cpp/libwhisper.a(ggml-backend.o): in function `ggml_backend_reg_get_name':
ggml-backend.c:(.text+0x1b12): undefined reference to `ggml_backend_cuda_reg_devices'
/usr/bin/ld: ~/GolandProjects/project/whisper.cpp/libwhisper.a(ggml-backend.o): in function `ggml_backend_reg_get_default_buffer_type':
ggml-backend.c:(.text+0x1bb2): undefined reference to `ggml_backend_cuda_reg_devices'
/usr/bin/ld: ~/GolandProjects/project/whisper.cpp/libwhisper.a(ggml-backend.o): in function `ggml_backend_reg_alloc_buffer':
ggml-backend.c:(.text+0x1c5a): undefined reference to `ggml_backend_cuda_reg_devices'
/usr/bin/ld: ~/GolandProjects/project/whisper.cpp/libwhisper.a(ggml-backend.o):ggml-backend.c:(.text+0x1d0a): more undefined references to `ggml_backend_cuda_reg_devices' follow
collect2: error: ld returned 1 exit status
FAIL github.com/ggerganov/whisper.cpp/bindings/go [build failed]
FAIL
make: *** [Makefile:36: test] Error 1
I believe this pr has been superseded by https://github.com/ggerganov/whisper.cpp/commit/206459a80477f00799b383d4c7e81d207c95d00b. Please feel free to reopen if there is anything missing in the current implementation