Skip to content

Commit 7270e73

Browse files
committed
Auto merge of #135074 - wzssyqa:mips-mti, r=oli-obk
Target: Add mips mti baremetal support Do the same thing as gcc, which use the vendor `mti` to mark the toolchain as MIPS32r2 default. We support both big endian and little endian flavor: mips-mti-none-elf mipsel-mti-none-elf
2 parents 8417f83 + 1a82287 commit 7270e73

File tree

12 files changed

+120
-4
lines changed

12 files changed

+120
-4
lines changed

compiler/rustc_target/src/spec/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1926,6 +1926,8 @@ supported_targets! {
19261926
("mipsel-sony-psp", mipsel_sony_psp),
19271927
("mipsel-sony-psx", mipsel_sony_psx),
19281928
("mipsel-unknown-none", mipsel_unknown_none),
1929+
("mips-mti-none-elf", mips_mti_none_elf),
1930+
("mipsel-mti-none-elf", mipsel_mti_none_elf),
19291931
("thumbv4t-none-eabi", thumbv4t_none_eabi),
19301932
("armv4t-none-eabi", armv4t_none_eabi),
19311933
("thumbv5te-none-eabi", thumbv5te_none_eabi),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use crate::abi::Endian;
2+
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
3+
4+
pub(crate) fn target() -> Target {
5+
Target {
6+
data_layout: "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(),
7+
llvm_target: "mips".into(),
8+
metadata: crate::spec::TargetMetadata {
9+
description: Some("MIPS32r2 BE Baremetal Softfloat".into()),
10+
tier: Some(3),
11+
host_tools: Some(false),
12+
std: None, // ?
13+
},
14+
pointer_width: 32,
15+
arch: "mips".into(),
16+
17+
options: TargetOptions {
18+
vendor: "mti".into(),
19+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
20+
linker: Some("rust-lld".into()),
21+
endian: Endian::Big,
22+
cpu: "mips32r2".into(),
23+
24+
max_atomic_width: Some(32),
25+
26+
features: "+mips32r2,+soft-float,+noabicalls".into(),
27+
executables: true,
28+
panic_strategy: PanicStrategy::Abort,
29+
relocation_model: RelocModel::Static,
30+
emit_debug_gdb_scripts: false,
31+
eh_frame_header: false,
32+
singlethread: true,
33+
..Default::default()
34+
},
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
use crate::abi::Endian;
2+
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions};
3+
4+
pub(crate) fn target() -> Target {
5+
Target {
6+
data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(),
7+
llvm_target: "mipsel".into(),
8+
metadata: crate::spec::TargetMetadata {
9+
description: Some("MIPS32r2 LE Baremetal Softfloat".into()),
10+
tier: Some(3),
11+
host_tools: Some(false),
12+
std: None, // ?
13+
},
14+
pointer_width: 32,
15+
arch: "mips".into(),
16+
17+
options: TargetOptions {
18+
vendor: "mti".into(),
19+
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
20+
linker: Some("rust-lld".into()),
21+
endian: Endian::Little,
22+
cpu: "mips32r2".into(),
23+
24+
max_atomic_width: Some(32),
25+
26+
features: "+mips32r2,+soft-float,+noabicalls".into(),
27+
executables: true,
28+
panic_strategy: PanicStrategy::Abort,
29+
relocation_model: RelocModel::Static,
30+
emit_debug_gdb_scripts: false,
31+
eh_frame_header: false,
32+
singlethread: true,
33+
..Default::default()
34+
},
35+
}
36+
}

src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
- [m68k-unknown-linux-gnu](platform-support/m68k-unknown-linux-gnu.md)
6363
- [mips64-openwrt-linux-musl](platform-support/mips64-openwrt-linux-musl.md)
6464
- [mipsel-sony-psx](platform-support/mipsel-sony-psx.md)
65+
- [mips\*-mti-none-elf](platform-support/mips-mti-none-elf.md)
6566
- [mipsisa\*r6\*-unknown-linux-gnu\*](platform-support/mips-release-6.md)
6667
- [nvptx64-nvidia-cuda](platform-support/nvptx64-nvidia-cuda.md)
6768
- [powerpc-unknown-openbsd](platform-support/powerpc-unknown-openbsd.md)

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

+2
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,8 @@ target | std | host | notes
332332
`mipsel-unknown-linux-uclibc` | ✓ | | MIPS (LE) Linux with uClibc
333333
[`mipsel-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | 32-bit MIPS (LE), requires mips32 cpu support
334334
`mipsel-unknown-none` | * | | Bare MIPS (LE) softfloat
335+
[`mips-mti-none-elf`](platform-support/mips-mti-none-elf.md) | * | | Bare MIPS32r2 (BE) softfloat
336+
[`mipsel-mti-none-elf`](platform-support/mips-mti-none-elf.md) | * | | Bare MIPS32r2 (LE) softfloat
335337
[`mipsisa32r6-unknown-linux-gnu`](platform-support/mips-release-6.md) | ? | | 32-bit MIPS Release 6 Big Endian
336338
[`mipsisa32r6el-unknown-linux-gnu`](platform-support/mips-release-6.md) | ? | | 32-bit MIPS Release 6 Little Endian
337339
[`mipsisa64r6-unknown-linux-gnuabi64`](platform-support/mips-release-6.md) | ? | | 64-bit MIPS Release 6 Big Endian
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# `mips*-mti-none-elf`
2+
3+
**Tier: 3**
4+
5+
MIPS32r2 baremetal softfloat, Big Endian or Little Endian.
6+
7+
- mips-mti-none-elf
8+
- mipsel-mti-none-elf
9+
10+
## Target maintainers
11+
12+
- YunQiang Su, `[email protected]`, https://github.com/wzssyqa
13+
14+
## Background
15+
16+
These 2 targets, aka mips-mti-none-elf and mipsel-mti-none-elf, are for
17+
baremetal development of MIPS32r2. The lld is used instead of Gnu-ld.
18+
19+
## Requirements
20+
21+
The target only supports cross compilation and no host tools. The target
22+
supports `alloc` with a default allocator while only support `no-std` development.
23+
24+
The vendor name `mti` follows the naming of gcc to indicate MIPS32r2.
25+
26+
## Cross-compilation toolchains and C code
27+
28+
Compatible C code can be built for this target on any compiler that has a MIPS32r2
29+
target. On clang and ld.lld linker, it can be generated using the
30+
`-march=mips`/`-march=mipsel`, `-mabi=32` with llvm features flag
31+
`features=+mips32r2,+soft-float,+noabicalls`.

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

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ static TARGETS: &[&str] = &[
128128
"mipsisa64r6el-unknown-linux-gnuabi64",
129129
"mipsel-unknown-linux-gnu",
130130
"mipsel-unknown-linux-musl",
131+
"mips-mti-none-elf",
132+
"mipsel-mti-none-elf",
131133
"nvptx64-nvidia-cuda",
132134
"powerpc-unknown-linux-gnu",
133135
"powerpc64-unknown-linux-gnu",

tests/assembly/targets/targets-elf.rs

+6
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,12 @@
285285
//@ revisions: mips_unknown_linux_uclibc
286286
//@ [mips_unknown_linux_uclibc] compile-flags: --target mips-unknown-linux-uclibc
287287
//@ [mips_unknown_linux_uclibc] needs-llvm-components: mips
288+
//@ revisions: mips_mti_none_elf
289+
//@ [mips_mti_none_elf] compile-flags: --target mips-mti-none-elf
290+
//@ [mips_mti_none_elf] needs-llvm-components: mips
291+
//@ revisions: mipsel_mti_none_elf
292+
//@ [mipsel_mti_none_elf] compile-flags: --target mipsel-mti-none-elf
293+
//@ [mipsel_mti_none_elf] needs-llvm-components: mips
288294
//@ revisions: mipsel_sony_psp
289295
//@ [mipsel_sony_psp] compile-flags: --target mipsel-sony-psp
290296
//@ [mipsel_sony_psp] needs-llvm-components: mips

tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ warning: unexpected `cfg` condition value: `value`
1515
LL | #[cfg(target_vendor = "value")]
1616
| ^^^^^^^^^^^^^^^^^^^^^^^
1717
|
18-
= note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs`
18+
= note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs`
1919
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
2020

2121
warning: unexpected `cfg` condition name: `feature`

tests/ui/check-cfg/exhaustive-names-values.feature.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ warning: unexpected `cfg` condition value: `value`
1515
LL | #[cfg(target_vendor = "value")]
1616
| ^^^^^^^^^^^^^^^^^^^^^^^
1717
|
18-
= note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs`
18+
= note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs`
1919
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
2020

2121
warning: unexpected `cfg` condition value: `unk`

tests/ui/check-cfg/exhaustive-names-values.full.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ warning: unexpected `cfg` condition value: `value`
1515
LL | #[cfg(target_vendor = "value")]
1616
| ^^^^^^^^^^^^^^^^^^^^^^^
1717
|
18-
= note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs`
18+
= note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs`
1919
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
2020

2121
warning: unexpected `cfg` condition value: `unk`

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
230230
LL | target_vendor = "_UNEXPECTED_VALUE",
231231
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
232232
|
233-
= note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs`
233+
= note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs`
234234
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
235235

236236
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`

0 commit comments

Comments
 (0)