Skip to content

llama.cpp: ship the SONAME links so llama-cli/llama-server start - #1371

Merged
bryan-minimal merged 1 commit into
mainfrom
fix/llama-cpp-sonames
Nov 7, 2026
Merged

bryan-minimal merged 1 commit into
mainfrom
fix/llama-cpp-sonames

Conversation

@bryan-minimal

Copy link
Copy Markdown
Member

Problem

llama-cli --version and llama-server --version exit 127. The loader can't find libllama.so.0, libllama-common.so.0, libmtmd.so.0 or libggml*.so.0. This turned up in the 2026-11-06 smoke-test sweep on an arm64 min session.

Root cause

This line in packages/llama.cpp/build.sh:

install -vm755 build/bin/*.so $OUTPUT_DIR/usr/lib/

The build makes each library as lib*.so -> lib*.so.0 -> lib*.so.0.x.y. install follows the link and writes the real file under the unversioned name only. Everything links against the SONAME (*.so.0), and that name was never shipped.

Fix

  • cp -av build/bin/*.so* $OUTPUT_DIR/usr/lib/ keeps the links and the real files. The outputs glob usr/lib/* already covers them.
  • A build-time check fails the build if any shipped ELF has a DT_NEEDED that this build produced (it is in build/bin) but that is missing from $OUTPUT_DIR/usr/lib. It also fails if no DT_NEEDED resolves to build/bin at all, so the check can't pass vacuously.
  • Standalone smoke tests: /usr/bin/llama-cli --version and /usr/bin/llama-server --version. They have no test_deps, because base would mask a missing library.

The pinned web-UI Source, its unpack step and the license notes (pkgs#994) are untouched.

Verification (arm64 min session, pkgbuild loadout)

  • With this PR, min package build --rebuild succeeds. It installs libllama.so{,.0,.0.9.0}, libggml*.so{,.0,.0.29.0}, libmtmd, libllama-common, and the *-impl.so libraries. In min check --packages llama.cpp every check passes, including standalone tests, missing runtime_deps and fmt.
  • Negative control 1: the build.sh from main plus the new tests. The build succeeds, but standalone tests...Fail, with llama-cli and llama-server each exiting with code 127.
  • Negative control 2: the old install line plus the new check. The build fails with ERROR: .../libllama.so needs libggml.so.0, built here but not installed and similar errors for libmtmd.so, libllama-server-impl.so and the others.

Rebuild scope

Only llama.cpp. Nothing in pkgs imports it.

🤖 Generated with Claude Code

`install -vm755 build/bin/*.so` followed each lib*.so -> lib*.so.0 ->
lib*.so.0.x.y chain and installed the library under its unversioned name
only. The binaries and the *-impl.so libraries need the SONAMEs
(libllama.so.0, libllama-common.so.0, libmtmd.so.0, libggml*.so.0), which
never shipped, so both binaries exited 127 at load.

Copy build/bin/*.so* with cp -a, add a build-time check that every
DT_NEEDED this build produced is in the output (fail closed, non-vacuous),
and add standalone --version smoke tests for both binaries with no
test_deps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bryan-minimal
bryan-minimal requested a review from a team as a code owner November 6, 2026 21:35
@coderabbitai

coderabbitai Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 2 billable files and costs up to $0.50.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 32 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 64 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 7a198f0 and 6df5d59.

Files selected for processing: 2

  • packages/llama.cpp/build.ncl
  • packages/llama.cpp/build.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@norrietaylor norrietaylor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Scope matches the title. The diff changes how build.sh installs the libraries, adds a fail-closed DT_NEEDED check and adds two standalone smoke tests. Nothing else changes. Clobber none. git log on packages/llama.cpp shows that the PR keeps the pinned web-UI work from #879 and the b12110 bump from #1330. Correctness cp -a keeps the symlinks (-a implies -P), and the usr/lib/* OutputLib glob covers all three names. The readelf | sed expression matches the (NEEDED) Shared library: [x] lines. -e build/bin/$lib follows the SONAME symlink. The found counter stops the check from passing vacuously. toolchain supplies readelf. standaloneTest is an existing helper, and redis, netcat, gdbm, less and coreutils use it the same way. The new tests are the regression tests for the fix. The bug is local to this package: the only other install ... *.so in a build.sh is nss, and its libraries have unversioned SONAMEs. One nit is on comments that narrate history. Not checked the build and the tests themselves, because they need a build. The PR body reports both, with negative controls.

# The shared libraries ship as built: lib*.so -> lib*.so.0 -> lib*.so.0.x.y.
# `install build/bin/*.so` followed each link and wrote the library under its
# unversioned name only, so the binaries' DT_NEEDED (the SONAME, libllama.so.0
# etc.) was never shipped and llama-cli/llama-server exited 127 at startup.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit · Only the first sentence explains the code. The rest tells how the old install line failed, and that is the PR's story. build.ncl:82-83 does the same thing ("Both binaries exited 127 ... before build.sh kept the SONAME links"). Keep the reason in both places: cp -a keeps the SONAME symlinks, and the tests use no test_deps because base can mask a missing library. Move the history to the commit message.

@bryan-minimal
bryan-minimal added this pull request to the merge queue Nov 7, 2026
Merged via the queue into main with commit ce32993 Nov 7, 2026
15 checks passed
@bryan-minimal
bryan-minimal deleted the fix/llama-cpp-sonames branch November 7, 2026 23:28
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