Rust-lang (rustc/cargo) for OpenWrt - testing needed

My issue seems to be a few-fold. First, rust defaults to hard-float, which is incompatible with OpenWrt (which uses soft-float userland). Second, they statically link libs and musl needs dynamically linked libs. Building from source should fix this, but I'm still hitting issues with getting rust to not hit the host's linker.

I'm wondering if i shouldn't just try and do a multi-stage build.. Compile the host toolchain and then deal with the target. But the compile is already taking in excess of 40 minutes to build each time. ah well. I'm on the rust zulip, and they have been helpful in the past, but I'll check out the reddit as well!

It seems I've gotten it to compile. I've got a stage2 rustc binary which should be able to cross-compile mips64-muslabi64. I'll have to test and create a target and see.

Still moving forward!

I'm still hashing out issues with the rust dev folks because getting it to work breaks things :smiley: I'll post back when i get more.

I came back to this just now after not changing any of my actual packaging or code and it definitely did not work. I think at some point the OpenWrt rustup/cargo etc. crossed wires with my host's tools, so when I purged my host toolchain this all stopped working.

Basically, when I try to compile my "hello world" example, I get:

error[E0463]: can't find crate for `std`
  |
  = note: the `mipsel-unknown-linux-musl` target may not be installed

error: aborting due to previous error

The OpenWrt rustup is not installing the appropriate target, and I cannot figure out how to manually invoke the Host/Install target to see if that's the problem. Running make by itself (which usually builds everything and compiles the firmware image) fails with the same cause.

I'll put together a "clean" example and come back with more detail if I can.

Sorry, I've been away :slight_smile:
Couple of things.. First, I'm at a stand-still on incorporating Rust/Cargo into OpenWrt until Rust/Cargo fixes their code..

Rustup does work, but makes some very broad assumptions, and is limited in use.. Rustup assumes 1) your target is a hard-float target, and 2) your target uses statically linked libraries and not dynamically linked.

Both of these break my arch (mips64 octeon3), as I need -msoft-float AND dynamically linked libs..

