Skip to content

Commit 070425e

Browse files
committed
Add aarch64_be-unknown-none-softfloat target
Signed-off-by: Jens Reidel <[email protected]>
1 parent 0f35336 commit 070425e

File tree

6 files changed

+123
-0
lines changed

6 files changed

+123
-0
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2146,6 +2146,7 @@ supported_targets! {
21462146

21472147
("aarch64-unknown-none", aarch64_unknown_none),
21482148
("aarch64-unknown-none-softfloat", aarch64_unknown_none_softfloat),
2149+
("aarch64_be-unknown-none-softfloat", aarch64_be_unknown_none_softfloat),
21492150
("aarch64-unknown-nuttx", aarch64_unknown_nuttx),
21502151

21512152
("x86_64-fortanix-unknown-sgx", x86_64_fortanix_unknown_sgx),
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Generic big-endian AArch64 target for bare-metal code - Floating point disabled
2+
//
3+
// Can be used in conjunction with the `target-feature` and
4+
// `target-cpu` compiler flags to opt-in more hardware-specific
5+
// features.
6+
//
7+
// For example, `-C target-cpu=cortex-a53`.
8+
use rustc_abi::Endian;
9+
10+
use crate::spec::{
11+
Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, SanitizerSet, StackProbeType, Target,
12+
TargetMetadata, TargetOptions,
13+
};
14+
15+
pub(crate) fn target() -> Target {
16+
let opts = TargetOptions {
17+
abi: "softfloat".into(),
18+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
19+
linker: Some("rust-lld".into()),
20+
features: "+v8a,+strict-align,-neon,-fp-armv8".into(),
21+
relocation_model: RelocModel::Static,
22+
disable_redzone: true,
23+
max_atomic_width: Some(128),
24+
supported_sanitizers: SanitizerSet::KCFI | SanitizerSet::KERNELADDRESS,
25+
stack_probes: StackProbeType::Inline,
26+
panic_strategy: PanicStrategy::Abort,
27+
endian: Endian::Big,
28+
..Default::default()
29+
};
30+
Target {
31+
llvm_target: "aarch64_be-unknown-none".into(),
32+
metadata: TargetMetadata {
33+
description: Some("Bare ARM64 (big-endian), softfloat".into()),
34+
tier: Some(3),
35+
host_tools: Some(false),
36+
std: Some(false),
37+
},
38+
pointer_width: 64,
39+
data_layout: "E-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
40+
arch: "aarch64".into(),
41+
options: opts,
42+
}
43+
}

src/doc/rustc/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
- [\*-apple-visionos](platform-support/apple-visionos.md)
4848
- [aarch64-nintendo-switch-freestanding](platform-support/aarch64-nintendo-switch-freestanding.md)
4949
- [aarch64-unknown-linux-musl](platform-support/aarch64-unknown-linux-musl.md)
50+
- [aarch64_be-unknown-none-softfloat](platform-support/aarch64_be-unknown-none-softfloat.md)
5051
- [amdgcn-amd-amdhsa](platform-support/amdgcn-amd-amdhsa.md)
5152
- [armeb-unknown-linux-gnueabi](platform-support/armeb-unknown-linux-gnueabi.md)
5253
- [arm-none-eabi](platform-support/arm-none-eabi.md)

src/doc/rustc/src/platform-support.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ target | std | host | notes
273273
`aarch64_be-unknown-linux-gnu` | ✓ | ✓ | ARM64 Linux (big-endian)
274274
`aarch64_be-unknown-linux-gnu_ilp32` | ✓ | ✓ | ARM64 Linux (big-endian, ILP32 ABI)
275275
[`aarch64_be-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | ARM64 NetBSD (big-endian)
276+
[`aarch64_be-unknown-none-softfloat`](platform-support/aarch64_be-unknown-none-softfloat.md) | * | | Bare big-endian ARM64, softfloat
276277
[`amdgcn-amd-amdhsa`](platform-support/amdgcn-amd-amdhsa.md) | * | | `-Ctarget-cpu=gfx...` to specify [the AMD GPU] to compile for
277278
[`arm64_32-apple-watchos`](platform-support/apple-watchos.md) | ✓ | | Arm Apple WatchOS 64-bit with 32-bit pointers
278279
[`arm64e-apple-darwin`](platform-support/arm64e-apple-darwin.md) | ✓ | ✓ | ARM64e Apple Darwin
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# aarch64_be-unknown-none-softfloat
2+
3+
**Tier: 3**
4+
5+
Target for freestanding/bare-metal big-endian ARM64 binaries in ELF format:
6+
firmware, kernels, etc.
7+
8+
## Target maintainers
9+
10+
[@Gelbpunkt](https://github.com/Gelbpunkt)
11+
12+
## Requirements
13+
14+
This target is cross-compiled. There is no support for `std`. There is no
15+
default allocator, but it's possible to use `alloc` by supplying an allocator.
16+
17+
The target does not assume existence of a FPU and does not make use of any
18+
non-GPR register. This allows the generated code to run in environments, such
19+
as kernels, which may need to avoid the use of such registers or which may have
20+
special considerations about the use of such registers (e.g. saving and
21+
restoring them to avoid breaking userspace code using the same registers). You
22+
can change code generation to use additional CPU features via the
23+
`-C target-feature=` codegen options to rustc, or via the `#[target_feature]`
24+
mechanism within Rust code.
25+
26+
By default, code generated with the soft-float target should run on any
27+
big-endian ARM64 hardware, enabling additional target features may raise this
28+
baseline.
29+
30+
`extern "C"` uses the [architecture's standard calling convention][aapcs64].
31+
32+
[aapcs64]: https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst
33+
34+
The targets generate binaries in the ELF format. Any alternate formats or
35+
special considerations for binary layout will require linker options or linker
36+
scripts.
37+
38+
## Building the target
39+
40+
You can build Rust with support for the target by adding it to the `target`
41+
list in `bootstrap.toml`:
42+
43+
```toml
44+
[build]
45+
target = ["aarch64_be-unknown-none-softfloat"]
46+
```
47+
48+
## Building Rust programs
49+
50+
Rust does not yet ship pre-compiled artifacts for this target. To compile for
51+
this target, you will first need to build Rust with the target enabled (see
52+
"Building the target" above).
53+
54+
## Cross-compilation
55+
56+
For cross builds, you will need an appropriate ARM64 C/C++ toolchain for
57+
linking, or if you want to compile C code along with Rust (such as for Rust
58+
crates with C dependencies).
59+
60+
Rust *may* be able to use an `aarch64_be-unknown-linux-{gnu,musl}-` toolchain
61+
with appropriate standalone flags to build for this target (depending on the
62+
assumptions of that toolchain, see below), or you may wish to use a separate
63+
`aarch64_be-unknown-none-softfloat` toolchain.
64+
65+
On some ARM64 hosts that use ELF binaries, you *may* be able to use the host C
66+
toolchain, if it does not introduce assumptions about the host environment that
67+
don't match the expectations of a standalone environment. Otherwise, you may
68+
need a separate toolchain for standalone/freestanding development, just as when
69+
cross-compiling from a non-ARM64 platform.
70+
71+
## Testing
72+
73+
As the target supports a variety of different environments and does not support
74+
`std`, it does not support running the Rust test suite.

tests/assembly-llvm/targets/targets-elf.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
//@ revisions: aarch64_be_unknown_netbsd
1111
//@ [aarch64_be_unknown_netbsd] compile-flags: --target aarch64_be-unknown-netbsd
1212
//@ [aarch64_be_unknown_netbsd] needs-llvm-components: aarch64
13+
//@ revisions: aarch64_be_unknown_none_softfloat
14+
//@ [aarch64_be_unknown_none_softfloat] compile-flags: --target aarch64_be-unknown-none-softfloat
15+
//@ [aarch64_be_unknown_none_softfloat] needs-llvm-components: aarch64
1316
//@ revisions: aarch64_kmc_solid_asp3
1417
//@ [aarch64_kmc_solid_asp3] compile-flags: --target aarch64-kmc-solid_asp3
1518
//@ [aarch64_kmc_solid_asp3] needs-llvm-components: aarch64

0 commit comments

Comments
 (0)