Skip to content

Compile bug: Build fails on Oracle Linux 8 with GCC 8.5 undefined filesystem references in libggml.so #16019

@slamonic

Description

@slamonic

c### Git commit

b6479

Operating systems

Linux

GGML backends

CPU

Problem description & steps to reproduce

Environment

  • OS: Oracle Linux 8
  • Compiler: GCC 8.5.0 20210514 (Red Hat 8.5.0-28.0.1)
  • CMake version: 3.26.5
  • llama.cpp version: Latest (b6479)

Build fails during test linking with undefined filesystem references. The issue appears to be that libggml.so contains C++17 filesystem code but isn't properly linked with libstdc++fs library required for GCC 8.x.

Error Output:
[ 27%] Building CXX object tests/CMakeFiles/test-tokenizer-0.dir/test-tokenizer-0.cpp.o
[ 27%] Linking CXX executable ../bin/test-tokenizer-0
../bin/libggml.so: undefined reference to std::filesystem::current_path[abi:cxx11]()' ../bin/libggml.so: undefined reference to std::filesystem::__cxx11::path::_M_split_cmpts()'
../bin/libggml.so: undefined reference to std::filesystem::__cxx11::path::_M_find_extension() const' ../bin/libggml.so: undefined reference to std::filesystem::__cxx11::path::compare(std::filesystem::__cxx11::path const&) const'
../bin/libggml.so: undefined reference to std::filesystem::__cxx11::directory_iterator::directory_iterator(std::filesystem::__cxx11::path const&, std::filesystem::directory_options, std::error_code*)' ../bin/libggml.so: undefined reference to std::filesystem::__cxx11::path::has_root_directory() const'
../bin/libggml.so: undefined reference to std::filesystem::__cxx11::path::has_filename() const' ../bin/libggml.so: undefined reference to std::filesystem::__cxx11::directory_iterator::operator++()'
../bin/libggml.so: undefined reference to std::filesystem::__cxx11::directory_iterator::operator*() const' ../bin/libggml.so: undefined reference to std::filesystem::status(std::filesystem::__cxx11::path const&)'
collect2: error: ld returned 1 exit status
gmake[2]: *** [tests/CMakeFiles/test-tokenizer-0.dir/build.make:103: bin/test-tokenizer-0] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1887: tests/CMakeFiles/test-tokenizer-0.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2

Attempted Solutions:
Tried multiple CMake configurations including:
-DCMAKE_SHARED_LINKER_FLAGS="-lstdc++fs"
-DCMAKE_EXE_LINKER_FLAGS="-lstdc++fs"
-DGGML_BUILD_TESTS=OFF (still tries to build tests)

None resolved the issue.

First Bad Commit

No response

Compile command

cmake -DCMAKE_CXX_STANDARD=17 ..
cmake --build .

Also tried with explicit linker flags (failed):
cmake -DCMAKE_CXX_STANDARD=17 \
      -DCMAKE_SHARED_LINKER_FLAGS="-lstdc++fs" \
      -DCMAKE_EXE_LINKER_FLAGS="-lstdc++fs" ..

Also tried with tests disabled (still failed):
cmake -DCMAKE_CXX_STANDARD=17 -DGGML_BUILD_TESTS=OFF ..

Relevant log output

[ 27%] Building CXX object tests/CMakeFiles/test-tokenizer-0.dir/test-tokenizer-0.cpp.o
[ 27%] Linking CXX executable ../bin/test-tokenizer-0
../bin/libggml.so: undefined reference to `std::filesystem::current_path[abi:cxx11]()'
../bin/libggml.so: undefined reference to `std::filesystem::__cxx11::path::_M_split_cmpts()'
../bin/libggml.so: undefined reference to `std::filesystem::__cxx11::path::_M_find_extension() const'
../bin/libggml.so: undefined reference to `std::filesystem::__cxx11::path::compare(std::filesystem::__cxx11::path const&) const'
../bin/libggml.so: undefined reference to `std::filesystem::__cxx11::directory_iterator::directory_iterator(std::filesystem::__cxx11::path const&, std::filesystem::directory_options, std::error_code*)'
../bin/libggml.so: undefined reference to `std::filesystem::__cxx11::path::has_root_directory() const'
../bin/libggml.so: undefined reference to `std::filesystem::__cxx11::path::has_filename() const'
../bin/libggml.so: undefined reference to `std::filesystem::__cxx11::directory_iterator::operator++()'
../bin/libggml.so: undefined reference to `std::filesystem::__cxx11::directory_iterator::operator*() const'
../bin/libggml.so: undefined reference to `std::filesystem::status(std::filesystem::__cxx11::path const&)'
collect2: error: ld returned 1 exit status
gmake[2]: *** [tests/CMakeFiles/test-tokenizer-0.dir/build.make:103: bin/test-tokenizer-0] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:1887: tests/CMakeFiles/test-tokenizer-0.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2

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