Skip to content

Commit f34a05f

Browse files
no9264Dennisbonke
committed
compiler: Add x86_64-unknown-managarm-mlibc target
Co-authored-by: Matt Taylor <[email protected]> Co-authored-by: Dennis Bonke <[email protected]>
1 parent a8cfc83 commit f34a05f

File tree

6 files changed

+66
-3
lines changed

6 files changed

+66
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use crate::spec::{Cc, cvs, LinkArgs, LinkerFlavor, Lld, RelroLevel, TargetOptions};
2+
3+
pub fn opts() -> TargetOptions {
4+
let mut args = LinkArgs::new();
5+
args.insert(
6+
LinkerFlavor::Gnu(Cc::Yes, Lld::No),
7+
vec![
8+
// We want to be able to strip as much executable code as possible
9+
// from the linker command line, and this flag indicates to the
10+
// linker that it can avoid linking in dynamic libraries that don't
11+
// actually satisfy any symbols up to that point (as with many other
12+
// resolutions the linker does). This option only applies to all
13+
// following libraries so we're sure to pass it as one of the first
14+
// arguments.
15+
"-Wl,--as-needed".to_string().into(),
16+
// Always enable NX protection when it is available
17+
"-Wl,-z,noexecstack".to_string().into(),
18+
],
19+
);
20+
21+
TargetOptions {
22+
os: "managarm".to_string().into(),
23+
env: "mlibc".to_string().into(),
24+
dynamic_linking: true,
25+
executables: true,
26+
families: cvs!["unix"],
27+
has_rpath: true,
28+
pre_link_args: args,
29+
position_independent_executables: true,
30+
relro_level: RelroLevel::Full,
31+
has_thread_local: true,
32+
crt_static_respected: true,
33+
..Default::default()
34+
}
35+
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub(crate) mod linux_gnu;
1717
pub(crate) mod linux_musl;
1818
pub(crate) mod linux_ohos;
1919
pub(crate) mod linux_uclibc;
20+
pub(crate) mod managarm_mlibc;
2021
pub(crate) mod msvc;
2122
pub(crate) mod netbsd;
2223
pub(crate) mod nto_qnx;

compiler/rustc_target/src/spec/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1539,6 +1539,8 @@ supported_targets! {
15391539
("aarch64-unknown-redox", aarch64_unknown_redox),
15401540
("x86_64-unknown-redox", x86_64_unknown_redox),
15411541

1542+
("x86_64-unknown-managarm-mlibc", x86_64_unknown_managarm_mlibc),
1543+
15421544
("i386-apple-ios", i386_apple_ios),
15431545
("x86_64-apple-ios", x86_64_apple_ios),
15441546
("aarch64-apple-ios", aarch64_apple_ios),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata};
2+
3+
pub fn target() -> Target {
4+
let mut base = base::managarm_mlibc::opts();
5+
base.cpu = "x86-64".to_string().into();
6+
base.max_atomic_width = Some(64);
7+
base.pre_link_args.get_mut(&LinkerFlavor::Gnu(Cc::Yes, Lld::No)).unwrap().push("-m64".to_string().into());
8+
// don't use probe-stack=inline-asm until rust-lang/rust#83139 is resolved.
9+
base.stack_probes = StackProbeType::Call;
10+
11+
Target {
12+
llvm_target: "x86_64-unknown-managarm-mlibc".to_string().into(),
13+
pointer_width: 64,
14+
data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
15+
.to_string().into(),
16+
arch: "x86_64".to_string().into(),
17+
options: base,
18+
metadata: TargetMetadata {
19+
std: Some(false),
20+
tier: Some(3),
21+
..Default::default()
22+
}
23+
}
24+
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ static TARGETS: &[&str] = &[
166166
"x86_64-unknown-linux-gnux32",
167167
"x86_64-unknown-linux-musl",
168168
"x86_64-unknown-linux-ohos",
169+
"x86_64-unknown-managarm-mlibc",
169170
"x86_64-unknown-netbsd",
170171
"x86_64-unknown-none",
171172
"x86_64-unknown-redox",

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
136136
LL | target_env = "_UNEXPECTED_VALUE",
137137
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
138138
|
139-
= note: expected values for `target_env` are: ``, `gnu`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`
139+
= note: expected values for `target_env` are: ``, `gnu`, `mlibc`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `ohos`, `p2`, `psx`, `relibc`, `sgx`, `uclibc`
140140
= note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration
141141

142142
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
@@ -190,7 +190,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
190190
LL | target_os = "_UNEXPECTED_VALUE",
191191
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
192192
|
193-
= 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`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, `zkvm`
193+
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `managarm`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, `zkvm`
194194
= note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration
195195

196196
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
@@ -263,7 +263,7 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux`
263263
| |
264264
| help: there is a expected value with a similar name: `"linux"`
265265
|
266-
= 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`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, `zkvm`
266+
= note: expected values for `target_os` are: `aix`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `managarm`, `netbsd`, `none`, `nto`, `openbsd`, `psp`, `redox`, `solaris`, `solid_asp3`, `teeos`, `tvos`, `uefi`, `unknown`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, `zkvm`
267267
= note: see <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/check-cfg.html> for more information about checking conditional configuration
268268

269269
warning: 27 warnings emitted

0 commit comments

Comments
 (0)