-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #113480 - Sword-Destiny:master, r=petrochenkov
add aarch64-unknown-teeos target TEEOS is a mini os run in TrustZone, for trusted/security apps. The libc of TEEOS is a part of musl. The kernel of TEEOS is micro kernel. This MR is to add a target for teeos. MRs for libc and rust-std are in progress. Compiler team MCP: [MCP](rust-lang/compiler-team#652)
- Loading branch information
Showing
9 changed files
with
153 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use crate::spec::Target; | ||
|
||
pub fn target() -> Target { | ||
let mut base = super::teeos_base::opts(); | ||
base.features = "+strict-align,+neon,+fp-armv8".into(); | ||
base.max_atomic_width = Some(128); | ||
base.linker = Some("aarch64-linux-gnu-ld".into()); | ||
|
||
Target { | ||
llvm_target: "aarch64-unknown-none".into(), | ||
pointer_width: 64, | ||
data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".into(), | ||
arch: "aarch64".into(), | ||
options: base, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use super::{Cc, LinkerFlavor, Lld, PanicStrategy}; | ||
use crate::spec::{RelroLevel, TargetOptions}; | ||
|
||
pub fn opts() -> TargetOptions { | ||
let lld_args = &["-zmax-page-size=4096", "-znow", "-ztext", "--execute-only"]; | ||
let cc_args = &["-Wl,-zmax-page-size=4096", "-Wl,-znow", "-Wl,-ztext", "-mexecute-only"]; | ||
|
||
let mut pre_link_args = TargetOptions::link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), lld_args); | ||
super::add_link_args(&mut pre_link_args, LinkerFlavor::Gnu(Cc::Yes, Lld::No), cc_args); | ||
|
||
TargetOptions { | ||
os: "teeos".into(), | ||
vendor: "unknown".into(), | ||
dynamic_linking: true, | ||
linker_flavor: LinkerFlavor::Gnu(Cc::Yes, Lld::No), | ||
// rpath hardcodes -Wl, so it can't be used together with ld.lld. | ||
// C TAs also don't support rpath, so this is fine. | ||
has_rpath: false, | ||
// Note: Setting has_thread_local to true causes an error when | ||
// loading / dyn-linking the TA | ||
has_thread_local: false, | ||
position_independent_executables: true, | ||
relro_level: RelroLevel::Full, | ||
crt_static_respected: true, | ||
pre_link_args, | ||
panic_strategy: PanicStrategy::Abort, | ||
..Default::default() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
src/doc/rustc/src/platform-support/aarch64-unknown-teeos.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# `aarch64-unknown-teeos` | ||
|
||
**Tier: 3** | ||
|
||
Target for the TEEOS operating system. | ||
|
||
TEEOS is a mini os run in TrustZone, for trusted/security apps. The kernel of TEEOS is HongMeng/ChCore micro kernel. The libc for TEEOS is a part of musl. | ||
It's very small that there is no RwLock, no network, no stdin, and no file system for apps in TEEOS. | ||
|
||
Some abbreviation: | ||
| Abbreviation | The full text | Description | | ||
| ---- | ---- | ---- | | ||
| TEE | Trusted Execution Environment | ARM TrustZone devide the system into two worlds/modes -- the secure world/mode and the normal world/mode. TEE is in the secure world/mode. | | ||
| REE | Rich Execution Environment | The normal world. for example, Linux for Android phone is in REE side. | | ||
| TA | Trusted Application | The app run in TEE side system. | | ||
| CA | Client Application | The progress run in REE side system. | | ||
|
||
TEEOS is open source in progress. [MORE about](https://gitee.com/opentrustee-group) | ||
|
||
## Target maintainers | ||
|
||
- Petrochenkov Vadim | ||
- Sword-Destiny | ||
|
||
## Setup | ||
We use OpenHarmony SDK for TEEOS. | ||
|
||
The OpenHarmony SDK doesn't currently support Rust compilation directly, so | ||
some setup is required. | ||
|
||
First, you must obtain the OpenHarmony SDK from [this page](https://gitee.com/openharmony/docs/tree/master/en/release-notes). | ||
Select the version of OpenHarmony you are developing for and download the "Public SDK package for the standard system". | ||
|
||
Create the following shell scripts that wrap Clang from the OpenHarmony SDK: | ||
|
||
`aarch64-unknown-teeos-clang.sh` | ||
|
||
```sh | ||
#!/bin/sh | ||
exec /path/to/ohos-sdk/linux/native/llvm/bin/clang \ | ||
--target aarch64-linux-gnu \ | ||
"$@" | ||
``` | ||
|
||
`aarch64-unknown-teeos-clang++.sh` | ||
|
||
```sh | ||
#!/bin/sh | ||
exec /path/to/ohos-sdk/linux/native/llvm/bin/clang++ \ | ||
--target aarch64-linux-gnu \ | ||
"$@" | ||
``` | ||
|
||
## Building the target | ||
|
||
To build a rust toolchain, create a `config.toml` with the following contents: | ||
|
||
```toml | ||
profile = "compiler" | ||
changelog-seen = 2 | ||
|
||
[build] | ||
sanitizers = true | ||
profiler = true | ||
target = ["x86_64-unknown-linux-gnu", "aarch64-unknown-teeos"] | ||
submodules = false | ||
compiler-docs = false | ||
extended = true | ||
|
||
[install] | ||
bindir = "bin" | ||
libdir = "lib" | ||
|
||
[target.aarch64-unknown-teeos] | ||
cc = "/path/to/scripts/aarch64-unknown-teeos-clang.sh" | ||
cxx = "/path/to/scripts/aarch64-unknown-teeos-clang.sh" | ||
linker = "/path/to/scripts/aarch64-unknown-teeos-clang.sh" | ||
ar = "/path/to/ohos-sdk/linux/native/llvm/bin/llvm-ar" | ||
ranlib = "/path/to/ohos-sdk/linux/native/llvm/bin/llvm-ranlib" | ||
llvm-config = "/path/to/ohos-sdk/linux/native/llvm/bin/llvm-config" | ||
``` | ||
|
||
## Building Rust programs | ||
|
||
Rust does not yet ship pre-compiled artifacts for this target. To compile for | ||
this target, you will either need to build Rust with the target enabled (see | ||
"Building the target" above), or build your own copy of `core` by using | ||
`build-std` or similar. | ||
|
||
You will need to configure the linker to use in `~/.cargo/config`: | ||
```toml | ||
[target.aarch64-unknown-teeos] | ||
linker = "/path/to/aarch64-unknown-teeos-clang.sh" | ||
``` | ||
|
||
## Testing | ||
|
||
Running the Rust testsuite is not possible now. | ||
|
||
More information about how to test CA/TA. [See here](https://gitee.com/openharmony-sig/tee_tee_dev_kit/tree/master/docs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters