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

Build breaks on arm64 and i386 #1

Open
yurivict opened this issue Nov 9, 2023 · 11 comments
Open

Build breaks on arm64 and i386 #1

yurivict opened this issue Nov 9, 2023 · 11 comments

Comments

@yurivict
Copy link

yurivict commented Nov 9, 2023

On arm64 the error is:

Running `CARGO=/usr/local/bin/cargo CARGO_CRATE_NAME=bsd_kvm CARGO_MANIFEST_DIR=/wrkdirs/usr/ports/sysutils/procs/work/procs-0.14.3/cargo-crates/bsd-kvm-0.1.2 CARGO_PKG_AUTHORS='[dalance@gmail.com](mailto:dalance@gmail.com)' CARGO_PKG_DESCRIPTION='BSD Kernel Data Access Library (libkvm) binding' CARGO_PKG_HOMEPAGE='' CARGO_PKG_LICENSE='MIT OR Apache-2.0' CARGO_PKG_LICENSE_FILE='' CARGO_PKG_NAME=bsd-kvm CARGO_PKG_README=README.md CARGO_PKG_REPOSITORY='https://github.com/dalance/bsd-kvm' CARGO_PKG_RUST_VERSION='' CARGO_PKG_VERSION=0.1.2 CARGO_PKG_VERSION_MAJOR=0 CARGO_PKG_VERSION_MINOR=1 CARGO_PKG_VERSION_PATCH=2 CARGO_PKG_VERSION_PRE='' LD_LIBRARY_PATH='/wrkdirs/usr/ports/sysutils/procs/work/target/release/deps:/usr/local/lib' /usr/local/bin/rustc --crate-name bsd_kvm --edition=2021 /wrkdirs/usr/ports/sysutils/procs/work/procs-0.14.3/cargo-crates/bsd-kvm-0.1.2/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C o
pt-level=3 -C panic=abort -C linker-plugin-lto -C codegen-units=1 -C metadata=a49964d6f87c9731 -C extra-filename=-a49964d6f87c9731 --out-dir /wrkdirs/usr/ports/sysutils/procs/work/target/aarch64-unknown-freebsd/release/deps --target aarch64-unknown-freebsd -C linker=/usr/local/llvm15/bin/clang -L dependency=/wrkdirs/usr/ports/sysutils/procs/work/target/aarch64-unknown-freebsd/release/deps -L dependency=/wrkdirs/usr/ports/sysutils/procs/work/target/release/deps --extern bsd_kvm_sys=/wrkdirs/usr/ports/sysutils/procs/work/target/aarch64-unknown-freebsd/release/deps/libbsd_kvm_sys-18fd27defc761218.rmeta --extern libc=/wrkdirs/usr/ports/sysutils/procs/work/target/aarch64-unknown-freebsd/release/deps/liblibc-3fef3e84d519faf9.rmeta --extern thiserror=/wrkdirs/usr/ports/sysutils/procs/work/target/aarch64-unknown-freebsd/release/deps/libthiserror-53aa004348e9ac9c.rmeta --cap-lints warn -C target-cpu= -C link-arg=-fstack-protector-strong`
error[E0308]: arguments to this function are incorrect
   --> /wrkdirs/usr/ports/sysutils/procs/work/procs-0.14.3/cargo-crates/bsd-kvm-0.1.2/src/lib.rs:51:13
    |
51  |             bsd_kvm_sys::kvm_openfiles(
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
note: expected `*const u8`, found `*const i8`
   --> /wrkdirs/usr/ports/sysutils/procs/work/procs-0.14.3/cargo-crates/bsd-kvm-0.1.2/src/lib.rs:52:17
    |
52  |                 execfile_ptr,
    |                 ^^^^^^^^^^^^
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`
note: expected `*const u8`, found `*const i8`
   --> /wrkdirs/usr/ports/sysutils/procs/work/procs-0.14.3/cargo-crates/bsd-kvm-0.1.2/src/lib.rs:53:17
    |
53  |                 corefile_ptr,
    |                 ^^^^^^^^^^^^
    = note: expected raw pointer `*const u8`
               found raw pointer `*const i8`
note: expected `*mut u8`, found `*mut i8

rust-1.73.0
FreeBSD 13.2

@pkubaj
Copy link

pkubaj commented Nov 14, 2023

For aarch64 (and also powerpc64 and powerpc64le), the problem is because those architectures use unsigned char by default, but there are lots of signed char definitions, e.g.:
pub moretdname: [i8; MAXCOMLEN as usize - TDNAMLEN as usize + 1],

An example for a fix is PonasKovas/rlaunch@2f73499
Basically, you need to use c_char type instead of i8.

dalance added a commit that referenced this issue Nov 20, 2023
@dalance
Copy link
Owner

dalance commented Nov 20, 2023

Thank you for your suggestion.
I changed from i8 to c_char.
Could you try cargo test at the latest revision of this repository?

@pkubaj
Copy link

pkubaj commented Nov 22, 2023

Better, but there are still some errors.

  1. nice is still i8 strictly. See src/unix/bsd/freebsdlike/freebsd/freebsd14/mod.rs in libc crate.
  2. kvm_openfiles() function as a fifth parameter takes a c_char, but the passed errbuf is i8, which causes similar issue. I tried switching to u8 for my usecase (obviously needs to be done better, but I don't really know Rust) and bsd-kvm compiled, although procs still didn't, but let's fix this one first.

dalance added a commit that referenced this issue Nov 22, 2023
@dalance
Copy link
Owner

dalance commented Nov 22, 2023

I fixed the type of nice and errbuf.
Could you provide the error of procs compilation?

@pkubaj
Copy link

pkubaj commented Nov 22, 2023

error[E0308]: mismatched types
   --> src/./columns/command.rs:111:48
    |
111 |             let comm = crate::util::i8_to_cstr(proc.curr_proc.info.comm.as_ref());
    |                        ----------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&[i8]`, found `&[u8]`
    |                        |
    |                        arguments to this function are incorrect
    |
    = note: expected reference `&[i8]`
               found reference `&[u8]`
note: function defined here
   --> src/util.rs:358:8
    |
358 | pub fn i8_to_cstr(x: &[i8]) -> Result<&std::ffi::CStr, std::ffi::FromBytesUntilNulError> {
    |        ^^^^^^^^^^ --------

error[E0308]: mismatched types
   --> src/./columns/file_name.rs:45:44
    |
45  |         let comm = crate::util::i8_to_cstr(proc.curr_proc.info.comm.as_ref());
    |                    ----------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&[i8]`, found `&[u8]`
    |                    |
    |                    arguments to this function are incorrect
    |
    = note: expected reference `&[i8]`
               found reference `&[u8]`
note: function defined here
   --> src/util.rs:358:8
    |
358 | pub fn i8_to_cstr(x: &[i8]) -> Result<&std::ffi::CStr, std::ffi::FromBytesUntilNulError> {
    |        ^^^^^^^^^^ --------

error[E0308]: mismatched types
   --> src/./columns/state.rs:125:63
    |
125 |         if (flag & libc::P_WEXIT as i64) != 0 && info.stat != libc::SZOMB as i8 {
    |                                                  ---------    ^^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
    |                                                  |
    |                                                  expected because this is `u8`
    |
help: you can convert an `i8` to a `u8` and panic if the converted value doesn't fit
    |
125 |         if (flag & libc::P_WEXIT as i64) != 0 && info.stat != (libc::SZOMB as i8).try_into().unwrap() {
    |                                                               +                 +++++++++++++++++++++

error[E0308]: mismatched types
   --> src/./columns/wchan.rs:48:70
    |
48  |         let raw_content = if let Ok(wmesg) = crate::util::i8_to_cstr(&proc.curr_proc.info.wmesg) {
    |                                              ----------------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&[i8]`, found `&[u8; 9]`
    |                                              |
    |                                              arguments to this function are incorrect
    |
    = note: expected reference `&[i8]`
               found reference `&[u8; 9]`
note: function defined here
   --> src/util.rs:358:8
    |
358 | pub fn i8_to_cstr(x: &[i8]) -> Result<&std::ffi::CStr, std::ffi::FromBytesUntilNulError> {
    |        ^^^^^^^^^^ --------

For more information about this error, try `rustc --explain E0308`.
error: could not compile `procs` (bin "procs") due to 4 previous errors

@dalance
Copy link
Owner

dalance commented Nov 23, 2023

I fixed procs: dalance/procs@ef802bc.
Could you try it?

@pkubaj
Copy link

pkubaj commented Nov 23, 2023

Thanks, this makes procs build on powerpc64.

@dalance
Copy link
Owner

dalance commented Nov 24, 2023

I released bsd-kvm v0.1.3 and procs v0.14.4.

@dalance dalance closed this as completed Nov 28, 2023
@yurivict
Copy link
Author

yurivict commented Jan 21, 2024

@dalance
Here is the fresh failure of the sysutils/procs port with bsd-kvm-0.1.4.

@dalance dalance reopened this Jan 21, 2024
dalance added a commit that referenced this issue Jan 22, 2024
@dalance
Copy link
Owner

dalance commented Jan 22, 2024

@yurivict I've released bsd-kvm-0.1.5. Could you try it?

@yurivict
Copy link
Author

Unfortunately I don't have access to the i386 system, so I can't try it.
The failures occur on the build servers.

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

3 participants