Skip to content

Commit 681a866

Browse files
committed
Add Trusty OS as tier 3 target
1 parent eef00c8 commit 681a866

File tree

8 files changed

+138
-2
lines changed

8 files changed

+138
-2
lines changed

compiler/rustc_target/src/spec/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1750,6 +1750,9 @@ supported_targets! {
17501750

17511751
("x86_64-unikraft-linux-musl", x86_64_unikraft_linux_musl),
17521752

1753+
("armv7-unknown-trusty", armv7_unknown_trusty),
1754+
("aarch64-unknown-trusty", aarch64_unknown_trusty),
1755+
17531756
("riscv32i-unknown-none-elf", riscv32i_unknown_none_elf),
17541757
("riscv32im-risc0-zkvm-elf", riscv32im_risc0_zkvm_elf),
17551758
("riscv32im-unknown-none-elf", riscv32im_unknown_none_elf),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Trusty OS target for AArch64.
2+
3+
use crate::spec::{LinkSelfContainedDefault, PanicStrategy, RelroLevel, Target, TargetOptions};
4+
5+
pub fn target() -> Target {
6+
Target {
7+
llvm_target: "aarch64-unknown-unknown-musl".into(),
8+
metadata: crate::spec::TargetMetadata {
9+
description: Some("ARM64 Trusty".into()),
10+
tier: Some(2),
11+
host_tools: Some(false),
12+
std: Some(false),
13+
},
14+
pointer_width: 64,
15+
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
16+
arch: "aarch64".into(),
17+
options: TargetOptions {
18+
features: "+neon,+fp-armv8,+reserve-x18".into(),
19+
executables: true,
20+
max_atomic_width: Some(128),
21+
panic_strategy: PanicStrategy::Abort,
22+
os: "trusty".into(),
23+
position_independent_executables: true,
24+
static_position_independent_executables: true,
25+
crt_static_default: true,
26+
crt_static_respected: true,
27+
dynamic_linking: false,
28+
link_self_contained: LinkSelfContainedDefault::InferredForMusl,
29+
relro_level: RelroLevel::Full,
30+
mcount: "\u{1}_mcount".into(),
31+
..Default::default()
32+
},
33+
}
34+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
use crate::spec::{LinkSelfContainedDefault, PanicStrategy, RelroLevel, Target, TargetOptions};
2+
3+
pub fn target() -> Target {
4+
Target {
5+
// It's important we use "gnueabi" and not "musleabi" here. LLVM uses it
6+
// to determine the calling convention and float ABI, and it doesn't
7+
// support the "musleabi" value.
8+
llvm_target: "armv7-unknown-unknown-gnueabi".into(),
9+
metadata: crate::spec::TargetMetadata {
10+
description: Some("Armv7-A Trusty".into()),
11+
tier: Some(2),
12+
host_tools: Some(false),
13+
std: Some(false),
14+
},
15+
pointer_width: 32,
16+
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
17+
arch: "arm".into(),
18+
options: TargetOptions {
19+
abi: "eabi".into(),
20+
features: "+v7,+thumb2,+soft-float,-neon,+reserve-x18".into(),
21+
max_atomic_width: Some(64),
22+
mcount: "\u{1}mcount".into(),
23+
os: "trusty".into(),
24+
link_self_contained: LinkSelfContainedDefault::InferredForMusl,
25+
dynamic_linking: false,
26+
executables: true,
27+
crt_static_default: true,
28+
crt_static_respected: true,
29+
relro_level: RelroLevel::Full,
30+
panic_strategy: PanicStrategy::Abort,
31+
position_independent_executables: true,
32+
static_position_independent_executables: true,
33+
34+
..Default::default()
35+
},
36+
}
37+
}

src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
- [aarch64-unknown-teeos](platform-support/aarch64-unknown-teeos.md)
5050
- [\*-espidf](platform-support/esp-idf.md)
5151
- [\*-unknown-fuchsia](platform-support/fuchsia.md)
52+
- [\*-unknown-trusty](platform-support/trusty.md)
5253
- [\*-kmc-solid_\*](platform-support/kmc-solid.md)
5354
- [csky-unknown-linux-gnuabiv2\*](platform-support/csky-unknown-linux-gnuabiv2.md)
5455
- [hexagon-unknown-linux-musl](platform-support/hexagon-unknown-linux-musl.md)

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

+2
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ target | std | host | notes
264264
[`aarch64-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | ARM64 NetBSD
265265
[`aarch64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | ARM64 OpenBSD
266266
[`aarch64-unknown-redox`](platform-support/redox.md) | ✓ | | ARM64 Redox OS
267+
[`aarch64-unknown-trusty`](platform-support/trusty.md) | ? | |
267268
`aarch64-uwp-windows-msvc` | ✓ | |
268269
[`aarch64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | ARM64 VxWorks OS
269270
`aarch64_be-unknown-linux-gnu_ilp32` | ✓ | ✓ | ARM64 Linux (big-endian, ILP32 ABI)
@@ -283,6 +284,7 @@ target | std | host | notes
283284
[`armv7-unknown-linux-uclibceabihf`](platform-support/armv7-unknown-linux-uclibceabihf.md) | ✓ | ? | Armv7-A Linux with uClibc, hardfloat
284285
`armv7-unknown-freebsd` | ✓ | ✓ | Armv7-A FreeBSD
285286
[`armv7-unknown-netbsd-eabihf`](platform-support/netbsd.md) | ✓ | ✓ | Armv7-A NetBSD w/hard-float
287+
[`armv7-unknown-trusty`](platform-support/trusty.md) | ? | |
286288
[`armv7-wrs-vxworks-eabihf`](platform-support/vxworks.md) | ✓ | | Armv7-A for VxWorks
287289
[`armv7a-kmc-solid_asp3-eabi`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3
288290
[`armv7a-kmc-solid_asp3-eabihf`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3, hardfloat
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# `aarch64-unknown-trusty` and `armv7-unknown-trusty`
2+
3+
**Tier: 3**
4+
5+
[Trusty] is a secure Operating System that provides a Trusted Execution
6+
Environment (TEE) for Android.
7+
8+
## Target maintainers
9+
10+
- Nicole LeGare (@randomPoison)
11+
- Stephen Crane (@rinon)
12+
- As a fallback [email protected] can be contacted
13+
14+
## Requirements
15+
16+
This target is cross-compiled. It has no special requirements for the host.
17+
18+
It fully supports alloc with the default allocator, and partially supports std.
19+
Notably, most I/O functionality is not supported, e.g. filesystem support and
20+
networking support are not present and any APIs that rely on them will panic at
21+
runtime.
22+
23+
Trusty uses the ELF file format.
24+
25+
## Building the target
26+
27+
The targets can be built by enabling them for a `rustc` build, for example:
28+
29+
```toml
30+
[build]
31+
build-stage = 1
32+
target = ["aarch64-unknown-trusty", "armv7-unknown-trusty"]
33+
```
34+
35+
## Building Rust programs
36+
37+
There is currently no supported way to build a Trusty app with Cargo. You can
38+
follow the [Trusty build instructions] to build the Trusty kernel along with any
39+
Rust apps that are setup in the project.
40+
41+
## Testing
42+
43+
See the [Trusty build instructions] for information on how to build Rust code
44+
within the main Trusty project. The main project also includes infrastructure
45+
for testing Rust applications within a QEMU emulator.
46+
47+
## Cross-compilation toolchains and C code
48+
49+
See the [Trusty build instructions] for information on how C code is built
50+
within Trusty.
51+
52+
[Trusty]: https://source.android.com/docs/security/features/trusty
53+
[Trusty build instructions]: https://source.android.com/docs/security/features/trusty/download-and-build

tests/assembly/targets/targets-elf.rs

+6
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@
6666
//@ revisions: aarch64_unknown_teeos
6767
//@ [aarch64_unknown_teeos] compile-flags: --target aarch64-unknown-teeos
6868
//@ [aarch64_unknown_teeos] needs-llvm-components: aarch64
69+
//@ revisions: aarch64_unknown_trusty
70+
//@ [aarch64_unknown_trusty] compile-flags: --target aarch64-unknown-trusty
71+
//@ [aarch64_unknown_trusty] needs-llvm-components: aarch64
6972
//@ revisions: aarch64_wrs_vxworks
7073
//@ [aarch64_wrs_vxworks] compile-flags: --target aarch64-wrs-vxworks
7174
//@ [aarch64_wrs_vxworks] needs-llvm-components: aarch64
@@ -153,6 +156,9 @@
153156
//@ revisions: armv7_unknown_netbsd_eabihf
154157
//@ [armv7_unknown_netbsd_eabihf] compile-flags: --target armv7-unknown-netbsd-eabihf
155158
//@ [armv7_unknown_netbsd_eabihf] needs-llvm-components: arm
159+
//@ revisions: armv7_unknown_trusty
160+
//@ [armv7_unknown_trusty] compile-flags: --target armv7-unknown-trusty
161+
//@ [armv7_unknown_trusty] needs-llvm-components: arm
156162
//@ revisions: armv7_wrs_vxworks_eabihf
157163
//@ [armv7_wrs_vxworks_eabihf] compile-flags: --target armv7-wrs-vxworks-eabihf
158164
//@ [armv7_wrs_vxworks_eabihf] needs-llvm-components: arm

tests/ui/check-cfg/well-known-values.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
201201
LL | target_os = "_UNEXPECTED_VALUE",
202202
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
203203
|
204-
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm`
204+
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm`
205205
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
206206

207207
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
@@ -285,7 +285,7 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux`
285285
| |
286286
| help: there is a expected value with a similar name: `"linux"`
287287
|
288-
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm`
288+
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm`
289289
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
290290

291291
warning: 29 warnings emitted

0 commit comments

Comments
 (0)