Skip to content

Commit f38fa90

Browse files
authored
Rollup merge of rust-lang#53233 - andre-richter:master, r=alexcrichton
targets: aarch64: Add bare-metal aarch64 target A generic AArch64 target that can be used for writing bare-metal code for 64-bit ARM architectures.
2 parents 08efa99 + 898950c commit f38fa90

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Generic AArch64 target for bare-metal code
12+
//
13+
// Can be used in conjunction with the `target-feature` and
14+
// `target-cpu` compiler flags to opt-in more hardware-specific
15+
// features.
16+
//
17+
// For example, `-C target-cpu=cortex-a53`.
18+
19+
use super::{LldFlavor, LinkerFlavor, Target, TargetOptions, PanicStrategy};
20+
21+
pub fn target() -> Result<Target, String> {
22+
let opts = TargetOptions {
23+
linker: Some("rust-lld".to_owned()),
24+
executables: true,
25+
relocation_model: "static".to_string(),
26+
disable_redzone: true,
27+
linker_is_gnu: true,
28+
max_atomic_width: Some(128),
29+
panic_strategy: PanicStrategy::Abort,
30+
abi_blacklist: super::arm_base::abi_blacklist(),
31+
.. Default::default()
32+
};
33+
Ok(Target {
34+
llvm_target: "aarch64-unknown-none".to_string(),
35+
target_endian: "little".to_string(),
36+
target_pointer_width: "64".to_string(),
37+
target_c_int_width: "32".to_string(),
38+
target_os: "none".to_string(),
39+
target_env: "".to_string(),
40+
target_vendor: "".to_string(),
41+
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(),
42+
arch: "aarch64".to_string(),
43+
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
44+
options: opts,
45+
})
46+
}

src/librustc_target/spec/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,8 @@ supported_targets! {
380380
("x86_64-unknown-hermit", x86_64_unknown_hermit),
381381

382382
("riscv32imac-unknown-none-elf", riscv32imac_unknown_none_elf),
383+
384+
("aarch64-unknown-none", aarch64_unknown_none),
383385
}
384386

385387
/// Everything `rustc` knows about how to compile for a specific target.

0 commit comments

Comments
 (0)