So, this has had me scratching me head (read: nearly throwing my computer through the window) for a day, but I think I can now confidently say there's something broken about the linux/arm/v7
of the current Docker image.
In short, cargo
doesn't work. I've not run into this before because in general I cross compile my services locally and then just copy the compiled binary into a docker image to run on the target device, but I have one thing I'm building that depends on some non-Rust libraries that it's just easier to build and link on the target architecture. So, I set up an xbuild process, which works fine building for linux/arm64 but bursts into flames for linux/arm/v7:
[Sasha:project-maramures-ssbt/pn532-nfc-driver] timwa% ./build-nfc.sh
[+] Building 24.4s (14/23)
=> [internal] load build definition from Dockerfile
=> => transferring dockerfile: 1.31kB
=> [internal] load .dockerignore
=> => transferring context: 2B
=> [internal] load metadata for docker.io/library/ubuntu:bionic
=> [internal] load metadata for docker.io/library/rust:latest
=> [internal] load build context
=> => transferring context: 29.90kB
=> [builder 1/12] FROM docker.io/library/rust@sha256:86bb2e39e20f602b169ade0bc5cff7460a49af2f60b9aefc390db48eb888d20a
=> => resolve docker.io/library/rust@sha256:86bb2e39e20f602b169ade0bc5cff7460a49af2f60b9aefc390db48eb888d20a
=> [stage-1 1/6] FROM docker.io/library/ubuntu:bionic@sha256:ea188fdc5be9b25ca048f1e882b33f1bc763fb976a8a4fea446b38ed0efcbeba
=> => resolve docker.io/library/ubuntu:bionic@sha256:ea188fdc5be9b25ca048f1e882b33f1bc763fb976a8a4fea446b38ed0efcbeba
=> => sha256:b017766c8f695603aa5da2f534135bd1fbe253f667ef6faa77a77c66be9ba9f5 187B / 187B
=> => sha256:0e961f21c7ea83c265a6de2897b8255e9e03cf1d39b74fb208b4ca936c6a53c5 853B / 853B
=> => sha256:6d8bd15f2f6189f24e8f1b5dc573a293c963565ab012ca6a42e51a3023e72e7e 22.29MB / 22.29MB
=> => extracting sha256:6d8bd15f2f6189f24e8f1b5dc573a293c963565ab012ca6a42e51a3023e72e7e
=> => extracting sha256:0e961f21c7ea83c265a6de2897b8255e9e03cf1d39b74fb208b4ca936c6a53c5
=> => extracting sha256:b017766c8f695603aa5da2f534135bd1fbe253f667ef6faa77a77c66be9ba9f5
=> CACHED [builder 2/12] RUN echo "I am running on linux/amd64, building for linux/arm/v7"
=> CACHED [builder 3/12] RUN apt-get update
=> [builder 4/12] RUN apt-get install -y libi2c-dev libusb-dev libnfc-bin libnfc-dev libnfc-examples libnfc-pn53x-examples
=> [stage-1 2/6] RUN apt-get update
=> CANCELED [stage-1 3/6] RUN apt-get install -y libnfc5 libnfc-bin
=> [builder 5/12] WORKDIR /usr/src
=> ERROR [builder 6/12] RUN cargo install cargo-build-dependencies
------
> [builder 6/12] RUN cargo install cargo-build-dependencies:
#14 0.834 Updating crates.io index
#14 1.590 warning: spurious network error (2 tries remaining): could not read directory '/usr/local/cargo/registry/index/github.com-1285ae84e5963aae/.git//refs': Value too large for defined data type; class=Os (2)
#14 2.087 warning: spurious network error (1 tries remaining): could not read directory '/usr/local/cargo/registry/index/github.com-1285ae84e5963aae/.git//refs': Value too large for defined data type; class=Os (2)
#14 2.628 error: failed to fetch `https://github.com/rust-lang/crates.io-index`
#14 2.628
#14 2.628 Caused by:
#14 2.629 could not read directory '/usr/local/cargo/registry/index/github.com-1285ae84e5963aae/.git//refs': Value too large for defined data type; class=Os (2)
------
failed to solve: rpc error: code = Unknown desc = executor failed running [/bin/sh -c cargo install cargo-build-dependencies]: exit code: 101
(I'm using Docker QEmu based cross-platform to sloooowly build.)
I am going to hazard a wild guess that the problem ("value too large for defined data type") is some kind of datatype sizing problem in the 32-bit build environment (inode maybe?) causing Cargo to crash and burn.
Through a process of elimination, I've determined that versions earlier than 1.30 don't blow up in this way (although there are other problems it seems...)
I'm not sure yet if the problem is isolated to the official docker images, or if it's the Rust toolchain itself that's broken on arm/v7 - I'm going to attempt to set up a build environment of my own to see if I can work that out. Maybe someone here already knows..? Should I give up trying to get Rust to compile on arm/v7? (Not for arm/v7, but on arm/v7)?
Note that linux/arm64 works just fine, so I assume this is a 32bit/64bit issue. Unfortunately my target device is not running 64 bit...