Skip to content

Commit 4d63510

Browse files
Rollup merge of #162325 - RalfJung:aix-abi, r=beetrees
powerpc64-ibm-aix: fix cfg(target_abi) value Our powerpc64-ibm-aix target currently sets `cfg_abi` to "vec-extabi", which means that programs compiled for this target *think* they use that ABI. Even our inline asm logic trusts this field. But that's a lie, we're actually using the default ABI since we are never setting `EnableAIXExtendedAltivecABI` on the LLVM side. We should fix that discrepancy. Between changing how we generate the code, and changing the label we put into `cfg_abi`, the latter is the less risky change. So let's do that. This has been tried before in #153830. We then decided to wait a bit while the target maintainers investigate whether they want to change the ABI or not. I think we have waited long enough. The last comment from them that I found is [this one](#153876 (comment)) which says "I'd conclude the extend vector ABI should be disabled for now"; there have been further questions but no further communication. We can always still change the ABI in the future, but for now let's fix the obvious bug where the ABI we report in `cfg_abi` does not match the actual ABI we are compiling for. Cc @Gelbpunkt @daltenty @gilamn5tr @amy-kwan @taiki-e
2 parents e5cde7f + 7dc9aee commit 4d63510

11 files changed

Lines changed: 896 additions & 558 deletions

File tree

‎compiler/rustc_target/src/asm/powerpc.rs‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use rustc_data_structures::fx::FxIndexSet;
44
use rustc_span::Symbol;
55

66
use super::{InlineAsmArch, InlineAsmType, ModifierInfo};
7-
use crate::spec::{CfgAbi, RelocModel, RustcAbi, Target};
7+
use crate::spec::{RelocModel, RustcAbi, Target};
88

99
def_reg_class! {
1010
PowerPC PowerPCInlineAsmRegClass {
@@ -107,11 +107,8 @@ fn reserved_v20to31(
107107
_is_clobber: bool,
108108
) -> Result<(), &'static str> {
109109
if target.is_like_aix {
110-
match &target.options.cfg_abi {
111-
CfgAbi::VecDefault => Err("v20-v31 (vs52-vs63) are reserved on vec-default ABI"),
112-
CfgAbi::VecExtAbi => Ok(()),
113-
abi => unreachable!("unrecognized AIX ABI: {abi}"),
114-
}
110+
// We do not support the vec-extabi at the moment.
111+
Err("v20-v31 (vs52-vs63) are reserved on vec-default ABI")
115112
} else {
116113
Ok(())
117114
}

‎compiler/rustc_target/src/spec/base/aix.rs‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@ use crate::spec::{
77

88
pub(crate) fn opts() -> TargetOptions {
99
TargetOptions {
10-
cfg_abi: CfgAbi::VecExtAbi,
10+
// It makes no sense to set "vec-extabi" here without also actually configuring LLVM to use
11+
// that ABI. Since https://github.com/llvm/llvm-project/pull/221670 this probably just needs
12+
// `llvm_abiname` to be set properly. If you are doing that, make sure to also:
13+
// - adjust the logic in `reserved_v20to31` in `asm/powerpc.rs` to allow the extra registers
14+
// to be used depending on `llvm_abiname`.
15+
// - adjust the logic in `spec/consistency.rs` to correlate `llvm_abiname` with `cfg_abi`.
16+
cfg_abi: CfgAbi::VecDefault,
1117
code_model: Some(CodeModel::Large),
1218
cpu: "pwr7".into(),
1319
os: Os::Aix,

‎compiler/rustc_target/src/spec/consistency.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ impl Target {
484484
// (vec-default vs vec-ext).
485485
check_matches!(
486486
(&self.llvm_abiname, &self.cfg_abi),
487-
(LlvmAbi::Unspecified, CfgAbi::VecDefault | CfgAbi::VecExtAbi),
487+
(LlvmAbi::Unspecified, CfgAbi::VecDefault),
488488
"invalid PowerPC64 AIX ABI name and `cfg(target_abi)` combination:\n\
489489
ABI name: {}\n\
490490
cfg(target_abi): {}",

‎compiler/rustc_target/src/spec/mod.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1950,7 +1950,6 @@ crate::target_spec_enum! {
19501950
Spe = "spe",
19511951
Uwp = "uwp",
19521952
VecDefault = "vec-default",
1953-
VecExtAbi = "vec-extabi",
19541953
X32 = "x32",
19551954
V8Plus = "v8plus",
19561955
Unspecified = "",

0 commit comments

Comments
 (0)