Stream: general

Topic: how can I test on a big endian platform?


Jake Goulding (Jul 28 2019 at 17:45, on Zulip):

In twox-hash, I do some bit-banging work. I'm all but certain that I've screwed something up with respect to big- and little-endian, but I only have access to my x86 little-endian laptop, so I can't test to be sure.

Is there some big-endian emulator setup that I can run Rust code in?

RalfJ (Jul 28 2019 at 18:08, on Zulip):

if you are using Linux, you can use qemu to run binaries for pretty much any architecture

RalfJ (Jul 28 2019 at 18:09, on Zulip):

if you are not using Linux I guess you could run it in a VM^^

RalfJ (Jul 28 2019 at 18:10, on Zulip):

qemu-binfmt is pretty cool: https://wiki.debian.org/QemuUserEmulation
with that, you can literally ./binary for binaries that have the "wrong" architecture, and it will transparently use qemu to run it (you need the dynamic linker and libs for that architecture obviously, but at least on debian, thanks to multiarch that all is fairly easyto set up)

RalfJ (Jul 28 2019 at 18:12, on Zulip):

alternatively, you could use Miri :D but unfortunately cross-building libstd is not as easy as it could be (https://github.com/rust-lang/rust/issues/56443)

RalfJ (Jul 28 2019 at 18:18, on Zulip):

Also see https://github.com/rust-lang/miri/issues/864, I think it should be possible to make it easier to cross-run things with Miri.

nagisa (Jul 28 2019 at 18:59, on Zulip):

https://cfarm.tetaneutral.net/news/ has some big endian targets.

nagisa (Jul 28 2019 at 19:00, on Zulip):

MIPS and SPARC most notably.

Thom Chiovoloni (Jul 29 2019 at 00:28, on Zulip):

I've used https://github.com/rust-embedded/cross in CI for things similar to this

Last update: Nov 20 2019 at 11:30UTC