Is there a Rust build for aarch64-linux-android?

7.2k Views Asked by At

Recently I got a new smartphone with fairly beefy specs, so wanting to play around with Rust on the go I installed Termux and tried to rustup-init. However, this fails:

info: syncing channel updates for 'stable-aarch64-linux-android'
info: latest update on 2017-08-31, rust version 1.20.0 (f3d6973f4 2017-08-27)
error: target not found: 'aarch64-linux-android'

Is there another way to get a Rust environment on android?

4

There are 4 best solutions below

4
On BEST ANSWER

Sadly rustup won't work on android.

You can manage to install cargo and rustc using Termux.

Also if you have rustup already installed, rm .cargo will remove the stub (which otherwise interferes with calling cargo or rustc).

2
On

There is a rust package available via pkg install rust. It contains Cargo and appears to install packages successfully.

The package source is here: https://github.com/termux/termux-packages/tree/master/packages/rust

Just a note: I had a binary failing to build during installation via Cargo due to libsqlite3-sys intermediate. This was solved by installing binutils package, which adds the archiver (ar) aarch64-linux-android-ar. The ecosystem is not flawless yet.

0
On

You can use rustup inside of a prooted distro. Example using arch linux:

pkg update && pkg upgrade
pkg in proot-distro
proot-distro install archlinux
proot-distro login archlinux
# Ideally you should now setup a non-root user, but i'll omit this step for brevity
sudo pacman -Syu base-devel --needed
sudo pacman -Syu rustup # it's better to install rustup from repo
rustup toolchain default stable
rustup update
# Now you have a working rustup installation, but it can only be used from inside the distro. Anyway, that's better than nothing.

I personally don't use termux's environment at all and do everything inside the distro, so you might prefer to do the same.

1
On

or you can use rustup directly in termux. guide. all rust related tools and frameworks will work too after patching them.