Skip to content

tests : link each test against only the libraries it uses - #30299

Merged
ggerganov merged 1 commit into
masterfrom
gg/tests-decouple-libllama
Oct 12, 2026
Merged

ggerganov merged 1 commit into
masterfrom
gg/tests-decouple-libllama

Conversation

@ggerganov

@ggerganov ggerganov commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

Overview

llama_build() and llama_build_and_test() hard-coded their link libraries (llama llama-common and llama-common). Since llama-common PUBLIC-links llama and llama PUBLIC-links ggml, every test executable transitively pulled in libllama — plus llama-common's PUBLIC interface — even when the test never references a llama_* or common_* symbol.

This PR gives both helpers a LINK keyword (default: unchanged, llama-common) and updates each call site to declare its real dependency:

  • ggml-only tests now link ggml only: test-opt, test-metal-graph-optimize, test-backend-ops, test-tiled-mulmat, test-barrier, test-quantize-fns, test-quantize-perf, test-rope, test-col2im-1d, test-gguf, test-alloc
  • llama-only tests drop llama-common: test-unicode, test-sampling, test-grammar-parser, test-llama-grammar, test-batch-alloc, test-gbnf-validator, test-quant-type-selection
  • both mtmd tests link mtmd only, removing the set(LLAMA_TEST_NAME ...) / target_link_libraries(... mtmd) workarounds

tests/testing.h no longer includes common.h (it used nothing from it except string_join, now inlined).

Additional information

  • test-metal-graph-optimize now takes LINK ggml ggml-metal instead of a separate target_link_libraries line.

Requirements

Give llama_build() and llama_build_and_test() a LINK keyword (default:
llama-common) so call sites can declare what a test actually needs:

- ggml-only tests now link just ggml: test-opt, test-metal-graph-optimize,
  test-backend-ops, test-tiled-mulmat, test-barrier, test-quantize-fns,
  test-quantize-perf, test-rope, test-col2im-1d, test-gguf, test-alloc
- llama-only tests drop llama-common: test-unicode, test-sampling,
  test-grammar-parser, test-llama-grammar, test-batch-alloc,
  test-gbnf-validator, test-quant-type-selection
- both mtmd tests link mtmd only, dropping the LLAMA_TEST_NAME /
  target_link_libraries workarounds

Both helpers now set cxx_std_17 explicitly, since the tests no longer
inherit it from llama-common's PUBLIC interface.

tests/testing.h no longer includes common.h; the only symbol it used from
there (string_join) is inlined.

Assisted-by: pi:llama.cpp/Qwen3.8-Flash-Next
@github-actions github-actions Bot added the testing Everything test related label Oct 10, 2026
@ggerganov
ggerganov marked this pull request as ready for review October 11, 2026 11:42
@ggerganov
ggerganov merged commit ccdbe29 into master Oct 12, 2026
25 of 26 checks passed
@ggerganov
ggerganov deleted the gg/tests-decouple-libllama branch October 12, 2026 10:33
Nathanw1014 added a commit to Nathanw1014/llama.cpp that referenced this pull request Oct 18, 2026
Master links each test against only the libraries it uses (ggml-org#30299); the
rebase gave test-tq2t and test-tqk LINK ggml but missed test-tqp, which
then fails to link in a GGML_BACKEND_DL build.

Assisted-by: Claude Opus 5.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

testing Everything test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant