-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Program cross compiled for mips-unknown-linux-musl crashes with SIGILL #37507
Comments
The only thing that I think you could be doing wrong is compiling the binary for I'd like to check a few things:
My guess, since C code is involved in all the crashes, is that we are building If it's not the C side, then we may need to tweak our LLVM codegen options. Or it could be a bad |
|
This is what happends when using jemalloc fn main() {
println!("Hello world");
}
|
A SIGILL probably means that we're miscompiling jemalloc somehow (maybe some weird codegen option) but if it still faults with the system allocator then it's likely not exclusively a jemalloc problem. |
I tried to run the program on an OM2P (MIPS device) and it's working fine, even with jemalloc. OM2P uses an Atheros AR7240 so the issue seems to be something more specific to Broadcom 6358. UPDATE: It crashes also when using glibc instead musl on the Huawei EchoLife HG556a.
|
Interesting. Then this could be due to codegen options related to "architecture level" (-march) or CPU optimizations (-mcpu) in the sense that the current rustc options generate instructions that are not available on some of these devices. Unfortunately, I don't know the MIPS ISA well enough to confirm this. |
This is probably due to the ISA level. The HG556a seems to use MIPS32r1 and the OM2P uses MIPS32r2. I think LLVM defaults to MIPS32r2 unless told otherwise. It would be interesting to get a disassembly at the SIGILL, then I could tell you for certain that this was the problem. |
I'm experiencing this issue too (on a Broadcom chip, though). |
I have suffered similar losses in the battle for Illegal Instructions on mips. My research so far and i hope this helps: Minimal build for VU+ DUO2 mipsel-unknown-linux-gnu with Rust on WindowsTo save you some hours i describe the process how i build a hello world without Target Specs
What you needTo compile for the target i used Codescape GNU Tools 2018.09-03 Binaries Rust components used:
Install "The sysroot manager that lets you build and customize
SetupEnvironmentPaths are specific to my setup and locations. This can vary in your case and you Add your cross-compiler to the search path
Specify the compiler setup to use:
Build filesAny minimal
Build file for Xargo
Cargo configurationLocal cargo configuration
Compilingrun
or if you have set up a runner in
to see it work. and
to see it fail again with illegal instruction as it is compiled against the Rust |
I cant withstand not to add an example: https://github.com/Jedzia/RokerDepp |
cc @Bigomby @alexcrichton
Originally reported as japaric/rust-cross#27
Original report below:
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:
In first place I downloaded the LEDE SDK and compiled successfully the image and the toolchain for my device (
mips-openwrt-linux-musl-gcc
).Install the Rust std using
rustup add mips-unknown-linux-musl
.Create a
.cargo/config
file in my project with the following content:Build the app using
cargo build --release --target=mips-unknown-linux-musl
.Deploy the executable to the device using
scp
.Got
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.
The text was updated successfully, but these errors were encountered: