Require sram target feature on AVR
This commit is contained in:
parent
8cbc623c3a
commit
895ea0c2f5
6 changed files with 44 additions and 7 deletions
|
|
@ -915,7 +915,7 @@ static AVR_FEATURES: &[(&str, Stability, ImpliedFeatures)] = &[
|
|||
("rmw", Unstable(sym::avr_target_feature), &[]),
|
||||
("spm", Unstable(sym::avr_target_feature), &[]),
|
||||
("spmx", Unstable(sym::avr_target_feature), &[]),
|
||||
("sram", Unstable(sym::avr_target_feature), &[]),
|
||||
("sram", Forbidden { reason: "devices that have no SRAM are unsupported" }, &[]),
|
||||
("tinyencoding", Unstable(sym::avr_target_feature), &[]),
|
||||
// tidy-alphabetical-end
|
||||
];
|
||||
|
|
@ -1020,11 +1020,7 @@ impl Target {
|
|||
Arch::Sparc | Arch::Sparc64 => SPARC_FEATURES,
|
||||
Arch::M68k => M68K_FEATURES,
|
||||
Arch::Avr => AVR_FEATURES,
|
||||
Arch::AmdGpu
|
||||
| Arch::Msp430
|
||||
| Arch::SpirV
|
||||
| Arch::Xtensa
|
||||
| Arch::Other(_) => &[],
|
||||
Arch::AmdGpu | Arch::Msp430 | Arch::SpirV | Arch::Xtensa | Arch::Other(_) => &[],
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1247,6 +1243,12 @@ impl Target {
|
|||
// because the vector and float registers overlap.
|
||||
FeatureConstraints { required: &[], incompatible: &["soft-float"] }
|
||||
}
|
||||
Arch::Avr => {
|
||||
// SRAM is minimum requirement for C/C++ in both avr-gcc and Clang,
|
||||
// and backends of them only support assembly for devices have no SRAM.
|
||||
// See the discussion in https://github.com/rust-lang/rust/pull/146900 for more.
|
||||
FeatureConstraints { required: &["sram"], incompatible: &[] }
|
||||
}
|
||||
_ => NOTHING,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,6 +68,8 @@ the possible variants:
|
|||
|
||||
https://github.com/llvm/llvm-project/blob/093d4db2f3c874d4683fb01194b00dbb20e5c713/clang/lib/Basic/Targets/AVR.cpp#L32
|
||||
|
||||
Note that devices that have no SRAM are not supported, same as when compiling C/C++ programs with avr-gcc or Clang.
|
||||
|
||||
## Testing
|
||||
|
||||
You can use [`simavr`](https://github.com/buserror/simavr) to emulate the
|
||||
|
|
|
|||
12
tests/ui/abi/avr-sram.disable_sram.stderr
Normal file
12
tests/ui/abi/avr-sram.disable_sram.stderr
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
warning: target feature `sram` cannot be disabled with `-Ctarget-feature`: devices that have no SRAM are unsupported
|
||||
|
|
||||
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
|
||||
|
||||
warning: target feature `sram` must be enabled to ensure that the ABI of the current target can be implemented correctly
|
||||
|
|
||||
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
|
||||
|
||||
warning: 2 warnings emitted
|
||||
|
||||
7
tests/ui/abi/avr-sram.no_sram.stderr
Normal file
7
tests/ui/abi/avr-sram.no_sram.stderr
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
warning: target feature `sram` must be enabled to ensure that the ABI of the current target can be implemented correctly
|
||||
|
|
||||
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
|
||||
|
||||
warning: 1 warning emitted
|
||||
|
||||
15
tests/ui/abi/avr-sram.rs
Normal file
15
tests/ui/abi/avr-sram.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
//@ revisions: has_sram no_sram disable_sram
|
||||
//@ build-pass
|
||||
//@[has_sram] compile-flags: --target avr-none -C target-cpu=atmega328p
|
||||
//@[has_sram] needs-llvm-components: avr
|
||||
//@[no_sram] compile-flags: --target avr-none -C target-cpu=attiny11
|
||||
//@[no_sram] needs-llvm-components: avr
|
||||
//@[disable_sram] compile-flags: --target avr-none -C target-cpu=atmega328p -C target-feature=-sram
|
||||
//@[disable_sram] needs-llvm-components: avr
|
||||
//@ ignore-backends: gcc
|
||||
//[no_sram,disable_sram]~? WARN target feature `sram` must be enabled
|
||||
//[disable_sram]~? WARN target feature `sram` cannot be disabled with `-Ctarget-feature`
|
||||
|
||||
#![feature(no_core)]
|
||||
#![no_core]
|
||||
#![crate_type = "lib"]
|
||||
|
|
@ -323,7 +323,6 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE");
|
|||
`spe`
|
||||
`spm`
|
||||
`spmx`
|
||||
`sram`
|
||||
`ssbs`
|
||||
`sse`
|
||||
`sse2`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue