cargo: Value too large for defined data type when cargo build on armv7 with qemu
Problem
Trying to build an app for armv7 in a docker container with qemu. The current result is explained here with the steps to reproduce it : https://github.com/jdrouet/docker-bug-value-too-long
Steps
- install docker
- install docker-buildx
- follow the steps here
Possible Solution(s) No idea.
Notes The guys from docker claim it’s coming from cargo.
Output of cargo version:
The one from the docker image rust:1-slim-buster
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 15
- Comments: 15 (1 by maintainers)
Links to this issue
Commits related to this issue
- Remove arm from docker workflow. Seems to be broken at the moment: https://github.com/rust-lang/cargo/issues/8719 — committed to nielssp/uncomment by nielssp 5 years ago
- build: Use tmpfs for cargo cache That seems to workaround https://github.com/rust-lang/cargo/issues/8719. — committed to nijel/docker by nijel 5 years ago
- build: Use tmpfs for cargo cache That seems to workaround https://github.com/rust-lang/cargo/issues/8719. — committed to nijel/docker by nijel 5 years ago
- build: Use tmpfs for cargo cache That seems to workaround https://github.com/rust-lang/cargo/issues/8719. — committed to nijel/docker by nijel 5 years ago
- build: Use tmpfs for cargo cache That seems to workaround https://github.com/rust-lang/cargo/issues/8719. — committed to nijel/docker by nijel 5 years ago
- build: Use tmpfs for cargo cache That seems to workaround https://github.com/rust-lang/cargo/issues/8719. — committed to nijel/docker by nijel 5 years ago
- build: Use tmpfs for cargo cache That seems to workaround https://github.com/rust-lang/cargo/issues/8719. — committed to nijel/docker by nijel 5 years ago
- build: Use tmpfs for cargo cache - That avoids bug in cargo/qemu/ext4, see https://github.com/rust-lang/cargo/issues/8719. - Increase swap space to give tmpfs bigger size — committed to nijel/docker by nijel 5 years ago
- build: Use tmpfs for cargo cache - That avoids bug in cargo/qemu/ext4, see https://github.com/rust-lang/cargo/issues/8719. - Increase swap space to give tmpfs bigger size — committed to nijel/docker by nijel 5 years ago
- build: Use tmpfs for cargo cache - That avoids bug in cargo/qemu/ext4, see https://github.com/rust-lang/cargo/issues/8719. - Increase swap space to give tmpfs bigger size — committed to nijel/docker by nijel 5 years ago
- build: Use tmpfs for cargo cache - That avoids bug in cargo/qemu/ext4, see https://github.com/rust-lang/cargo/issues/8719. - Increase swap space to give tmpfs bigger size — committed to WeblateOrg/docker by nijel 5 years ago
- specter: Fix build in emulated ARM32v7 envirnoments See https://github.com/pyca/cryptography/issues/5771, https://github.com/rust-lang/cargo/issues/8719 — committed to ez-org/eznode by shesek 5 years ago
- https://github.com/rust-lang/cargo/issues/8719#issuecomment-932084513 — committed to sdr-enthusiasts/browser-screenshot-service by mikenye 5 years ago
- remove armv7 from docker build due to rust-lang/cargo#8719 — committed to ultram4rine/alerter by ultram4rine 5 years ago
- genimage: do not use qemu wrapper to execute target shlibsign While use qemu-arm to run 32-bit shlibsign on 64-bit host[1], there is a potential Linux Large File error ... $ qemu-arm -r 3.2.0 -L path... — committed to Wind-River/meta-lat by hongxu-jia 5 years ago
- genimage: do not use qemu wrapper to execute target shlibsign While use qemu-arm to run 32-bit shlibsign on 64-bit host[1], there is a potential Linux Large File error ... $ qemu-arm -r 3.2.0 -L path... — committed to WindRiver-Labs/wr-ostree by hongxu-jia 5 years ago
- Workaround Workaround for https://github.com/rust-lang/cargo/issues/8719 — committed to CasaMack/easee_status by Areskiko 4 years ago
- Attempt to fix qemu error with ARM7 build https://github.com/rust-lang/cargo/issues/8719 and https://github.com/rust-lang/cargo/issues/9545 — committed to sdr-enthusiasts/acars_router by fredclausen 4 years ago
- workaround rust-lang/cargo/issues/8719 — committed to vivid-lapin/docker-mitmproxy by ci7lus 4 years ago
- Implement workaround for Cargo issue on ARMv7 See rust-lang/cargo#8719 — committed to y-almannaee/tecberry by y-almannaee 4 years ago
If you can’t make the above Dockerfile-based workaround, what works as well is using tmpfs for the whole
/var/lib/dockeron the build host. For GitHub actions, I’ve done that here: https://github.com/WeblateOrg/docker/pull/1274Very nice @nijel! I used your example and made a reusable Action for those affected by this issue 😃
If someone is coming here and also needs a workaround for a docker build: Put this in the beginning of the Dockerfile:
# syntax = docker/dockerfile:experimentalThen do something like this:RUN --security=insecure mkdir -p /root/.cargo && chmod 777 /root/.cargo && mount -t tmpfs none /root/.cargo && some_command_that_uses_cargoSince cargo (stable) now supports the sparse registry protocol, the easiest workaround is to set the envinronment variable
CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse. This avoids the problematic call to libgit2 altogether. You have to make sure the git binary is installed though, but that shouldn’t be a problem.If you are using buildkit, there is a much cleaner workaround than using the
--security=insecureoption. Just useRUN --mountlike this:For anyone having this issue, in the end I went to the path of making a Dockerfile with multi-stage builds that will cross-compile for all the architectures I need on the architecture of the pipeline agent and scrapped using qemu for the cargo build, I only use it to run apt install and other small stuff at the end.
If you project allows for this route, you can follow my Dockerfile as guidance
https://github.com/madiele/vod2pod-rss/blob/cac3d27c415ed8341fa8da738e4604b7427c04ae/Dockerfile
I went form 2+ hours build times to 5-10 minutes build times, it was worth the effort.
I had to adapt this slightly to use a different directory for cargo to get it working with the rust base image to build a rust project.
RUN --mount=type=tmpfs,target=/.cargo CARGO_HOME=/.cargo cargo build --release