Skip to content

fix(build): link llama-common-base so CUDA/SYCL source builds link - #45

Merged
SnowCheetos merged 1 commit into
mainfrom
fix/source-build-buildinfo-link
Jul 8, 2026
Merged

fix(build): link llama-common-base so CUDA/SYCL source builds link#45
SnowCheetos merged 1 commit into
mainfrom
fix/source-build-buildinfo-link

Conversation

@SnowCheetos

Copy link
Copy Markdown
Contributor

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:

rust-lld: error: undefined symbol: llama_build_info()
                 undefined symbol: llama_build_number()
                 undefined symbol: llama_commit() / llama_compiler() / llama_build_target()

(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-base that libllama-common depends on but that cmake does not install. So build.rs's install-dir scan links libllama-common.a (which references llama_build_number() etc.) but never libllama-common-base.a (which defines them) → undefined symbols. Prebuilt targets are unaffected: their libllama-common.so already contains build-info.

Fix

  • build.rs: link libllama-common-base.a explicitly, emitted after the install libs so it follows llama-common on the link line (static-link order: the referencer must precede the definer).
  • bridge: drop the #ifndef LLAMA_CPP_PREBUILT fallback 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 from libllama-common in both modes.

Verification (against a real b9837 checkout)

  • nm libllama-common-base.adefines llama_build_number (T), llama_build_info (T), LLAMA_BUILD_NUMBER (D), …
  • nm libllama-common.areferences them (U).
  • Bridge compiles in both source and prebuilt modes after removing the fallbacks.

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.

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>
Copilot AI review requested due to automatic review settings July 8, 2026 04:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.rs to explicitly link llama-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.

@SnowCheetos SnowCheetos self-assigned this Jul 8, 2026
@SnowCheetos
SnowCheetos merged commit 72d5c64 into main Jul 8, 2026
9 checks passed
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