whisper.cpp
whisper.cpp copied to clipboard
Examples do not build, link error: undefined reference to `ggml_cpu_has_avx`
trafficstars
Hello, I'm chasing down a build issue discussed here https://github.com/NixOS/nixpkgs/pull/382394
The example binaries, e.g. bench and cli seem to be unable to resolve the symbols for CPU feature checks. The ggml and whisper libraries build successfully, but the final linking seems to have an issue.
❯ git log | head
commit d682e150908e10caa4c15883c633d7902d385237
Author: Judd <[email protected]>
Date: Thu Feb 6 15:37:21 2025 +0800
❯ bat /tmp/build
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p cmake
set -xeuo pipefail
d=build
rm -rf $d
cmake -S . -B $d \
-DCMAKE_BUILD_TYPE=Release \
-DWHISPER_BUILD_EXAMPLES=ON \
-DGGML_NATIVE=OFF \
-DGGML_LTO=true \
-DGGML_CCACHE=OFF \
-DGGML_STANDALONE=OFF \
-DBUILD_SHARED_LIBS=ON \
-DGGML_CPU_ALL_VARIANTS=OFF \
-DGGML_BACKEND_DL=ON
cmake --build $d --config Release -- -j 16
[ 83%] Linking CXX executable ../../bin/whisper-bench
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_get_f32_nd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_avx'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_vsx'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_arm_fma'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_avx2'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_graph_compute_with_ctx'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_f16c'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_set_f32_nd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_wasm_simd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_set_f32'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_set_i32_nd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_ssse3'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_neon'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_fp16_va'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_get_i32_nd'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_sse3'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_backend_cpu_init'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_graph_plan'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_graph_compute'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_avx512'
/nix/store/5h5ghy2qf6l91l52j6m5vx473zi38vc3-binutils-2.43.1/bin/ld: ../../src/libwhisper.so.1.7.4: undefined reference to `ggml_cpu_has_fma'
collect2: error: ld returned 1 exit status
[ 85%] Linking CXX static library libcommon.a
make[2]: *** [examples/bench/CMakeFiles/whisper-bench.dir/build.make:104: bin/whisper-bench] Error 1
make[1]: *** [CMakeFiles/Makefile2:559: examples/bench/CMakeFiles/whisper-bench.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 85%] Built target common
make: *** [Makefile:136: all] Error 2
/data/whisper.cpp/build/bin master
❯ nm ../src/libwhisper.so | grep ggml_cpu_has_avx
U ggml_cpu_has_avx
U ggml_cpu_has_avx2
U ggml_cpu_has_avx512
/data/whisper.cpp/build/bin master
❯ nm libggml-cpu.so | grep ggml_cpu_has_avx
0000000000029a50 T ggml_cpu_has_avx
0000000000029a70 T ggml_cpu_has_avx2
0000000000029a80 T ggml_cpu_has_avx512
0000000000029ab0 T ggml_cpu_has_avx512_bf16
0000000000029a90 T ggml_cpu_has_avx512_vbmi
0000000000029aa0 T ggml_cpu_has_avx512_vnni
0000000000029a60 T ggml_cpu_has_avx_vnni
These two issues may be relevant:
- https://github.com/ggerganov/whisper.cpp/issues/2661
- https://github.com/ggerganov/whisper.cpp/issues/2793
I bisected the appearance of the issue to this commit https://github.com/ggerganov/whisper.cpp/commit/746bf2596f65465a74d6d65fa4d1b5dd9c6cd27c
Would appreciate any guidance! Thank you.
Looks that libwhisper wants to link to these functions statically, but they are now in a separated so.