Skip to content

Comments

rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing#150468

Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
Gelbpunkt:rustc-target-callconv-spec-elf-abi
Feb 22, 2026
Merged

rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing#150468
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
Gelbpunkt:rustc-target-callconv-spec-elf-abi

Conversation

@Gelbpunkt
Copy link
Contributor

@Gelbpunkt Gelbpunkt commented Dec 28, 2025

View all comments

All PowerPC64 targets except AIX explicitly set the ABI in the target options. We can therefore stop hardcoding the ABI to be used based on the target environment or OS, except for the AIX special case.

The fallback based on endianness is kept for the sake of compatibility with custom targets.

This makes it so that big endian targets not explicitly accounted for before (powerpc64-unknown-openbsd) and targets that don't use the expected default ABI (big-endian ELFv2 Glibc targets) use the correct ABI in the calling convention code.

The second commit is a tiny change to validate the llvm_abiname set on PowerPC64(LE) targets. See the commit messages for details.

CC @RalfJung who pointed out the missing llvm_abiname validation

@rustbot
Copy link
Collaborator

rustbot commented Dec 28, 2025

These commits modify compiler targets.
(See the Target Tier Policy.)

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 28, 2025
@rustbot
Copy link
Collaborator

rustbot commented Dec 28, 2025

r? @chenyukang

rustbot has assigned @chenyukang.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@chenyukang
Copy link
Member

@rustbot reroll

@rustbot rustbot assigned jieyouxu and unassigned chenyukang Jan 13, 2026
@jieyouxu
Copy link
Member

@rustbot reroll

@rustbot rustbot assigned fee1-dead and unassigned jieyouxu Jan 13, 2026
…instead of guessing

All PowerPC64 targets except AIX explicitly set the ABI in the target
options. We can therefore stop hardcoding the ABI to be used based on
the target environment or OS, except for the AIX special case.

The fallback based on endianness is kept for the sake of compatibility
with custom targets.

This makes it so that big endian targets not explicitly accounted for
before (powerpc64-unknown-openbsd) and targets that don't use the
expected default ABI (ELFv2 Glibc targets) use the correct ABI in the
calling convention code.
@Gelbpunkt Gelbpunkt force-pushed the rustc-target-callconv-spec-elf-abi branch from 35377f3 to b2e1f69 Compare January 13, 2026 14:56
@rustbot
Copy link
Collaborator

rustbot commented Jan 13, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Gelbpunkt Gelbpunkt force-pushed the rustc-target-callconv-spec-elf-abi branch from b2e1f69 to d40f0cd Compare January 13, 2026 15:33
… PowerPC64(LE)

PowerPC64 ELF targets (effectively anything that isn't AIX) use either
the ELFv1 or ELFv2 ABI. The ELFv1 ABI is only specified for big endian
targets, while ELFv2 can be used by both little- and big-endian targets.
Make sure that, if an LLVM ABI is set, it is set to one of the two. AIX
does not set an LLVM ABI name, so ensure that AIX targets don't set
anything other than an empty ABI name.
@Gelbpunkt Gelbpunkt force-pushed the rustc-target-callconv-spec-elf-abi branch from d40f0cd to 168f324 Compare January 15, 2026 03:00
@fee1-dead
Copy link
Member

@rustbot reroll

@rustbot rustbot assigned davidtwco and unassigned fee1-dead Jan 18, 2026
@RalfJung
Copy link
Member

r? me

This LGTM from by 10k foot view without knowing anything about the details of these ABIs ;) . However, do we have to worry about this breaking the ABI for anyone already using these targets?

Also, @workingjubilee I wouldn't mind a second opinion. :)

@rustbot rustbot assigned RalfJung and unassigned davidtwco Jan 18, 2026
@Gelbpunkt
Copy link
Contributor Author

However, do we have to worry about this breaking the ABI for anyone already using these targets?

Previously, this hardcoded the list of big-endian targets using ELFv2 to musl and FreeBSD, which was not kept up to date (OpenBSD is missing from here). Since all PowerPC64 targets now specify their ABI, we can stop hardcoding the list. It will not break the ABI for any of them, AFAICT this is strictly a fix for the OpenBSD target and makes it so there's one less part of the code we need to worry about when changing or adding new targets.

@jhpratt
Copy link
Member

jhpratt commented Feb 22, 2026

yielding to encompassing rollup

@bors yield

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 22, 2026

Auto build cancelled. Cancelled workflows:

The next pull request likely to be tested is #152957.

rust-bors bot pushed a commit that referenced this pull request Feb 22, 2026
Rollup of 13 pull requests

Successful merges:

 - #150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing)
 - #151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts)
 - #151871 (don't use env with infer vars)
 - #152591 (Simplify internals of `{Rc,Arc}::default`)
 - #152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned)
 - #152908 (Enable rust.remap-debuginfo in the dist profile)
 - #152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7)
 - #152767 (fix typo in `carryless_mul` macro invocation)
 - #152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`)
 - #152871 (Fix warnings in rs{begin,end}.rs files)
 - #152921 (Add build.rustdoc option to bootstrap config)
 - #152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint)
 - #152937 (remove unneeded reboxing)
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 22, 2026

⌛ Testing commit 168f324 with merge 7c35f94...

Workflow: https://github.com/rust-lang/rust/actions/runs/22273503822

rust-bors bot pushed a commit that referenced this pull request Feb 22, 2026
… r=RalfJung

rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing

All PowerPC64 targets except AIX explicitly set the ABI in the target options. We can therefore stop hardcoding the ABI to be used based on the target environment or OS, except for the AIX special case.

The fallback based on endianness is kept for the sake of compatibility with custom targets.

This makes it so that big endian targets not explicitly accounted for before (powerpc64-unknown-openbsd) and targets that don't use the expected default ABI (big-endian ELFv2 Glibc targets) use the correct ABI in the calling convention code.

The second commit is a tiny change to validate the `llvm_abiname` set on PowerPC64(LE) targets. See the commit messages for details.

CC @RalfJung who pointed out the missing `llvm_abiname` validation
jhpratt added a commit to jhpratt/rust that referenced this pull request Feb 22, 2026
…ec-elf-abi, r=RalfJung

rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing

All PowerPC64 targets except AIX explicitly set the ABI in the target options. We can therefore stop hardcoding the ABI to be used based on the target environment or OS, except for the AIX special case.

The fallback based on endianness is kept for the sake of compatibility with custom targets.

This makes it so that big endian targets not explicitly accounted for before (powerpc64-unknown-openbsd) and targets that don't use the expected default ABI (big-endian ELFv2 Glibc targets) use the correct ABI in the calling convention code.

The second commit is a tiny change to validate the `llvm_abiname` set on PowerPC64(LE) targets. See the commit messages for details.

CC @RalfJung who pointed out the missing `llvm_abiname` validation
@jhpratt
Copy link
Member

jhpratt commented Feb 22, 2026

once again

@bors yield

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 22, 2026

Auto build cancelled. Cancelled workflows:

The next pull request likely to be tested is #152960.

rust-bors bot pushed a commit that referenced this pull request Feb 22, 2026
Rollup of 15 pull requests

Successful merges:

 - #150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing)
 - #151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts)
 - #151871 (don't use env with infer vars)
 - #152591 (Simplify internals of `{Rc,Arc}::default`)
 - #152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned)
 - #152908 (Enable rust.remap-debuginfo in the dist profile)
 - #147859 (reduce the amount of panics in `{TokenStream, Literal}::from_str` calls)
 - #152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7)
 - #152767 (fix typo in `carryless_mul` macro invocation)
 - #152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`)
 - #152871 (Fix warnings in rs{begin,end}.rs files)
 - #152879 (Remove `impl IntoQueryParam<P> for &'a P`.)
 - #152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint)
 - #152937 (remove unneeded reboxing)
 - #152953 (Fix typo in armv7a-vex-v5.md)
