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

llama_cpp_sys build issue: u8 vs i8 in APIs #70

Closed
anisse opened this issue Apr 5, 2024 · 3 comments · Fixed by #71
Closed

llama_cpp_sys build issue: u8 vs i8 in APIs #70

anisse opened this issue Apr 5, 2024 · 3 comments · Fixed by #71

Comments

@anisse
Copy link

anisse commented Apr 5, 2024

An empty project with llama_cpp fails to build the sys crate, on rust 1.77.1, linux arm64:

248  |             llama_tokenize(
     |             -------------- arguments to this function are incorrect
249  |                 **self.model,
250  |                 content.as_ptr() as *const i8,
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`

Full details:

$ mkdir new-project
$ cd new-project
$ cargo init         
     Created binary (application) package
$ cargo add llama_cpp
    Updating crates.io index
      Adding llama_cpp v0.3.1 to dependencies.
             Features:
             + accel
             + avx
             + avx2
             + compat
             + f16c
             + fma
             + native
             - avx512
             - avx512_vmbi
             - avx512_vnni
             - blas
             - clblast
             - cuda
             - cuda_dmmv
             - cuda_f16
             - cuda_mmq
             - hipblas
             - metal
             - mpi
             - vulkan
    Updating crates.io index
$ rustc --version
rustc 1.77.1 (7cf61ebde 2024-03-27)
$ rustup show active-toolchain
stable-aarch64-unknown-linux-gnu (default)
$ cargo build
   Compiling proc-macro2 v1.0.79
   Compiling unicode-ident v1.0.12
   Compiling libc v0.2.153
   Compiling glob v0.3.1
   Compiling rustix v0.38.32
   Compiling prettyplease v0.2.17
   Compiling cfg-if v1.0.0
   Compiling either v1.10.0
   Compiling regex-syntax v0.8.3
   Compiling autocfg v1.2.0
   Compiling minimal-lexical v0.2.1
   Compiling memchr v2.7.2
   Compiling linux-raw-sys v0.4.13
   Compiling clang-sys v1.7.0
   Compiling bitflags v2.5.0
   Compiling slab v0.4.9
   Compiling quote v1.0.35
   Compiling nom v7.1.3
   Compiling libloading v0.8.3
   Compiling syn v2.0.58
   Compiling home v0.5.9
   Compiling once_cell v1.19.0
   Compiling pin-project-lite v0.2.14
   Compiling jobserver v0.1.28
   Compiling regex-automata v0.4.6
   Compiling bindgen v0.69.4
   Compiling cc v1.0.90
   Compiling itertools v0.12.1
   Compiling cexpr v0.6.0
   Compiling which v4.4.2
   Compiling futures-sink v0.3.30
   Compiling futures-core v0.3.30
   Compiling log v0.4.21
   Compiling shlex v1.3.0
   Compiling rustc-hash v1.1.0
   Compiling regex v1.10.4
   Compiling lazy_static v1.4.0
   Compiling lazycell v1.3.0
   Compiling futures-channel v0.3.30
   Compiling futures-io v0.3.30
   Compiling pin-utils v0.1.0
   Compiling futures-task v0.3.30
   Compiling syn v1.0.109
   Compiling thiserror v1.0.58
   Compiling tracing-core v0.1.32
   Compiling convert_case v0.4.0
   Compiling link-cplusplus v1.0.9
   Compiling tokio v1.37.0
   Compiling num_cpus v1.16.0
   Compiling futures-macro v0.3.30
   Compiling thiserror-impl v1.0.58
   Compiling tracing-attributes v0.1.27
   Compiling derive_more v0.99.17
   Compiling futures-util v0.3.30
   Compiling tracing v0.1.40
   Compiling llama_cpp_sys v0.3.1
   Compiling futures-executor v0.3.30
   Compiling futures v0.3.30
   Compiling llama_cpp v0.3.1
error[E0308]: mismatched types
    --> /home/anisse/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama_cpp-0.3.1/src/model/mod.rs:250:17
     |
248  |             llama_tokenize(
     |             -------------- arguments to this function are incorrect
249  |                 **self.model,
250  |                 content.as_ptr() as *const i8,
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
     |
     = note: expected raw pointer `*const u8`
                found raw pointer `*const i8`
note: function defined here
    --> /home/anisse/dev/new-project/target/debug/build/llama_cpp_sys-a7988d5d0059f72f/out/bindings.rs:4019:12
     |
4019 |     pub fn llama_tokenize(
     |            ^^^^^^^^^^^^^^

error[E0308]: mismatched types
    --> /home/anisse/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama_cpp-0.3.1/src/model/mod.rs:326:17
     |
323  |             llama_token_to_piece(
     |             -------------------- arguments to this function are incorrect
...
326  |                 buffer.as_mut_ptr() as *mut i8,
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*mut u8`, found `*mut i8`
     |
     = note: expected raw pointer `*mut u8`
                found raw pointer `*mut i8`
note: function defined here
    --> /home/anisse/dev/new-project/target/debug/build/llama_cpp_sys-a7988d5d0059f72f/out/bindings.rs:4030:12
     |
4030 |     pub fn llama_token_to_piece(
     |            ^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
    --> /home/anisse/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama_cpp-0.3.1/src/model/mod.rs:340:21
     |
337  |                 llama_token_to_piece(
     |                 -------------------- arguments to this function are incorrect
...
340  |                     buffer.as_mut_ptr() as *mut i8,
     |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*mut u8`, found `*mut i8`
     |
     = note: expected raw pointer `*mut u8`
                found raw pointer `*mut i8`
note: function defined here
    --> /home/anisse/dev/new-project/target/debug/build/llama_cpp_sys-a7988d5d0059f72f/out/bindings.rs:4030:12
     |
4030 |     pub fn llama_token_to_piece(
     |            ^^^^^^^^^^^^^^^^^^^^

error[E0308]: mismatched types
    --> /home/anisse/.cargo/registry/src/index.crates.io-6f17d22bba15001f/llama_cpp-0.3.1/src/model/mod.rs:382:21
     |
379  |                 llama_cpp_sys::llama_token_to_piece(
     |                 ----------------------------------- arguments to this function are incorrect
...
382  |                     token_buf.as_mut_ptr() as *mut i8,
     |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*mut u8`, found `*mut i8`
     |
     = note: expected raw pointer `*mut u8`
                found raw pointer `*mut i8`
note: function defined here
    --> /home/anisse/dev/new-project/target/debug/build/llama_cpp_sys-a7988d5d0059f72f/out/bindings.rs:4030:12
     |
4030 |     pub fn llama_token_to_piece(
     |            ^^^^^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0308`.
error: could not compile `llama_cpp` (lib) due to 4 previous errors
$ 
@anisse
Copy link
Author

anisse commented Apr 5, 2024

Looks like it might be platform-specific... I tried to fix it and failed: https://github.com/anisse/llama_cpp-rs/actions/runs/8569447184/job/23485360455#step:5:297

@pedro-devv pedro-devv linked a pull request Apr 5, 2024 that will close this issue
@pedro-devv
Copy link
Contributor

I've made some changes that should fix the issue, please let me know if it persists after I merge them.

@anisse
Copy link
Author

anisse commented Apr 5, 2024

Thank you, I confirmed this fixed the issue.

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

Successfully merging a pull request may close this issue.

2 participants