matsadler / magnus

Ruby bindings for Rust. Write Ruby extension gems in Rust, or call Ruby from Rust.

Home Page:https://docs.rs/magnus/latest/magnus/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Errors on `arm-linux`

ianks opened this issue · comments

Just documenting some errors I encountered on arm-linux. Mostly u32 <-> u64 things.

error[E0308]: mismatched types
    --> /home/runner/work/yrb/yrb/tmp/cargo-vendor/magnus/src/value.rs:2267:64
     |
2267 |             return Some(unsafe { Self::from_rb_value_unchecked(v.rotate_left(3) & !0x01 | 0x02) });
     |                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u32`, found `u64`
     |
help: you can convert a `u64` to a `u32` and panic if the converted value doesn't fit
     |
2267 |             return Some(unsafe { Self::from_rb_value_unchecked((v.rotate_left(3) & !0x01 | 0x02).try_into().unwrap()) });
     |                                                                +                               +++++++++++++++++++++

error[E0308]: mismatched types
    --> /home/runner/work/yrb/yrb/tmp/cargo-vendor/magnus/src/value.rs:2310:41
     |
2310 |             let v = (2_u64.wrapping_sub(b63) | v & !0x03).rotate_right(3);
     |                                         ^^^ expected `u64`, found `u32`
     |
help: you can convert a `u32` to a `u64`
     |
2310 |             let v = (2_u64.wrapping_sub(b63.into()) | v & !0x03).rotate_right(3);
     |                                            +++++++

error[E0308]: mismatched types
    --> /home/runner/work/yrb/yrb/tmp/cargo-vendor/magnus/src/value.rs:2310:48
     |
2310 |             let v = (2_u64.wrapping_sub(b63) | v & !0x03).rotate_right(3);
     |                                                ^^^^^^^^^ expected `u64`, found `u32`

error[E0277]: no implementation for `u64 | u32`
    --> /home/runner/work/yrb/yrb/tmp/cargo-vendor/magnus/src/value.rs:2310:46
     |
2310 |             let v = (2_u64.wrapping_sub(b63) | v & !0x03).rotate_right(3);
     |                                              ^ no implementation for `u64 | u32`
     |
     = help: the trait `BitOr<u32>` is not implemented for `u64`
     = help: the following other types implement trait `BitOr<Rhs>`:
               <&'a i128 as BitOr<i128>>
               <&'a i16 as BitOr<i16>>
               <&'a i32 as BitOr<i32>>
               <&'a i64 as BitOr<i64>>
               <&'a i8 as BitOr<i8>>
               <&'a isize as BitOr<isize>>
               <&'a u128 as BitOr<u128>>
               <&'a u16 as BitOr<u16>>
             and 52 others

Just FYI, I'm seeing these too: https://github.com/gjtorikian/commonmarker/actions/runs/3267161980/jobs/5371966486

Is there a problem with just applying the suggested changes? Happy to make a PR if so.

These errors are from the code supporting ‘flonum’ (encoding lower precision floats into Ruby’s VALUE pointer, so Ruby can avoid allocating an object for a float). This is only possible on 64bit systems, and arm-linux is 32 bit (64 bit arm is aarch64).

All the flonum support should be conditionally compiled only for 64 bit platforms. Ideally we’d be able to pick up the USE_FLONUM value from Ruby’s build config, as that’s what Ruby is using internally.

I’m honestly surprised these are the only compilation errors for 32bit systems, as I’ve not tested 32bit support at all.

These errors are from the code supporting ‘flonum’ (encoding lower precision floats into Ruby’s VALUE pointer, so Ruby can avoid allocating an object for a float). This is only possible on 64bit systems, and arm-linux is 32 bit (64 bit arm is aarch64).

All the flonum support should be conditionally compiled only for 64 bit platforms. Ideally we’d be able to pick up the USE_FLONUM value from Ruby’s build config, as that’s what Ruby is using internally.

I’m honestly surprised these are the only compilation errors for 32bit systems, as I’ve not tested 32bit support at all.

I solved this for rb-sys, and could expose it via cargo config, so DEP_USE_FLONUM is available

I solved this for rb-sys, and could expose it via cargo config, so DEP_USE_FLONUM is available

Yeah, that’d be great