Skip to content

Commit 04b949e

Browse files
committed
Add powerpc64-unknown-linux-gnuelfv2 target
This is virtually the same target as the existing -gnu target, but using the ELFv2 ABI instead of the ELFv1 ABI and made possible now that we expose target_abi = "elfv1" or "elfv2" on the 64-bit PowerPC targets. Signed-off-by: Jens Reidel <adrian@travitia.xyz>
1 parent 0864097 commit 04b949e

File tree

7 files changed

+86
-0
lines changed

7 files changed

+86
-0
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1781,6 +1781,7 @@ supported_targets! {
17811781
("powerpc-unknown-linux-muslspe", powerpc_unknown_linux_muslspe),
17821782
("powerpc64-ibm-aix", powerpc64_ibm_aix),
17831783
("powerpc64-unknown-linux-gnu", powerpc64_unknown_linux_gnu),
1784+
("powerpc64-unknown-linux-gnuelfv2", powerpc64_unknown_linux_gnuelfv2),
17841785
("powerpc64-unknown-linux-musl", powerpc64_unknown_linux_musl),
17851786
("powerpc64le-unknown-linux-gnu", powerpc64le_unknown_linux_gnu),
17861787
("powerpc64le-unknown-linux-musl", powerpc64le_unknown_linux_musl),
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
use rustc_abi::Endian;
2+
3+
use crate::spec::{
4+
Cc, LinkerFlavor, Lld, StackProbeType, Target, TargetMetadata, TargetOptions, base,
5+
};
6+
7+
pub(crate) fn target() -> Target {
8+
let mut base = base::linux_gnu::opts();
9+
base.cpu = "ppc64".into();
10+
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]);
11+
base.max_atomic_width = Some(64);
12+
base.stack_probes = StackProbeType::Inline;
13+
base.abi = "elfv2".into();
14+
base.llvm_abiname = "elfv2".into();
15+
16+
Target {
17+
llvm_target: "powerpc64-unknown-linux-gnu".into(),
18+
metadata: TargetMetadata {
19+
description: Some("PPC64 Linux (ELFv2 ABI, kernel 3.2, glibc 2.17)".into()),
20+
tier: Some(3),
21+
host_tools: Some(false),
22+
std: Some(true),
23+
},
24+
pointer_width: 64,
25+
data_layout: "E-m:e-Fn32-i64:64-i128:128-n32:64-S128-v256:256:256-v512:512:512".into(),
26+
arch: "powerpc64".into(),
27+
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
28+
}
29+
}

src/bootstrap/src/core/sanity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub struct Finder {
3434
// Targets can be removed from this list once they are present in the stage0 compiler (usually by updating the beta compiler of the bootstrap).
3535
const STAGE0_MISSING_TARGETS: &[&str] = &[
3636
// just a dummy comment so the list doesn't get onelined
37+
"powerpc64-unknown-linux-gnuelfv2",
3738
];
3839

3940
/// Minimum version threshold for libstdc++ required when using prebuilt LLVM

src/doc/rustc/src/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
- [powerpc-unknown-linux-gnuspe](platform-support/powerpc-unknown-linux-gnuspe.md)
9595
- [powerpc-unknown-linux-muslspe](platform-support/powerpc-unknown-linux-muslspe.md)
9696
- [powerpc64-ibm-aix](platform-support/aix.md)
97+
- [powerpc64-unknown-linux-gnuelfv2](platform-support/powerpc64-unknown-linux-gnuelfv2.md)
9798
- [powerpc64-unknown-linux-musl](platform-support/powerpc64-unknown-linux-musl.md)
9899
- [powerpc64le-unknown-linux-gnu](platform-support/powerpc64le-unknown-linux-gnu.md)
99100
- [powerpc64le-unknown-linux-musl](platform-support/powerpc64le-unknown-linux-musl.md)

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ target | std | host | notes
360360
[`powerpc-wrs-vxworks-spe`](platform-support/vxworks.md) | ✓ | |
361361
[`powerpc64-ibm-aix`](platform-support/aix.md) | ? | | 64-bit AIX (7.2 and newer)
362362
[`powerpc64-unknown-freebsd`](platform-support/freebsd.md) | ✓ | ✓ | PPC64 FreeBSD (ELFv2)
363+
[`powerpc64-unknown-linux-gnuelfv2`](platform-support/powerpc64-unknown-linux-gnuelfv2) | ✓ | ✓ | PPC64 Linux (ELFv2 ABI, kernel 3.2, glibc 2.17)
363364
[`powerpc64-unknown-linux-musl`](platform-support/powerpc64-unknown-linux-musl.md) | ✓ | ✓ | PPC64 Linux (kernel 4.19, musl 1.2.3)
364365
[`powerpc64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/powerpc64
365366
[`powerpc64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | |
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# powerpc64-unknown-linux-gnuelfv2
2+
3+
**Tier: 3**
4+
5+
Target for 64-bit big endian PowerPC Linux programs using the ELFv2 ABI and
6+
the GNU C library.
7+
8+
## Target maintainers
9+
10+
[@Gelbpunkt](https://github.com/Gelbpunkt)
11+
12+
## Requirements
13+
14+
Building the target itself requires a 64-bit big endian PowerPC compiler that
15+
uses the ELFv2 ABI and is supported by `cc-rs`.
16+
17+
## Building the target
18+
19+
The target can be built by enabling it for a `rustc` build.
20+
21+
```toml
22+
[build]
23+
target = ["powerpc64-unknown-linux-gnuelfv2"]
24+
```
25+
26+
Make sure your C compiler is included in `$PATH`, then add it to the
27+
`bootstrap.toml`:
28+
29+
```toml
30+
[target.powerpc64-unknown-linux-gnuelfv2]
31+
cc = "powerpc64-linux-gnu-gcc"
32+
cxx = "powerpc64-linux-gnu-g++"
33+
ar = "powerpc64-linux-gnu-ar"
34+
linker = "powerpc64-linux-gnu-gcc"
35+
```
36+
37+
## Building Rust programs
38+
39+
Rust does not yet ship pre-compiled artifacts for this target. To compile for
40+
this target, you will first need to build Rust with the target enabled (see
41+
"Building the target" above).
42+
43+
## Cross-compilation
44+
45+
This target can be cross-compiled from any host.
46+
47+
## Testing
48+
49+
This target can be tested as normal with `x.py` on a 64-bit big endian PowerPC
50+
host or via QEMU emulation.

tests/assembly/targets/targets-elf.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,9 @@
358358
//@ revisions: powerpc64_unknown_linux_gnu
359359
//@ [powerpc64_unknown_linux_gnu] compile-flags: --target powerpc64-unknown-linux-gnu
360360
//@ [powerpc64_unknown_linux_gnu] needs-llvm-components: powerpc
361+
//@ revisions: powerpc64_unknown_linux_gnuelfv2
362+
//@ [powerpc64_unknown_linux_gnuelfv2] compile-flags: --target powerpc64-unknown-linux-gnuelfv2
363+
//@ [powerpc64_unknown_linux_gnuelfv2] needs-llvm-components: powerpc
361364
//@ revisions: powerpc64_unknown_linux_musl
362365
//@ [powerpc64_unknown_linux_musl] compile-flags: --target powerpc64-unknown-linux-musl
363366
//@ [powerpc64_unknown_linux_musl] needs-llvm-components: powerpc

0 commit comments

Comments
 (0)