So, I moved to rust/cargo from source. I got it working, but rust/cargo from source fails to actually cross-compile (it's a known issue, and has been for a while). The Stage 2 artifacts aren't created properly and Cargo isn't informed of custom triples. I'm constantly updating the hash HEAD to see if they ever get it fixed. I was/am working with them on their Zulip, but who knows..

I've had issues with rust/cargo (including rustup) putting things where they don't belong (aka ~/.cargo/), and if you have rust on your host machine already, it will probably complicate things. Rust/Cargo is decent with most things, but they make far to many bad assumptions.

Here is the most recent rustup and rust Makefiles I've been working with..
rustup Makefile

# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk

PKG_NAME:=rustup
PKG_VERSION:=1.22.1
PKG_RELEASE:=1
PKG_LICENSE:=Apache-2.0 MIT
PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/rust-lang/rustup.git
PKG_SOURCE_DATE:=2020-07-08
PKG_SOURCE_VERSION:=995002f2b88e8eea1cdf4879fa9e7cdc402b4938
PKG_HASH:=f37a7b56b36e4acf24675d6d3794059c228b750f780654900d3f8a5cecd52695
PKG_HOST_ONLY:=1

include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk
include ./rustc-triple.mk

define Package/rustup
  	SECTION:=lang
  	CATEGORY:=Languages
  	TITLE:=Rust Programming Language Installer
  	URL:=https://www.rust-lang.org/
endef

define Package/rustup/description
  The rustup package installs the Rust Programming Language (rustc/cargo)
  for use with packages that require Rust to compile.

  For Rust Support, add the following to the package:
  ***************************************************
  PKG_BUILD_DEPENDS:=rustup/host
  include ../../lang/rustup/rustc-triple.mk

  CONFIGURE_VARS += \
  	CARGO_HOME=$$(CARGO_HOME) \
  	RUSTUP_HOME=$$(RUSTUP_HOME) \
  	ac_cv_path_CARGO="$$(CARGO_HOME)/bin/cargo" \
  	ac_cv_path_RUSTC="$$(CARGO_HOME)/bin/rustc"

endef

CONFIGURE_VARS += \
   CARGO_HOME=$(CARGO_HOME) \
   RUSTUP_HOME=$(RUSTUP_HOME) \
   ac_cv_path_CARGO="$(CARGO_HOME)/bin/cargo" \
   ac_cv_path_RUSTC="$(CARGO_HOME)/bin/rustc"

RUSTUP_INIT_ARGS := \
  	--profile default \
	--default-toolchain stable \
  	--target $(RUSTC_TARGET_ARCH)

define Host/Configure
	$(CONFIGURE_VARS) \
	$(BUILD_DIR_HOST)/$(PKG_SOURCE_SUBDIR)/rustup-init.sh -y -v $(RUSTUP_INIT_ARGS)
	source $(CARGO_HOME)/env
endef

define Host/Compile
	$(CONFIGURE_VARS) \
	$(CARGO_HOME)/bin/rustup toolchain install nightly -t $(RUSTC_TARGET_ARCH)
	$(CONFIGURE_VARS) \
	$(CARGO_HOME)/bin/rustup default nightly
endef

define Host/Install
	true
endef

define Host/Clean
	$(call Host/Clean/Default)
	rm -rf $(CARGO_HOME) $(RUSTUP_HOME) $(BUILD_DIR_HOST)/rust
endef

$(eval $(call HostBuild))
$(eval $(call BuildPackage,rustup))

rustc-triple.mk

# To enable rustc/cargo support in your packages, add:
# include $(TOPDIR)/feeds/packages/lang/rustup/rustc-triple.mk
# below include $(TOPDIR)/rules.mk
#
# You will need to add --host=$(RUSTC_TARGET_ARCH) to your packages
# CONFIGURE_VARS to cross-compile for the target architecture

RUSTC_ARCH_TARGETS:= \
aarch64-unknown-linux-gnu aarch64-unknown-linux-musl \
\
arm-unknown-linux-gnueabi arm-unknown-linux-gnueabihf \
arm-unknown-linux-musleabi arm-unknown-linux-musleabihf \
\
armv4t-unknown-linux-gnueabi \
\
armv5te-unknown-linux-gnueabi armv5te-unknown-linux-musleabi \
\
armv7-unknown-linux-gnueabi armv7-unknown-linux-gnueabihf \
armv7-unknown-linux-musleabi \
\
hexagon-unknown-linux-musl \
\
i586-unknown-linux-gnu i586-unknown-linux-musl \
\
i686-unknown-linux-gnu i686-unknown-linux-musl \
\
mips-unknown-linux-gnu mips-unknown-linux-musl mips-unknown-linux-uclibc \
\
mips64-unknown-linux-gnuabi64 mips64-unknown-linux-muslabi64 \
mips64-unknown-linux-gnuabi64sf mips64-unknown-linux-muslabi64sf \
\
mips64el-unknown-linux-gnuabi64 mips64el-unknown-linux-muslabi64 \
\
mipsel-unknown-linux-gnu mipsel-unknown-linux-musl \
mipsel-unknown-linux-uclibc \
\
mipsisa32r6-unknown-linux-gnu mipsisa32r6el-unknown-linux-gnu \
\
mipsisa64r6-unknown-linux-gnuabi64 mipsisa64r6el-unknown-linux-gnuabi64 \
\
powerpc-unknown-linux-gnu powerpc-unknown-linux-musl \
\
powerpc64-unknown-linux-gnu powerpc64-unknown-linux-musl \
\
powerpc64le-unknown-linux-gnu powerpc64le-unknown-linux-musl \
\
riscv64gc-unknown-linux-gnu \
\
s390x-unknown-linux-gnu \
\
sparc-unknown-linux-gnu \
\
sparc64-unknown-linux-gnu \
\
thumbv7neon-unknown-linux-gnueabihf thumbv7neon-unknown-linux-musleabihf \
\
x86_64-unknown-linux-gnu x86_64-unknown-linux-musl

CONFIG_HOST_SUFFIX:=$(shell cut -d"-" -f4 <<<"$(GNU_HOST_NAME)")
RUSTC_HOST_ARCH:= \
	$(strip $(foreach \
		v, \
		$(filter $(HOST_ARCH)-%, $(RUSTC_ARCH_TARGETS)), \
		$(if $(findstring -$(CONFIG_HOST_SUFFIX:"%"=%),$v),$v) \
		) \
	)

RUSTC_TARGET_ARCH_BASE:= \
	$(strip $(foreach \
		v, \
		$(filter $(ARCH)-%, $(RUSTC_ARCH_TARGETS)), \
		$(if $(findstring -$(CONFIG_TARGET_SUFFIX:"%"=%),$v),$v) \
		) \
	)

# Check to see if it's a soft-float target
ifeq ($(CONFIG_SOFT_FLOAT),y)
RUSTC_TARGET_ARCH:=$(strip $(filter %sf, $(RUSTC_TARGET_ARCH_BASE)))
else
RUSTC_TARGET_ARCH:=$(strip $(filter-out %sf, $(RUSTC_TARGET_ARCH_BASE)))
endif

# More than one triple-target remains.
ifneq ($(word 2, $(RUSTC_TARGET_ARCH)),)
$(error RUSTC ERROR: Unsupported or Unknown Target Triple: $(RUSTC_TARGET_ARCH))
endif

# These are environment variables that are used by other packages to
# define where rustc/cargo are kept.
CARGO_HOME:=$(BUILD_DIR_HOST)/.cargo
RUSTUP_HOME:=$(BUILD_DIR_HOST)/.rustup

Host/Install was depreciated and incorporated into the Compile I believe (at least, I believe that is what @jow told me). Everything installed for rustup is done via the Host/Compile call.

For Rust from source:
This includes the Makefile, menuconfig entries, etc.

Rust Makefile

# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk

PKG_NAME:=rust
PKG_VERSION:=1.49.0
PKG_RELEASE:=1
PKG_LICENSE:=Apache-2.0 MIT
PKG_LICENSE_FILES:=LICENSE-APACHE LICENSE-MIT

PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL:=https://github.com/rust-lang/rust.git
PKG_SOURCE_DATE:=2020-10-18
#PKG_SOURCE_VERSION:=c71248b70870960af9993de4f31d3cba9bbce7e8
#PKG_SOURCE_VERSION:=19356453cbfb734bc60a1853c10e3095d05e0342
PKG_SOURCE_VERSION:=b6ac411f45d38d867ce9f689bbd5c3e7456d0f65
PKG_HASH:=skip
PKG_HOST_ONLY:=1
#PKG_INSTALL:=1

include $(INCLUDE_DIR)/cmake.mk
include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk
include ./rustc-triple.mk
#include ../../lang/python/python3-package.mk

HOST_BUILD_DEPENDS:=ninja/host python3/host

define Package/rust
  	SECTION:=lang
  	CATEGORY:=Languages
  	TITLE:=Rust Programming Language Compiler
  	URL:=https://www.rust-lang.org/
	DEPENDS:=+python3 +ninja +pkg-config +libopenssl +openssl-util +libyaml +libyaml-cpp +python3-yaml
endef

define Package/rust/description
  Rust lang
endef

define Package/rust/config
	source "$(SOURCE)/Config.in"
endef

CMAKE_INSTALL:=1
RUSTC_TARGET_ARCH:=mips64-unknown-linux-muslabi64
# Basic Configuration Args that are used across all builds.
# Other build arguments are found in ./rustc-config.mk
#
# Default CONFIGURE_ARGS introduces unknown options - Use this instead
CONFIGURE_ARGS = \
	 --build=$(RUSTC_HOST_ARCH) \
	 --host=$(RUSTC_HOST_ARCH) \
	 --target=$(RUSTC_TARGET_ARCH) \
	 --prefix=$(CARGO_HOME) \
	 --bindir=$(CARGO_HOME)/bin \
	 --libdir=$(CARGO_HOME)/lib \
	 --sysconfdir=$(CARGO_HOME)/etc \
	 --datadir=$(CARGO_HOME)/share \
	 --localstatedir=/var \
	 --mandir=$(CARGO_HOME)/man \
	 --infodir=$(CARGO_HOME)/info \
	 --release-channel=experimental

include ./rustc-config.mk

define Host/Prepare
	$(call Host/Prepare/Default)
	# Allows outside packages to call $(BUILD_DIR_HOST)/rust as the dir
	# rather than needing the version number.
	[ -L $(BUILD_DIR_HOST)/rust ] || (cd $(BUILD_DIR_HOST); ln -s "$(PKG_NAME)-$(PKG_VERSION)" rust)

	# This is our $CARGO_HOME, so make sure it's there to receive files
	[ -d $(CARGO_HOME) ] || (mkdir -p $(CARGO_HOME))
	[ -d $(RUSTUP_HOME) ] || (mkdir -p $(RUSTUP_HOME))

endef

define Host/Configure
	# Required because OpenWrt Default CONFIGURE_ARGS contain extra
	# args that cause errors
	cd $(HOST_BUILD_DIR) && RUST_BACKTRACE=1 ./configure $(CONFIGURE_ARGS)
endef

define Host/Compile
	cd $(HOST_BUILD_DIR) && RUST_BACKTRACE=1 $(PYTHON) x.py dist library/std src/librustc
	cd $(HOST_BUILD_DIR) && RUST_BACKTRACE=1 $(PYTHON) x.py install \
	 --build=$(RUSTC_HOST_ARCH) \
	 --host=$(RUSTC_HOST_ARCH) \
	 --target=$(RUSTC_TARGET_ARCH)
endef

define Host/Clean
	$(call Host/Clean/Default)
	rm -rf $(CARGO_HOME) $(RUSTUP_HOME) $(BUILD_DIR_HOST)/rust
endef

define Host/InstallDev
	true
endef

define Package/install
	true
endef


$(eval $(call HostBuild))
$(eval $(call BuildPackage,rust))

Rust rustc-triple.mk

# To enable rustc/cargo support in your packages, add:
# include $(TOPDIR)/feeds/packages/lang/rustup/rustc-triple.mk
# below include $(TOPDIR)/rules.mk
#
# You will need to add --host=$(RUSTC_TARGET_ARCH) to your packages
# CONFIGURE_VARS to cross-compile for the target architecture

RUSTC_ARCH_TARGETS:= \
aarch64-unknown-linux-gnu aarch64-unknown-linux-musl \
\
arm-unknown-linux-gnueabi arm-unknown-linux-gnueabihf \
arm-unknown-linux-musleabi arm-unknown-linux-musleabihf \
\
armv4t-unknown-linux-gnueabi \
\
armv5te-unknown-linux-gnueabi armv5te-unknown-linux-musleabi \
\
armv7-unknown-linux-gnueabi armv7-unknown-linux-gnueabihf \
armv7-unknown-linux-musleabi \
\
hexagon-unknown-linux-musl \
\
i586-unknown-linux-gnu i586-unknown-linux-musl \
\
i686-unknown-linux-gnu i686-unknown-linux-musl \
\
mips-unknown-linux-gnu mips-unknown-linux-musl mips-unknown-linux-uclibc \
\
mips64-unknown-linux-gnuabi64 mips64-unknown-linux-muslabi64 \
mips64-unknown-linux-gnuabi64sf mips64-unknown-linux-muslabi64sf \
\
mips64el-unknown-linux-gnuabi64 mips64el-unknown-linux-muslabi64 \
\
mipsel-unknown-linux-gnu mipsel-unknown-linux-musl \
mipsel-unknown-linux-uclibc \
\
mipsisa32r6-unknown-linux-gnu mipsisa32r6el-unknown-linux-gnu \
\
mipsisa64r6-unknown-linux-gnuabi64 mipsisa64r6el-unknown-linux-gnuabi64 \
\
powerpc-unknown-linux-gnu powerpc-unknown-linux-musl \
\
powerpc64-unknown-linux-gnu powerpc64-unknown-linux-musl \
\
powerpc64le-unknown-linux-gnu powerpc64le-unknown-linux-musl \
\
riscv64gc-unknown-linux-gnu \
\
s390x-unknown-linux-gnu \
\
sparc-unknown-linux-gnu \
\
sparc64-unknown-linux-gnu \
\
thumbv7neon-unknown-linux-gnueabihf thumbv7neon-unknown-linux-musleabihf \
\
x86_64-unknown-linux-gnu x86_64-unknown-linux-musl

CONFIG_HOST_SUFFIX:=$(shell cut -d"-" -f4 <<<"$(GNU_HOST_NAME)")
RUSTC_HOST_ARCH:= \
	$(strip $(foreach \
		v, \
		$(filter $(HOST_ARCH)-%, $(RUSTC_ARCH_TARGETS)), \
		$(if $(findstring -$(CONFIG_HOST_SUFFIX:"%"=%),$v),$v) \
		) \
	)

RUSTC_TARGET_ARCH_BASE:= \
	$(strip $(foreach \
		v, \
		$(filter $(ARCH)-%, $(RUSTC_ARCH_TARGETS)), \
		$(if $(findstring -$(CONFIG_TARGET_SUFFIX:"%"=%),$v),$v) \
		) \
	)

# Check to see if it's a soft-float target
ifeq ($(CONFIG_SOFT_FLOAT),y)
RUSTC_TARGET_ARCH:=$(strip $(filter %sf, $(RUSTC_TARGET_ARCH_BASE)))
else
RUSTC_TARGET_ARCH:=$(strip $(filter-out %sf, $(RUSTC_TARGET_ARCH_BASE)))
endif

# More than one triple-target remains.
ifneq ($(word 2, $(RUSTC_TARGET_ARCH)),)
$(error RUSTC ERROR: Unsupported or Unknown Target Triple: $(RUSTC_TARGET_ARCH))
endif

# These are environment variables that are used by other packages to
# define where rustc/cargo are kept.
CARGO_HOME:=$(BUILD_DIR_HOST)/.cargo
RUSTUP_HOME:=$(BUILD_DIR_HOST)/.rustup

Rust rustc-config.mk:


ifeq ($(CONFIG_RUST_DEBUG),y)
CONFIGURE_ARGS += --enable-debug
endif

ifeq ($(CONFIG_RUST_DOCS),y)
CONFIGURE_ARGS += --enable-docs
else
CONFIGURE_ARGS += --disable-docs
endif

ifeq ($(CONFIG_RUST_COMPILER_DOCS),y)
CONFIGURE_ARGS += --enable-compiler-docs
else
CONFIGURE_ARGS += --disable-compiler-docs
endif

ifeq ($(CONFIG_RUST_OPTIMIZE_TESTS),y)
CONFIGURE_ARGS += --enable-optimize-tests
endif

ifeq ($(CONFIG_RUST_PARALLEL),y)
CONFIGURE_ARGS += --enable-parallel-compiler
endif

ifeq ($(CONFIG_RUST_VERBOSE_TESTS),y)
CONFIGURE_ARGS += --enable-verbose-tests
endif

ifeq ($(CONFIG_RUST_CCACHE),y)
CONFIGURE_ARGS += --enable-ccache
endif

ifeq ($(CONFIG_RUST_LLVM_STATIC),y)
CONFIGURE_ARGS += --enable-llvm-static-stdcpp
endif

ifeq ($(CONFIG_RUST_LLVM_SHARED),y)
CONFIGURE_ARGS += --enable-llvm-link-shared
endif

ifeq ($(CONFIG_RUST_CODEGEN_TESTS),y)
CONFIGURE_ARGS += --enable-codegen-tests
endif

ifeq ($(CONFIG_RUST_OPTION_CHECKING),y)
CONFIGURE_ARGS += --enable-option-checking
endif

ifeq ($(CONFIG_RUST_ENABLE_NINJA),y)
CONFIGURE_ARGS += --enable-ninja
endif

ifeq ($(CONFIG_RUST_LOCKED_DEPS),y)
CONFIGURE_ARGS += --enable-locked-deps
endif

ifeq ($(CONFIG_RUST_VENDOR),y)
CONFIGURE_ARGS += --enable-vendor
endif

ifeq ($(CONFIG_RUST_SANITIZERS),y)
CONFIGURE_ARGS += --enable-sanitizers
endif

ifeq ($(CONFIG_RUST_DIST_SRC),y)
CONFIGURE_ARGS += --enable-dist-src
endif

ifeq ($(CONFIG_RUST_CARGO_NATIVE_STATIC),y)
CONFIGURE_ARGS += --enable-cargo-native-static
endif

ifeq ($(CONFIG_RUST_PROFILER),y)
CONFIGURE_ARGS += --enable-profiler
endif

ifeq ($(CONFIG_RUST_FULL_TOOLS),y)
CONFIGURE_ARGS += --enable-full-tools
endif

ifeq ($(CONFIG_RUST_MISSING_TOOLS),y)
CONFIGURE_ARGS += --enable-missing-tools
endif

ifeq ($(CONFIG_RUST_USE_LIBCXX),y)
CONFIGURE_ARGS += --enable-use-libcxx
endif

ifeq ($(CONFIG_RUST_CONTROL_FLOW_GUARD),y)
CONFIGURE_ARGS += --enable-control-flow-guard
endif

ifeq ($(CONFIG_RUST_LLVM_LIB_UNWIND),y)
CONFIGURE_ARGS += --enable-llvm-libunwind
endif

ifeq ($(CONFIG_RUST_OPTIMIZE),y)
CONFIGURE_ARGS += --enable-optimize
endif

ifeq ($(CONFIG_RUST_OPTIMIZE_LLVM),y)
CONFIGURE_ARGS += --enable-optimize-llvm
endif

ifeq ($(CONFIG_RUST_LLVM_ASSERTIONS),y)
CONFIGURE_ARGS += --enable-llvm-assertions
endif

ifeq ($(CONFIG_RUST_DEBUG_ASSERTIONS),y)
CONFIGURE_ARGS += --enable-debug-assertions
endif

ifeq ($(CONFIG_RUST_LLVM_RELEASE_DEBUGINFO),y)
CONFIGURE_ARGS += --enable-llvm-release-debuginfo
endif

ifeq ($(CONFIG_RUST_MANAGE_SUBMODULES),y)
CONFIGURE_ARGS += --enable-manage-submodules
endif

ifeq ($(CONFIG_RUST_FULL_BOOTSTRAP),y)
CONFIGURE_ARGS += --enable-full-bootstrap
endif

ifeq ($(CONFIG_LIBC),"musl")
CONFIGURE_ARGS += \
  	 --set=target.$(RUSTC_TARGET_ARCH).musl-root=$(TOOLCHAIN_DIR)
endif

Rust Config.in:

# Rust Language Options
menu "Compiler Options"
	depends on PACKAGE_rust

	config RUST_DEBUG
		bool "Enables Debugging Environment (--enable-debug)"
		default n

	config RUST_DOCS
		bool "Build standard library documentation (--enable-docs)"
		default n

	config RUST_COMPILER_DOCS
		bool "Build compiler documentation (--enable-compiler-docs)"
		default n

	config RUST_OPTIMIZE_TESTS
		bool "Build tests with optimizations (--enable-optimized-tests)"
		default n

	config RUST_PARALLEL
		bool "Build with multi-threaded support (--enable-parallel-compiler)"
		default n

	config RUST_VERBOSE_TESTS
		bool "Enable verbose output when running tests (--enable-verbose-tests)"
		default n

	config RUST_CCACHE
		bool "Build with ccache enabled (--enable-ccache)"
		default n

	config RUST_LLVM_STATIC
		bool "Statically link to libstdc++ to LLVM (--enable-llvm-static-stdccp)"
		default n

	config RUST_LLVM_SHARED
		bool "Prefer shared linking to LLVM (--enable-llvm-link-shared)"
		default n

	config RUST_CODEGEN_TESTS
		bool "Run the src/test/codegen tests (--enable-codegen-tests)"
		default n

	config RUST_OPTION_CHECKING
		bool "Complain about unrecognized options in this configure script (--enable-option-checking)"
		default y

	config RUST_ENABLE_NINJA
		bool "Build LLVM using the Ninja generator (--enable-ninja)"
		default y

	config RUST_LOCKED_DEPS
		bool "Force Cargo.lock to be up to date (--enable-locked-deps)"
		default n

	config RUST_VENDOR
		bool "Enable usage of vendored Rust crates (--enable-vendor)"
		default n

	config RUST_SANITIZERS
		bool "Build the sanitizer runtimes (asan, lsan, msan, tsan) (--enable-sanitizers)"
		default n

	config RUST_DIST_SRC
		bool "When building tarballs enables building a source tarball (--enable-dist-src)"
		default n

	config RUST_CARGO_NATIVE_STATIC
		bool "Build static native libraries in Cargo (--enable-cargo-native-static)"
		default n

	config RUST_PROFILER
		bool "Build the profiler runtime (--enable-profiler)"
		default n

	config RUST_FULL_TOOLS
		bool "Build all tools (--enable-full-tools)"
		default n

	config RUST_MISSING_TOOLS
		bool "Allow failures when building tools (--enable-missing-tools)"
		default y

	config RUST_USE_LIBCXX
		bool "Build LLMV with libc++ (--enable-use-libcxx)"
		default n

	config RUST_CONTROL_FLOW_GUARD
		bool "Enable Control Flow Guard (--enable-control-flow-guard)"
		default n

	config RUST_LLVM_LIB_UNWIND
		bool "Use LLVM libunwind (--enable-llvm-libunwind)"
		default n

	config RUST_OPTIMIZE
		bool "Build optimized rust code (--enable-optimize)"
		default n

	config RUST_OPTIMIZE_LLVM
		bool "Build optimized LLVM (--enable-optimize-llvm)"
		default n

	config RUST_LLVM_ASSERTIONS
		bool "Build LLVM with assertions (--enable-llvm-assertions)"
		default n

	config RUST_DEBUG_ASSERTIONS
		bool "Build with debugging assertions (--enable-debug-assertions)"
		default n

	config RUST_LLVM_RELEASE_DEBUGINFO
		bool "Build LLVM with debugger metadata (--enable-llvm-release-debuginfo)"
		default n

	config RUST_MANAGE_SUBMODULES
		bool "Let the build manage the git submodules (--enable-manage-submodules)"
		default y

	config RUST_FULL_BOOTSTRAP
		bool "Full Bootstrap - Build three compilers instead of two (--enable-full-bootstrap)"
		default y

endmenu

If I do have hard float and static libs, will the Rust-from-source file work?

If you have hard float and static libs, just use Rustup. It's easier that way.

Try the new makefile and triple and see if it works better.

This is exactly what I've been struggling with, yes.

Regarding the new rustup makefile, what is required for a pure rust project for their makefile? Do I need a Build/Compile stanza that calls cargo build or something? (I'd try it now but I'm waiting for an image to finish building.)

define Host/Compile
	$(CONFIGURE_VARS) \
	$(CARGO_HOME)/bin/rustup toolchain install nightly -t $(RUSTC_TARGET_ARCH)
	$(CONFIGURE_VARS) \
	$(CARGO_HOME)/bin/rustup default nightly
endef

Is what I am running. It runs the rustup to install and configure the default toolchain for the HOST and TARGET.

If you are using both my Makefile and rustc-triple.mk, it'll put them in:

./build_dir/hostpkg/.cargo and ./build_dir/hostpkg/.rustup

Try this (the path is what I use, but I keep my rust stuff in ./feeds/packages/lang)

make -j1 V=sc package/feeds/packages/rustup/host/clean
make -j1 V=sc package/feeds/packages/rustup/host/compile

grommish@norwits:~/openwrt$ make -j1 V=sc package/feeds/packages/rustup/host/compile
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'
Makefile:81: WARNING: skipping rustup -- package has no install section
. /home/grommish/openwrt/include/shell.sh; xzcat /home/grommish/openwrt/dl/rustup-1.22.1.tar.xz | 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/.prepared4076afe0009415b51ab45ce392ce25b7_6664517399ebbbc92a37c5bb081b5c53
AR="mips64-openwrt-linux-musl-gcc-ar" AS="mips64-openwrt-linux-musl-gcc -c -O2 -pipe -mno-branch-likely -mabi=64 -g3 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -fmacro-prefix-map=/home/grommish/openwrt/build_dir/target-mips64_octeon3_64_musl/rustup-1.22.1=rustup-1.22.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" LD=mips64-openwrt-linux-musl-ld NM="mips64-openwrt-linux-musl-gcc-nm" CC="mips64-openwrt-linux-musl-gcc" GCC="mips64-openwrt-linux-musl-gcc" CXX="mips64-openwrt-linux-musl-g++" RANLIB="mips64-openwrt-linux-musl-gcc-ranlib" STRIP=mips64-openwrt-linux-musl-strip OBJCOPY=mips64-openwrt-linux-musl-objcopy OBJDUMP=mips64-openwrt-linux-musl-objdump SIZE=mips64-openwrt-linux-musl-size CFLAGS="-O2 -pipe -mno-branch-likely -mabi=64 -g3 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -fmacro-prefix-map=/home/grommish/openwrt/build_dir/target-mips64_octeon3_64_musl/rustup-1.22.1=rustup-1.22.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro " CXXFLAGS="-O2 -pipe -mno-branch-likely -mabi=64 -g3 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -fmacro-prefix-map=/home/grommish/openwrt/build_dir/target-mips64_octeon3_64_musl/rustup-1.22.1=rustup-1.22.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro " CPPFLAGS="-I/home/grommish/openwrt/staging_dir/target-mips64_octeon3_64_musl/usr/include -I/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/usr/include -I/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/include/fortify -I/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/include " LDFLAGS="-L/home/grommish/openwrt/staging_dir/target-mips64_octeon3_64_musl/usr/lib -L/home/grommish/openwrt/staging_dir/target-mips64_octeon3_64_musl/lib -L/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/usr/lib -L/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/lib -znow -zrelro "  CARGO_HOME=/home/grommish/openwrt/build_dir/hostpkg/.cargo RUSTUP_HOME=/home/grommish/openwrt/build_dir/hostpkg/.rustup ac_cv_path_CARGO="/home/grommish/openwrt/build_dir/hostpkg/.cargo/bin/cargo" ac_cv_path_RUSTC="/home/grommish/openwrt/build_dir/hostpkg/.cargo/bin/rustc" /home/grommish/openwrt/build_dir/hostpkg/rustup-1.22.1/rustup-init.sh -y -v --profile default --default-toolchain stable --target mips64-unknown-linux-muslabi64
info: downloading installer
verbose: creating home directory: '/home/grommish/openwrt/build_dir/hostpkg/.rustup'
info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
verbose: creating update-hash directory: '/home/grommish/openwrt/build_dir/hostpkg/.rustup/update-hashes'
verbose: installing toolchain '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 root: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/cwrnlrpat3oehldm_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/cwrnlrpat3oehldm_file
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/4ulbgu3dwdam8559_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/y7vnz1drfx_1qbwd_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/y7vnz1drfx_1qbwd_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/4ulbgu3dwdam8559_file.toml
info: latest update on 2020-10-08, rust version 1.47.0 (18bf6b4f0 2020-10-07)
info: downloading component 'cargo'
verbose: creating Download Directory directory: '/home/grommish/openwrt/build_dir/hostpkg/.rustup/downloads'
verbose: downloading file from: 'https://static.rust-lang.org/dist/2020-10-08/cargo-0.48.0-x86_64-unknown-linux-gnu.tar.xz'
verbose: downloading with reqwest
verbose: checksum passed
info: downloading component 'clippy'
verbose: downloading file from: 'https://static.rust-lang.org/dist/2020-10-08/clippy-0.0.212-x86_64-unknown-linux-gnu.tar.xz'
verbose: downloading with reqwest
verbose: checksum passed
info: downloading component 'rust-docs'
verbose: downloading file from: 'https://static.rust-lang.org/dist/2020-10-08/rust-docs-1.47.0-x86_64-unknown-linux-gnu.tar.xz'
verbose: downloading with reqwest
verbose: checksum passed
info: downloading component 'rust-std' for 'mips64-unknown-linux-muslabi64'
verbose: downloading file from: 'https://static.rust-lang.org/dist/2020-10-08/rust-std-1.47.0-mips64-unknown-linux-muslabi64.tar.xz'
verbose: downloading with reqwest
verbose: checksum passed
info: downloading component 'rust-std'
verbose: downloading file from: 'https://static.rust-lang.org/dist/2020-10-08/rust-std-1.47.0-x86_64-unknown-linux-gnu.tar.xz'
verbose: downloading with reqwest
verbose: checksum passed
info: downloading component 'rustc'
verbose: downloading file from: 'https://static.rust-lang.org/dist/2020-10-08/rustc-1.47.0-x86_64-unknown-linux-gnu.tar.xz'
verbose: downloading with reqwest
verbose: checksum passed
info: downloading component 'rustfmt'
verbose: downloading file from: 'https://static.rust-lang.org/dist/2020-10-08/rustfmt-1.4.20-x86_64-unknown-linux-gnu.tar.xz'
verbose: downloading with reqwest
verbose: checksum passed
info: installing component 'cargo'
verbose: creating temp directory: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/5i9y5b__p4usx4g8_dir
info: Defaulting to 500.0 MiB unpack ram
verbose: deleted temp directory: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/5i9y5b__p4usx4g8_dir
info: installing component 'clippy'
verbose: creating temp directory: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/b4c1mprf53c_o5lf_dir
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/tn_62r7bdo3inamv_file
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/relf5oa5so0257is_file
verbose: deleted temp directory: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/b4c1mprf53c_o5lf_dir
info: installing component 'rust-docs'
verbose: creating temp directory: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/6igcl5i0a7x_0rsr_dir
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/bf3ybupqs61gh7ke_file
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/3jhahwkw0t7icn5n_file
verbose: deleted temp directory: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/6igcl5i0a7x_0rsr_dir
info: installing component 'rust-std' for 'mips64-unknown-linux-muslabi64'
verbose: creating temp directory: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/gufiu7w5l_gwsqsj_dir
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/e_56qh1b0asl7tik_file
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/lkv_b4xwr4vxri3i_file
verbose: deleted temp directory: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/gufiu7w5l_gwsqsj_dir
info: installing component 'rust-std'
verbose: creating temp directory: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/jy2x3yj4fiqqlqmw_dir
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/nz3bl663et0wadsd_file
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/4wtlent76sr5kz20_file
verbose: deleted temp directory: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/jy2x3yj4fiqqlqmw_dir
info: installing component 'rustc'
verbose: creating temp directory: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/8t04jarrguxsccy0_dir
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/vce19yfmjl54_3bt_file
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/_bvanq0zd6u9qzt7_file
verbose: deleted temp directory: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/8t04jarrguxsccy0_dir
info: installing component 'rustfmt'
verbose: creating temp directory: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/r1p9w3etl03a2_gp_dir
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/0epe18neelvg90nh_file
verbose: creating temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/nm6a9supg11gm1hx_file
verbose: deleted temp directory: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/r1p9w3etl03a2_gp_dir
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/tn_62r7bdo3inamv_file
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/relf5oa5so0257is_file
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/bf3ybupqs61gh7ke_file
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/3jhahwkw0t7icn5n_file
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/e_56qh1b0asl7tik_file
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/lkv_b4xwr4vxri3i_file
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/nz3bl663et0wadsd_file
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/4wtlent76sr5kz20_file
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/vce19yfmjl54_3bt_file
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/_bvanq0zd6u9qzt7_file
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/0epe18neelvg90nh_file
verbose: deleted temp file: /home/grommish/openwrt/build_dir/hostpkg/.rustup/tmp/nm6a9supg11gm1hx_file
verbose: toolchain 'stable-x86_64-unknown-linux-gnu' installed
info: default toolchain set to 'stable'

  stable installed - rustc 1.47.0 (18bf6b4f0 2020-10-07)


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
source /home/grommish/openwrt/build_dir/hostpkg/.cargo/env
touch /home/grommish/openwrt/build_dir/hostpkg/rustup-1.22.1/.configured
AR="mips64-openwrt-linux-musl-gcc-ar" AS="mips64-openwrt-linux-musl-gcc -c -O2 -pipe -mno-branch-likely -mabi=64 -g3 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -fmacro-prefix-map=/home/grommish/openwrt/build_dir/target-mips64_octeon3_64_musl/rustup-1.22.1=rustup-1.22.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" LD=mips64-openwrt-linux-musl-ld NM="mips64-openwrt-linux-musl-gcc-nm" CC="mips64-openwrt-linux-musl-gcc" GCC="mips64-openwrt-linux-musl-gcc" CXX="mips64-openwrt-linux-musl-g++" RANLIB="mips64-openwrt-linux-musl-gcc-ranlib" STRIP=mips64-openwrt-linux-musl-strip OBJCOPY=mips64-openwrt-linux-musl-objcopy OBJDUMP=mips64-openwrt-linux-musl-objdump SIZE=mips64-openwrt-linux-musl-size CFLAGS="-O2 -pipe -mno-branch-likely -mabi=64 -g3 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -fmacro-prefix-map=/home/grommish/openwrt/build_dir/target-mips64_octeon3_64_musl/rustup-1.22.1=rustup-1.22.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro " CXXFLAGS="-O2 -pipe -mno-branch-likely -mabi=64 -g3 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -fmacro-prefix-map=/home/grommish/openwrt/build_dir/target-mips64_octeon3_64_musl/rustup-1.22.1=rustup-1.22.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro " CPPFLAGS="-I/home/grommish/openwrt/staging_dir/target-mips64_octeon3_64_musl/usr/include -I/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/usr/include -I/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/include/fortify -I/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/include " LDFLAGS="-L/home/grommish/openwrt/staging_dir/target-mips64_octeon3_64_musl/usr/lib -L/home/grommish/openwrt/staging_dir/target-mips64_octeon3_64_musl/lib -L/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/usr/lib -L/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/lib -znow -zrelro "  CARGO_HOME=/home/grommish/openwrt/build_dir/hostpkg/.cargo RUSTUP_HOME=/home/grommish/openwrt/build_dir/hostpkg/.rustup ac_cv_path_CARGO="/home/grommish/openwrt/build_dir/hostpkg/.cargo/bin/cargo" ac_cv_path_RUSTC="/home/grommish/openwrt/build_dir/hostpkg/.cargo/bin/rustc" /home/grommish/openwrt/build_dir/hostpkg/.cargo/bin/rustup toolchain install nightly -t mips64-unknown-linux-muslabi64
info: syncing channel updates for 'nightly-x86_64-unknown-linux-gnu'
info: latest update on 2020-11-01, rust version 1.49.0-nightly (4f7612ac1 2020-10-31)
info: skipping nightly which is missing installed component 'rustfmt-preview'
info: syncing channel updates for 'nightly-2020-10-31-x86_64-unknown-linux-gnu'
info: latest update on 2020-10-31, rust version 1.49.0-nightly (ffe52882e 2020-10-30)
info: skipping nightly which is missing installed component 'rustfmt-preview'
info: syncing channel updates for 'nightly-2020-10-30-x86_64-unknown-linux-gnu'
info: latest update on 2020-10-30, rust version 1.49.0-nightly (6bdae9edd 2020-10-29)
info: skipping nightly which is missing installed component 'rustfmt-preview'
info: syncing channel updates for 'nightly-2020-10-29-x86_64-unknown-linux-gnu'
info: latest update on 2020-10-29, rust version 1.49.0-nightly (31ee872db 2020-10-28)
info: skipping nightly which is missing installed component 'rustfmt-preview'
info: syncing channel updates for 'nightly-2020-10-28-x86_64-unknown-linux-gnu'
info: latest update on 2020-10-28, rust version 1.49.0-nightly (07e968b64 2020-10-27)
info: skipping nightly which is missing installed component 'rustfmt-preview'
info: syncing channel updates for 'nightly-2020-10-27-x86_64-unknown-linux-gnu'
info: latest update on 2020-10-27, rust version 1.49.0-nightly (fd542592f 2020-10-26)
info: skipping nightly which is missing installed component 'rustfmt-preview'
info: syncing channel updates for 'nightly-2020-10-26-x86_64-unknown-linux-gnu'
info: latest update on 2020-10-26, rust version 1.49.0-nightly (4760b8fb8 2020-10-25)
info: skipping nightly which is missing installed component 'rustfmt-preview'
info: syncing channel updates for 'nightly-2020-10-25-x86_64-unknown-linux-gnu'
info: latest update on 2020-10-25, rust version 1.49.0-nightly (ffa2e7ae8 2020-10-24)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std' for 'mips64-unknown-linux-muslabi64'
info: downloading component 'rust-std'
info: downloading component 'rustc'
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: Defaulting to 500.0 MiB unpack ram
info: installing component 'clippy'
info: installing component 'rust-docs'
info: installing component 'rust-std' for 'mips64-unknown-linux-muslabi64'
info: installing component 'rust-std'
info: installing component 'rustc'
info: installing component 'rustfmt'

  nightly-x86_64-unknown-linux-gnu installed - rustc 1.49.0-nightly (ffa2e7ae8 2020-10-24)

info: checking for self-updates
AR="mips64-openwrt-linux-musl-gcc-ar" AS="mips64-openwrt-linux-musl-gcc -c -O2 -pipe -mno-branch-likely -mabi=64 -g3 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -fmacro-prefix-map=/home/grommish/openwrt/build_dir/target-mips64_octeon3_64_musl/rustup-1.22.1=rustup-1.22.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" LD=mips64-openwrt-linux-musl-ld NM="mips64-openwrt-linux-musl-gcc-nm" CC="mips64-openwrt-linux-musl-gcc" GCC="mips64-openwrt-linux-musl-gcc" CXX="mips64-openwrt-linux-musl-g++" RANLIB="mips64-openwrt-linux-musl-gcc-ranlib" STRIP=mips64-openwrt-linux-musl-strip OBJCOPY=mips64-openwrt-linux-musl-objcopy OBJDUMP=mips64-openwrt-linux-musl-objdump SIZE=mips64-openwrt-linux-musl-size CFLAGS="-O2 -pipe -mno-branch-likely -mabi=64 -g3 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -fmacro-prefix-map=/home/grommish/openwrt/build_dir/target-mips64_octeon3_64_musl/rustup-1.22.1=rustup-1.22.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro " CXXFLAGS="-O2 -pipe -mno-branch-likely -mabi=64 -g3 -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -msoft-float -fmacro-prefix-map=/home/grommish/openwrt/build_dir/target-mips64_octeon3_64_musl/rustup-1.22.1=rustup-1.22.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro " CPPFLAGS="-I/home/grommish/openwrt/staging_dir/target-mips64_octeon3_64_musl/usr/include -I/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/usr/include -I/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/include/fortify -I/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/include " LDFLAGS="-L/home/grommish/openwrt/staging_dir/target-mips64_octeon3_64_musl/usr/lib -L/home/grommish/openwrt/staging_dir/target-mips64_octeon3_64_musl/lib -L/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/usr/lib -L/home/grommish/openwrt/staging_dir/toolchain-mips64_octeon3_64_gcc-10.2.0_musl/lib -znow -zrelro "  CARGO_HOME=/home/grommish/openwrt/build_dir/hostpkg/.cargo RUSTUP_HOME=/home/grommish/openwrt/build_dir/hostpkg/.rustup ac_cv_path_CARGO="/home/grommish/openwrt/build_dir/hostpkg/.cargo/bin/cargo" ac_cv_path_RUSTC="/home/grommish/openwrt/build_dir/hostpkg/.cargo/bin/rustc" /home/grommish/openwrt/build_dir/hostpkg/.cargo/bin/rustup default nightly
info: using existing install for 'nightly-x86_64-unknown-linux-gnu'
info: default toolchain set to 'nightly-x86_64-unknown-linux-gnu'

  nightly-x86_64-unknown-linux-gnu unchanged - rustc 1.49.0-nightly (ffa2e7ae8 2020-10-24)

touch /home/grommish/openwrt/build_dir/hostpkg/rustup-1.22.1/.built
true
mkdir -p /home/grommish/openwrt/staging_dir/hostpkg/stamp
touch /home/grommish/openwrt/build_dir/hostpkg/rustup-1.22.1/.built
touch /home/grommish/openwrt/staging_dir/hostpkg/stamp/.rustup_installed
make[2]: Leaving directory '/home/grommish/openwrt/feeds/packages/lang/rustup'
time: package/feeds/packages/rustup/host-compile#25.69#4.39#32.96
make[1]: Leaving directory '/home/grommish/openwrt'
grommish@norwits:~/openwrt$ which rustc
/home/grommish/openwrt/build_dir/hostpkg/.cargo/bin/rustc
grommish@norwits:~/openwrt$ which rustup
/home/grommish/openwrt/build_dir/hostpkg/.cargo/bin/rustup
grommish@norwits:~/openwrt$ which cargo
/home/grommish/openwrt/build_dir/hostpkg/.cargo/bin/cargo

AAAAARG it looks like I have soft float after all, dang it.

It's ok.. i found the very hard way were everything SEEMED to work fantastically, only to return a SIGILL Illegal Instruction error on a sdc1 opcode, which is Hard-float :frowning:

We'll get it to work as fast as Rust devs are willing to work on it.

I meant - if I have my own pure rust project (no C), do I need to anything special to invoke cargo build? Or is it the default build mechanism?

Believe it or not, but I don't know rust (or really any other programming lang).. I'm just persistent.

Once rustup is installed, you should be able to invoke cargo/rustc etc from anywhere, regardless of OpenWrt (because rustup/rust-from-source would install itself to the host, but just in a place that is easy to remove it from.. in this case, ./build_dir/hostpkg/.cargo) You can set that, btw, in rustc-triple.mk at the bottom.

Ah excellent. My existing makefile already invokes cargo build, so I will start from that.

Once you're happy to publish something, let me know. I could perhaps add the usual facility that OpenWrt language makefiles provide, which is default Build/Compile etc. stanzas that work out of the box in most common cases.

I'd say "well at least now you know GNU Make" but really it should be "well unfortunately now you know GNU Make." I'm extremely grateful for your efforts here.

The biggest issue to sending rustup up is the fact I don't know which archs it will work on versus which it won't. I know it won't on mine, but for specific reasons. I'd need to figure out a way to sift thru the archs to validate if it works or not (and why it doesn't). I'd need to find volunteers to actually test, because rustup works on my system until I go to run the rust-compiled program on the target arch, then it dumps.. So the testers would need to be testing beyond just compilation.

I reckon someone could just write a test battery that includes any potentially problematic code, turn it into a package, and then anyone who wants to volunteer can install it via opkg, run it, and paste a report into an issue tracker.

There is also potentially Qemu, but I have often found that some hardware bugs do not manifest in Qemu as they do on the real thing.

Well.. I was thinking more along the lines of figuring out which archs are hard-float and statically linked libs, and then disallowing the rest. Ideally, it's just removing the target archs from rustc-triple.mk and letting it fail gracefully on it's own. (For rustup)

Rust from source allows me/us to define custom triples. I have both

mips64-unknown-linux-gnuabi64 mips64-unknown-linux-muslabi64 \
mips64-unknown-linux-gnuabi64sf mips64-unknown-linux-muslabi64sf \

for hard-float vs soft-float targets (I've got a patch to add these targets). The issue is that rust from source builds won't cross compile right now. They are constantly adding to the git though, so they'll get it eventually. They are just very x86-centric.

Besides, you can do a lot more with source.

Interesting @detly, I went to look at the mipsel musl target, and it's already soft-float.. So, you won't even need to change to a custom triple to build from source..

Rust still fails on rustfmt and rls packages, but I'm not sure that those packages are critical to rustc/cargo itself. I've got it set to ignore tool failures, so...

use crate::spec::{LinkerFlavor, Target, TargetOptions};

pub fn target() -> Target {
    let mut base = super::linux_musl_base::opts();
    base.cpu = "mips32r2".to_string();
    base.features = "+mips32r2,+soft-float".to_string();
    base.max_atomic_width = Some(32);
    base.crt_static_default = false;
    Target {
        llvm_target: "mipsel-unknown-linux-musl".to_string(),
        target_endian: "little".to_string(),
        pointer_width: 32,
        target_c_int_width: "32".to_string(),
        data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".to_string(),
        arch: "mips".to_string(),
        target_os: "linux".to_string(),
        target_env: "musl".to_string(),
        target_vendor: "unknown".to_string(),
        linker_flavor: LinkerFlavor::Gcc,
        options: TargetOptions { target_mcount: "_mcount".to_string(), ..base },
    }
}

It does mean the rustc-triple.mk check for SOFT_FLOAT is now invalid :smiley: I'll need to rethink that.