Closed Bigomby closed 7 years ago
Hi, I'm trying to cross compile a Rust app for LEDE (fork of OpenWRT) but I'm stuck.
The application is just an hello_world example:
hello_world
fn main() { println!("Hello, world"); }
These are the steps I performed:
mips-openwrt-linux-musl-gcc
rustup add mips-unknown-linux-musl
Create a .cargo/config file in my project with the following content:
.cargo/config
[target.mips-unknown-linux-musl] linker = "mips-openwrt-linux-musl-gcc"
cargo build --release --target=mips-unknown-linux-musl
scp
Illegal instruction
On target
$ ldd hello_world /lib/ld-musl-mips-sf.so.1 (0x558c2000) libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x77cc4000) libc.so => /lib/ld-musl-mips-sf.so.1 (0x558c2000) $ ldd --version musl libc (mips-sf) Version 1.1.15 Dynamic Program Loader Usage: ldd [options] [--] pathname
On host
$ mips-openwrt-linux-musl-gcc -v Reading specs from /opt/lede/staging_dir/toolchain-mips_mips32_gcc-5.4.0_musl-1.1.15/bin/../lib/gcc/mips-openwrt-linux-musl/5.4.0/specs COLLECT_GCC=mips-openwrt-linux-musl-gcc COLLECT_LTO_WRAPPER=/opt/lede/staging_dir/toolchain-mips_mips32_gcc-5.4.0_musl-1.1.15/bin/../libexec/gcc/mips-openwrt-linux-musl/5.4.0/lto-wrapper Target: mips-openwrt-linux-musl Configured with: /home/diego/source/build_dir/toolchain-mips_mips32_gcc-5.4.0_musl-1.1.15/gcc-5.4.0/configure --with-bugurl=http://www.lede-project.org/bugs/ --with-pkgversion='LEDE GCC 5.4.0 r2032' --prefix=/home/diego/source/staging_dir/toolchain-mips_mips32_gcc-5.4.0_musl-1.1.15 --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=mips-openwrt-linux-musl --with-gnu-ld --enable-target-optspace --disable-libgomp --disable-libmudflap --disable-multilib --disable-libmpx --disable-nls --without-isl --without-cloog --with-host-libstdcxx=-lstdc++ --with-float=soft --with-gmp=/home/diego/source/staging_dir/host --with-mpfr=/home/diego/source/staging_dir/host --with-mpc=/home/diego/source/staging_dir/host --disable-decimal-float --with-mips-plt --with-diagnostics-color=auto-if-env --disable-libssp --enable-__cxa_atexit --with-headers=/home/diego/source/staging_dir/toolchain-mips_mips32_gcc-5.4.0_musl-1.1.15/include --disable-libsanitizer --enable-languages=c,c++ --enable-shared --enable-threads --with-slibdir=/home/diego/source/staging_dir/toolchain-mips_mips32_gcc-5.4.0_musl-1.1.15/lib --enable-lto --with-libelf=/home/diego/source/staging_dir/host Thread model: posix gcc version 5.4.0 (LEDE GCC 5.4.0 r2032)
If I use rust nightly and disable jemalloc as following:
#![feature(alloc_system)] extern crate alloc_system; fn main() { println!("Hello, world"); }
Then it works! But as I keep adding code the application eventually crashes with another Illegal instruction. For example:
Works
TcpStream::connect("130.206.193.115:80").unwrap();
Does not work
TcpStream::connect("google.com:80").unwrap();'
I don't know what I'm doing wrong. Any help will be appreciated.
Hola, Diego
This seems like a bug in either the Rust compiler or in the infrastructure that builds the binary releases of std for this target so I'm going to move this to rust-lang/rust.
Hi, I'm trying to cross compile a Rust app for LEDE (fork of OpenWRT) but I'm stuck.
The application is just an
hello_world
example:These are the steps I performed:
mips-openwrt-linux-musl-gcc
).rustup add mips-unknown-linux-musl
.Create a
.cargo/config
file in my project with the following content:cargo build --release --target=mips-unknown-linux-musl
.scp
.Illegal instruction
On target
On host
Disabling jemalloc
If I use rust nightly and disable jemalloc as following:
Then it works! But as I keep adding code the application eventually crashes with another
Illegal instruction
. For example:Works
Does not work
I don't know what I'm doing wrong. Any help will be appreciated.