Skip to content

Tests, examples fail to build with GGML_BACKEND_DL=ON #1120

Closed
@ckastner

Description

@ckastner

When building with GGML_BACKEND_DL=ON, linker failures start to appear. For example, from test-opt.c:843:

$ cmake -B build -DGGML_NATIVE=OFF -DGGML_BACKEND_DL=ON
...

$ cmake --build build
...
[ 25%] Building CXX object tests/CMakeFiles/test-opt.dir/test-opt.cpp.o
[ 26%] Linking CXX executable ../bin/test-opt
/usr/bin/ld: CMakeFiles/test-opt.dir/test-opt.cpp.o: in function `main':
test-opt.cpp:(.text.startup+0xbf): undefined reference to `ggml_backend_is_cpu'
/usr/bin/ld: test-opt.cpp:(.text.startup+0xd4): undefined reference to `ggml_backend_cpu_set_n_threads'
collect2: error: ld returned 1 exit status
gmake[2]: *** [tests/CMakeFiles/test-opt.dir/build.make:102: bin/test-opt] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:633: tests/CMakeFiles/test-opt.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2

I was looking into a PR to fix this, but I'm not sure to best go about it, or if this even needs fixing because it's working as intended.

Using the above example, when using GGML_BACKEND_DL, how would upstream guide to use ggml_backend_cpu_set_n_threads correctly? Should these be dlsymed by the caller?

My naive approach would have been to expect that there is some shim that takes care of this and that errors out when certain functionality is not available, which could be guarded by a ggml_backend_is_<foo>, but the latter two seems to be defined in the modules. But I'm not that familiar with the codebase yet, so perhaps this already exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions