Skip to content

Linking error with whisper-rs when using vulkan: multiple definitions of symbol #95

@FireFragment

Description

@FireFragment

When using the vulkan feature on both llama_cpp and whisper-rs from the same crate, build fails with many error messages similiar to this one:

/bin/ld: /home/user/Programming/Rust/tests/problem_isolation/vulkan-ai/target/debug/deps/libllama_cpp_sys-6172acf8774b4f66.rlib(3487caebe0aa41d4-ggml-vulkan.o):/home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama_cpp_sys-0.3.2/./thirdparty/llama.cpp/ggml-vulkan-shaders.hpp:69574: multiple definition of `sqr_f32_data'; /home/user/Programming/Rust/tests/problem_isolation/vulkan-ai/target/debug/deps/libwhisper_rs_sys-a2fb035baa881db4.rlib(ggml-vulkan-shaders.cpp.o):/home/user/Programming/Rust/tests/problem_isolation/vulkan-ai/target/debug/build/whisper-rs-sys-ea85f180824249f0/out/build/ggml/src/ggml-vulkan-shaders.cpp:126068: first defined here
collect2: error: ld returned 1 exit status

Note: See also similar issue I've made in whisper-rs repo: tazz4843/whisper-rs#194

To reproduce

Beware, that just creating a crate with dependencies on llama_cpp and whisper-rs with vulkan features isn't enough to reproduce this error, because (I guess) rust compiler optimizes the linking away so you need to actually use both crates in the code.

I have made a simple crate to reproduce this error. Build it with

git clone https://github.com/FireFragment/vulkan-ai-linkage-error
cd vulkan-ai-linkage-error
cargo b

If you use Nix, you can reproduce the full environment I got the build failure with

git clone https://github.com/FireFragment/vulkan-ai-linkage-error
cd vulkan-ai-linkage-error
nix develop -c cargo b

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions