forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#69478 - avr-rust:avr-support-upstream, r=jo…
…nas-schievink Enable AVR as a Tier 3 target upstream Tracking issue: rust-lang#44052. Things intentionally left out of the initial upstream: * The `target_cpu` flag I have made the cleanup suggestions by @jplatte and @jplatte in avr-rust@043550d. Anybody feel free to give the branch a test and see how it fares, or make suggestions on the code patch itself.
- Loading branch information
Showing
28 changed files
with
210 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,7 @@ fn main() { | |
"arm", | ||
"aarch64", | ||
"amdgpu", | ||
"avr", | ||
"mips", | ||
"powerpc", | ||
"systemz", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//! LLVM-frontend specific AVR calling convention implementation. | ||
//! | ||
//! # Current calling convention ABI | ||
//! | ||
//! Inherited from Clang's `clang::DefaultABIInfo` implementation - self described | ||
//! as | ||
//! | ||
//! > the default implementation for ABI specific details. This implementation | ||
//! > provides information which results in | ||
//! > self-consistent and sensible LLVM IR generation, but does not | ||
//! > conform to any particular ABI. | ||
//! > | ||
//! > - Doxygen Doxumentation of `clang::DefaultABIInfo` | ||
//! | ||
//! This calling convention may not match AVR-GCC in all cases. | ||
//! | ||
//! In the future, an AVR-GCC compatible argument classification ABI should be | ||
//! adopted in both Rust and Clang. | ||
//! | ||
//! *NOTE*: Currently, this module implements the same calling convention | ||
//! that clang with AVR currently does - the default, simple, unspecialized | ||
//! ABI implementation available to all targets. This ABI is not | ||
//! binary-compatible with AVR-GCC. Once LLVM [PR46140](https://bugs.llvm.org/show_bug.cgi?id=46140) | ||
//! is completed, this module should be updated to match so that both Clang | ||
//! and Rust emit code to the same AVR-GCC compatible ABI. | ||
//! | ||
//! In particular, both Clang and Rust may not have the same semantics | ||
//! when promoting arguments to indirect references as AVR-GCC. It is important | ||
//! to note that the core AVR ABI implementation within LLVM itself is ABI | ||
//! compatible with AVR-GCC - Rust and AVR-GCC only differ in the small amount | ||
//! of compiler frontend specific calling convention logic implemented here. | ||
use crate::abi::call::{ArgAbi, FnAbi}; | ||
|
||
fn classify_ret_ty<Ty>(ret: &mut ArgAbi<'_, Ty>) { | ||
if ret.layout.is_aggregate() { | ||
ret.make_indirect(); | ||
} | ||
} | ||
|
||
fn classify_arg_ty<Ty>(arg: &mut ArgAbi<'_, Ty>) { | ||
if arg.layout.is_aggregate() { | ||
arg.make_indirect(); | ||
} | ||
} | ||
|
||
pub fn compute_abi_info<Ty>(fty: &mut FnAbi<'_, Ty>) { | ||
if !fty.ret.is_ignore() { | ||
classify_ret_ty(&mut fty.ret); | ||
} | ||
|
||
for arg in &mut fty.args { | ||
if arg.is_ignore() { | ||
continue; | ||
} | ||
|
||
classify_arg_ty(arg); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use crate::spec::{LinkerFlavor, Target, TargetResult}; | ||
|
||
pub fn target() -> TargetResult { | ||
Ok(Target { | ||
llvm_target: "avr-unknown-unknown".to_string(), | ||
target_endian: "little".to_string(), | ||
target_pointer_width: "16".to_string(), | ||
data_layout: "e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-a:8".to_string(), | ||
arch: "avr".to_string(), | ||
linker_flavor: LinkerFlavor::Gcc, | ||
target_os: "unknown".to_string(), | ||
target_env: "".to_string(), | ||
target_vendor: "unknown".to_string(), | ||
target_c_int_width: 16.to_string(), | ||
options: super::freestanding_base::opts(), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::spec::{LinkArgs, LinkerFlavor, TargetOptions}; | ||
use std::default::Default; | ||
|
||
pub fn opts() -> TargetOptions { | ||
let mut args = LinkArgs::new(); | ||
|
||
args.insert( | ||
LinkerFlavor::Gcc, | ||
vec![ | ||
// We want to be able to strip as much executable code as possible | ||
// from the linker command line, and this flag indicates to the | ||
// linker that it can avoid linking in dynamic libraries that don't | ||
// actually satisfy any symbols up to that point (as with many other | ||
// resolutions the linker does). This option only applies to all | ||
// following libraries so we're sure to pass it as one of the first | ||
// arguments. | ||
"-Wl,--as-needed".to_string(), | ||
], | ||
); | ||
|
||
TargetOptions { | ||
dynamic_linking: false, | ||
executables: true, | ||
linker_is_gnu: true, | ||
has_rpath: false, | ||
pre_link_args: args, | ||
position_independent_executables: false, | ||
..Default::default() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Test that the AVR interrupt ABI cannot be used when avr_interrupt | ||
// feature gate is not used. | ||
|
||
extern "avr-interrupt" fn foo() {} | ||
//~^ ERROR avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change | ||
|
||
fn main() { | ||
foo(); | ||
} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/feature-gates/feature-gate-abi-avr-interrupt.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0658]: avr-interrupt and avr-non-blocking-interrupt ABIs are experimental and subject to change | ||
--> $DIR/feature-gate-abi-avr-interrupt.rs:4:8 | ||
| | ||
LL | extern "avr-interrupt" fn foo() {} | ||
| ^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #69664 <https://github.com/rust-lang/rust/issues/69664> for more information | ||
= help: add `#![feature(abi_avr_interrupt)]` to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.