Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows MSYS2 compilation error. [SOLVED] #7275

Closed
Zibri opened this issue May 14, 2024 · 4 comments
Closed

Windows MSYS2 compilation error. [SOLVED] #7275

Zibri opened this issue May 14, 2024 · 4 comments

Comments

@Zibri
Copy link

Zibri commented May 14, 2024

# 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
Copy link
Author

Zibri commented May 14, 2024

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 Zibri changed the title Windows MSYS2 compilation error. Windows MSYS2 compilation error. [SOLVED] May 14, 2024
@Zibri
Copy link
Author

Zibri commented May 14, 2024

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)

@arnfaldur
Copy link

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

@slaren slaren closed this as completed May 19, 2024
@0wwafa
Copy link

0wwafa commented May 20, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants