Skip to content

Add powerpc64-unknown-linux-gnuelfv2 target #144220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Gelbpunkt
Copy link
Contributor

@Gelbpunkt Gelbpunkt commented Jul 20, 2025

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.

The ELFv2 ABI is the preferred ABI for powerpc64 when compatibility with ELFv1 is not required and therefore used by e.g. distributions that were bootstrapped after the introduction of ELFv2.

Copying the target tier policy:

A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)

That would be me.

Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.

This is an interesting one, because I'm not aware of any toolchain that has a target triple for ppc64 + glibc + ELFv2, even though it is a totally valid combination and actively in used by some distributions. Clang and GCC both simply use -target powerpc64-unknown-linux-gnu -mabi=elfv2 to my knowledge (and cross-toolchains should be using --with-abi=elfv2 when configuring GCC). However, the chosen name should be somewhat in line with the other existing targets with special ABIs. Renaming powerpc64-unknown-linux-gnu to powerpc64-unknown-linux-gnuelfv1 at the same time to avoid ambiguity would've been an interesting idea, but it'd be a breaking change to a tier 2 target.

Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.

This target isn't any different than the ELFv1 target in this regard.

Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.

Nothing to comment on here on my end.

Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.

This target implements the entire standard library.

The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.

Documentation can be found in the markdown document added by this PR.

Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via @) to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.

Roger that :)

Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.

This PR doesn't touch any other targets.

Tier 3 targets must be able to produce assembly using at least one of rustc's supported backends from any host target. (Having support in a fork of the backend is not sufficient, it must be upstream.)

The LLVM backend works.

r? compiler

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 20, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 20, 2025

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

Some changes occurred in src/doc/rustc/src/platform-support

cc @Noratrieb

@rust-log-analyzer

This comment has been minimized.

@Gelbpunkt
Copy link
Contributor Author

Gelbpunkt commented Jul 20, 2025

Interesting, seems like a usecase like this one in particular is currently not intended, see here. The explicitly set ABI is processed in create_informational_target_machine, but apparently it doesn't make it through to the final data layout calculated.

EDIT: This is an LLVM bug, it doesn't reset the data layout when the ABI is explicitly set, while it does on ARM

@Gelbpunkt
Copy link
Contributor Author

Gelbpunkt commented Jul 20, 2025

LLVM side of the problem should hopefully get fixed by llvm/llvm-project#149725, I'll have to figure out how to get the bundled LLVM to use the patch in order to verify it it works!

@Gelbpunkt Gelbpunkt force-pushed the powerpc64-unknown-linux-gnuelfv2 branch from 255b058 to 755a1c9 Compare July 20, 2025 18:23
@rustbot rustbot added the A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. label Jul 20, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 20, 2025

⚠️ Warning ⚠️

  • Some commits in this PR modify submodules.

@Gelbpunkt Gelbpunkt force-pushed the powerpc64-unknown-linux-gnuelfv2 branch from 755a1c9 to ae5d567 Compare July 20, 2025 18:25
@rust-log-analyzer

This comment has been minimized.

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.

Signed-off-by: Jens Reidel <[email protected]>
@Gelbpunkt Gelbpunkt force-pushed the powerpc64-unknown-linux-gnuelfv2 branch from ae5d567 to d7200f0 Compare July 20, 2025 19:32
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu-llvm-19-1 failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
failures:

---- [assembly] tests/assembly/targets/targets-elf.rs#powerpc64_unknown_linux_gnuelfv2 stdout ----

error in revision `powerpc64_unknown_linux_gnuelfv2`: auxiliary build of /checkout/tests/auxiliary/minicore.rs failed to compile: 
status: exit status: 1
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/tests/auxiliary/minicore.rs" "-Zthreads=1" "-Zsimulate-remapped-rust-src-base=/rustc/FAKE_PREFIX" "-Ztranslate-remapped-path-to-local-path=no" "-Z" "ignore-directory-in-diagnostics-source-blocks=/cargo" "-Z" "ignore-directory-in-diagnostics-source-blocks=/checkout/vendor" "--sysroot" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage2" "--cfg" "powerpc64_unknown_linux_gnuelfv2" "--check-cfg" "cfg(test,FALSE,aarch64_be_unknown_linux_gnu,aarch64_be_unknown_linux_gnu_ilp32,aarch64_be_unknown_netbsd,aarch64_kmc_solid_asp3,aarch64_linux_android,aarch64_nintendo_switch_freestanding,aarch64_unknown_freebsd,aarch64_unknown_fuchsia,aarch64_unknown_hermit,aarch64_unknown_illumos,aarch64_unknown_linux_gnu,aarch64_unknown_linux_gnu_ilp32,aarch64_unknown_linux_musl,aarch64_unknown_linux_ohos,aarch64_unknown_netbsd,aarch64_unknown_none,aarch64_unknown_none_softfloat,aarch64_unknown_nto_qnx700,aarch64_unknown_nto_qnx710,aarch64_unknown_nto_qnx710_iosock,aarch64_unknown_nto_qnx800,aarch64_unknown_openbsd,aarch64_unknown_redox,aarch64_unknown_teeos,aarch64_unknown_nuttx,aarch64_unknown_trusty,aarch64_wrs_vxworks,arm_linux_androideabi,arm_unknown_linux_gnueabi,arm_unknown_linux_gnueabihf,arm_unknown_linux_musleabi,arm_unknown_linux_musleabihf,armeb_unknown_linux_gnueabi,armebv7r_none_eabi,armebv7r_none_eabihf,armv4t_none_eabi,armv4t_unknown_linux_gnueabi,armv5te_none_eabi,armv5te_unknown_linux_gnueabi,armv5te_unknown_linux_musleabi,armv5te_unknown_linux_uclibceabi,armv6_unknown_freebsd,armv6_unknown_netbsd_eabihf,armv6k_nintendo_3ds,armv7_linux_androideabi,armv7_rtems_eabihf,armv7_sony_vita_newlibeabihf,armv7_unknown_freebsd,armv7_unknown_linux_gnueabi,armv7_unknown_linux_gnueabihf,armv7_unknown_linux_musleabi,armv7_unknown_linux_musleabihf,armv7_unknown_linux_ohos,armv7_unknown_linux_uclibceabi,armv7_unknown_linux_uclibceabihf,armv7_unknown_netbsd_eabihf,armv7_unknown_trusty,armv7_wrs_vxworks_eabihf,armv7a_kmc_solid_asp3_eabi,armv7a_kmc_solid_asp3_eabihf,armv7a_none_eabi,armv7a_none_eabihf,armv7a_nuttx_eabi,armv7a_nuttx_eabihf,armv7r_none_eabi,armv7r_none_eabihf,armv8r_none_eabihf,hexagon_unknown_linux_musl,hexagon_unknown_none_elf,i686_pc_nto_qnx700,i586_unknown_linux_gnu,i586_unknown_linux_musl,i586_unknown_netbsd,i586_unknown_redox,i686_linux_android,i686_unknown_freebsd,i686_unknown_haiku,i686_unknown_hurd_gnu,i686_unknown_linux_gnu,i686_unknown_linux_musl,i686_unknown_netbsd,i686_unknown_openbsd,i686_wrs_vxworks,loongarch32_unknown_none,loongarch32_unknown_none_softfloat,loongarch64_unknown_linux_gnu,loongarch64_unknown_linux_musl,loongarch64_unknown_linux_ohos,loongarch64_unknown_none,loongarch64_unknown_none_softfloat,m68k_unknown_linux_gnu,m68k_unknown_none_elf,mips64_openwrt_linux_musl,mips64_unknown_linux_gnuabi64,mips64_unknown_linux_muslabi64,mips64el_unknown_linux_gnuabi64,mips64el_unknown_linux_muslabi64,mips_unknown_linux_gnu,mips_unknown_linux_musl,mips_unknown_linux_uclibc,mips_mti_none_elf,mipsel_mti_none_elf,mipsel_sony_psp,mipsel_sony_psx,mipsel_unknown_linux_gnu,mipsel_unknown_linux_musl,mipsel_unknown_linux_uclibc,mipsel_unknown_netbsd,mipsel_unknown_none,mipsisa32r6_unknown_linux_gnu,mipsisa32r6el_unknown_linux_gnu,mipsisa64r6_unknown_linux_gnuabi64,mipsisa64r6el_unknown_linux_gnuabi64,msp430_none_elf,powerpc64_unknown_freebsd,powerpc64_unknown_linux_gnu,powerpc64_unknown_linux_gnuelfv2,powerpc64_unknown_linux_musl,powerpc64_unknown_openbsd,powerpc64_wrs_vxworks,powerpc64le_unknown_freebsd,powerpc64le_unknown_linux_gnu,powerpc64le_unknown_linux_musl,powerpc_unknown_freebsd,powerpc_unknown_linux_gnu,powerpc_unknown_linux_gnuspe,powerpc_unknown_linux_musl,powerpc_unknown_linux_muslspe,powerpc_unknown_netbsd,powerpc_unknown_openbsd,powerpc_wrs_vxworks,powerpc_wrs_vxworks_spe,riscv32_wrs_vxworks,riscv32e_unknown_none_elf,riscv32em_unknown_none_elf,riscv32emc_unknown_none_elf,riscv32gc_unknown_linux_gnu,riscv32gc_unknown_linux_musl,riscv32i_unknown_none_elf,riscv32im_risc0_zkvm_elf,riscv32im_unknown_none_elf,riscv32ima_unknown_none_elf,riscv32imac_esp_espidf,riscv32imac_unknown_none_elf,riscv32imac_unknown_xous_elf,riscv32imafc_unknown_none_elf,riscv32imafc_esp_espidf,riscv32imc_esp_espidf,riscv32imc_unknown_none_elf,riscv64_linux_android,riscv64_wrs_vxworks,riscv64gc_unknown_freebsd,riscv64gc_unknown_fuchsia,riscv64gc_unknown_hermit,riscv64gc_unknown_linux_gnu,riscv64gc_unknown_linux_musl,riscv64gc_unknown_netbsd,riscv64gc_unknown_none_elf,riscv64gc_unknown_openbsd,riscv64imac_unknown_none_elf,s390x_unknown_linux_gnu,s390x_unknown_linux_musl,sparc64_unknown_linux_gnu,sparc64_unknown_netbsd,sparc64_unknown_openbsd,sparc_unknown_linux_gnu,sparc_unknown_none_elf,sparcv9_sun_solaris,thumbv4t_none_eabi,thumbv5te_none_eabi,thumbv6m_none_eabi,thumbv7em_none_eabi,thumbv7em_none_eabihf,thumbv7m_none_eabi,thumbv7neon_linux_androideabi,thumbv7neon_unknown_linux_gnueabihf,thumbv7neon_unknown_linux_musleabihf,thumbv8m_base_none_eabi,thumbv8m_main_none_eabi,thumbv8m_main_none_eabihf,wasm32_unknown_emscripten,wasm32_unknown_unknown,wasm32v1_none,wasm32_wasip1,wasm32_wasip1_threads,wasm32_wasip2,wasm32_wali_linux_musl,wasm64_unknown_unknown,x86_64_fortanix_unknown_sgx,x86_64_linux_android,x86_64_lynx_lynxos178,x86_64_pc_nto_qnx710,x86_64_pc_nto_qnx710_iosock,x86_64_pc_nto_qnx800,x86_64_pc_solaris,x86_64_unikraft_linux_musl,x86_64_unknown_dragonfly,x86_64_unknown_freebsd,x86_64_unknown_fuchsia,x86_64_unknown_haiku,x86_64_unknown_hurd_gnu,x86_64_unknown_hermit,x86_64_unknown_illumos,x86_64_unknown_l4re_uclibc,x86_64_unknown_linux_gnu,x86_64_unknown_linux_gnux32,x86_64_unknown_linux_musl,x86_64_unknown_linux_ohos,x86_64_unknown_linux_none,x86_64_unknown_netbsd,x86_64_unknown_none,x86_64_unknown_openbsd,x86_64_unknown_redox,x86_64_unknown_trusty,x86_64_wrs_vxworks,thumbv6m_nuttx_eabi,thumbv7a_nuttx_eabi,thumbv7a_nuttx_eabihf,thumbv7m_nuttx_eabi,thumbv7em_nuttx_eabi,thumbv7em_nuttx_eabihf,thumbv8m_base_nuttx_eabi,thumbv8m_main_nuttx_eabi,thumbv8m_main_nuttx_eabihf,riscv32imc_unknown_nuttx_elf,riscv32imac_unknown_nuttx_elf,riscv32imafc_unknown_nuttx_elf,riscv64imac_unknown_nuttx_elf,riscv64gc_unknown_nuttx_elf)" "-O" "-Cdebug-assertions=no" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/assembly/targets/targets-elf.powerpc64_unknown_linux_gnuelfv2/libminicore.rlib" "-A" "unused" "-A" "internal_features" "-A" "unused_parens" "-A" "unused_braces" "-Crpath" "-Cdebuginfo=0" "--target" "powerpc64-unknown-linux-gnuelfv2" "-Cpanic=abort" "-Cforce-unwind-tables=yes" "--crate-type" "rlib" "-Cpanic=abort"
stdout: none
--- stderr -------------------------------
error: data-layout for target `powerpc64-unknown-linux-gnuelfv2`, `E-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512`, differs from LLVM target's `powerpc64-unknown-linux-gnu` default layout, `E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512`

error: aborting due to 1 previous error
------------------------------------------


Comment on lines +27 to +28
url = https://github.com/Gelbpunkt/llvm-project.git
branch = rust-ppc64-gnu-elfv2
Copy link
Member

@jieyouxu jieyouxu Jul 21, 2025

Choose a reason for hiding this comment

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

Remark: this is fine for experimenting, but we can't land it in master with a fork. (I assume this is blocked on the upstream LLVM fix?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's blocked on the fix, but I'm not sure what to do afterwards. I guess it could be included in the Rust LLVM fork, but it still won't be included in some of the builders that use the old system LLVM. Those will fail CI like the aarch64-gnu-llvm-19-1 job above

@jieyouxu
Copy link
Member

@rustbot author
r? compiler_leads

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 21, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 21, 2025

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot assigned davidtwco and unassigned compiler-errors Jul 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-LLVM Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) 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.

6 participants