-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Regression test for AVR rjmp
offset
#131755
Regression test for AVR rjmp
offset
#131755
Conversation
This commit introduces a minimal `![no_core]`-test case running on AVR, that contains the MCWE mentioned in [129301]. The test case itself does not have any assertions yet, but it shows the minimal set an language items necessary within the test case. [129301]: rust-lang#129301 (comment)
The issue was, that the disassembled label was placed one instruction further down than expected. Therefore the test annotations check, that the label is placed above the loop-contents (writing the one value, then writing the other one).
Failed to set assignee to
|
This PR modifies cc @jieyouxu |
0426aaa
to
070e838
Compare
This comment has been minimized.
This comment has been minimized.
This comment was marked as resolved.
This comment was marked as resolved.
This fixes the [build error] caused by the `avr-gcc` (used as linker) not being available in the Rust CI. [build error]: rust-lang#131755 (comment)
This comment has been minimized.
This comment has been minimized.
r? compiler |
This fixes the [build error] caused by the `avr-gcc` (used as linker) not being available in the Rust CI. [build error]: rust-lang#131755 (comment)
a71fe55
to
5beb86c
Compare
This comment has been minimized.
This comment has been minimized.
Hm, there's a problem: it works locally, but not in CI. CI reports either of two issues:
I could force |
What do you mean by suggested tool-flow? |
Even if not yet merged, PR #131651 documents, that the
I called the fact, that one should use |
... I mean, kinda, if you add a linker detection directive in compiletest that conditionally runs the test if And if we're not testing the "standard" recommended linker, it won't reflect the actual avr environment that users usually have, right? Although if e.g. the regression can be reproduced with using a linker other than Basically, if using a different linker will still repro the regression, then I think it's okay to use a linker that's not part of the "default" tool-flow. Footnotes
|
Thank you for your feedback! Based on that I propose: we add the test with |
This fixes the [build error] caused by the `avr-gcc` (used as linker) not being available in the Rust CI. This is a viable solution, which shows the wrong/right behavior and, since no functions from `libgcc` are called, does not produce errors. This was discussed [here]. Another small problem is, that `lld` doesn't link the correct startup-code by default. This is not a problem for this test (since it does not actually use anything the startup code is needed for (no variables, no stack, no interrupts)), but this causes the `main`-function to be removed by the default flag `--gc-sections`. Therefore the `rmake`-driver also adds the linker flag `--entry=main` to mark the `main`-function as the entry point and thus preventing it from getting removed. The code would work on a real AVR device. [build error]: rust-lang#131755 (comment) [here]: rust-lang#131755 (comment)
5beb86c
to
4920c6a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a reasonable compromise to me. I'll r+ when PR CI is green. Thanks.
Thany very much for your support! Again: Thank you! |
@bors r+ rollup=iffy (linker dependent) |
@bors r- I need to double check the rust-lld directive, seems sus (not actionable for you, waiting on me) |
I don't see why this won't run in at least one CI, but maybe T-infra will tell me a few months later 😆 Anyway |
Rollup of 9 pull requests Successful merges: - rust-lang#130136 (Partially stabilize const_pin) - rust-lang#131755 (Regression test for AVR `rjmp` offset) - rust-lang#131774 (Add getentropy for RTEMS) - rust-lang#131802 (Dont ICE when computing coverage of synthetic async closure body) - rust-lang#131809 (Fix predicate signatures in retain_mut docs) - rust-lang#131858 (Remove outdated documentation for `repeat_n`) - rust-lang#131866 (Avoid use imports in `thread_local_inner!`) - rust-lang#131874 (Default to the medium code model on OpenHarmony LoongArch target) - rust-lang#131877 (checktools.sh: add link to issue for more context about disabled Miri tests) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#131755 - jfrimmel:avr-rjmp-offset-regression-test, r=jieyouxu Regression test for AVR `rjmp` offset This adds a regression test for rust-lang#129301 by minimizing the code in the linked issue and putting it into a `#![no_core]`-compatible format, so that it can easily be used within an `rmake`-test. This needs to be a `rmake` test (opposed to a `tests/assembly` one), since the linked issue describes, that the problem only occurs if the code is directly compiled. Note, that `lld` is used instead of `avr-gcc`; see the [comments](rust-lang#131755 (comment)) [below](rust-lang#131755 (comment)). Closes rust-lang#129301. To show, that the test actually catches the wrong behavior, this can be tested with a faulty rustc: ```bash $ rustup install nightly-2024-08-19 $ rustc +nightly-2024-08-19 -C opt-level=s -C panic=abort --target avr-unknown-gnu-atmega328 -Clinker=build/x86_64-unknown-linux-gnu/ci-llvm/bin/lld -Clink-arg='--entry=main' -o compiled tests/run-make/avr-rjmp-offset/avr-rjmp-offsets.rs $ llvm-objdump -d compiled | grep '<main>' -A 6 000110b4 <main>: 110b4: 81 e0 ldi r24, 0x1 110b6: 92 e0 ldi r25, 0x2 110b8: 85 b9 out 0x5, r24 110ba: 95 b9 out 0x5, r25 110bc: fe cf rjmp .-4 ``` One can see, that the wrong label offset (`4` instead of `6`) is produced, which would trigger an assertion in the test case. This would be a good candidate for using the `minicore` proposed in rust-lang#130693. Since this is not yet merged, there is a FIXME. r? Patryk27 I think, you are the yet-to-be official target maintainer, hence I'll assign to you. `@rustbot` label +O-AVR
@bors r- (bors???) |
@jfrimmel hi, this test seems to have spuriously failed in #131527 (comment) with a heap corruption... does that look genunine to you? |
|
Wait that looks like the linker died, maybe similar to #115985 |
Puh, I don't thibk, this is really actionable by me. I don't have the CI environment here to try to reproduce it and the linked issue looks like this is spurious behavior. Of course, the underlying issue is not introduced by this PR but rather "just" unveiled. |
Yeah mb, I don't think it's the test itself, it looks like an underlying bug with rust-lld. |
This test seems to be failing somewhat often:
All on x86_64-mingw. Can we maybe disable it on x86_64-mingw until it is fixed? |
I think the linker is crashing... Yeah let's disable it for x86-64-mingw. EDIT: see #133481 |
This adds a regression test for #129301 by minimizing the code in the linked issue and putting it into a
#![no_core]
-compatible format, so that it can easily be used within anrmake
-test. This needs to be armake
test (opposed to atests/assembly
one), since the linked issue describes, that the problem only occurs if the code is directly compiled. Note, thatlld
is used instead ofavr-gcc
; see the comments below.Closes #129301.
To show, that the test actually catches the wrong behavior, this can be tested with a faulty rustc:
One can see, that the wrong label offset (
4
instead of6
) is produced, which would trigger an assertion in the test case.This would be a good candidate for using the
minicore
proposed in #130693. Since this is not yet merged, there is a FIXME.r? Patryk27
I think, you are the yet-to-be official target maintainer, hence I'll assign to you.
@rustbot label +O-AVR