Skip to content

Commit 3c50995

Browse files
committed
Add arm64e-apple-darwin target
1 parent dc66caf commit 3c50995

File tree

6 files changed

+67
-0
lines changed

6 files changed

+67
-0
lines changed

compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1544,6 +1544,7 @@ supported_targets! {
15441544
("i686-unknown-hurd-gnu", i686_unknown_hurd_gnu),
15451545

15461546
("aarch64-apple-darwin", aarch64_apple_darwin),
1547+
("arm64e-apple-darwin", arm64e_apple_darwin),
15471548
("x86_64-apple-darwin", x86_64_apple_darwin),
15481549
("x86_64h-apple-darwin", x86_64h_apple_darwin),
15491550
("i686-apple-darwin", i686_apple_darwin),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
use super::apple_base::{macos_llvm_target, opts, Arch};
2+
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
3+
4+
pub fn target() -> Target {
5+
let arch = Arch::Arm64e;
6+
let mut base = opts("macos", arch);
7+
base.cpu = "apple-m1".into();
8+
base.max_atomic_width = Some(128);
9+
10+
// FIXME: The leak sanitizer currently fails the tests, see #88132.
11+
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::THREAD;
12+
13+
Target {
14+
// Clang automatically chooses a more specific target based on
15+
// MACOSX_DEPLOYMENT_TARGET. To enable cross-language LTO to work
16+
// correctly, we do too.
17+
llvm_target: macos_llvm_target(arch).into(),
18+
pointer_width: 64,
19+
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
20+
arch: arch.target_arch(),
21+
options: TargetOptions {
22+
mcount: "\u{1}mcount".into(),
23+
frame_pointer: FramePointer::NonLeaf,
24+
..base
25+
},
26+
}
27+
}

src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- [Target Tier Policy](target-tier-policy.md)
1717
- [Template for Target-specific Documentation](platform-support/TEMPLATE.md)
1818
- [arm64e-apple-ios.md](platform-support/arm64e-apple-ios.md)
19+
- [arm64e-apple-darwin.md](platform-support/arm64e-apple-darwin.md)
1920
- [aarch64-apple-ios-sim](platform-support/aarch64-apple-ios-sim.md)
2021
- [\*-apple-tvos](platform-support/apple-tvos.md)
2122
- [\*-apple-watchos\*](platform-support/apple-watchos.md)

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

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ host tools.
217217
target | std | host | notes
218218
-------|:---:|:----:|-------
219219
[`arm64e-apple-ios`](platform-support/arm64e-apple-ios.md) | ✓ | | ARM64e Apple iOS
220+
[`arm64e-apple-darwin`](platform-support/arm64e-apple-darwin.md) | ✓ | ✓ | ARM64e Apple Darwin
220221
`aarch64-apple-ios-macabi` | ? | | Apple Catalyst on ARM64
221222
[`aarch64-apple-tvos`](platform-support/apple-tvos.md) | ? | | ARM64 tvOS
222223
[`aarch64-apple-tvos-sim`](platform-support/apple-tvos.md) | ? | | ARM64 tvOS Simulator
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# `arm64e-apple-darwin`
2+
3+
**Tier: 3 (with Host Tools)**
4+
5+
ARM64e macOS (11.0+, Big Sur+)
6+
7+
## Target maintainers
8+
9+
- Artyom Tetyukhin ([@arttet](https://github.com/https://github.com/arttet))
10+
11+
## Requirements
12+
13+
Target for `macOS` on late-generation `M` series Apple chips.
14+
15+
## Building the target
16+
17+
You can build Rust with support for the targets by adding it to the `target` list in `config.toml`:
18+
19+
```toml
20+
[build]
21+
target = [ "arm64e-apple-darwin" ]
22+
```
23+
24+
## Building Rust programs
25+
26+
Rust does not yet ship pre-compiled artifacts for this target.
27+
To compile for this target, you will need to build Rust with the target enabled (see [Building the target](#building-the-target) above).
28+
29+
## Testing
30+
31+
The target does support running binaries on macOS platforms with `arm64e` architecture.
32+
33+
## Cross-compilation toolchains and C code
34+
35+
The targets do support `C` code.
36+
To build compatible `C` code, you have to use XCode with the same compiler and flags.

src/tools/build-manifest/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ static HOSTS: &[&str] = &[
5050

5151
static TARGETS: &[&str] = &[
5252
"aarch64-apple-darwin",
53+
"arm64e-apple-darwin",
5354
"aarch64-apple-ios",
5455
"arm64e-apple-ios",
5556
"aarch64-apple-ios-sim",

0 commit comments

Comments
 (0)