-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
arm-unknown-linux-gnueabihf generates armv7 instructions #45284
Comments
Hi @ddemarco5, just to be sure, have you checked if this happens in rust code not C code? Also, the target cpu you want for the RPi1 is |
@parched this is compiling rust code with rustc via cargo, not compiling any C code to my knowledge. I set the target cpu to arm1176jzf-s, outcome didn't change. |
Could you find out from which function did the problem instruction come from, by using |
The instruction that hits first is in "deregister_tm_clones", but it appears elsewhere as well. Here's the output of a grep on the file for cbz. I'd be happy to upload the full file if anyone needs it.
|
Yes but the standard library depends on C code, e.g., libc, and the compiler also generates calls to it's own runtime, some of which are written in C.
|
I think that's in the C runtime startup code so I suspect you are using a Armv7 toolchain (which most named |
Also what Linux distribution are you using on the RPi1? To my knowledge, there aren't any hard-float distros for RPi1, so maybe you want to use the |
I pulled gcc-arm-linux-gnueabihf from the standard debian repos. I'm using the newest version of raspbian on the pi. I'll try without the hardfloat. |
There are plenty of hard-float distros, Raspbian uses hard floats, as does Arch Linux ARM. I'm deploying to a similar target locally (RPi 1 Model B) and successfully use the |
I checked my distro and it does in fact use hardfloat, so I stopped trying to compile it for the softfloat target. I'm currently operating under the assumption that the arm-unknown-linux-gnueabi compiler I have is an armv7 version. I'm trying to get a different version. |
Sure:
Note that I'm using |
I'm building a toolchain specific to the RPI B+. If that solves the issue I'll go ahead and close the issue, as it appears to be a problem of libc being compiled for ARMv7. |
Ah yes you're quite right, I was just thinking of the standard debian ports armel and armhf. @ddemarco5 Yes, I think the debian |
My project works fine with the current nightly, but I'm using the libc that's installed on the Pi. |
Built a toolchain with libc included targeted toward ARMv6 and the Pi B+ and that fixed the issue, thanks for the help guys. |
@ddemarco5 sorry to comment on this old issue, but I'm facing the same problem. I can't figure out the flags to pass in the Can anyone give me some directions? I'm targeting I've tried compiling with Is this the right way to pass flags to the compiler? p.s. I can also target thanks! |
Oof. This was a while ago. I read the bug through again to try to refresh myself... It looks like you're getting confused as I was, that target you're using says it works for the rpi1, but the default arm-linux-gnueabihf toolchain you get from pretty much any distro with apt-get, yum, etc... if built for ARMv7. So when you go to compile your program, some ARMv7 code is included (not sure if it's in the compile or link step, I need a refresher on rust's libc). The solution is to compile (or find) another version of the gcc toolchain targeted specifically for ARMv6. I would recommend buildroot (https://buildroot.org/), it takes most of the pain out of the process. Once you have that compiled and good to go, you need to go and configure cargo to use that toolchain for the triple you're using to compile for the RPI1. You can see a little bit of an example of that here. I hope this sets you on the right path! Again, it's been a while so some of the information here may be a bit off here any there... but I hope it gets you going in the right direction. |
uhm ... interesting but also a bit of a let down. Reading this answer on S.O. I thought I could tweak the flags to have the right executable for The bad surprise is that
This is all pretty confusing. Anyway, thanks for the heads-up 👍 I'll explore your suggestion, too. |
Welcome to the reason people like interpreted languages! :P It can feel like a lot to take on, and error messages are rarely helpful, but you'll start to get the hang of it. Once you see enough of this stuff, the picture starts to come together. |
I'm working on a dual platform embedded project. One is running an ARMv7 processor, and one is running on ARMv6 (RPI1 B+).
The ARMv7 platform runs without issue, however, trying to get ARMv6 code generated has caused problems.
When running the binary on the ARMv6 target, I fail with an illegal instruction.
Tracing on it reveals
cbz r3, 0x7f55a264
, a compare and branch on 0... an ARMv7 instruction, absent from the ARMv6 instruction set.Here is my target in the cargo config:
The broadcom SOC isn't an available target-cpu (oddly, all the cpus in the target list are armv7 processors), so I tried generic, I've tried enabling the armv6 feature and disabling a handful of armv7 features, but had no luck. I've passed args to the linker to ensure the target arch is indeed armv6 as far as it's concerned, but armv7 instructions are still getting through.
I've tried a couple options, but the supported targets list at https://forge.rust-lang.org/platform-support.html
arm-unknown-linux-gnueabihf | ✓ | ✓ | ✓ | ARMv6 Linux, hardfloat
is misleading.
Is there a way to disable all target-features except the ones you explicitly enable? That might be a possible workaround for the time being.
The text was updated successfully, but these errors were encountered: