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

AVR: interrupt code broken by optimization flags #77541

Closed
no111u3 opened this issue Oct 4, 2020 · 4 comments
Closed

AVR: interrupt code broken by optimization flags #77541

no111u3 opened this issue Oct 4, 2020 · 4 comments
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness O-AVR Target: AVR processors (ATtiny, ATmega, etc.) requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@no111u3
Copy link

no111u3 commented Oct 4, 2020

I've run into an issue with code that uses interrupts on AVR. I'm not sure if this applies to any other platform.
This issue has same behavior as #75504 but It can't resolved after update compiler to current nightly version.
This issue reproduce on everything nightly rust compiler with AVR target support (I trying to compile it every nightly compiler updates).

I create minimal reproduce project for this issue - https://github.com/no111u3/m328p_robo_rust. Than I change optimization flags to size optimization level opt-level="z" or opt-level="s" upper code doesn't work correctly, there has two options:

  • for release build there is broken in interrupt handler code
  • for debug build there is broken fully, code run stopped and mcu looks halted.

I run upper code on two different mcu's that I have: on Atmega48 and Atmega328p, if we use same flags we have same behavior for run. For optimization level 2 I can use huge code in interrupt such as - https://github.com/no111u3/m48_robo_rust/blob/master/examples/dynamic_indication.rs#L119 but If I use z or s optimization interrupt works only for short code such as - https://github.com/no111u3/m48_robo_rust/blob/master/examples/pwm_int.rs#L39

@jonas-schievink jonas-schievink added C-bug Category: This is a bug. O-AVR Target: AVR processors (ATtiny, ATmega, etc.) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 4, 2020
@couchand
Copy link
Contributor

couchand commented Oct 5, 2020

@no111u3 would you mind pasting in the assembler output for the builds? You can get that by compiling with the RUSTFLAGS environment variable: RUSTFLAGS='--emit asm'. Thanks!

@no111u3
Copy link
Author

no111u3 commented Oct 5, 2020

@no111u3 would you mind pasting in the assembler output for the builds? You can get that by compiling with the RUSTFLAGS environment variable: RUSTFLAGS='--emit asm'. Thanks!

This is not possible for debug build because:
Caused by: process didn't exit successfully: rustc --crate-name core --edition=2018 /Users/nis/.rustup/toolchains/nightly-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts --crate-type lib --emit=dep-info,metadata,link -C opt-level=2 -C panic=abort -C linker-plugin-lto -C debuginfo=2 -C debug-assertions=on -C metadata=bb7c8a4bc5fd3810 -C extra-filename=-bb7c8a4bc5fd3810 --out-dir /Users/nis/Develop/m328p_robo_rust/target/avr-atmega328p/debug/deps --target /Users/nis/Develop/m328p_robo_rust/avr-atmega328p.json -Z force-unstable-if-unmarked -L dependency=/Users/nis/Develop/m328p_robo_rust/target/avr-atmega328p/debug/deps -L dependency=/Users/nis/Develop/m328p_robo_rust/target/debug/deps --cap-lints allow --emit asm (signal: 11, SIGSEGV: invalid memory reference) warning: build failed, waiting for other jobs to finish... error: build failed

But I create gist with disassembler output for opt-level=2 and opt-level="s": https://gist.github.com/no111u3/e796c4e3f5ba5c7fbe7233832af4cbe3

Also I create gist for --emit asm for opt-level=2 and opt-level="s" for release:
https://gist.github.com/no111u3/96e5031f82f0c3fddad2f962120b764b

@jonas-schievink jonas-schievink added A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness requires-nightly This issue requires a nightly compiler in some way. labels Nov 7, 2020
@Patryk27
Copy link
Contributor

fwiw, I think this was solved after #96845, too 🙂

@workingjubilee
Copy link
Member

This reproducer uses crates that depend on nightly features that are no longer enabled by the compiler and patches against unmarked git repos without reference to a revision or even branch. If you can remake this with updated dependencies, or without dependencies at all, we can look into this. However, until then, I am going to close this. Sorry!

@workingjubilee workingjubilee closed this as not planned Won't fix, can't repro, duplicate, stale Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. C-bug Category: This is a bug. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness O-AVR Target: AVR processors (ATtiny, ATmega, etc.) requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants