Skip to content
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

whisper-rs-sys fails to build on macOS #180

Closed
hagmonk opened this issue Oct 9, 2024 · 5 comments · Fixed by #181
Closed

whisper-rs-sys fails to build on macOS #180

hagmonk opened this issue Oct 9, 2024 · 5 comments · Fixed by #181

Comments

@hagmonk
Copy link

hagmonk commented Oct 9, 2024

Hitting the error described below … happy to help debug further!

Tried building full_usage at first. I changed Cargo.toml to include:

whisper-rs = { path = "../..", features = [ "coreml", "metal", "whisper-cpp-log", "whisper-cpp-tracing"] }

Then tried reproducing it trying to build In the sys directory for the same result.

> cargo build --features "coreml,metal"
   Compiling whisper-rs-sys v0.11.0 (/Users/hagmonk/src/github.com/tazz4843/whisper-rs/sys)
error: could not find native static library `whisper.coreml`, perhaps an -L flag is missing?

error: could not compile `whisper-rs-sys` (lib) due to 1 previous error

Not sure if it's still required, but I have in ~/.cargo/config.toml, doesn't seem to change the output either way.

[target.aarch64-apple-darwin]
rustflags = "-lc++ -l framework=Accelerate"

I looked in the target/debug/build/whsiper-rs-sys-xxx/out directory and found build/src/libwhisper.coreml.a which was not present in lib. I tried copying that file over, but then get a different linking error:

  = note: Undefined symbols for architecture arm64:
            "___kmpc_barrier", referenced from:
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                ...
            "___kmpc_end_single", referenced from:
                _ggml_graph_compute.omp_outlined in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
            "___kmpc_for_static_fini", referenced from:
                ggml_backend_blas_mul_mat(ggml_backend_blas_context*, ggml_tensor*) (.omp_outlined) in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[13](ggml-blas.cpp.o)
            "___kmpc_for_static_init_8", referenced from:
                ggml_backend_blas_mul_mat(ggml_backend_blas_context*, ggml_tensor*) (.omp_outlined) in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[13](ggml-blas.cpp.o)
            "___kmpc_fork_call", referenced from:
                _ggml_graph_compute in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                ggml_backend_blas_graph_compute(ggml_backend*, ggml_cgraph*) in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[13](ggml-blas.cpp.o)
            "___kmpc_global_thread_num", referenced from:
                _ggml_graph_compute in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                _ggml_compute_forward_diag_mask_f32 in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                ggml_backend_blas_graph_compute(ggml_backend*, ggml_cgraph*) in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[13](ggml-blas.cpp.o)
            "___kmpc_push_num_threads", referenced from:
                _ggml_graph_compute in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
                ggml_backend_blas_graph_compute(ggml_backend*, ggml_cgraph*) in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[13](ggml-blas.cpp.o)
            "___kmpc_single", referenced from:
                _ggml_graph_compute.omp_outlined in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
            "_omp_get_num_threads", referenced from:
                _ggml_graph_compute.omp_outlined in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
            "_omp_get_thread_num", referenced from:
                _ggml_graph_compute.omp_outlined in libwhisper_rs_sys-dd0b36bc7e34e95c.rlib[7](ggml.c.o)
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

I can build whisper-cpp from its top of tree just fine, with WHSPER_COREML=1 set as an environment variable. So I know whisper-cpp does work on this system.

@Maaarcocr
Copy link

Maaarcocr commented Oct 11, 2024

ec609f1 this seems to be the root cause, you can disable the default features (which enable openmp, which causes this link failures), especially if you're planning on using metal, and it should start building!

@solaoi
Copy link
Contributor

solaoi commented Oct 12, 2024

I am experiencing the same build error:

  = note: ld: warning: ignoring duplicate libraries: '-lSystem', '-lc++', '-lobjc'
          Undefined symbols for architecture arm64:
            "___kmpc_barrier", referenced from:
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                ...
            "___kmpc_end_single", referenced from:
                _ggml_graph_compute.omp_outlined in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
            "___kmpc_for_static_fini", referenced from:
                ggml_backend_blas_mul_mat(ggml_backend_blas_context*, ggml_tensor*) (.omp_outlined) in libwhisper_rs_sys-79a4549ef4a144de.rlib[9](ggml-blas.cpp.o)
            "___kmpc_for_static_init_8", referenced from:
                ggml_backend_blas_mul_mat(ggml_backend_blas_context*, ggml_tensor*) (.omp_outlined) in libwhisper_rs_sys-79a4549ef4a144de.rlib[9](ggml-blas.cpp.o)
            "___kmpc_fork_call", referenced from:
                _ggml_graph_compute in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                ggml_backend_blas_graph_compute(ggml_backend*, ggml_cgraph*) in libwhisper_rs_sys-79a4549ef4a144de.rlib[9](ggml-blas.cpp.o)
            "___kmpc_global_thread_num", referenced from:
                _ggml_graph_compute in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_graph_compute_thread in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                _ggml_compute_forward_diag_mask_f32 in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                ggml_backend_blas_graph_compute(ggml_backend*, ggml_cgraph*) in libwhisper_rs_sys-79a4549ef4a144de.rlib[9](ggml-blas.cpp.o)
            "___kmpc_push_num_threads", referenced from:
                _ggml_graph_compute in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
                ggml_backend_blas_graph_compute(ggml_backend*, ggml_cgraph*) in libwhisper_rs_sys-79a4549ef4a144de.rlib[9](ggml-blas.cpp.o)
            "___kmpc_single", referenced from:
                _ggml_graph_compute.omp_outlined in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
            "_omp_get_num_threads", referenced from:
                _ggml_graph_compute.omp_outlined in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
            "_omp_get_thread_num", referenced from:
                _ggml_graph_compute.omp_outlined in libwhisper_rs_sys-79a4549ef4a144de.rlib[5](ggml.c.o)
          ld: symbol(s) not found for architecture arm64
          clang: error: linker command failed with exit code 1 (use -v to see invocation)

This error occurs when I build with the following entry in my Cargo.toml:

whisper-rs = { git = "https://github.com/tazz4843/whisper-rs.git", rev = "ec609f1" }

However, the build works fine with the previous commit 67924ca.

@arizhih
Could you provide any insight into what might have changed?
Thank you in advance for your help.

@arizhih
Copy link
Contributor

arizhih commented Oct 14, 2024

Hi @solaoi, I've made some changes, you can check in #181

@solaoi
Copy link
Contributor

solaoi commented Oct 15, 2024

@arizhih
Thank you for your great work!
The fix is working perfectly.

@tazz4843 tazz4843 linked a pull request Oct 22, 2024 that will close this issue
@hagmonk
Copy link
Author

hagmonk commented Oct 24, 2024

Thanks all!

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 a pull request may close this issue.

4 participants