Skip to content

Commit

Permalink
Rollup merge of rust-lang#102293 - ecnelises:aix.initial, r=davidtwco
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Manishearth authored Nov 22, 2022
2 parents 90e8b94 + aef3d93 commit ab6f755
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 1 deletion.
32 changes: 32 additions & 0 deletions compiler/rustc_target/src/spec/aix_base.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
use crate::abi::Endian;
use crate::spec::{crt_objects, cvs, Cc, CodeModel, LinkOutputKind, LinkerFlavor, TargetOptions};

pub fn opts() -> TargetOptions {
TargetOptions {
abi: "vec-extabi".into(),
code_model: Some(CodeModel::Small),
cpu: "pwr7".into(),
os: "aix".into(),
vendor: "ibm".into(),
dynamic_linking: true,
endian: Endian::Big,
executables: true,
archive_format: "aix_big".into(),
families: cvs!["unix"],
has_rpath: false,
has_thread_local: true,
crt_static_respected: true,
linker_flavor: LinkerFlavor::Unix(Cc::No),
linker: Some("ld".into()),
eh_frame_header: false,
is_like_aix: true,
default_dwarf_version: 3,
function_sections: true,
pre_link_objects: crt_objects::new(&[
(LinkOutputKind::DynamicNoPicExe, &["/usr/lib/crt0_64.o", "/usr/lib/crti_64.o"]),
(LinkOutputKind::DynamicPicExe, &["/usr/lib/crt0_64.o", "/usr/lib/crti_64.o"]),
]),
dll_suffix: ".a".into(),
..Default::default()
}
}
8 changes: 8 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ use rustc_macros::HashStable_Generic;
pub mod abi;
pub mod crt_objects;

mod aix_base;
mod android_base;
mod apple_base;
mod avr_gnu_base;
Expand Down Expand Up @@ -1027,6 +1028,7 @@ supported_targets! {
("powerpc-unknown-linux-gnu", powerpc_unknown_linux_gnu),
("powerpc-unknown-linux-gnuspe", powerpc_unknown_linux_gnuspe),
("powerpc-unknown-linux-musl", powerpc_unknown_linux_musl),
("powerpc64-ibm-aix", powerpc64_ibm_aix),
("powerpc64-unknown-linux-gnu", powerpc64_unknown_linux_gnu),
("powerpc64-unknown-linux-musl", powerpc64_unknown_linux_musl),
("powerpc64le-unknown-linux-gnu", powerpc64le_unknown_linux_gnu),
Expand Down Expand Up @@ -1454,6 +1456,9 @@ pub struct TargetOptions {
pub families: StaticCow<[StaticCow<str>]>,
/// Whether the target toolchain's ABI supports returning small structs as an integer.
pub abi_return_struct_as_int: bool,
/// Whether the target toolchain is like AIX's. Linker options on AIX are special and it uses
/// XCOFF as binary format. Defaults to false.
pub is_like_aix: bool,
/// Whether the target toolchain is like macOS's. Only useful for compiling against iOS/macOS,
/// in particular running dsymutil and some other stuff like `-dead_strip`. Defaults to false.
/// Also indiates whether to use Apple-specific ABI changes, such as extending function
Expand Down Expand Up @@ -1817,6 +1822,7 @@ impl Default for TargetOptions {
staticlib_suffix: ".a".into(),
families: cvs![],
abi_return_struct_as_int: false,
is_like_aix: false,
is_like_osx: false,
is_like_solaris: false,
is_like_windows: false,
Expand Down Expand Up @@ -2488,6 +2494,7 @@ impl Target {
key!(staticlib_suffix);
key!(families, TargetFamilies);
key!(abi_return_struct_as_int, bool);
key!(is_like_aix, bool);
key!(is_like_osx, bool);
key!(is_like_solaris, bool);
key!(is_like_windows, bool);
Expand Down Expand Up @@ -2741,6 +2748,7 @@ impl ToJson for Target {
target_option_val!(staticlib_suffix);
target_option_val!(families, "target-family");
target_option_val!(abi_return_struct_as_int);
target_option_val!(is_like_aix);
target_option_val!(is_like_osx);
target_option_val!(is_like_solaris);
target_option_val!(is_like_windows);
Expand Down
23 changes: 23 additions & 0 deletions compiler/rustc_target/src/spec/powerpc64_ibm_aix.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use crate::spec::{Cc, LinkerFlavor, Target};

pub fn target() -> Target {
let mut base = super::aix_base::opts();
base.max_atomic_width = Some(64);
base.add_pre_link_args(
LinkerFlavor::Unix(Cc::No),
&[
"-b64".into(),
"-bpT:0x100000000".into(),
"-bpD:0x110000000".into(),
"-bcdtors:all:0:s".into(),
],
);

Target {
llvm_target: "powerpc64-ibm-aix".into(),
pointer_width: 64,
data_layout: "E-m:a-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
arch: "powerpc64".into(),
options: base,
}
}
1 change: 1 addition & 0 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ target | std | host | notes
`powerpc64-wrs-vxworks` | ? | |
`powerpc64le-unknown-linux-musl` | ? | |
[`powerpc64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/powerpc64
`powerpc64-ibm-aix` | ? | | 64-bit AIX (7.2 and newer)
`riscv32gc-unknown-linux-gnu` | | | RISC-V Linux (kernel 5.4, glibc 2.33)
`riscv32gc-unknown-linux-musl` | | | RISC-V Linux (kernel 5.4, musl + RISCV32 support patches)
`riscv32im-unknown-none-elf` | * | | Bare RISC-V (RV32IM ISA)
Expand Down
2 changes: 1 addition & 1 deletion src/test/ui/check-cfg/well-known-values.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LL | #[cfg(target_os = "linuz")]
| |
| help: did you mean: `"linux"`
|
= 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
= 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
= note: `#[warn(unexpected_cfgs)]` on by default

warning: unexpected `cfg` condition value
Expand Down

0 comments on commit ab6f755

Please sign in to comment.