Skip to content

Commit 9bd8430

Browse files
committed
Add powerpc-unknown-linux-muslspe compile target
This is almost identical to already existing targets: - powerpc_unknown_linux_musl.rs - powerpc_unknown_linux_gnuspe.rs It has support for PowerPC SPE (muslspe), which can be used with GCC version up to 8. It is useful for Freescale or IBM cores like e500. This was verified to be working with OpenWrt build system for CZ.NIC's Turris 1.x routers, which are using Freescale P2020, e500v2, so add it as a Tier 3 target.
1 parent 5753b30 commit 9bd8430

File tree

6 files changed

+66
-0
lines changed

6 files changed

+66
-0
lines changed

compiler/rustc_target/src/spec/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1558,6 +1558,7 @@ supported_targets! {
15581558
("powerpc-unknown-linux-gnu", powerpc_unknown_linux_gnu),
15591559
("powerpc-unknown-linux-gnuspe", powerpc_unknown_linux_gnuspe),
15601560
("powerpc-unknown-linux-musl", powerpc_unknown_linux_musl),
1561+
("powerpc-unknown-linux-muslspe", powerpc_unknown_linux_muslspe),
15611562
("powerpc64-ibm-aix", powerpc64_ibm_aix),
15621563
("powerpc64-unknown-linux-gnu", powerpc64_unknown_linux_gnu),
15631564
("powerpc64-unknown-linux-musl", powerpc64_unknown_linux_musl),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use crate::abi::Endian;
2+
use crate::spec::{base, Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetOptions};
3+
4+
pub fn target() -> Target {
5+
let mut base = base::linux_gnu::opts();
6+
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-mspe"]);
7+
base.max_atomic_width = Some(32);
8+
base.stack_probes = StackProbeType::Inline;
9+
10+
Target {
11+
llvm_target: "powerpc-unknown-linux-muslspe".into(),
12+
metadata: crate::spec::TargetMetadata {
13+
description: Some("PowerPC SPE Linux with musl".into()),
14+
tier: Some(3),
15+
host_tools: Some(false),
16+
std: Some(true),
17+
},
18+
pointer_width: 32,
19+
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
20+
arch: "powerpc".into(),
21+
options: TargetOptions {
22+
abi: "spe".into(),
23+
endian: Endian::Big,
24+
mcount: "_mcount".into(),
25+
..base
26+
},
27+
}
28+
}

src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
- [mipsisa\*r6\*-unknown-linux-gnu\*](platform-support/mips-release-6.md)
6262
- [nvptx64-nvidia-cuda](platform-support/nvptx64-nvidia-cuda.md)
6363
- [powerpc-unknown-openbsd](platform-support/powerpc-unknown-openbsd.md)
64+
- [powerpc-unknown-linux-muslspe](platform-support/powerpc-unknown-linux-muslspe.md)
6465
- [powerpc64-ibm-aix](platform-support/aix.md)
6566
- [riscv32im-risc0-zkvm-elf](platform-support/riscv32im-risc0-zkvm-elf.md)
6667
- [riscv32imac-unknown-xous-elf](platform-support/riscv32imac-unknown-xous-elf.md)

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

+1
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ target | std | host | notes
331331
`msp430-none-elf` | * | | 16-bit MSP430 microcontrollers
332332
`powerpc-unknown-linux-gnuspe` | ✓ | | PowerPC SPE Linux
333333
`powerpc-unknown-linux-musl` | ? | | PowerPC Linux with musl 1.2.3
334+
[`powerpc-unknown-linux-muslspe`](platform-support/powerpc-unknown-linux-muslspe.md) | ? | | PowerPC SPE Linux
334335
[`powerpc-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD 32-bit powerpc systems
335336
[`powerpc-unknown-openbsd`](platform-support/powerpc-unknown-openbsd.md) | * | |
336337
`powerpc-wrs-vxworks-spe` | ? | |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# powerpc-unknown-linux-muslspe
2+
3+
**Tier: 3**
4+
5+
This target is very similar to already existing ones like `powerpc_unknown_linux_musl` and `powerpc_unknown_linux_gnuspe`.
6+
This one has PowerPC SPE support for musl. Unfortunately, the last supported gcc version with PowerPC SPE is 8.4.0.
7+
8+
## Target maintainers
9+
10+
- [@BKPepe](https://github.com/BKPepe)
11+
12+
## Requirements
13+
14+
This target is cross-compiled. There is no support for `std`. There is no
15+
default allocator, but it's possible to use `alloc` by supplying an allocator.
16+
17+
This target generated binaries in the ELF format.
18+
19+
## Building the target
20+
21+
This target was tested and used within the `OpenWrt` build system for CZ.NIC Turris 1.x routers using Freescale P2020.
22+
23+
## Building Rust programs
24+
25+
Rust does not yet ship pre-compiled artifacts for this target. To compile for
26+
this target, you will either need to build Rust with the target enabled (see
27+
"Building the target" above), or build your own copy of `core` by using
28+
`build-std` or similar.
29+
30+
## Testing
31+
32+
This is a cross-compiled target and there is no support to run rustc test suite.

tests/assembly/targets/targets-elf.rs

+3
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,9 @@
345345
//@ revisions: powerpc_unknown_linux_musl
346346
//@ [powerpc_unknown_linux_musl] compile-flags: --target powerpc-unknown-linux-musl
347347
//@ [powerpc_unknown_linux_musl] needs-llvm-components: powerpc
348+
//@ revisions: powerpc_unknown_linux_muslspe
349+
//@ [powerpc_unknown_linux_muslspe] compile-flags: --target powerpc-unknown-linux-muslspe
350+
//@ [powerpc_unknown_linux_muslspe] needs-llvm-components: powerpc
348351
//@ revisions: powerpc_unknown_netbsd
349352
//@ [powerpc_unknown_netbsd] compile-flags: --target powerpc-unknown-netbsd
350353
//@ [powerpc_unknown_netbsd] needs-llvm-components: powerpc

0 commit comments

Comments
 (0)