Skip to content

Add aarch64_be-unknown-linux-musl target #144551

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1943,6 +1943,7 @@ supported_targets! {
("armv7-unknown-linux-musleabihf", armv7_unknown_linux_musleabihf),
("aarch64-unknown-linux-gnu", aarch64_unknown_linux_gnu),
("aarch64-unknown-linux-musl", aarch64_unknown_linux_musl),
("aarch64_be-unknown-linux-musl", aarch64_be_unknown_linux_musl),
("x86_64-unknown-linux-musl", x86_64_unknown_linux_musl),
("i686-unknown-linux-musl", i686_unknown_linux_musl),
("i586-unknown-linux-musl", i586_unknown_linux_musl),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use rustc_abi::Endian;

use crate::spec::{SanitizerSet, StackProbeType, Target, TargetMetadata, TargetOptions, base};

pub(crate) fn target() -> Target {
let mut base = base::linux_musl::opts();
base.max_atomic_width = Some(128);
base.supports_xray = true;
base.features = "+v8a".into();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should outline-atomics be included here, as per #144429?

base.stack_probes = StackProbeType::Inline;
base.supported_sanitizers = SanitizerSet::ADDRESS
| SanitizerSet::CFI
| SanitizerSet::LEAK
| SanitizerSet::MEMORY
| SanitizerSet::THREAD;

Target {
llvm_target: "aarch64_be-unknown-linux-musl".into(),
metadata: TargetMetadata {
description: Some("ARM64 Linux (big-endian) with musl-libc 1.2.5".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
},
pointer_width: 64,
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(),
arch: "aarch64".into(),
options: TargetOptions {
mcount: "\u{1}_mcount".into(),
endian: Endian::Big,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason the frame_pointer changes to the aarch64-unknown-linux-musl target wouldn't also apply to this target?

// the AAPCS64 expects use of non-leaf frame pointers per
// https://github.com/ARM-software/abi-aa/blob/4492d1570eb70c8fd146623e0db65b2d241f12e7/aapcs64/aapcs64.rst#the-frame-pointer
// and we tend to encounter interesting bugs in AArch64 unwinding code if we do not
frame_pointer: FramePointer::NonLeaf,

..base
},
}
}
1 change: 1 addition & 0 deletions src/doc/rustc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
- [\*-apple-visionos](platform-support/apple-visionos.md)
- [aarch64-nintendo-switch-freestanding](platform-support/aarch64-nintendo-switch-freestanding.md)
- [aarch64-unknown-linux-musl](platform-support/aarch64-unknown-linux-musl.md)
- [aarch64_be-unknown-linux-musl](platform-support/aarch64_be-unknown-linux-musl.md)
- [amdgcn-amd-amdhsa](platform-support/amdgcn-amd-amdhsa.md)
- [armeb-unknown-linux-gnueabi](platform-support/armeb-unknown-linux-gnueabi.md)
- [arm-none-eabi](platform-support/arm-none-eabi.md)
Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ target | std | host | notes
[`aarch64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | ARM64 VxWorks OS
`aarch64_be-unknown-linux-gnu` | ✓ | ✓ | ARM64 Linux (big-endian)
`aarch64_be-unknown-linux-gnu_ilp32` | ✓ | ✓ | ARM64 Linux (big-endian, ILP32 ABI)
[`aarch64_be-unknown-linux-musl`](platform-support/aarch64_be-unknown-linux-musl.md) | ✓ | ✓ | ARM64 Linux (big-endian) with musl-libc 1.2.5
[`aarch64_be-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | ARM64 NetBSD (big-endian)
[`amdgcn-amd-amdhsa`](platform-support/amdgcn-amd-amdhsa.md) | * | | `-Ctarget-cpu=gfx...` to specify [the AMD GPU] to compile for
[`arm64_32-apple-watchos`](platform-support/apple-watchos.md) | ✓ | | Arm Apple WatchOS 64-bit with 32-bit pointers
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# aarch64_be-unknown-linux-musl

**Tier: 3**

ARM64 Linux (big-endian) with musl-libc.

## Target maintainers

[@neuschaefer](https://github.com/neuschaefer)
[@Gelbpunkt](https://github.com/Gelbpunkt)

## Requirements

The target requires a `aarch64_be-*-linux-musl` toolchain, which likely has to
be built from source because this is a rare combination. [Buildroot] provides
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just noticed that musl.cc/musl-cross-make includes an aarch64_be toolchain, which necessitates some rephrasing in this paragraph.

a way of doing so:

- select _Target options_ → _Target Architecture_ → _AArch64 (big endian)_
- select _Toolchain_ → _C library_ → _musl_
- select _Toolchain_ → _Enable C++ support_

Host tools are supported.

[Buildroot]: https://buildroot.org/


## Building the target

The target can be enabled in bootstrap.toml:

```toml
[build]
target = ["aarch64_be-unknown-linux-musl"]

[target.aarch64_be-unknown-linux-musl]
cc = "/path/to/buildroot/host/bin/aarch64_be-buildroot-linux-musl-cc"
cxx = "/path/to/buildroot/host/bin/aarch64_be-buildroot-linux-musl-c++"
linker = "/path/to/buildroot/host/bin/aarch64_be-buildroot-linux-musl-cc"
ar = "/path/to/buildroot/host/bin/aarch64_be-buildroot-linux-musl-ar"
ranlib = "/path/to/buildroot/host/bin/aarch64_be-buildroot-linux-musl-ranlib"
musl-root = "/path/to/buildroot/staging"
crt-static = "/path/to/buildroot/target"
```


## Testing

Binaries can be run under `qemu-aarch64_be` or under a big-endian Linux kernel.
3 changes: 3 additions & 0 deletions tests/assembly-llvm/targets/targets-elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
//@ revisions: aarch64_be_unknown_linux_gnu_ilp32
//@ [aarch64_be_unknown_linux_gnu_ilp32] compile-flags: --target aarch64_be-unknown-linux-gnu_ilp32
//@ [aarch64_be_unknown_linux_gnu_ilp32] needs-llvm-components: aarch64
//@ revisions: aarch64_be_unknown_linux_musl
//@ [aarch64_be_unknown_linux_musl] compile-flags: --target aarch64_be-unknown-linux-musl
//@ [aarch64_be_unknown_linux_musl] needs-llvm-components: aarch64
//@ revisions: aarch64_be_unknown_netbsd
//@ [aarch64_be_unknown_netbsd] compile-flags: --target aarch64_be-unknown-netbsd
//@ [aarch64_be_unknown_netbsd] needs-llvm-components: aarch64
Expand Down
Loading