Cargo in termux - 'illegal instruction'

I recently installed the rust programming language in termux (armeabi-v7a 32bit),

but I'm having trouble with cargo

cargo --version
illegal instruction

Rust is required during the build phase of python cryptography, (you do not need to have Rust installed after you've built cryptography)
So I can't have any Python cryptography either, in a Murphy's Law way!.

Why should another programming language be used for python cryptography?
I think this is a disadvantage for a programming language that can't do it itself.

Where have you installed it from? It isn't supported officially, so you've likely used some source not known to most of us.

Yeah, Python is quite weak by itself, it wasn't able to do much without C since the very beginning.

3 Likes

from here:
curl --proto '=https' --tlsv1.3 https://sh.rustup.rs -sSf | sh

source $HOME/.cargo/env
rustc --version and rustup --version worked.
but cargo --version failed.

Interesting. If I understand correctly, Android is currently Tier 2 without host tools, i.e. I'd probably expect the installation to fail entirely. What does rustup toolchain list show?

1 Like

Last I checked, rustup doesn't work because it doesn't detect the platform correctly. You need to add the its-pointless repo and then run pkg install rust. I think if you try pkg install rust first, it'll tell you how to add the repo.

2 Likes

Because Python is incredibly slow. Basically because it is an interpreted language and makes use of a garbage collector. All performance sensitive work done in Python is actually done in a language that compiles to fast native code. Like C, C++ and now Rust.

Yes, that is a disadvantage of using language systems like Python. Typically less of a disadvantage if the code Python depends on in written in C/C++ as they have been everywhere for decades.

2 Likes

Adding Rust as a dependency of Python cryptography was very controversial for this exact reason. Their FAQ addresses the upsides but not really this downside of their decision.

2 Likes

info: default toolchain set to 'stable-armv7-unknown-linux-gnueabi
hf'

stable-armv7-unknown-linux-gnueabihf installed - rustc 1.76.0 (07dca489a 2024-02-04)

Rust is installed now. Great!

I installed it through ubuntu in termux.

cat /etc/lsb-release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.6 LTS"

What did you use to get Ubuntu running inside termux? Termux normally uses custom builds of all packages without using a regular distro.

proot

I think the problem is either in the Rust programming language or its requirements.
And when you google it, it is almost everywhere.

It's definitely not a problem with the language. It's most likely a problem with rustup. You can try installing rustc/cargo/std from your package manager, but the way most likely to succeed would be to cross-compile rustc/cargo/std from a different platform and copy it over.

3 Likes

Why so? There is no evidence of that.

The illegal instruction error immediately strongly suggests that the cargo binary you want to run has been compiled for a CPU other than the one you actually have there.

6 Likes

How can We build a cargo project for the one you have there?
Shouldn't it do this automatically?
lscpu (or dpkg --print-architecture) Display information about the CPU architecture.

The best temporary solution is to install the old version of python cryptography==2.8

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.