Skip to content

Examples do not build, link error: undefined reference to ggml_cpu_has_avx #2825

Open
@hughobrien

Description

Hello, I'm chasing down a build issue discussed here NixOS/nixpkgs#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 <foldl@users.noreply.github.com>
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:

I bisected the appearance of the issue to this commit 746bf25

Would appreciate any guidance! Thank you.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions