Skip to content

Commit 23a159f

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.
1 parent 9c963ee commit 23a159f

7 files changed

Lines changed: 88 additions & 0 deletions

File tree

compiler/rustc_target/src/spec/mod.rs

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

src/bootstrap/src/core/sanity.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ pub struct Finder {
3737
/// when the newly-bumped stage 0 compiler now knows about the formerly-missing targets.
3838
const STAGE0_MISSING_TARGETS: &[&str] = &[
3939
// just a dummy comment so the list doesn't get onelined
40+
"powerpc64-unknown-linux-gnuelfv2",
4041
];
4142

4243
/// 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
@@ -107,6 +107,7 @@
107107
- [powerpc-unknown-linux-gnuspe](platform-support/powerpc-unknown-linux-gnuspe.md)
108108
- [powerpc-unknown-linux-muslspe](platform-support/powerpc-unknown-linux-muslspe.md)
109109
- [powerpc64-ibm-aix](platform-support/aix.md)
110+
- [powerpc64-unknown-linux-gnuelfv2](platform-support/powerpc64-unknown-linux-gnuelfv2.md)
110111
- [powerpc64-unknown-linux-musl](platform-support/powerpc64-unknown-linux-musl.md)
111112
- [powerpc64le-unknown-linux-gnu](platform-support/powerpc64le-unknown-linux-gnu.md)
112113
- [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
@@ -385,6 +385,7 @@ target | std | host | notes
385385
[`powerpc-wrs-vxworks-spe`](platform-support/vxworks.md) | ✓ | |
386386
[`powerpc64-ibm-aix`](platform-support/aix.md) | ? | | 64-bit AIX (7.2 and newer)
387387
[`powerpc64-unknown-freebsd`](platform-support/freebsd.md) | ✓ | ✓ | PPC64 FreeBSD (ELFv2)
388+
[`powerpc64-unknown-linux-gnuelfv2`](platform-support/powerpc64-unknown-linux-gnuelfv2.md) | ✓ | ✓ | PPC64 Linux (ELFv2 ABI, kernel 3.2, glibc 2.17)
388389
[`powerpc64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/powerpc64
389390
[`powerpc64-wrs-vxworks`](platform-support/vxworks.md) | ✓ | |
390391
[`powerpc64le-unknown-freebsd`](platform-support/freebsd.md) | ✓ | ✓ | PPC64LE FreeBSD
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-llvm/targets/targets-elf.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@
394394
//@ revisions: powerpc64_unknown_linux_gnu
395395
//@ [powerpc64_unknown_linux_gnu] compile-flags: --target powerpc64-unknown-linux-gnu
396396
//@ [powerpc64_unknown_linux_gnu] needs-llvm-components: powerpc
397+
//@ revisions: powerpc64_unknown_linux_gnuelfv2
398+
//@ [powerpc64_unknown_linux_gnuelfv2] compile-flags: --target powerpc64-unknown-linux-gnuelfv2
399+
//@ [powerpc64_unknown_linux_gnuelfv2] min-llvm-version: 22
400+
//@ [powerpc64_unknown_linux_gnuelfv2] needs-llvm-components: powerpc
397401
//@ revisions: powerpc64_unknown_linux_musl
398402
//@ [powerpc64_unknown_linux_musl] compile-flags: --target powerpc64-unknown-linux-musl
399403
//@ [powerpc64_unknown_linux_musl] needs-llvm-components: powerpc

0 commit comments

Comments
 (0)