Installing Rust on ARM - memory allocation error

Hello.
I have a problem when I am installing Rust.
nightly:

root@ekm3:~# rustup toolchain remove stable && rustup toolchain add nightly
info: no toolchain installed for 'stable-armv7-unknown-linux-gnueabihf'
info: syncing channel updates for 'nightly-armv7-unknown-linux-gnueabihf'
info: latest update on 2020-01-27, rust version 1.42.0-nightly (698fcd38f 2020-01-26)
info: downloading component 'cargo'
4.3 MiB / 4.3 MiB (100 %) 1.7 MiB/s in 4s ETA: 0s
info: downloading component 'clippy'
info: downloading component 'rust-std'
15.3 MiB / 15.3 MiB (100 %) 2.0 MiB/s in 8s ETA: 0s
info: downloading component 'rustc'
70.2 MiB / 70.2 MiB (100 %) 2.0 MiB/s in 34s ETA: 0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
4.3 MiB / 4.3 MiB (100 %) 1.3 MiB/s in 3s ETA: 0s
info: installing component 'clippy'
1.7 MiB / 1.7 MiB (100 %) 1.2 MiB/s in 1s ETA: 0s
info: installing component 'rust-std'
15.3 MiB / 15.3 MiB (100 %) 1.8 MiB/s in 8s ETA: 0s
info: installing component 'rustc'
33.7 MiB / 70.2 MiB ( 48 %) 1.2 MiB/s in 25s ETA: 31smemory allocation of 250871720 bytes failedAborted

stable:

info: profile set to 'default'
info: default host triple is armv7-unknown-linux-gnueabihf
info: syncing channel updates for 'stable-armv7-unknown-linux-gnueabihf'
info: latest update on 2019-12-19, rust version 1.40.0 (73528e339 2019-12-16)
warning: Force-skipping unavailable component 'clippy-armv7-unknown-linux-gnueabihf'
info: downloading component 'cargo'
4.2 MiB / 4.2 MiB (100 %) 3.7 MiB/s in 3s ETA: 0s
info: downloading component 'rust-std'
16.1 MiB / 16.1 MiB (100 %) 3.6 MiB/s in 5s ETA: 0s
info: downloading component 'rustc'
52.4 MiB / 52.4 MiB (100 %) 3.6 MiB/s in 16s ETA: 0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
4.2 MiB / 4.2 MiB (100 %) 1.3 MiB/s in 3s ETA: 0s
info: installing component 'rust-std'
16.1 MiB / 16.1 MiB (100 %) 1.5 MiB/s in 9s ETA: 0s
info: installing component 'rustc'
34.5 MiB / 52.4 MiB ( 66 %) 1.3 MiB/s in 30s ETA: 13smemory allocation of 125946904 bytes failed./rustup.sh: line 371: 3181 Aborted "$@"
root@ekm3:~#

Please, help me.

How many RAM do you have on board? Looks like it's simply not enough.

@Cerberuser Embedded ARM, 256 MB memory.

Compiling a medium-complexity crate can consume a couple of gigabytes of RAM to compile, so it's very unlikely (bordering on impossible) that 256MB RAM is enough to compile stdlib.

You're probably better off cross-compiling, or using one of the existing ARM targets for rust.

1 Like

Although it is kind of funny, that rustup can not handle 256MB of memory :man_shrugging:

That the install fails is weird I'll admit, and my guess is that that's due to ARM not being a tier 1 platform (yet?).
But even if it had succeeded, what I said previously still holds, and that's probably how it got broken in the first place: not many people at present compile on ARM hardware. Many more cross-compile their applications for ARM.

Might have something to do with ARMs history with designing hardware that is power-efficient but anemic compared to desktop-class chips (something that is no longer necessary true) but the legacy of that remains.

Am I missing something? It looks to me like it’s running out of memory while merely downloading and unpacking precompiled packages. That 256MB of ram is not enough to do this seems a lot more surprising than if they were trying to build stdlib from source. (Is some component of rustup buffering a full download before writing it out??

I believe this section from the .tar.gz unpacking code unpacks each file into an in-memory buffer before writing it to disk. The abort happened when trying to allocate 120 MB, which might be the size of a single file in a Rust toolchain (though on my system, the largest toolchain files are about 60 MB).

This could probably be changed to unpack and write the file in smaller chunks, though other commenters might be right that compiling non-trivial Rust crates might be impossible on a system with this little free memory.

Are you sure this is a ram issue? The error looks a lot like what I see using apt to install large packages on an image based rootfs linux distro. At a point there is just no more room on the partition. I can often work around the trouble by creating a tmpfs or symlinkng to a larger partition.

I am stabbing in the dark a bit, but thought I'd clarify this point. If I'm wrong you may ignore me :upside_down_face:

AFAIK, "memory allocation failed" is exactly the "out of memory" error.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.