I would like to install Rust cross-compile to MIPS32 little-endian. It will impress my manager. I looked at several web pages, like cross-compile for wifi pineapple but that is from 2017. How to install Rust for MIPS cross in year 2025 ? I've got 3 books on Rust and I'm reading the first.
I have a C compiler and linker and its runtime, but will accept LLVM machine machine code.
Environment:
- host = ubuntu 22.04 linux
- host GCC = gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
- cargo: beta-x86_64-unknown-linux-gnu (default)
- The currently active
rustcversion isrustc 1.86.0-beta.6 (8c7969a3a 2025-03-16) - admin access on host: nope, installing in my home dir.
- target cpu = mips32 "mips32_1004kc" little-endian
- target env = bare-metal deep embedded, no OS, no RTOS
- target download: JTAG pod
- existing C compiler = Green Hills
- Me: been doing embedded programs and Linux for decades (and Solaris).
The main theme that is blocking me is rustup target add mips-unknown-none says your toolchain does not support target. I am confused since rustc --print=target-list | grep mips shows that target! And having "~/.cargo/config" is outdated since 2021, right?
~/Rust$ rustc --print=target-list | grep mips
mips-mti-none-elf
mips-unknown-linux-gnu
mips-unknown-linux-musl
mips-unknown-linux-uclibc
mips64-openwrt-linux-musl
mips64-unknown-linux-gnuabi64
mips64-unknown-linux-muslabi64
mips64el-unknown-linux-gnuabi64
mips64el-unknown-linux-muslabi64
mipsel-mti-none-elf
mipsel-sony-psp
mipsel-sony-psx
mipsel-unknown-linux-gnu
mipsel-unknown-linux-musl
mipsel-unknown-linux-uclibc
mipsel-unknown-netbsd
mipsel-unknown-none <-- see, right there!!
mipsisa32r6-unknown-linux-gnu
mipsisa32r6el-unknown-linux-gnu
mipsisa64r6-unknown-linux-gnuabi64
mipsisa64r6el-unknown-linux-gnuabi64
~/Rust$
~/Rust$ rustup target add mipsel-unknown-none
error: toolchain 'beta-x86_64-unknown-linux-gnu' does not support target 'mipsel-unknown-none'; did you mean 'bpfel-unknown-none'?
note: you can see a list of supported targets with `rustc --print=target-list`
note: if you are adding support for a new target to rustc itself, see https://rustc-dev-guide.rust-lang.org/building/new-target.html
~/Rust$
Places I visited and what happened:
I already have a toolchain. Command rustup target add mips-unknown-linux-musl says toolchain does not support target.
Wants me to run cargo new --edition 2018 --bin app . Let's move to current decade.
I tried rustup toolchain install beta-mipsel-unknown-none and got re-direction to rustup target add mipsel-unknown-none. Second command gives same "toolchain does not support target" error.
Do I really need to compile LLVM myself?
No Linux on my target, it is bare-metal, CPU is inside an SoC.
Page from Sept 2016, and things have evolved since.
Nice page from January 2017, and things have evolved since.
How do I get this working?