fix(build): link llama-common-base so CUDA/SYCL source builds link - #45
Merged
Conversation
The CUDA/SYCL source builds (v0.17.5) got past the bridge compile and then failed at link with undefined llama_build_number(), llama_commit(), llama_build_info(), llama_compiler(), llama_build_target(). Since b9837, llama.cpp compiles build-info into a dedicated static archive `llama-common-base` that libllama-common depends on but that cmake does not install — so build.rs's install-dir scan linked libllama-common (which references those symbols) but never llama-common-base (which defines them). - build.rs: link libllama-common-base.a explicitly, after the install libs so it follows llama-common on the link line (which references the symbols). - bridge: drop the `#ifndef LLAMA_CPP_PREBUILT` fallback globals — they now collide with the real definitions in llama-common-base. build-info comes from libllama-common in both modes (prebuilt .so / source .a). Verified against a b9837 checkout: llama-common-base.a defines the missing symbols, libllama-common.a references them, and the bridge still compiles in both prebuilt and source modes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Resolves the CUDA/SYCL from-source build link failure caused by missing llama.cpp build-info symbols by ensuring the new llama-common-base static archive is linked, and by removing now-conflicting fallback symbol definitions from the C++ bridge.
Changes:
- Update
build.rsto explicitly linkllama-common-base(emitted after install-dir libs to preserve static link order). - Remove non-prebuilt fallback
LLAMA_BUILD_*global definitions from the C++ bridge to avoid duplicate-symbol collisions once build-info is properly linked.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/llama-sys/build.rs | Explicitly links llama-common-base from the build tree to satisfy build-info symbols missing from the install-dir scan. |
| crates/llama-sys/src/autocommit_common_bridge.cpp | Removes fallback build-info globals that would collide with real definitions once llama-common-base is linked. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Fixes the CUDA/SYCL link failure seen in
v0.17.5(run 28915721077). It was not OOM/timeout — the source builds now compile fully and fail at link:(Good news: the resilience change from #44 worked — v0.17.5 still published the macOS, Linux CPU, and Linux Vulkan binaries despite these two failing.)
Root cause
Since b9837, llama.cpp compiles build-info into a dedicated static archive
llama-common-basethatlibllama-commondepends on but that cmake does not install. So build.rs's install-dir scan linkslibllama-common.a(which referencesllama_build_number()etc.) but neverlibllama-common-base.a(which defines them) → undefined symbols. Prebuilt targets are unaffected: theirlibllama-common.soalready contains build-info.Fix
libllama-common-base.aexplicitly, emitted after the install libs so it followsllama-commonon the link line (static-link order: the referencer must precede the definer).#ifndef LLAMA_CPP_PREBUILTfallback globals (LLAMA_BUILD_NUMBER = 0, …). Those were a stand-in for when build-info wasn't linked; now that we link the real archive, keeping them would cause duplicate-symbol errors. build-info comes fromlibllama-commonin both modes.Verification (against a real b9837 checkout)
nm libllama-common-base.a→ definesllama_build_number(T),llama_build_info(T),LLAMA_BUILD_NUMBER(D), …nm libllama-common.a→ references them (U).Caveat: I can't run the CUDA/SYCL toolchains (or even a full CPU source build — this box lacks
openblas-devel) locally, so this resolves the confirmed undefined symbols but can't rule out a further downstream link issue on those two backends. #44's resilience change backstops that — the other three targets still ship regardless.Worth considering
This is the 4th sequential source-build break since the b9837 bump. Vulkan already covers NVIDIA + AMD + Intel GPUs and passes CI. It may be worth dropping the dedicated CUDA/SYCL release targets rather than continuing to chase these — happy to send that as a one-line matrix change instead.