Skip to content

fix(build): link the split ggml archives with static whisper - #2296

Open
naanlizard wants to merge 1 commit into
OvenMediaLabs:masterfrom
naanlizard:fix/whisper-static-ggml-link
Open

fix(build): link the split ggml archives with static whisper#2296
naanlizard wants to merge 1 commit into
OvenMediaLabs:masterfrom
naanlizard:fix/whisper-static-ggml-link

Conversation

@naanlizard

Copy link
Copy Markdown
Contributor

The below is Claude-written (as is the change). Manually tested/reproduced by me

Reproduction

On current master, in a fresh build directory:

cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release -DOME_BUILD_TESTS=ON
cmake --build build

The test binaries fail to link (excerpt):

/usr/bin/ld: /opt/ovenmediaengine/lib/libwhisper.a(whisper.cpp.o): in function `whisper_full_with_state':
whisper.cpp:(.text+0x293f3): undefined reference to `ggml_backend_buffer_free'
/usr/bin/ld: whisper.cpp:(.text+0x299bc): undefined reference to `ggml_time_us'
/usr/bin/ld: /opt/ovenmediaengine/lib/libwhisper.a(whisper.cpp.o): in function `whisper_log_set':
whisper.cpp:(.text+0x102d1): undefined reference to `ggml_log_set'
/usr/bin/ld: /opt/ovenmediaengine/lib/libwhisper.a(whisper.cpp.o): in function `whisper_vad_init_with_params::{lambda(vad_tensor, ggml_tensor*)#2}::operator()(vad_tensor, ggml_tensor*) const [clone .cold]':
whisper.cpp:(.text.unlikely+0x81e): undefined reference to `ggml_free'
clang: error: linker command failed with exit code 1

Cause

Release builds use static whisper (OME_WHISPER_STATIC defaults to ON for Release), and whisper.cpp ships ggml as three static archives: libggml.a, libggml-base.a, libggml-cpu.a. The build only tells the linker about ggml-cpu. The other two do appear on the link line (via whisper.pc), but before libwhisper.a. A static archive placed before the code that uses it does not resolve anything.

The main OvenMediaEngine binary links anyway, by luck: third_parties.cpp calls two ggml functions directly, which makes the linker pull in the right archives early. Any other binary that links whisper, such as the test binaries, fails.

Fix

Add all three ggml archives to the link line again, after libwhisper.a, where the linker can actually use them. Shared-whisper builds are unaffected.

Static whisper splits ggml into ggml + ggml-base + ggml-cpu. whisper.pc
places ggml and ggml-base before libwhisper.a on the link line, where a
single-pass linker cannot resolve backward references; only ggml-cpu
followed it. Test binaries surfaced the miss.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@naanlizard
naanlizard requested a review from a team as a code owner August 19, 2026 00:24
@naanlizard
naanlizard requested review from getroot and removed request for a team August 19, 2026 00:24
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.

2 participants