mdrokz / rust-llama.cpp

LLama.cpp rust bindings
https://crates.io/crates/llama_cpp_rs/
MIT License
290 stars 42 forks source link

Cant compile on Win64 #10

Closed Scaletta closed 9 months ago

Scaletta commented 9 months ago

Hi i cannot compile on my Win11 machine. This is the verbose warning:

PS C:\Users\gtnom\RustroverProjects\rust-llama.cpp> cargo build --verbose Fresh unicode-ident v1.0.9 Fresh glob v0.3.1 Fresh minimal-lexical v0.2.1 Fresh regex-syntax v0.7.2 Fresh either v1.8.1 Fresh once_cell v1.18.0 Fresh log v0.4.19 Fresh shlex v1.1.0 Fresh lazy_static v1.4.0 Fresh proc-macro2 v1.0.63 Fresh regex v1.8.4 Fresh lazycell v1.3.0 Fresh rustc-hash v1.1.0 Fresh bitflags v2.3.3 Fresh peeking_take_while v0.1.2 Fresh cc v1.0.79 Fresh libc v0.2.147 Fresh winapi v0.3.9 Fresh quote v1.0.29 Fresh memchr v2.5.0 Fresh nom v7.1.3 Fresh syn v2.0.22 Fresh libloading v0.7.4 Fresh which v4.4.0 Fresh prettyplease v0.2.9 Fresh clang-sys v1.6.1 Fresh cexpr v0.6.0 Fresh bindgen v0.66.1 Compiling llama_cpp_rs v0.2.0 (C:\Users\gtnom\RustroverProjects\rust-llama.cpp) RunningC:\Users\gtnom\RustroverProjects\rust-llama.cpp\target\debug\build\llama_cpp_rs-684aac4c827c5037\build-script-build` The following warnings were emitted during compilation:

warning: cl : Command line error D8021 : invalid numeric argument '/Wextra'

error: failed to run custom build command for llama_cpp_rs v0.2.0 (C:\Users\gtnom\RustroverProjects\rust-llama.cpp)

Caused by: process didn't exit successfully: C:\Users\gtnom\RustroverProjects\rust-llama.cpp\target\debug\build\llama_cpp_rs-684aac4c827c5037\build-script-build (exit code: 1) --- stdout cargo:rerun-if-env-changed=TARGET cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64-pc-windows-msvc cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64_pc_windows_msvc cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS cargo:rerun-if-changed=C:\Program Files\LLVM\lib\clang\17\include\stdbool.h TARGET = Some("x86_64-pc-windows-msvc") OPT_LEVEL = Some("0") HOST = Some("x86_64-pc-windows-msvc") cargo:rerun-if-env-changed=CC_x86_64-pc-windows-msvc CC_x86_64-pc-windows-msvc = None cargo:rerun-if-env-changed=CC_x86_64_pc_windows_msvc CC_x86_64_pc_windows_msvc = None cargo:rerun-if-env-changed=HOST_CC HOST_CC = None cargo:rerun-if-env-changed=CC CC = None cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-msvc CFLAGS_x86_64-pc-windows-msvc = None cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_msvc CFLAGS_x86_64_pc_windows_msvc = None cargo:rerun-if-env-changed=HOST_CFLAGS HOST_CFLAGS = None cargo:rerun-if-env-changed=CFLAGS CFLAGS = None cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = None CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2") DEBUG = Some("true") running: "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\HostX64\x64\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "./llama.cpp" "-W4" "-Wall" "-Wextra" "-Wpedantic" "-Wcast-qual" "-Wdouble-promotion" "-Wshadow" "-Wstrict-prototypes" "-Wpointer-arith" "-march=native" "- mtune=native" "-FoC:\Users\gtnom\RustroverProjects\rust-llama.cpp\target\debug\build\llama_cpp_rs-261afeb35ceff647\out\./llama.cpp/ggml.o" "-c" "./llama.cpp/ggml.c" cargo:warning=cl : Command line error D8021 : invalid numeric argument '/Wextra' exit code: 2

--- stderr

error occurred: Command "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\bin\HostX64\x64\cl.exe" "-nologo" "-MD" "-Z7" "-Brepro" "-I" "./llama.cpp" "-W4" "-Wall" "-Wextra" "-Wpedantic" "-Wcast-qual" "-Wdouble-promotion" "-Wshadow" "-Wstrict-prototypes" "-Wpointer-arith" "-m arch=native" "-mtune=native" "-FoC:\Users\gtnom\RustroverProjects\rust-llama.cpp\target\debug\build\llama_cpp_rs-261afeb35ceff647\out\./llama.cpp/ggml.o" "-c" "./llama.cpp/ggml.c" with args "cl.exe" did not execute successfully (status code exit code: 2).`

Scaletta commented 9 months ago

The branch fix does not work for me. I'm getting another error now.

PS C:\Users\gtnom\RustroverProjects\rust-llama.cpp> cargo build
   Compiling llama_cpp_rs v0.2.0 (C:\Users\gtnom\RustroverProjects\rust-llama.cpp)
The following warnings were emitted during compilation:

warning: ./llama.cpp/ggml.c: In function 'quantize_row_q8_0':
warning: ./llama.cpp/ggml.c:1125:15: warning: unused variable 'nb' [-Wunused-variable]
warning:  1125 |     const int nb = k / QK8_0;
warning:       |               ^~
warning: ./llama.cpp/ggml.c: In function 'quantize_row_q8_1':
warning: ./llama.cpp/ggml.c:1320:15: warning: unused variable 'nb' [-Wunused-variable]
warning:  1320 |     const int nb = k / QK8_1;
warning:       |               ^~
warning: gcc.exe: warning: /W4: linker input file unused because linking not done
warning: gcc.exe: error: /W4: linker input file not found: No such file or directory
warning: gcc.exe: warning: /Wall: linker input file unused because linking not done
warning: gcc.exe: error: /Wall: linker input file not found: No such file or directory
warning: gcc.exe: warning: /wd4820: linker input file unused because linking not done
warning: gcc.exe: error: /wd4820: linker input file not found: No such file or directory
warning: gcc.exe: warning: /wd4710: linker input file unused because linking not done
warning: gcc.exe: error: /wd4710: linker input file not found: No such file or directory
warning: gcc.exe: warning: /wd4711: linker input file unused because linking not done
warning: gcc.exe: error: /wd4711: linker input file not found: No such file or directory
warning: gcc.exe: warning: /wd4820: linker input file unused because linking not done
warning: gcc.exe: error: /wd4820: linker input file not found: No such file or directory
warning: gcc.exe: warning: /wd4514: linker input file unused because linking not done
warning: gcc.exe: error: /wd4514: linker input file not found: No such file or directory

error: failed to run custom build command for `llama_cpp_rs v0.2.0 (C:\Users\gtnom\RustroverProjects\rust-llama.cpp)`

