Skip to content

Commit 6577a0f

Browse files
no92Dennisbonke
andcommitted
compiler: Add {x86_64,aarch64,riscv64gc}-unknown-managarm-mlibc targets
Co-authored-by: Dennis Bonke <[email protected]>
1 parent 6073411 commit 6577a0f

File tree

11 files changed

+109
-4
lines changed

11 files changed

+109
-4
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::spec::{RelroLevel, TargetOptions, cvs};
2+
3+
pub(crate) fn opts() -> TargetOptions {
4+
TargetOptions {
5+
os: "managarm".into(),
6+
env: "mlibc".into(),
7+
dynamic_linking: true,
8+
executables: true,
9+
families: cvs!["unix"],
10+
has_rpath: true,
11+
position_independent_executables: true,
12+
relro_level: RelroLevel::Full,
13+
has_thread_local: true,
14+
crt_static_respected: true,
15+
..Default::default()
16+
}
17+
}

compiler/rustc_target/src/spec/base/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub(crate) mod linux_ohos;
2020
pub(crate) mod linux_uclibc;
2121
pub(crate) mod linux_wasm;
2222
pub(crate) mod lynxos178;
23+
pub(crate) mod managarm_mlibc;
2324
pub(crate) mod msvc;
2425
pub(crate) mod netbsd;
2526
pub(crate) mod nto_qnx;

compiler/rustc_target/src/spec/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,6 +2032,10 @@ supported_targets! {
20322032
("i586-unknown-redox", i586_unknown_redox),
20332033
("x86_64-unknown-redox", x86_64_unknown_redox),
20342034

2035+
("x86_64-unknown-managarm-mlibc", x86_64_unknown_managarm_mlibc),
2036+
("aarch64-unknown-managarm-mlibc", aarch64_unknown_managarm_mlibc),
2037+
("riscv64gc-unknown-managarm-mlibc", riscv64gc_unknown_managarm_mlibc),
2038+
20352039
("i386-apple-ios", i386_apple_ios),
20362040
("x86_64-apple-ios", x86_64_apple_ios),
20372041
("aarch64-apple-ios", aarch64_apple_ios),
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
use crate::spec::{StackProbeType, Target, base};
2+
3+
pub(crate) fn target() -> Target {
4+
let mut base = base::managarm_mlibc::opts();
5+
base.max_atomic_width = Some(128);
6+
base.stack_probes = StackProbeType::Inline;
7+
base.features = "+v8a".into();
8+
9+
Target {
10+
llvm_target: "aarch64-unknown-managarm-mlibc".into(),
11+
metadata: crate::spec::TargetMetadata {
12+
description: Some("managarm/aarch64".into()),
13+
tier: Some(3),
14+
host_tools: Some(false),
15+
std: Some(false),
16+
},
17+
pointer_width: 64,
18+
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128-Fn32".into(),
19+
arch: "aarch64".into(),
20+
options: base
21+
}
22+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use crate::spec::{CodeModel, Target, TargetOptions, base};
2+
3+
pub(crate) fn target() -> Target {
4+
Target {
5+
llvm_target: "riscv64-unknown-managarm-mlibc".into(),
6+
metadata: crate::spec::TargetMetadata {
7+
description: Some("managarm/riscv64".into()),
8+
tier: Some(3),
9+
host_tools: Some(false),
10+
std: Some(false),
11+
},
12+
pointer_width: 64,
13+
data_layout: "e-m:e-p:64:64-i64:64-i128:128-n32:64-S128".into(),
14+
arch: "riscv64".into(),
15+
options: TargetOptions {
16+
code_model: Some(CodeModel::Medium),
17+
cpu: "generic-rv64".into(),
18+
features: "+m,+a,+f,+d,+c".into(),
19+
llvm_abiname: "lp64d".into(),
20+
max_atomic_width: Some(64),
21+
..base::managarm_mlibc::opts()
22+
},
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use crate::spec::{Cc, LinkerFlavor, Lld, StackProbeType, Target, base};
2+
3+
pub(crate) fn target() -> Target {
4+
let mut base = base::managarm_mlibc::opts();
5+
base.cpu = "x86-64".into();
6+
base.max_atomic_width = Some(64);
7+
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
8+
base.stack_probes = StackProbeType::Inline;
9+
10+
Target {
11+
llvm_target: "x86_64-unknown-managarm-mlibc".into(),
12+
metadata: crate::spec::TargetMetadata {
13+
description: Some("managarm/amd64".into()),
14+
tier: Some(3),
15+
host_tools: Some(false),
16+
std: Some(false),
17+
},
18+
pointer_width: 64,
19+
data_layout:
20+
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128".into(),
21+
arch: "x86_64".into(),
22+
options: base,
23+
}
24+
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ static TARGETS: &[&str] = &[
7171
"aarch64-unknown-none-softfloat",
7272
"aarch64-unknown-redox",
7373
"aarch64-unknown-uefi",
74+
"aarch64-unknown-managarm-mlibc",
7475
"amdgcn-amd-amdhsa",
7576
"arm64e-apple-darwin",
7677
"arm64e-apple-ios",
@@ -155,6 +156,7 @@ static TARGETS: &[&str] = &[
155156
"riscv64gc-unknown-none-elf",
156157
"riscv64gc-unknown-linux-gnu",
157158
"riscv64gc-unknown-linux-musl",
159+
"riscv64gc-unknown-managarm-mlibc",
158160
"s390x-unknown-linux-gnu",
159161
"sparc64-unknown-linux-gnu",
160162
"sparcv9-sun-solaris",
@@ -194,6 +196,7 @@ static TARGETS: &[&str] = &[
194196
"x86_64-unknown-redox",
195197
"x86_64-unknown-hermit",
196198
"x86_64-unknown-uefi",
199+
"x86_64-unknown-managarm-mlibc",
197200
];
198201

199202
/// This allows the manifest to contain rust-docs for hosts that don't build

tests/assembly-llvm/targets/targets-elf.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@
5252
//@ revisions: aarch64_unknown_linux_ohos
5353
//@ [aarch64_unknown_linux_ohos] compile-flags: --target aarch64-unknown-linux-ohos
5454
//@ [aarch64_unknown_linux_ohos] needs-llvm-components: aarch64
55+
//@ revisions: aarch64_unknown_managarm_mlibc
56+
//@ [aarch64_unknown_managarm_mlibc] compile-flags: --target aarch64-unknown-managarm-mlibc
57+
//@ [aarch64_unknown_managarm_mlibc] needs-llvm-components: aarch64
5558
//@ revisions: aarch64_unknown_netbsd
5659
//@ [aarch64_unknown_netbsd] compile-flags: --target aarch64-unknown-netbsd
5760
//@ [aarch64_unknown_netbsd] needs-llvm-components: aarch64
@@ -490,6 +493,9 @@
490493
//@ revisions: riscv64gc_unknown_linux_musl
491494
//@ [riscv64gc_unknown_linux_musl] compile-flags: --target riscv64gc-unknown-linux-musl
492495
//@ [riscv64gc_unknown_linux_musl] needs-llvm-components: riscv
496+
//@ revisions: riscv64gc_unknown_managarm_mlibc
497+
//@ [riscv64gc_unknown_managarm_mlibc] compile-flags: --target riscv64gc-unknown-managarm-mlibc
498+
//@ [riscv64gc_unknown_managarm_mlibc] needs-llvm-components: riscv
493499
//@ revisions: riscv64gc_unknown_netbsd
494500
//@ [riscv64gc_unknown_netbsd] compile-flags: --target riscv64gc-unknown-netbsd
495501
//@ [riscv64gc_unknown_netbsd] needs-llvm-components: riscv
@@ -649,6 +655,9 @@
649655
//@ revisions: x86_64_unknown_linux_none
650656
//@ [x86_64_unknown_linux_none] compile-flags: --target x86_64-unknown-linux-none
651657
//@ [x86_64_unknown_linux_none] needs-llvm-components: x86
658+
//@ revisions: x86_64_unknown_managarm_mlibc
659+
//@ [x86_64_unknown_managarm_mlibc] compile-flags: --target x86_64-unknown-managarm-mlibc
660+
//@ [x86_64_unknown_managarm_mlibc] needs-llvm-components: x86
652661
//@ revisions: x86_64_unknown_netbsd
653662
//@ [x86_64_unknown_netbsd] compile-flags: --target x86_64-unknown-netbsd
654663
//@ [x86_64_unknown_netbsd] needs-llvm-components: x86

tests/ui/attributes/auxiliary/used_pre_main_constructor.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
target_os = "nto",
2121
target_os = "openbsd",
2222
target_os = "fuchsia",
23+
target_os = "managarm",
2324
),
2425
link_section = ".init_array"
2526
)]

tests/ui/check-cfg/cfg-crate-features.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ warning: unexpected `cfg` condition value: `does_not_exist`
2424
LL | #![cfg(not(target(os = "does_not_exist")))]
2525
| ^^^^^^^^^^^^^^^^^^^^^
2626
|
27-
= note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, and `uefi` and 10 more
27+
= note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, and `tvos` and 11 more
2828
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
2929
= note: `#[warn(unexpected_cfgs)]` on by default
3030

0 commit comments

Comments
 (0)