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

compile error: the trait bound u64: ToUsize is not satisfied on raspberry pi(armv7-unknown-linux-gnueabihf) #191

Closed
2 tasks
pymongo opened this issue Jul 11, 2021 · 3 comments

Comments

@pymongo
Copy link
Contributor

pymongo commented Jul 11, 2021

toolchains: nightly-2021-06-26-armv7-unknown-linux-gnueabihf

    Checking server_mysql v0.9.3 (/home/pi/repos/tensorbase/crates/server_mysql)
   Compiling arrow-flight v5.0.0-SNAPSHOT (/home/pi/repos/tensorbase/crates/arrow-flight)
error[E0277]: the trait bound `u64: ToUsize` is not satisfied
   --> crates/server_mysql/src/commands.rs:142:49
    |
142 |     let (i, bytes) = nom::bytes::complete::take(len)(i)?;
    |                                                 ^^^ the trait `ToUsize` is not implemented for `u64`
    | 
   ::: /home/pi/.cargo/registry/src/github.com-1285ae84e5963aae/nom-5.1.2/src/bytes/complete.rs:381:6
    |
381 |   C: ToUsize,
    |      ------- required by this bound in `nom::bytes::complete::take`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
error: could not compile `server_mysql`

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

ARM 32 bit CPU usize is u32, can not convert a u64 to a usize(u32) on 32-bit CPU!

parse_len_enc_int(i: &[u8]) -> nom::IResult<&[u8], u64>

other difference between ARM 32bit and x86_64:

  • libc::time_t: i32
  • libc::c_long: i32
  • libc::c_char: u8 (on x86_64 is i8)

tasks list to support ARM or 32-bit CPU:

  • solve all usize::from(u64) code
  • use cfg to detect cpu arch, enhance all std::arch::x86_64 usage
@jinmingjian
Copy link
Contributor

@pymongo very thanks for trying to build on ARM. I personally think there are some trivial works for ARM64 in that I have no hardware to test till now.

For your this issue, the crate server_mysql is a new comer, and not well investigated. In the future, we will align to modern 64bit processors as tier1 hardware. However, if we can help for other 32bit platform, it is still welcome! Could you like to submit a PR for this?

@pymongo
Copy link
Contributor Author

pymongo commented Jul 11, 2021

The std::arch::x86_64::_mm_crc32_u64 function is not found on ARM

unsafe fn _hash(k1: u64, k2: u64) -> u64 {
use std::arch::x86_64::*;
_mm_crc32_u64(k1, k2)
}
unsafe { _hash(0, *self as u64) }

@jinmingjian
Copy link
Contributor

@pymongo there is a workaround here at riscv branch. You can have this in your testing, to see if it is ok to clear the building.

@pymongo pymongo closed this as completed May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants