Skip to content
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

crate rs_ws281x is compiled with undefined instruction #1570

Open
4 of 11 tasks
ziutech opened this issue Oct 9, 2024 · 7 comments
Open
4 of 11 tasks

crate rs_ws281x is compiled with undefined instruction #1570

ziutech opened this issue Oct 9, 2024 · 7 comments

Comments

@ziutech
Copy link
Contributor

ziutech commented Oct 9, 2024

Checklist

Describe your issue

Compiling crate rs_ws281x with cross for target armv7-unknown-linux-gnueabihf results in a illegal instruction.

What target(s) are you cross-compiling for?

armv7-unknown-linux-gnueabihf

Which operating system is the host (e.g computer cross is on) running?

  • macOS
  • Windows
  • Linux / BSD
  • other OS (specify in description)

What architecture is the host?

  • x86_64 / AMD64
  • arm32
  • arm64 (including Mac M1)

What container engine is cross using?

  • docker
  • podman
  • other container engine (specify in description)

cross version

cross 0.2.5 (ac4c11c 2024-09-24)

Example

git clone https://github.com/rpi-ws281x/rpi-ws281x-rust

# I had to set correct pin, strip len and strip type in examples/basic.rs, otherwise it did not run

cross b --target armv7-unknown-linux-gnueabihf --example basic

# copy to raspberry pi

./basic

# Illegal instruction

Additional information / notes

(gdb) disas $pc-40,$pc+40
Dump of assembler code from 0x425734 to 0x425784:
   0x00425734 <setup_pwm+1700>: tst     r0, #10
   0x00425738 <setup_pwm+1704>: bl      0x4791d0
   0x0042573c <setup_pwm+1708>: tst     r0, #1
   0x00425740 <setup_pwm+1712>: tst     r0, #0
   0x00425744 <setup_pwm+1716>: str     r0, [sp, #120]  ; 0x78
   0x00425748 <setup_pwm+1720>: b       0x42574c <setup_pwm+1724>
   0x0042574c <setup_pwm+1724>: ldr     r0, [sp, #120]  ; 0x78
   0x00425750 <setup_pwm+1728>: and     r0, r0, #1
   0x00425754 <setup_pwm+1732>: tst     r0, #1
   0x00425758 <setup_pwm+1736>: bne     0x425760 <setup_pwm+1744>
=> 0x0042575c <setup_pwm+1740>: udf     #65006  ; 0xfdee
   0x00425760 <setup_pwm+1744>: tst     r0, #1
   0x00425764 <setup_pwm+1748>: b       0x425768 <setup_pwm+1752>
   0x00425768 <setup_pwm+1752>: tst     r0, #1
   0x0042576c <setup_pwm+1756>: str     r0, [sp, #116]  ; 0x74
   0x00425770 <setup_pwm+1760>: b       0x425774 <setup_pwm+1764>
   0x00425774 <setup_pwm+1764>: ldr     r0, [sp, #116]  ; 0x74
   0x00425778 <setup_pwm+1768>: and     r0, r0, #1
   0x0042577c <setup_pwm+1772>: tst     r0, #1
   0x00425780 <setup_pwm+1776>: bne     0x425788 <setup_pwm+1784>
End of assembler dump.

Potentially related issue: ziglang/zig#16585

@Emilgardis
Copy link
Member

Are you sure armv7 is correct? What rpi is this?

@Emilgardis
Copy link
Member

That udf looks like a proper udf call, im not sure this is a cross-rs issue

@ziutech
Copy link
Contributor Author

ziutech commented Oct 9, 2024

Are you sure armv7 is correct? What rpi is this?

It's for rpi 3. I'm not sure if armv7 is correct, I used to compile for this target without cross and it worked. Now I need to compile for older glibc, and it's not working anymore.

@Emilgardis
Copy link
Member

the thing is, all cross does is give you a cross compiler, it might be an issue with the cc, would want to the opcode of the instruction it's generating that is shown as udf

@ziutech
Copy link
Contributor Author

ziutech commented Oct 15, 2024

Right, to me this looks like an issue with zig. I was not sure if I should report this here, in cargo-zigbuild or in zig. Sorry for that.

I found a way to do what I wanted to do without zig, by using a custom docker image, so this can probably be closed.

@Emilgardis
Copy link
Member

oh, are you using zig in Cross.toml?

@ziutech
Copy link
Contributor Author

ziutech commented Oct 15, 2024

oh, are you using zig in Cross.toml?

Yes, I forgot to specify that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants