shepmaster / twox-hash

A Rust implementation of the XXHash algorithm.
MIT License
361 stars 41 forks source link

Support big-endian platforms #86

Closed uweigand closed 2 years ago

uweigand commented 2 years ago

When using the UnalignedBuffer mechanism to operate on multiple input bytes at once, the resulting u32 or u64 needs to be byte-swapped on big-endian platforms.

uweigand commented 2 years ago

Ping? Any updates on this?

shepmaster commented 2 years ago

This doesn't seem to regress any existing tests, but I don't have access to any big-endian hardware to test on. I'll merge this for now as it doesn't appear to be in any worse of a state.

Do you have any insights about how to test big endian platforms in GitHub CI?

uweigand commented 2 years ago

Thanks!

Do you have any insights about how to test big endian platforms in GitHub CI?

There would be two possibilities to test on s390x (IBM Z) specifically, which is the big-endian platform I'm familar with.

One would be to request access to an actual IBM Z machine (well, one virtual guest on an actual machine) via the IBM LinuxONE Community Cloud hosted at Marist College: https://linuxone.cloud.marist.edu [This is available free of charge for the purpose of open-source development.] You could then create a Github action that logs into that machine and triggers a build and test run there. (However, there's probably a bit of development/scripting effort needed to set all this up.)

The other option would be to test under emulation: QEMU supports emulating the IBM Z (s390x) architecture, and you can set up a Github action that cross-compiles the package for s390x and runs the test suite under QEMU. Another project I know is using this approach is wasmtime, see their Github CI scripts here: https://github.com/bytecodealliance/wasmtime/blob/main/.github/workflows/main.yml#L230

shepmaster commented 2 years ago

Released in https://crates.io/crates/twox-hash/1.6.3

shepmaster commented 2 years ago

Thanks! I was able to add it without too much pain. https://github.com/shepmaster/twox-hash/pull/90