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

fails to build on 32-bit #323

Closed
plugwash opened this issue Nov 6, 2022 · 2 comments
Closed

fails to build on 32-bit #323

plugwash opened this issue Nov 6, 2022 · 2 comments

Comments

@plugwash
Copy link

plugwash commented Nov 6, 2022

While packaging stuff for debian I noticed some build failures on 32-bit architectures.

The first is in rkyv_derive and happens with default features.

error: literal out of range for `usize`
   --> rkyv_derive/src/archive.rs:785:41
    |
785 |                         4_294_967_296..=18_446_744_073_709_551_615 => IntRepr::U64,
    |                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: the literal `18_446_744_073_709_551_615` does not fit into the type `usize` whose range is `0..=4294967295`

My fix was to change the match statement to.

let int_repr = match data.variants.len() as u128 {

This works, but I'm not sure what if-any impact it has on optimisation of the code. Possiblly something with cfg attributes would be more efficient.

After fixing that, I ran into a second issue in the rkyv crate, but only when the (non-default) size_64 option is enabled.

error[E0599]: the method `as_ptr` exists for struct `rel_ptr::RelPtr<T, i64>`, but its trait bounds were not satisfied
   --> rkyv/src/boxed.rs:19:27
    |
19  |         unsafe { &*self.0.as_ptr() }
    |                           ^^^^^^ method cannot be called on `rel_ptr::RelPtr<T, i64>` due to unsatisfied trait bounds
    |
   ::: rkyv/src/rel_ptr/mod.rs:267:1
    |
267 | pub struct RelPtr<T: ArchivePointee + ?Sized, O> {
   | ------------------------------------------------ method `as_ptr` not found for this
   |
    = note: the following trait bounds were not satisfied:
            `i64: Offset`

And a bunch more similar errors, I don't know if it makes any sense to build rkyv with the size_64 option on a system that can't actually handle data structures that size.

@djkoloski
Copy link
Collaborator

58eb31f fixes the data.variants.len() issue. For the second issue with size_64, you're correct. rkyv only the use of pointer offsets that can actually be supported by the target architecture. Otherwise you could end up in tricky situations with getelementptr and friends. Does that resolve this issue?

@djkoloski
Copy link
Collaborator

The compiler error has been fixed, so I'm closing this issue. The size_64 feature (now renamed to pointer_width_64) does not work on 32-bit and lower machines.

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