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

Expected u32 found u64 compilation error on ARMv7 (or maybe all 32-bit arches?) #1

Open
reivilibre opened this issue Jun 8, 2022 · 1 comment · May be fixed by #2
Open

Expected u32 found u64 compilation error on ARMv7 (or maybe all 32-bit arches?) #1

reivilibre opened this issue Jun 8, 2022 · 1 comment · May be fixed by #2

Comments

@reivilibre
Copy link

error[E0308]: mismatched types
   --> src/lib.rs:148:69
    |
148 |         match unsafe { ffi::fvad_process(self.fvad, frame.as_ptr(), frame.len() as u64) } {
    |                                                                     ^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64`
    |
help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit
    |
148 |         match unsafe { ffi::fvad_process(self.fvad, frame.as_ptr(), (frame.len() as u64).try_into().unwrap()) } {
    |                                                                     +                  +++++++++++++++++++++

For more information about this error, try `rustc --explain E0308`.

How to reproduce

Unless you have a capable ARMv7 thing lying around, it'll probably be more convenient to cross-compile to reproduce this.

Install cross:

cargo install cross --git https://github.com/cross-rs/cross

Clone the repo and cd into it:

git clone https://github.com/rvolosatovs/fvad && cd fvad

Create armv7.Dockerfile in the same directory:

FROM ghcr.io/cross-rs/armv7-unknown-linux-gnueabihf:main

RUN dpkg --add-architecture armhf && \
    apt-get update && \
    apt-get install --assume-yes libasound2-dev:armhf libssl-dev:armhf libc++-dev:armhf clang-3.9

Build:

docker build -t unpublished:armv7-unknown-linux-gnueabihf -f armv7.Dockerfile .

Create Cross.toml in the same directory:

[target.armv7-unknown-linux-gnueabihf]
image = "unpublished:armv7-unknown-linux-gnueabihf"

Build with Cross:

cross build --target armv7-unknown-linux-gnueabihf

I don't know how this is meant to be solved. There might be some bindgen trick that I'm not aware of (it seems like it should be typed at usize??) or maybe the source code just has to be 'coincidentally compatible' with both u32 and u64...?

@reivilibre
Copy link
Author

This appears to be rust-lang/rust-bindgen#1901.

I think the simple answer is to enable some size_t_is_usize option and say sorry to the people who are using a rare platform where that doesn't hold true :/.

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.

1 participant