-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Array comparisons don't work on AVR #78022
Comments
Any known workarounds? This is blocking one of my projects :( |
I can still reproduce it on |
I'm running into this issue as well. I know what's going on, but I don't have any idea how to fix it. The short version is that the compiler loads the address of the array into a register, calls
Critically, note that R22 and R23 are not modified by When So anyways, that's what's going on, but I have no idea why or how to fix it. |
On further investigation, I think the issue is in the LLVM IR:
I'm not an expert in LLVM IR by any stretch, but if I'm interpreting this correctly it's doing a 32-bit compare for the return value of
|
OK, I believe this issue is the root cause: #32610: |
…rochenkov make memcmp return a value of c_int_width instead of i32 This is an attempt to fix rust-lang#32610 and rust-lang#78022, namely, that `memcmp` always returns an `i32` regardless of the platform. I'm running into some issues and was hoping I could get some help. Here's what I've been attempting so far: 1. Build the stage0 compiler with all the changes _expect_ for the changes in `library/core/src/slice/cmp.rs` and `compiler/rustc_codegen_llvm/src/context.rs`; this is because `target_c_int_width` isn't passed through and recognized as a valid config option yet. I'm building with `./x.py build --stage 0 library/core library/proc_macro compiler/rustc` 2. Next I add in the `#[cfg(c_int_width = ...)]` params to `cmp.rs` and `context.rs` and build the stage 1 compiler by running `./x.py build --keep-stage 0 --stage 1 library/core library/proc_macro compiler/rustc`. This step now runs successfully. 3. Lastly, I try to build the test program for AVR mentioned in rust-lang#78022 with `RUSTFLAGS="--emit llvm-ir" cargo build --release`, and look at the resulting llvm IR, which still shows: ``` ... %11 = call addrspace(1) i32 `@memcmp(i8*` nonnull %5, i8* nonnull %10, i16 5) rust-lang#7, !dbg !1191 %.not = icmp eq i32 %11, 0, !dbg !1191 ... ; Function Attrs: nounwind optsize declare i32 `@memcmp(i8*,` i8*, i16) local_unnamed_addr addrspace(1) #4 ``` Any ideas what I'm missing here? Alternately, if this is totally the wrong approach I'm open to other suggestions. cc `@Rahix`
This issue should be fixed at this point. |
For some reason, comparing to identical arrays does not yield
true
in all cases.I tried this code:
I expected to see this happen: all lines print
true
Instead, this happened: some print
false
. See the code.Meta
rustc --version --verbose
:I am cross compiling for the
avr-unknown-unknown
target. I did not try any other targets except the host (x86_64-unknown-linux-gnu
), on which it does work.The text was updated successfully, but these errors were encountered: