Skip to content

lib/systems: Adjust stdenv.*Platform.rust.rustcTargetSpec for ELFv2 glibc - #493084

Open
OPNA2608 wants to merge 1 commit into
NixOS:masterfrom
OPNA2608:fix/rust-ppc64-elfv2
Open

OPNA2608 wants to merge 1 commit into
NixOS:masterfrom
OPNA2608:fix/rust-ppc64-elfv2

Conversation

@OPNA2608

@OPNA2608 OPNA2608 commented Feb 22, 2026

Copy link
Copy Markdown
Contributor

Rustc 1.98 added official support for powerpc64-unknown-linux-gnuabielfv2! They just name it not quite that: https://doc.rust-lang.org/nightly/rustc/platform-support/powerpc64-unknown-linux-gnuelfv2.html


Fixes i.e. pkgsCross.ppc64-elfv2.fd.

I don't know if this has come up in your cross ppc64-elfv2 deployments for work, but CC @minijackson just in case.

puna@Yubel ~/D/nixpkgs (wip/ppc64-installer-testing)> file /nix/store/pvsmsnp5ghwvv6mfcac5lcmakk5wqnrq-fd-powerpc64-unknown-linux-gnuabielfv1-10.5.0/bin/fd
/nix/store/pvsmsnp5ghwvv6mfcac5lcmakk5wqnrq-fd-powerpc64-unknown-linux-gnuabielfv1-10.5.0/bin/fd: ELF 64-bit MSB pie executable, 64-bit PowerPC or cisco 7500, Power ELF V1 ABI, version 1 (SYSV), dynamically linked, interpreter /nix/store/1jc1lk03jpvx5vlf25vvblvr56s1zbmm-glibc-powerpc64-unknown-linux-gnuabielfv1-2.42-84/lib/ld64.so.1, for GNU/Linux 3.10.0, not stripped
puna@Yubel ~/D/nixpkgs (wip/ppc64-installer-testing)> file /nix/store/6mr32jpr2s8a7g2c9hhvpvq6p7951ix6-fd-powerpc64-unknown-linux-gnuabielfv2-10.5.0/bin/fd
/nix/store/6mr32jpr2s8a7g2c9hhvpvq6p7951ix6-fd-powerpc64-unknown-linux-gnuabielfv2-10.5.0/bin/fd: ELF 64-bit MSB pie executable, 64-bit PowerPC or cisco 7500, OpenPOWER ELF V2 ABI, version 1 (SYSV), dynamically linked, interpreter /nix/store/78lvs5hjgsx0hh0gv42p93v5xrim2n00-glibc-powerpc64-unknown-linux-gnuabielfv2-2.42-84/lib/ld64.so.2, for GNU/Linux 3.10.0, not stripped
puna@Yubel ~/D/nixpkgs (wip/ppc64-installer-testing)> file /nix/store/rjh7dpvaxanfpkb3h6xcv5d4n8wx31b3-fd-powerpc64-unknown-linux-musl-10.5.0/bin/fd
/nix/store/rjh7dpvaxanfpkb3h6xcv5d4n8wx31b3-fd-powerpc64-unknown-linux-musl-10.5.0/bin/fd: ELF 64-bit MSB pie executable, 64-bit PowerPC or cisco 7500, OpenPOWER ELF V2 ABI, version 1 (SYSV), dynamically linked, interpreter /nix/store/zjrl0qa65qly3mb1jpi2k8w01bv5hq34-musl-powerpc64-unknown-linux-musl-1.2.6/lib/ld-musl-powerpc64.so.1, not stripped
puna@Yubel ~/D/nixpkgs (wip/ppc64-installer-testing)> /nix/store/pvsmsnp5ghwvv6mfcac5lcmakk5wqnrq-fd-powerpc64-unknown-linux-gnuabielfv1-10.5.0/bin/fd 'lomiri\.nix' nixos/tests/
nixos/tests/lomiri.nix
puna@Yubel ~/D/nixpkgs (wip/ppc64-installer-testing)> /nix/store/6mr32jpr2s8a7g2c9hhvpvq6p7951ix6-fd-powerpc64-unknown-linux-gnuabielfv2-10.5.0/bin/fd 'lomiri\.nix' nixos/tests/
nixos/tests/lomiri.nix
puna@Yubel ~/D/nixpkgs (wip/ppc64-installer-testing)> /nix/store/rjh7dpvaxanfpkb3h6xcv5d4n8wx31b3-fd-powerpc64-unknown-linux-musl-10.5.0/bin/fd 'lomiri\.nix' nixos/tests/
nixos/tests/lomiri.nix

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • powerpc64-linux (pkgsCross.ppc64-elfv1.fd, pkgsCross.ppc64-elfv2.fd, pkgsCross.ppc64-musl.fd)
    • aarch64-darwin
  • Tested, as applicable:
  • Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • Package update: when the change is major or breaking.
  • NixOS Release Notes
    • Module addition: when adding a new NixOS module.
    • Module update: when the change is significant.
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.
  • Follows the automation/AI policy.

@nixpkgs-ci
nixpkgs-ci Bot requested review from a team, Mic92, alyssais, winterqt and zowoq February 22, 2026 17:17
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. labels Feb 22, 2026
@emilazy

emilazy commented Feb 22, 2026

Copy link
Copy Markdown
Member

Rust supports JSON target spec files for unsupported platforms, which would be the correct thing to use here; cc @dramforever.

@dramforever

dramforever commented Feb 23, 2026

Copy link
Copy Markdown
Contributor

