Skip to content

Misc. bug: Shared libraries don't properly contain /common/ functions #13156

Open
@kinchahoy

Description

@kinchahoy

Name and Version

I'm using cppyy to create python bindings to the terrific, cleaned-up multimodal functionality in mtmd.cpp (great work @ngxson!)

I managed to get it working (happy to share some example code), but I had to create a custom Makefile to create a separate library for functions in /common because they don't seem to correctly get included in libllama.dylib (or .so).

Functions like "common_params_sampling" or "common_batch_add" are not available in libllama.dylib even after correctly building with BUILD_SHARED_LIBS=1.

Okay - after some digging, I think the correct thing to do is simply to have the common target respect the overall build settings. So instead of forcing static (like we do now)

add_library(${TARGET} STATIC

switch to

add_library(${TARGET}
// Equivalent to add_library(${TARGET} SHARED when BUILD_SHARED_LIBS=ON

This ensures that when you build with -DBUILD_SHARED_LIBS=ON, lib_common.so (or dylib) is created.

I don't believe there are performance concerns here (ran some quick benchmarks), but we could also consider a distinct flag to build lib_common.so.

I'll submit a PR to propose the simple version for now.

Operating systems

No response

Which llama.cpp modules do you know to be affected?

No response

Command line

Problem description & steps to reproduce

cmake -B build-DBUILD_SHARED_LIBS=ON

does not provide shared library access to common inferencing functions like common_batch_add (no libcommon.so created)

First Bad Commit

No response

Relevant log output

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions