ggerganov/llama.cpp

Windows MSYS2 compilation error. [SOLVED]

Zibri opened this issue · 4 comments

Zibri commented
# CC=clang CPP=clang++ cmake --fresh .
-- The C compiler identification is Clang 18.1.4
-- The CXX compiler identification is GNU 14.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /mingw64/bin/clang.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /mingw64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Git: /usr/bin/git.exe (found version "2.45.0")
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- ccache found, compilation results will be cached. Disable with LLAMA_CCACHE=OFF.
-- CMAKE_SYSTEM_PROCESSOR: x86_64
-- x86 detected
-- Configuring done (4.1s)
-- Generating done (1.2s)
-- Build files have been written to: /home/Zibri/llama.cpp

# make
[  0%] Building C object CMakeFiles/ggml.dir/ggml.c.o
In file included from C:/msys64/home/Zibri/llama.cpp/ggml.c:4:
In file included from C:/msys64/home/Zibri/llama.cpp/ggml-impl.h:3:
C:/msys64/home/Zibri/llama.cpp/ggml.h:860:5: warning: 'format' attribute argument not supported: gnu_
printf [-Wignored-attributes]
  860 |     GGML_ATTRIBUTE_FORMAT(2, 3)
      |     ^
C:/msys64/home/Zibri/llama.cpp/ggml.h:212:55: note: expanded from macro 'GGML_ATTRIBUTE_FORMAT'
  212 | #    define GGML_ATTRIBUTE_FORMAT(...) __attribute__((format(gnu_printf, __VA_ARGS__)))
      |                                                       ^
1 warning generated.
[  1%] Building C object CMakeFiles/ggml.dir/ggml-alloc.c.o

[.....]

C:/msys64/home/Zibri/llama.cpp/ggml.h:860:5: warning: 'format' attribute argument not supported:
      gnu_printf [-Wignored-attributes]
  860 |     GGML_ATTRIBUTE_FORMAT(2, 3)
      |     ^
C:/msys64/home/Zibri/llama.cpp/ggml.h:212:55: note: expanded from macro 'GGML_ATTRIBUTE_FORMAT'
  212 | #    define GGML_ATTRIBUTE_FORMAT(...) __attribute__((format(gnu_printf, __VA_ARGS__)))
      |                                                       ^
In file included from C:/msys64/home/Zibri/llama.cpp/examples/server/server.cpp:14:
C:/msys64/home/Zibri/llama.cpp/examples/server/httplib.h:2696:14: error: no member named
      'CreateFile2' in the global namespace
 2696 |   hFile_ = ::CreateFile2(wpath.c_str(), GENERIC_READ, FILE_SHARE_READ,
      |            ~~^
1 warning and 1 error generated.
make[2]: *** [examples/server/CMakeFiles/server.dir/build.make:92: examples/server/CMakeFiles/server.dir/server.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:3180: examples/server/CMakeFiles/server.dir/all] Error 2
make: *** [Makefile:146: all] Error 2
Zibri commented

and in MSYS:

[  3%] Built target ggml
[  4%] Built target ggml_static
[  4%] Building CXX object CMakeFiles/llama.dir/llama.cpp.o
/home/Zibri/llama.cpp/llama.cpp: In member function ‘bool llama_mlock::raw_lock(const void*, size_t) const’:
/home/Zibri/llama.cpp/llama.cpp:1559:34: error: ‘RLIMIT_MEMLOCK’ was not declared in this scope; did you mean ‘RLIMIT_STACK’?
 1559 |         if (suggest && getrlimit(RLIMIT_MEMLOCK, &lock_limit)) {
      |                                  ^~~~~~~~~~~~~~
      |                                  RLIMIT_STACK
make[2]: *** [CMakeFiles/llama.dir/build.make:76: CMakeFiles/llama.dir/llama.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:872: CMakeFiles/llama.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

Zibri commented

This is the full script to compile it under MSYS2 CLANG.

#!/bin/bash
pacman -Suy mingw-w64-clang-x86_64-toolchain mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-openblas
git clone --recurse-submodules https://github.com/ggerganov/llama.cpp
cd llama.cpp
export CC=/clang64/bin/clang.exe
export CPP=/clang64/bin/clang++.exe
export LDFLAGS='-DLLAMA_NATIVE=ON -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON'
cmake .
make -j $(nproc)

If the issue is solved you should close it. Thank you for sharing the solution.

Or also:
in msys2/mingw

export CC=gcc
export CPP=g++
export LDFLAGS='-DLLAMA_NATIVE=ON -DLLAMA_BUILD_SERVER=ON -DBUILD_SHARED_LIBS=ON -DLLMODEL_CUDA=OFF'
git reset --hard
git clean -fd
git pull
cmake .
make