Rustup (rustc/cargo) for OpenWrt

I'm working on creating a rustup package so that OpenWrt can utilize rustc/cargo built applications.

I've created the start of a Makefile and sent it as a Draft PR here.

Anyone interested in lending a hand to get it working and tested? Currently, I've only cross-targeted mips/mips64, and even then I've hard-set my own target for testing.

Any assistance would be gratefully welcome!

Currently, the host package stuff doesn't get run in a timely manner. I'm using this to build Suricata as my test bench.

if i run things manually, they ALMOST run..

grommish@norwits:~/openwrt$ make -j1 V=sc package/feeds/packages/rustup/host/{configure,install}
Collecting package info: done
make[2]: Entering directory '/home/grommish/openwrt/scripts/config'
make[2]: 'conf' is up to date.
make[2]: Leaving directory '/home/grommish/openwrt/scripts/config'
make[1]: Entering directory '/home/grommish/openwrt'
make[2]: Entering directory '/home/grommish/openwrt/feeds/packages/lang/rustup'
. /home/grommish/openwrt/include/shell.sh; gzip -dc /home/grommish/openwrt/dl/rustup-1.22.1-src.tar.gz | tar -C /home/grommish/openwrt/build_dir/hostpkg/rustup-1.22.1/.. -xf -
[ ! -d ./src/ ] || cp -fpR ./src/* /home/grommish/openwrt/build_dir/hostpkg/rustup-1.22.1
touch /home/grommish/openwrt/build_dir/hostpkg/rustup-1.22.1/.prepareda5917125a56383f7f887bd7eec0404c0_6664517399ebbbc92a37c5bb081b5c53
RUSTUP_HOME=/home/grommish/openwrt/build_dir/hostpkg/.rustup CARGO_HOME=/home/grommish/openwrt/build_dir/hostpkg/.cargo /home/grommish/openwrt/build_dir/hostpkg/rustup-1.22.1/rustup-init.sh -y -v --profile default --target mips64-unknown-linux-muslabi64
info: downloading installer
info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
warning: Updating existing toolchain, profile choice will be ignored
verbose: updating existing install for 'stable-x86_64-unknown-linux-gnu'
verbose: toolchain directory: '/home/grommish/openwrt/build_dir/hostpkg/.rustup/toolchains/stable-x86_64-unknown-linux-gnu'
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/_xik10jey7v5pnks_file
verbose: downloading file from: 'https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256'
verbose: downloading with reqwest
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/_xik10jey7v5pnks_file
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/t36cje6p0179wyoy_file.toml
verbose: downloading file from: 'https://static.rust-lang.org/dist/channel-rust-stable.toml'
verbose: downloading with reqwest
verbose: checksum passed
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/66l4gvtxmip4jwfs_file
verbose: downloading file from: 'https://static.rust-lang.org/dist/channel-rust-stable.toml.asc'
verbose: downloading with reqwest
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/66l4gvtxmip4jwfs_file
verbose: Good signature from on https://static.rust-lang.org/dist/channel-rust-stable.toml from:
verbose: from builtin Rust release key
verbose:   RSA/85AB96E6-FA1BE5FE - Rust Language (Tag and Release Signing Key) <rust-key@rust-lang.org>
verbose:   Fingerprint: 108F 6620 5EAE B0AA A8DD 5E1C 85AB 96E6 FA1B E5FE
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/t36cje6p0179wyoy_file.toml
info: latest update on 2020-08-03, rust version 1.45.2 (d3fb005a3 2020-07-31)
info: component 'rust-std' for target 'mips64-unknown-linux-muslabi64' is up to date
verbose: toolchain is already up to date
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu unchanged - rustc 1.45.2 (d3fb005a3 2020-07-31)


Rust is installed now. Great!

To get started you need Cargo's bin directory 
(/home/grommish/openwrt/build_dir/hostpkg/.cargo/bin) in your PATH
environment variable. Next time you log in this will be done
automatically.

To configure your current shell run 
source /home/grommish/openwrt/build_dir/hostpkg/.cargo/env
touch /home/grommish/openwrt/build_dir/hostpkg/rustup-1.22.1/.configured
make[2]: Leaving directory '/home/grommish/openwrt/feeds/packages/lang/rustup'
time: package/feeds/packages/rustup/host-configure#0.51#0.32#1.56
make[1]: Leaving directory '/home/grommish/openwrt'
make[2]: Entering directory '/home/grommish/openwrt/scripts/config'
make[2]: 'conf' is up to date.
make[2]: Leaving directory '/home/grommish/openwrt/scripts/config'
make[1]: Entering directory '/home/grommish/openwrt'
make[1]: *** No rule to make target 'package/feeds/packages/rustup/host/install'.  Stop.
make[1]: Leaving directory '/home/grommish/openwrt'
make: *** [/home/grommish/openwrt/include/toplevel.mk:235: package/feeds/packages/rustup/host/install] Error 2

Obviously, there is a define Host/Install in the Makefile, but it tells me there isn't one. Host/Configure doesn't seem to be called during a full build, because when Suricata gets built, it fails to find rustc.

And, just for clarity: in this case, Host/Configure sets up rustup, which then is used in Host/Install to actually install the target toolchain (which will be the one you cross-compile your images for - mips64-unknown-linux-muslabi64 in my case)

I'm very interested in this, but the amount of time I can contribute is highly variable. Still, I'm up for testing builds and dummy packages and things.

1 Like

I managed to get rustup working and is it now being picked apart by the people who know better :slight_smile:

It'll need to be tested for various target platforms once it is done, since each rustc triple is target dependent. Feel free to look, comment, suggest :+1:

I'm actively re-working this. It was a concern that the rustup installer uses pre-compiled binaries. I'm trying to see what can be done about it.

Anyone want to test the PR? I'm ready to call it finished from what I can test..

and it can be tested with this:

If it doesn't work, let me know. The suricata5 package is strictly for testing rustc/cargo, so I didn't polish the package yet. I'm just trying to test rustc/cargo at this point.

1 Like