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

Unable to build on 32-bit architectures #500

Closed
ptrcnull opened this issue Jul 5, 2023 · 5 comments
Closed

Unable to build on 32-bit architectures #500

ptrcnull opened this issue Jul 5, 2023 · 5 comments
Assignees

Comments

@ptrcnull
Copy link

ptrcnull commented Jul 5, 2023

Trying to build a program depending on this library returns the following errors:

error[E0308]: mismatched types
  --> /home/buildozer/.cargo/registry/src/index.crates.io-1cd66030c949c28d/libbpf-rs-0.20.1/src/program.rs:56:17
   |
56 |             sz: mem::size_of::<Self>() as u64,
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64`
error[E0308]: mismatched types
  --> /home/buildozer/.cargo/registry/src/index.crates.io-1cd66030c949c28d/libbpf-rs-0.20.1/src/program.rs:79:17
   |
79 |             sz: mem::size_of::<Self>() as u64,
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64`
error[E0308]: mismatched types
   --> /home/buildozer/.cargo/registry/src/index.crates.io-1cd66030c949c28d/libbpf-rs-0.20.1/src/program.rs:538:17
    |
538 |             sz: mem::size_of::<Self>() as u64,
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64`
For more information about this error, try `rustc --explain E0308`.
@danielocfb danielocfb self-assigned this Jul 5, 2023
@danielocfb
Copy link
Collaborator

Thanks for the report. We should fix that.

@danielocfb
Copy link
Collaborator

@ptrcnull could you try with the changes from #501, by any chance ? I'd think that should fix your problems, but don't have a 32 bit x86 handy.

@ptrcnull
Copy link
Author

ptrcnull commented Jul 6, 2023

seems to fix all issues for me:

libbpf-rs# curl -sL https://github.com/libbpf/libbpf-rs/pull/501.patch | git am
Applying: Fix (some?) 32 bit builds
Applying: Add aarch32 cross-compilation workflow
libbpf-rs# cargo build
   Compiling libbpf-rs v0.21.0 (/tmp/tmp.minrtqU9IM/libbpf-rs/libbpf-rs)
   Compiling libbpf-cargo v0.21.0 (/tmp/tmp.minrtqU9IM/libbpf-rs/libbpf-cargo)
   Compiling bpf_query v0.1.0 (/tmp/tmp.minrtqU9IM/libbpf-rs/examples/bpf_query)
   Compiling tproxy v0.1.0 (/tmp/tmp.minrtqU9IM/libbpf-rs/examples/tproxy)
   Compiling runqslower v0.1.0 (/tmp/tmp.minrtqU9IM/libbpf-rs/examples/runqslower)
   Compiling capable v0.1.0 (/tmp/tmp.minrtqU9IM/libbpf-rs/examples/capable)
   Compiling tc_whitelist_ports v0.1.0 (/tmp/tmp.minrtqU9IM/libbpf-rs/examples/tc_port_whitelist)
   Compiling runqslower v0.1.0 (/tmp/tmp.minrtqU9IM/libbpf-rs/examples/runqslower)
    Finished dev [unoptimized + debuginfo] target(s) in 2.29s

@danielocfb
Copy link
Collaborator

Great! Thanks for checking.

danielocfb pushed a commit that referenced this issue Jul 6, 2023
We don't really test on 32 bit systems. As a result we could experience
unintentional breakages on certain targets. Add a CI workflow that build
everything on aarch32. Ideally we'd do the same for x86
(i386/i686/whatever), but I haven't been able to set that up in
reasonable effort.
aarch32 actually seems to expose more mismatches than x86 and is a true
superset [0] [1]

[0]: https://github.com/danielocfb/libbpf-rs/actions/runs/5469860425/jobs/9959276295
[1]: #500

Signed-off-by: Daniel Müller <deso@posteo.net>
@danielocfb
Copy link
Collaborator

The fix is included in v0.21.1.

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

2 participants