Hi, strange that it is giving the errors on your side. I got it working without errors on my side even without the configure arguments. I don't have rust installed on the host, only in the toolchain through your lang/rust
package. I'm now working to build the std
crate package and disable static linking.
My update on github is now working perfect, even pulling in external crates and building them. I only need to have the Cargo.toml
and source files in the src
directory. In my setup the IPK is build ok and I can install using opkg
which is good.
I didn't use the ac_cv_path_
variables nor CONFIGURE_VARS
as I'm not using autoconf, cmake or not even GNU Make but pure Rust Cargo. The key was to use cargo rustc
instead of cargo build
and pass in the correct compiler and linker with the $(CARGO_HOME)
variable.
I think the Makefile is now quite universal and we could send in a patch in the OpenWRT build system to have a rust.mk
for rust packages which define these build functions. What do you think?
I now read that Rust is not ABI stable which is off course bad for OpenWRT where binary size is of the utmost importance. However as OpenWRT is compiled from source this should not be a huge issue as upgrading rust just means to recompile all rust binaries in the toolchain and doing a sysupgrade.
My first attempts as creating the libstd-**.so are not successful, makefile here: daanpape/rust-libstd: OpenWRT package which provides the libstd-*.so shared library (github.com)
UPDATE
I now realized that the libstd-**.so
is already compiled by the rust
package itself and it's living in the staging_dir
of the toolchain. I have updated the makefile of the rust-libstd
package to create an IPK file of it. I also updated the rust-hello-world
example to make use of this. It runs perfectly on my MIPS softfloat target (Atheros Qualcomm AR9331). I think this is a good setup for OpenWRT devices as you can now write multiple rust applications without having having a ton of RAM and flash usage. The only downside to this is that for every crate that you import a separate package should be made which also compiles this external crate with dynamic linking, for some crates this could become tedious. It would be handy if you could select which crates to link in dynamically (libstd) and which statically, I don't know if this is possible?
Current sizes:
rust-hello-world 4204B (4.11kB)
libstd-61e1ef472d25ade8.so 2029380B (1981.82kB)
The libstd thus is very very large, as a comparison libc (musl) is 626692B (612KB)