Caused by:
  process didn't exit successfully: `C:\Users\gtnom\RustroverProjects\rust-llama.cpp\target\debug\build\llama_cpp_rs-a006777b57f02e0a\build-script-build` (exit code: 1)
  --- stdout
  cargo:rerun-if-env-changed=TARGET
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64-pc-windows-gnu
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS_x86_64_pc_windows_gnu
  cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS
  cargo:rerun-if-changed=C:\Program Files\LLVM\lib\clang\17\include\stdbool.h
  TARGET = Some("x86_64-pc-windows-gnu")
  OPT_LEVEL = Some("0")
  HOST = Some("x86_64-pc-windows-gnu")
  cargo:rerun-if-env-changed=CC_x86_64-pc-windows-gnu
  CC_x86_64-pc-windows-gnu = None
  cargo:rerun-if-env-changed=CC_x86_64_pc_windows_gnu
  CC_x86_64_pc_windows_gnu = None
  cargo:rerun-if-env-changed=HOST_CC
  HOST_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64-pc-windows-gnu
  CFLAGS_x86_64-pc-windows-gnu = None
  cargo:rerun-if-env-changed=CFLAGS_x86_64_pc_windows_gnu
  CFLAGS_x86_64_pc_windows_gnu = None
  cargo:rerun-if-env-changed=HOST_CFLAGS
  HOST_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("true")
  CARGO_CFG_TARGET_FEATURE = Some("fxsr,sse,sse2")
  running: "gcc.exe" "-O0" "-ffunction-sections" "-fdata-sections" "-gdwarf-2" "-fno-omit-frame-pointer" "-m64" "-I" "./llama.cpp" "-Wall" "-Wextra" "/W4" "/Wall" "/wd4820" "/wd4710" "/wd4711" "/wd4820" "/wd4514" "-o" "C:\\Users\\gtnom\\RustroverProjects\\rust-llama.cpp\\target\\debug\\build\\llama_cpp_rs-2a8724fb4a40171d\\out\\./llama.cpp/ggml.o" "-c" "./llama.cpp/ggml.c"
  cargo:warning=./llama.cpp/ggml.c: In function 'quantize_row_q8_0':
  cargo:warning=./llama.cpp/ggml.c:1125:15: warning: unused variable 'nb' [-Wunused-variable]
  cargo:warning= 1125 |     const int nb = k / QK8_0;
  cargo:warning=      |               ^~
  cargo:warning=./llama.cpp/ggml.c: In function 'quantize_row_q8_1':
  cargo:warning=./llama.cpp/ggml.c:1320:15: warning: unused variable 'nb' [-Wunused-variable]
  cargo:warning= 1320 |     const int nb = k / QK8_1;
  cargo:warning=      |               ^~
  cargo:warning=gcc.exe: warning: /W4: linker input file unused because linking not done
  cargo:warning=gcc.exe: error: /W4: linker input file not found: No such file or directory
  cargo:warning=gcc.exe: warning: /Wall: linker input file unused because linking not done
  cargo:warning=gcc.exe: error: /Wall: linker input file not found: No such file or directory
  cargo:warning=gcc.exe: warning: /wd4820: linker input file unused because linking not done
  cargo:warning=gcc.exe: error: /wd4820: linker input file not found: No such file or directory
  cargo:warning=gcc.exe: warning: /wd4710: linker input file unused because linking not done
  cargo:warning=gcc.exe: error: /wd4710: linker input file not found: No such file or directory
  cargo:warning=gcc.exe: warning: /wd4711: linker input file unused because linking not done
  cargo:warning=gcc.exe: error: /wd4711: linker input file not found: No such file or directory
  cargo:warning=gcc.exe: warning: /wd4820: linker input file unused because linking not done
  cargo:warning=gcc.exe: error: /wd4820: linker input file not found: No such file or directory
  cargo:warning=gcc.exe: warning: /wd4514: linker input file unused because linking not done
  cargo:warning=gcc.exe: error: /wd4514: linker input file not found: No such file or directory
  exit code: 1

  --- stderr

  error occurred: Command "gcc.exe" "-O0" "-ffunction-sections" "-fdata-sections" "-gdwarf-2" "-fno-omit-frame-pointer" "-m64" "-I" "./llama.cpp" "-Wall" "-Wextra" "/W4" "/Wall" "/wd4820" "/wd4710" "/wd4711" "/wd4820" "/wd4514" "-o" "C:\\Users\\gtnom\\RustroverProjects\\rust-llama.cpp\\target\\debug\\build\\llama_cpp_rs-2a8724fb4a40171d\\out\\./llama.cpp/ggml.o" "-c" "./llama.cpp/ggml.c" with args "gcc.exe" did not execute successfully (status code exit code: 1).

I have mingw64 installed and working.

Scaletta commented 9 months ago

The fix/windows_flags fixed the problem. I also needed to run the following commands: rustup toolchain install stable-msvc rustup default stable-msvc

Now it works.