dermesser / integer-encoding-rs

Integer encoding for primitive integer types: Supports varint/varint+zigzag and fixed-length integer encoding and decoding, and provides synchronous and asynchronous Write/Read types for easily writing/reading integers.
Other
66 stars 16 forks source link

Build of the crate fails on big-endian architecture #24

Open Laiot opened 2 years ago

Laiot commented 2 years ago

The build fails for the s390x architecture, might be a problem with any big-endian architecture.

failures:
---- fixed_tests::tests::test_i16_enc stdout ----
thread 'fixed_tests::tests::test_i16_enc' panicked at 'assertion failed: `(left == right)`
  left: `[128, 0]`,
 right: `[0, 128]`', src/fixed_tests.rs:26:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- fixed_tests::tests::test_i32_enc stdout ----
thread 'fixed_tests::tests::test_i32_enc' panicked at 'assertion failed: `(left == right)`
  left: `[255, 255, 128, 1]`,
 right: `[1, 128, 255, 255]`', src/fixed_tests.rs:31:9
---- fixed_tests::tests::test_i32_enc_light stdout ----
thread 'fixed_tests::tests::test_i32_enc_light' panicked at 'assertion failed: `(left == right)`
  left: `[255, 255, 128, 1]`,
 right: `[1, 128, 255, 255]`', src/fixed_tests.rs:48:9
---- fixed_tests::tests::test_u16_enc stdout ----
thread 'fixed_tests::tests::test_u16_enc' panicked at 'assertion failed: `(left == right)`
  left: `[1, 0]`,
 right: `[0, 1]`', src/fixed_tests.rs:21:9
---- fixed_tests::tests::test_u32_enc stdout ----
thread 'fixed_tests::tests::test_u32_enc' panicked at 'assertion failed: `(left == right)`
  left: `[0, 0, 0, 32]`,
 right: `[32, 0, 0, 0]`', src/fixed_tests.rs:16:9
failures:
    fixed_tests::tests::test_i16_enc
    fixed_tests::tests::test_i32_enc
    fixed_tests::tests::test_i32_enc_light
    fixed_tests::tests::test_u16_enc
    fixed_tests::tests::test_u32_enc
test result: FAILED. 18 passed; 5 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
dermesser commented 2 years ago

Ah well, the time has come... so far, for simplicity and laziness reasons, I've simply not bothered about BE architectures. If this issue is more than "it doesn't build, shrug" (i.e. "I need this to build!"), please let me know and I will investigate ways to implement this properly.

Laiot commented 2 years ago

I wanted to make a Fedora package of this crate because many other crates depend on this one (eg message-io). One of the review tests we run before approving a package is indeed on an s390x machine.

dermesser commented 2 years ago

I've implemented fixes for fixed-width integers. I believe that all important tests are updated accordingly, but could you run the build process again before I publish a new version before reporting back? That would be very helpful!

Laiot commented 2 years ago

I'm sorry it took me so long to reply and thank you for your work. Unfortunately, neither of the two patches works, the build on the s390x architecture keeps failing. Also the last patch (46f5f3e40c7d4819f7e8484cb58a571caa22c3b4) makes builds on standard architectures fail too.

dermesser commented 2 years ago

This is unfortunate - especially as the tests pass on x86 (Github CI and locally). Can you post the specific errors for the respective architecture, so I can better understand what is going wrong? They should at least be different from the ones you posted initially.