Skip to content

Commit ab6f755

Browse files
authored
Rollup merge of rust-lang#102293 - ecnelises:aix.initial, r=davidtwco
Add powerpc64-ibm-aix as Tier-3 target This is part of the effort mentioned in rust-lang/compiler-team#553. A reference to these options are definitions from [clang](https://github.com/llvm/llvm-project/blob/ad6fe32032a6229e0c40510e9bed419a01c695b3/clang/lib/Basic/Targets/PPC.h#L414-L448) and [llvm](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp). AIX has a system `ld` but [its options and behaviors](https://www.ibm.com/docs/en/aix/7.3?topic=l-ld-command) are different from GNU ld. Thanks to `@bzEq` for contributing the linking args.
2 parents 90e8b94 + aef3d93 commit ab6f755

File tree

5 files changed

+65
-1
lines changed

5 files changed

+65
-1
lines changed
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use crate::abi::Endian;
2+
use crate::spec::{crt_objects, cvs, Cc, CodeModel, LinkOutputKind, LinkerFlavor, TargetOptions};
3+
4+
pub fn opts() -> TargetOptions {
5+
TargetOptions {
6+
abi: "vec-extabi".into(),
7+
code_model: Some(CodeModel::Small),
8+
cpu: "pwr7".into(),
9+
os: "aix".into(),
10+
vendor: "ibm".into(),
11+
dynamic_linking: true,
12+
endian: Endian::Big,
13+
executables: true,
14+
archive_format: "aix_big".into(),
15+
families: cvs!["unix"],
16+
has_rpath: false,
17+
has_thread_local: true,
18+
crt_static_respected: true,
19+
linker_flavor: LinkerFlavor::Unix(Cc::No),
20+
linker: Some("ld".into()),
21+
eh_frame_header: false,
22+
is_like_aix: true,
23+
default_dwarf_version: 3,
24+
function_sections: true,
25+
pre_link_objects: crt_objects::new(&[
26+
(LinkOutputKind::DynamicNoPicExe, &["/usr/lib/crt0_64.o", "/usr/lib/crti_64.o"]),
27+
(LinkOutputKind::DynamicPicExe, &["/usr/lib/crt0_64.o", "/usr/lib/crti_64.o"]),
28+
]),
29+
dll_suffix: ".a".into(),
30+
..Default::default()
31+
}
32+
}

compiler/rustc_target/src/spec/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ use rustc_macros::HashStable_Generic;
5858
pub mod abi;
5959
pub mod crt_objects;
6060

61+
mod aix_base;
6162
mod android_base;
6263
mod apple_base;
6364
mod avr_gnu_base;
@@ -1027,6 +1028,7 @@ supported_targets! {
10271028
("powerpc-unknown-linux-gnu", powerpc_unknown_linux_gnu),
10281029
("powerpc-unknown-linux-gnuspe", powerpc_unknown_linux_gnuspe),
10291030
("powerpc-unknown-linux-musl", powerpc_unknown_linux_musl),
1031+
("powerpc64-ibm-aix", powerpc64_ibm_aix),
10301032
("powerpc64-unknown-linux-gnu", powerpc64_unknown_linux_gnu),
10311033
("powerpc64-unknown-linux-musl", powerpc64_unknown_linux_musl),
10321034
("powerpc64le-unknown-linux-gnu", powerpc64le_unknown_linux_gnu),
@@ -1454,6 +1456,9 @@ pub struct TargetOptions {
14541456
pub families: StaticCow<[StaticCow<str>]>,
14551457
/// Whether the target toolchain's ABI supports returning small structs as an integer.
14561458
pub abi_return_struct_as_int: bool,
1459+
/// Whether the target toolchain is like AIX's. Linker options on AIX are special and it uses
1460+
/// XCOFF as binary format. Defaults to false.
1461+
pub is_like_aix: bool,
14571462
/// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS,
14581463
/// in particular running dsymutil and some other stuff like `-dead_strip`. Defaults to false.
14591464
/// Also indiates whether to use Apple-specific ABI changes, such as extending function
@@ -1817,6 +1822,7 @@ impl Default for TargetOptions {
18171822
staticlib_suffix: ".a".into(),
18181823
families: cvs![],
18191824
abi_return_struct_as_int: false,
1825+
is_like_aix: false,
18201826
is_like_osx: false,
18211827
is_like_solaris: false,
18221828
is_like_windows: false,
@@ -2488,6 +2494,7 @@ impl Target {
24882494
key!(staticlib_suffix);
24892495
key!(families, TargetFamilies);
24902496
key!(abi_return_struct_as_int, bool);
2497+
key!(is_like_aix, bool);
24912498
key!(is_like_osx, bool);
24922499
key!(is_like_solaris, bool);
24932500
key!(is_like_windows, bool);
@@ -2741,6 +2748,7 @@ impl ToJson for Target {
27412748
target_option_val!(staticlib_suffix);
27422749
target_option_val!(families, "target-family");
27432750
target_option_val!(abi_return_struct_as_int);
2751+
target_option_val!(is_like_aix);
27442752
target_option_val!(is_like_osx);
27452753
target_option_val!(is_like_solaris);
27462754
target_option_val!(is_like_windows);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use crate::spec::{Cc, LinkerFlavor, Target};
2+
3+
pub fn target() -> Target {
4+
let mut base = super::aix_base::opts();
5+
base.max_atomic_width = Some(64);
6+
base.add_pre_link_args(
7+
LinkerFlavor::Unix(Cc::No),
8+
&[
9+
"-b64".into(),
10+
"-bpT:0x100000000".into(),
11+
"-bpD:0x110000000".into(),
12+
"-bcdtors:all:0:s".into(),
13+
],
14+
);
15+
16+
Target {
17+
llvm_target: "powerpc64-ibm-aix".into(),
18+
pointer_width: 64,
19+
data_layout: "E-m:a-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
20+
arch: "powerpc64".into(),
21+
options: base,
22+
}
23+
}

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

+1
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ target | std | host | notes
283283
`powerpc64-wrs-vxworks` | ? | |
284284
`powerpc64le-unknown-linux-musl` | ? | |
285285
[`powerpc64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/powerpc64
286+
`powerpc64-ibm-aix` | ? | | 64-bit AIX (7.2 and newer)
286287
`riscv32gc-unknown-linux-gnu` | | | RISC-V Linux (kernel 5.4, glibc 2.33)
287288
`riscv32gc-unknown-linux-musl` | | | RISC-V Linux (kernel 5.4, musl + RISCV32 support patches)
288289
`riscv32im-unknown-none-elf` | * | | Bare RISC-V (RV32IM ISA)

src/test/ui/check-cfg/well-known-values.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ LL | #[cfg(target_os = "linuz")]
66
| |
77
| help: did you mean: `"linux"`
88
|
9-
= note: expected values for `target_os` are: android, cuda, dragonfly, emscripten, espidf, freebsd, fuchsia, haiku, hermit, horizon, illumos, ios, l4re, linux, macos, netbsd, none, nto, openbsd, psp, redox, solaris, solid_asp3, tvos, uefi, unknown, vxworks, wasi, watchos, windows, xous
9+
= note: expected values for `target_os` are: aix, android, cuda, dragonfly, emscripten, espidf, freebsd, fuchsia, haiku, hermit, horizon, illumos, ios, l4re, linux, macos, netbsd, none, nto, openbsd, psp, redox, solaris, solid_asp3, tvos, uefi, unknown, vxworks, wasi, watchos, windows, xous
1010
= note: `#[warn(unexpected_cfgs)]` on by default
1111

1212
warning: unexpected `cfg` condition value

0 commit comments

Comments
 (0)