1
Fork 0

Add OpenHarmony targets

- `aarch64-unknown-linux-ohos`
- `armv7-unknown-linux-ohos`
This commit is contained in:
Amanieu d'Antras 2022-11-10 10:06:34 +00:00
parent dd19135b04
commit e3968be331
15 changed files with 238 additions and 7 deletions

View file

@ -0,0 +1,31 @@
use crate::spec::{Target, TargetOptions};
use super::SanitizerSet;
pub fn target() -> Target {
let mut base = super::linux_musl_base::opts();
base.env = "ohos".into();
base.crt_static_default = false;
base.max_atomic_width = Some(128);
Target {
// LLVM 15 doesn't support OpenHarmony yet, use a linux target instead.
llvm_target: "aarch64-unknown-linux-musl".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: TargetOptions {
features: "+reserve-x18".into(),
mcount: "\u{1}_mcount".into(),
force_emulated_tls: true,
supported_sanitizers: SanitizerSet::ADDRESS
| SanitizerSet::CFI
| SanitizerSet::LEAK
| SanitizerSet::MEMORY
| SanitizerSet::MEMTAG
| SanitizerSet::THREAD
| SanitizerSet::HWADDRESS,
..base
},
}
}

View file

@ -0,0 +1,27 @@
use crate::spec::{Target, TargetOptions};
// This target is for OpenHarmony on ARMv7 Linux with thumb-mode, but no NEON or
// hardfloat.
pub fn target() -> Target {
// Most of these settings are copied from the armv7_unknown_linux_musleabi
// target.
Target {
// LLVM 15 doesn't support OpenHarmony yet, use a linux target instead.
llvm_target: "armv7-unknown-linux-gnueabi".into(),
pointer_width: 32,
data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".into(),
arch: "arm".into(),
options: TargetOptions {
abi: "eabi".into(),
features: "+v7,+thumb2,+soft-float,-neon".into(),
max_atomic_width: Some(64),
env: "ohos".into(),
crt_static_default: false,
mcount: "\u{1}mcount".into(),
force_emulated_tls: true,
..super::linux_musl_base::opts()
},
}
}

View file

@ -1261,6 +1261,9 @@ supported_targets! {
("aarch64-unknown-nto-qnx710", aarch64_unknown_nto_qnx_710),
("x86_64-pc-nto-qnx710", x86_64_pc_nto_qnx710),
("aarch64-unknown-linux-ohos", aarch64_unknown_linux_ohos),
("armv7-unknown-linux-ohos", armv7_unknown_linux_ohos),
}
/// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]>
@ -1734,6 +1737,9 @@ pub struct TargetOptions {
/// Whether the target supports XRay instrumentation.
pub supports_xray: bool,
/// Forces the use of emulated TLS (__emutls_get_address)
pub force_emulated_tls: bool,
}
/// Add arguments for the given flavor and also for its "twin" flavors
@ -1954,6 +1960,7 @@ impl Default for TargetOptions {
entry_name: "main".into(),
entry_abi: Conv::C,
supports_xray: false,
force_emulated_tls: false,
}
}
}
@ -2605,6 +2612,7 @@ impl Target {
key!(entry_name);
key!(entry_abi, Conv)?;
key!(supports_xray, bool);
key!(force_emulated_tls, bool);
if base.is_builtin {
// This can cause unfortunate ICEs later down the line.
@ -2859,6 +2867,7 @@ impl ToJson for Target {
target_option_val!(entry_name);
target_option_val!(entry_abi);
target_option_val!(supports_xray);
target_option_val!(force_emulated_tls);
if let Some(abi) = self.default_adjusted_cabi {
d.insert("default-adjusted-cabi".into(), Abi::name(abi).to_json());