Skip to content

fix go bindings #2330

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

fix go bindings #2330

wants to merge 1 commit into from

Conversation

gyorgy1
Copy link

@gyorgy1 gyorgy1 commented Jul 31, 2024

This PR fixes missing ggml issues in go bindings

@gleicon
Copy link
Contributor

gleicon commented Jul 31, 2024

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/...

@hsinhoyeh
Copy link
Contributor

@Binozo
Copy link
Contributor

Binozo commented Sep 3, 2024

I tried this fix but sadly it didn't work for me 😕

~/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.23.0.linux-amd64/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

@danbev
Copy link
Collaborator

danbev commented Apr 2, 2025

I believe this pr has been superseded by 206459a.
Please feel free to reopen if there is anything missing in the current implementation

@danbev danbev closed this Apr 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants