1

I encountered some errors during cross compilation

When I was building a program on aarch64-unknown-linux-gnu, I encountered the following error:

error[E0308]: mismatched types
    --> common/models/src/meta_data.rs:258:37
     |
258  |     check_err(unsafe { libc::statfs(c_storage_path.as_ptr() as *const i8, statfs.as_mut_ptr()) })?;
     |                        ------------ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `*const u8`, found `*const i8`
     |                        |
     |                        arguments to this function are incorrect
     |
     = note: expected raw pointer `*const u8`
                found raw pointer `*const i8`
note: function defined here
    --> /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/libc-0.2.140/src/unix/linux_like/mod.rs:1675:12
     |
1675 |     pub fn statfs(path: *const ::c_char, buf: *mut statfs) -> ::c_int;
     |            ^^^^^^

For more information about this error, try `rustc --explain E0308`.
error: could not compile `models` (lib) due to previous error
warning: build failed, waiting for other jobs to finish...

Reproduction steps:

  1. You can view this PR:https://github.com/cnosdb/cnosdb/pull/1093

  2. Execute script commands

chmod +x scripts/package/setup.sh
./scripts/package/setup.sh
Ivan Gao
  • 35
  • 4

1 Answers1

1

The code is not applicable to all system architectures, when cross-compiling target is aarch64-unknown-linux-gnu, I need to change i8 to u8

Ivan
  • 96
  • 8