I'll rebase I have rebased #446668 some time later this week. PTAL

I think this is the nicest way to get custom target JSON working - although having target JSON files in-tree doesn't look particularly nice, I'm hoping that at least it could be temporary, until maaaybe upstream rustc adds a elfv2 variant.

@OPNA2608
OPNA2608 marked this pull request as draft February 28, 2026 12:04
@OPNA2608 OPNA2608 changed the title rustc-unwrapped: Patch to allow targeting ppc64-elfv2 lib.systems.examples: Add rustcTargetSpec for powerpc64 glibc examples Mar 8, 2026
@OPNA2608
OPNA2608 force-pushed the fix/rust-ppc64-elfv2 branch from fbac021 to f5b1b6c Compare March 8, 2026 11:52
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 6.topic: lib The Nixpkgs function library and removed 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 6.topic: rust General-purpose programming language emphasizing performance, type safety, and concurrency. labels Mar 8, 2026
@OPNA2608

OPNA2608 commented Mar 8, 2026

Copy link
Copy Markdown
Contributor Author

Changed this to instead add rustcTargetSpec settings for the ppc64-elfv1 & ppc64-elfv2 examples, and added a JSON spec file for the ELFv2 target generated with the help of Rust 1.94.0 on staging (hence still the staging target).

Do we have anything in /pkgs/top-level/release-cross.nix that actually checks Rust cross, so there's some automated tests of such target specs? Would it make sense to add one (i.e. fd)? Rust docs say that the JSON's format isn't stable and should be pinned to a compiler version, so it'd be nice to have some test of this.

Comment thread lib/systems/examples.nix Outdated
@nixpkgs-ci nixpkgs-ci Bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Mar 9, 2026
@OPNA2608
OPNA2608 force-pushed the fix/rust-ppc64-elfv2 branch from f5b1b6c to 81d59f8 Compare March 10, 2026 10:51
@OPNA2608
OPNA2608 marked this pull request as ready for review March 10, 2026 12:01
@nixpkgs-ci
nixpkgs-ci Bot requested a review from a team March 10, 2026 12:26
@OPNA2608 OPNA2608 mentioned this pull request Mar 16, 2026
13 tasks
@alyssais

Copy link
Copy Markdown
Member

This will sadly be broken by #510674, which deprecates JSON target specs :(

@OPNA2608

Copy link
Copy Markdown
Contributor Author

Hmm… So back to patching /compiler/rustc_target/src/spec/targets/powerpc64_unknown_linux_gnu.rs then, like in fbac021?

@OPNA2608
OPNA2608 marked this pull request as draft April 19, 2026 10:31
@alyssais

alyssais commented Apr 19, 2026 via email

Copy link
Copy Markdown
Member

@OPNA2608

Copy link
Copy Markdown
Contributor Author

Based on the conversations in rust-lang/rust#151528, rust-lang/rust#155620, and LibreELEC/LibreELEC.tv#11205, I guess this should go back to making changes in /compiler/rustc_target/src/spec/targets/ for now.

I couldn't find an example of how to i.e. make a powerpc64-unknown-linux-gnuabielfv2.rs that inherits the base settings from powerpc64-unknown-linux-gnu.rs, and I didn't plan on learning Rust just to fix a target that I realistically won't even use due to other issues, so I'd change this PR back to ~ the state of fbac021 if that's fine with everyone?

@alyssais

Copy link
Copy Markdown
Member

If you're not otherwise going to use it, does making any change here justify the complexity increase in our rustc packaging? I'm all for supporting exotic platforms, but it seems silly to go out of our way to support something upstream doesn't, and that is also not useful for other reasons.

@OPNA2608

Copy link
Copy Markdown
Contributor Author

I know we have users of powerpc64-unknown-linux-gnuabielfv2 (#451088 (comment), CC @minijackson), and people who IIRC would prolly prefer for us to have gnuabielfv2 as our default ABI again (CC @amaanq). I'm fine with ELFv1 myself, but I can test ELFv2 stuff on hardware, so I don't mind doing a little bit of work to support it.

@OPNA2608

Copy link
Copy Markdown
Contributor Author

Should maybe be possible to just change the target adjustment in /lib/systems/default.nix soon: rust-lang/rust#144220

…libc

It is now properly supported by rustc, ABI component of the triplet just differs from the one recognised by GCC and
Clang.
@OPNA2608
OPNA2608 force-pushed the fix/rust-ppc64-elfv2 branch from 81d59f8 to 62b9f45 Compare September 12, 2026 22:50
@OPNA2608 OPNA2608 changed the title lib.systems.examples: Add rustcTargetSpec for powerpc64 glibc examples lib/systems: Adjust stdenv.*Platform.rust.rustcTargetSpec for ELFv2 glibc Sep 12, 2026
@OPNA2608

Copy link
Copy Markdown
Contributor Author

Switched to adjusting our rustcTargetSpec to map GCC powerpc64-unknown-linux-gnuabielfv2 target -> rustc 1.98's new powerpc64-unknown-linux-gnuelfv2 target.

@OPNA2608
OPNA2608 changed the base branch from staging to master September 12, 2026 23:14
@OPNA2608
OPNA2608 marked this pull request as ready for review September 12, 2026 23:15
@nixpkgs-ci nixpkgs-ci Bot closed this Sep 12, 2026
@nixpkgs-ci nixpkgs-ci Bot reopened this Sep 12, 2026
@github-project-automation github-project-automation Bot moved this from Done to Backlog in Nixpkgs Lib Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: lib The Nixpkgs function library 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

5 participants