Skip to content

Commit 5d591c6

Browse files
yetistheiher
andcommitted
Add new Tier-3 target: loongarch64-unknown-linux-ohos
MCP: rust-lang/compiler-team#784 Co-authored-by: WANG Rui <[email protected]>
1 parent 66b0b29 commit 5d591c6

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1886,6 +1886,7 @@ supported_targets! {
18861886

18871887
("aarch64-unknown-linux-ohos", aarch64_unknown_linux_ohos),
18881888
("armv7-unknown-linux-ohos", armv7_unknown_linux_ohos),
1889+
("loongarch64-unknown-linux-ohos", loongarch64_unknown_linux_ohos),
18891890
("x86_64-unknown-linux-ohos", x86_64_unknown_linux_ohos),
18901891

18911892
("x86_64-unknown-linux-none", x86_64_unknown_linux_none),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use crate::spec::{Target, TargetOptions, base};
2+
3+
pub(crate) fn target() -> Target {
4+
Target {
5+
// LLVM 15 doesn't support OpenHarmony yet, use a linux target instead.
6+
llvm_target: "loongarch64-unknown-linux-musl".into(),
7+
metadata: crate::spec::TargetMetadata {
8+
description: Some("LoongArch64 OpenHarmony".into()),
9+
tier: Some(3),
10+
host_tools: Some(false),
11+
std: Some(true),
12+
},
13+
pointer_width: 64,
14+
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
15+
arch: "loongarch64".into(),
16+
options: TargetOptions {
17+
cpu: "generic".into(),
18+
features: "+f,+d".into(),
19+
llvm_abiname: "lp64d".into(),
20+
max_atomic_width: Some(64),
21+
..base::linux_ohos::opts()
22+
},
23+
}
24+
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,7 @@ target | std | host | notes
315315
`i686-uwp-windows-msvc` | ✓ | | [^x86_32-floats-return-ABI]
316316
[`i686-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 32-bit Windows 7 support [^x86_32-floats-return-ABI]
317317
[`i686-wrs-vxworks`](platform-support/vxworks.md) | ✓ | | [^x86_32-floats-return-ABI]
318+
[`loongarch64-unknown-linux-ohos`](platform-support/openharmony.md) | ✓ | LoongArch64 OpenHarmony
318319
[`m68k-unknown-linux-gnu`](platform-support/m68k-unknown-linux-gnu.md) | ? | | Motorola 680x0 Linux
319320
`mips-unknown-linux-gnu` | ✓ | ✓ | MIPS Linux (kernel 4.4, glibc 2.23)
320321
`mips-unknown-linux-musl` | ✓ | | MIPS Linux with musl 1.2.3

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

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
**Tier: 2**
44

5+
* aarch64-unknown-linux-ohos
6+
* armv7-unknown-linux-ohos
7+
* x86_64-unknown-linux-ohos
8+
9+
**Tier: 3**
10+
11+
* loongarch64-unknown-linux-ohos
12+
513
Targets for the [OpenHarmony](https://gitee.com/openharmony/docs/) operating
614
system.
715

tests/assembly/targets/targets-elf.rs

+3
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,9 @@
252252
//@ revisions: loongarch64_unknown_linux_musl
253253
//@ [loongarch64_unknown_linux_musl] compile-flags: --target loongarch64-unknown-linux-musl
254254
//@ [loongarch64_unknown_linux_musl] needs-llvm-components: loongarch
255+
//@ revisions: loongarch64_unknown_linux_ohos
256+
//@ [loongarch64_unknown_linux_ohos] compile-flags: --target loongarch64-unknown-linux-ohos
257+
//@ [loongarch64_unknown_linux_ohos] needs-llvm-components: loongarch
255258
//@ revisions: loongarch64_unknown_none
256259
//@ [loongarch64_unknown_none] compile-flags: --target loongarch64-unknown-none
257260
//@ [loongarch64_unknown_none] needs-llvm-components: loongarch

0 commit comments

Comments
 (0)