@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 22, 2026

⌛ Testing commit 168f324 with merge e59a71a...

Workflow: https://github.com/rust-lang/rust/actions/runs/22275041573

rust-bors bot pushed a commit that referenced this pull request Feb 22, 2026
… r=RalfJung

rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing

All PowerPC64 targets except AIX explicitly set the ABI in the target options. We can therefore stop hardcoding the ABI to be used based on the target environment or OS, except for the AIX special case.

The fallback based on endianness is kept for the sake of compatibility with custom targets.

This makes it so that big endian targets not explicitly accounted for before (powerpc64-unknown-openbsd) and targets that don't use the expected default ABI (big-endian ELFv2 Glibc targets) use the correct ABI in the calling convention code.

The second commit is a tiny change to validate the `llvm_abiname` set on PowerPC64(LE) targets. See the commit messages for details.

CC @RalfJung who pointed out the missing `llvm_abiname` validation
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 22, 2026
…ec-elf-abi, r=RalfJung

rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing

All PowerPC64 targets except AIX explicitly set the ABI in the target options. We can therefore stop hardcoding the ABI to be used based on the target environment or OS, except for the AIX special case.

The fallback based on endianness is kept for the sake of compatibility with custom targets.

This makes it so that big endian targets not explicitly accounted for before (powerpc64-unknown-openbsd) and targets that don't use the expected default ABI (big-endian ELFv2 Glibc targets) use the correct ABI in the calling convention code.

The second commit is a tiny change to validate the `llvm_abiname` set on PowerPC64(LE) targets. See the commit messages for details.

CC @RalfJung who pointed out the missing `llvm_abiname` validation
@JonathanBrouwer
Copy link
Contributor

once again

@bors yield

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 22, 2026

Auto build cancelled. Cancelled workflows:

The next pull request likely to be tested is #152965.

rust-bors bot pushed a commit that referenced this pull request Feb 22, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing)
 - #151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts)
 - #151871 (don't use env with infer vars)
 - #152591 (Simplify internals of `{Rc,Arc}::default`)
 - #152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned)
 - #147859 (reduce the amount of panics in `{TokenStream, Literal}::from_str` calls)
 - #152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7)
 - #152767 (fix typo in `carryless_mul` macro invocation)
 - #152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`)
 - #152871 (Fix warnings in rs{begin,end}.rs files)
 - #152879 (Remove `impl IntoQueryParam<P> for &'a P`.)
 - #152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint)
 - #152937 (remove unneeded reboxing)
 - #152953 (Fix typo in armv7a-vex-v5.md)
rust-bors bot pushed a commit that referenced this pull request Feb 22, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing)
 - #151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts)
 - #151871 (don't use env with infer vars)
 - #152591 (Simplify internals of `{Rc,Arc}::default`)
 - #152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned)
 - #147859 (reduce the amount of panics in `{TokenStream, Literal}::from_str` calls)
 - #152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7)
 - #152767 (fix typo in `carryless_mul` macro invocation)
 - #152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`)
 - #152871 (Fix warnings in rs{begin,end}.rs files)
 - #152879 (Remove `impl IntoQueryParam<P> for &'a P`.)
 - #152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint)
 - #152937 (remove unneeded reboxing)
 - #152953 (Fix typo in armv7a-vex-v5.md)
@RalfJung RalfJung added the relnotes Marks issues that should be documented in the release notes of the next release. label Feb 22, 2026
@rust-bors rust-bors bot merged commit 7360a83 into rust-lang:main Feb 22, 2026
11 of 12 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 22, 2026
rust-timer added a commit that referenced this pull request Feb 22, 2026
Rollup merge of #150468 - Gelbpunkt:rustc-target-callconv-spec-elf-abi, r=RalfJung

rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing

All PowerPC64 targets except AIX explicitly set the ABI in the target options. We can therefore stop hardcoding the ABI to be used based on the target environment or OS, except for the AIX special case.

The fallback based on endianness is kept for the sake of compatibility with custom targets.

This makes it so that big endian targets not explicitly accounted for before (powerpc64-unknown-openbsd) and targets that don't use the expected default ABI (big-endian ELFv2 Glibc targets) use the correct ABI in the calling convention code.

The second commit is a tiny change to validate the `llvm_abiname` set on PowerPC64(LE) targets. See the commit messages for details.

CC @RalfJung who pointed out the missing `llvm_abiname` validation
@Gelbpunkt
Copy link
Contributor Author

Also, @Gelbpunkt do you think this needs to be mentioned in the release notes?

I'm a bit late since you already added the label, sorry! It doesn't hurt to mention it, specifically since this should be a change in behavior for OpenBSD, even if it is a fix. Thanks for getting back to the PR!

github-actions bot pushed a commit to rust-lang/rust-analyzer that referenced this pull request Feb 23, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing)
 - rust-lang/rust#151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts)
 - rust-lang/rust#151871 (don't use env with infer vars)
 - rust-lang/rust#152591 (Simplify internals of `{Rc,Arc}::default`)
 - rust-lang/rust#152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned)
 - rust-lang/rust#147859 (reduce the amount of panics in `{TokenStream, Literal}::from_str` calls)
 - rust-lang/rust#152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7)
 - rust-lang/rust#152767 (fix typo in `carryless_mul` macro invocation)
 - rust-lang/rust#152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`)
 - rust-lang/rust#152871 (Fix warnings in rs{begin,end}.rs files)
 - rust-lang/rust#152879 (Remove `impl IntoQueryParam<P> for &'a P`.)
 - rust-lang/rust#152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint)
 - rust-lang/rust#152937 (remove unneeded reboxing)
 - rust-lang/rust#152953 (Fix typo in armv7a-vex-v5.md)
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Feb 23, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#150468 (rustc_target: callconv: powerpc64: Use the ABI set in target options instead of guessing)
 - rust-lang/rust#151628 (Fix ICE in const eval of packed SIMD types with non-power-of-two element counts)
 - rust-lang/rust#151871 (don't use env with infer vars)
 - rust-lang/rust#152591 (Simplify internals of `{Rc,Arc}::default`)
 - rust-lang/rust#152865 (Fixed ByteStr not padding within its Display trait when no specific alignment is mentioned)
 - rust-lang/rust#147859 (reduce the amount of panics in `{TokenStream, Literal}::from_str` calls)
 - rust-lang/rust#152705 (Test(lib/win/proc): Skip `raw_attributes` doctest under Win7)
 - rust-lang/rust#152767 (fix typo in `carryless_mul` macro invocation)
 - rust-lang/rust#152837 (fix(codegen): Use `body_codegen_attrs` For Caller In `adjust_target_feature_sig`)
 - rust-lang/rust#152871 (Fix warnings in rs{begin,end}.rs files)
 - rust-lang/rust#152879 (Remove `impl IntoQueryParam<P> for &'a P`.)
 - rust-lang/rust#152933 (Start migration for `LintDiagnostic` items by adding API and migrating `LinkerOutput` lint)
 - rust-lang/rust#152937 (remove unneeded reboxing)
 - rust-lang/rust#152953 (Fix typo in armv7a-vex-v5.md)
Comment on lines +109 to +112
let abi = if cx.target_spec().options.abi == Abi::ElfV2 {
ELFv2
} else if cx.target_spec().options.abi == Abi::ElfV1 {
ELFv1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I only just realized that this could also check llvm_abiname -- which is what actually gets sanity-checked in the target spec logic, and it is what actually tells LLVM what to do, so it's the more reliable source of truth.

Can you submit a PR to check llvm_abiname here instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

relnotes Marks issues that should be documented in the release notes of the next release. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.