Skip to content

haskell.compiler: Apply patches to fix PPC64 ELFv2 support#462247

Merged
wolfgangwalther merged 1 commit intoNixOS:stagingfrom
OPNA2608:add/ghc-ppc64-elfv2
Jan 10, 2026
Merged

haskell.compiler: Apply patches to fix PPC64 ELFv2 support#462247
wolfgangwalther merged 1 commit intoNixOS:stagingfrom
OPNA2608:add/ghc-ppc64-elfv2

Conversation

@OPNA2608
Copy link
Contributor

@OPNA2608 OPNA2608 commented Nov 16, 2025

Fixes pkgsCross.ppc64-elfv2.haskellPackages.hello

Things done

  • Built on platform:
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • 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.

Add a 👍 reaction to pull requests you find important.

@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: haskell General-purpose, statically typed, purely functional programming language labels Nov 16, 2025
@alexfmpe
Copy link
Member

alexfmpe commented Nov 18, 2025

Dunno what branch this needs to go against yet

Should target staging going by the "5001+" rebuilds label

Doesn't apply on GHC 9.8, needs manual backport

As in, patch fails? Then let's add a versionAtLeast. 9.10 is the default anyway (which is why this causes so many rebuilds) so I think the few if any people people wanting this platform/ghc can just update ghc

@OPNA2608
Copy link
Contributor Author

OPNA2608 commented Nov 18, 2025

Should target staging going by the "5001+" rebuilds label

Yepyep, I'll fix that before undrafting. I just don't have the spoons for this rn, so it'll take abit. Hence, draft.

As in, patch fails?

Fails to apply, yeah.


Edit:

9.10 is the default anyway (which is why this causes so many rebuilds) so I think the few if any people people wanting this platform/ghc can just update ghc

Actually, 9.4 is kind of being used for testing cross-compilation of GHC, and maybe future bootstrapping of our GHCs via tarballs of cross-compiled static GHC builds. On powerpc64 that GHC would have to be ELFv2.

@OPNA2608 OPNA2608 force-pushed the add/ghc-ppc64-elfv2 branch 2 times, most recently from c7f73c3 to efdb95c Compare November 24, 2025 16:33
@OPNA2608 OPNA2608 changed the base branch from master to staging November 24, 2025 16:34
@nixpkgs-ci nixpkgs-ci bot closed this Nov 24, 2025
@nixpkgs-ci nixpkgs-ci bot reopened this Nov 24, 2025
@OPNA2608
Copy link
Contributor Author

Made the fetchpatched version of the patch work with Hadrian-using GHCs <=9.8, and manually backported it to GHC 9.4 to allow building of a cross-compiled GHC. Should be fine now, I think.

@OPNA2608 OPNA2608 marked this pull request as ready for review November 24, 2025 16:48
@OPNA2608 OPNA2608 force-pushed the add/ghc-ppc64-elfv2 branch 2 times, most recently from cac83c1 to 537d452 Compare December 11, 2025 13:28
@OPNA2608

This comment was marked as resolved.

@OPNA2608 OPNA2608 force-pushed the add/ghc-ppc64-elfv2 branch from 537d452 to b75e92b Compare December 11, 2025 13:45
@wolfgangwalther

This comment was marked as resolved.

Copy link
Contributor

@wolfgangwalther wolfgangwalther left a comment

Choose a reason for hiding this comment

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

Diff LGTM; was not able to test.

@nixpkgs-ci nixpkgs-ci bot added the 12.approvals: 1 This PR was reviewed and approved by one person. label Dec 17, 2025
@nixpkgs-ci nixpkgs-ci bot added the 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. label Dec 17, 2025
@alexfmpe
Copy link
Member

I can test a couple builds sometime this week if we want more confidence?

@wolfgangwalther
Copy link
Contributor

Sure, that would be appreciated.

@alexfmpe
Copy link
Member

$ nix-build -A pkgsCross.ppc64-musl.haskellPackages.hello
/nix/store/xfklsd7j6ks01ybz4rk5jmx4zdl06xfr-hello-powerpc64-unknown-linux-musl-1.0.0.2

$(nix-build -A qemu-user)/bin/qemu-ppc64 /nix/store/xfklsd7j6ks01ybz4rk5jmx4zdl06xfr-hello-powerpc64-unknown-linux-musl-1.0.0.2/bin/hello
Hello, World!
$ nix-build -A pkgsCross.ppc64-elfv2.haskellPackages.hello
/nix/store/8ymx3z3g75sgfsfn5pfqvl43g6k1fbj2-hello-powerpc64-unknown-linux-gnuabielfv2-1.0.0.2

$ $(nix-build -A qemu-user)/bin/qemu-ppc64 /nix/store/8ymx3z3g75sgfsfn5pfqvl43g6k1fbj2-hello-powerpc64-unknown-linux-gnuabielfv2-1.0.0.2/bin/hello
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
[1]    2457937 segmentation fault (core dumped)  ./result-qemu-user/bin/qemu-ppc64 result/bin/hello
$ nix-build -A pkgsCross.ppc64-elfv2.haskell.compiler.ghc94 --keep-going
error: builder for '/nix/store/lhivz1xls2qlz8mhi7l1s064hqrfif90-gcc-15.2.0-powerpc64-unknown-linux-gnuabielfv2.drv' failed with exit code 2;

@OPNA2608 OPNA2608 marked this pull request as draft December 19, 2025 21:13
@OPNA2608 OPNA2608 force-pushed the add/ghc-ppc64-elfv2 branch from b75e92b to 4abca77 Compare December 19, 2025 21:13
@OPNA2608
Copy link
Contributor Author

OPNA2608 commented Dec 19, 2025

$ $(nix-build -A qemu-user)/bin/qemu-ppc64 /nix/store/8ymx3z3g75sgfsfn5pfqvl43g6k1fbj2-hello-powerpc64-unknown-linux-gnuabielfv2-1.0.0.2/bin/hello
qemu: uncaught target signal 11 (Segmentation fault) - core dumped
[1]    2457937 segmentation fault (core dumped)  ./result-qemu-user/bin/qemu-ppc64 result/bin/hello

Can confirm the crash on hardware. Unfortunately, we seem to have more fundamental issues with glibc-elfv2 when it comes to native building, so my focus is mainly on glibc-elfv1 (default glibc ABI on this platform, our default for pkgs) & musl-elfv2 (only ABI musl supports, pkgsStatic).


ppc64-elfv1 & ppc64-musl hellos work.

puna@Yubel ~> /nix/store/n56nxj73hw6s45cix6mjfs207iqqcjyq-hello-powerpc64-unknown-linux-gnuabielfv1-1.0.0.2/bin/hello 
Hello, World!
puna@Yubel ~> /nix/store/wfi73nz25xvcrhia9vzdcxrh4jgn6676-hello-powerpc64-unknown-linux-musl-1.0.0.2/bin/hello 
Hello, World!

ghc94s build, but don't run.

puna@Yubel ~> /nix/store/dhv857lm0ahyfbg7np9jprg5j0b9nkz1-ghc-powerpc64-unknown-linux-gnuabielfv1-9.4.8/bin/ghci
fish: Job 1, '/nix/store/dhv857lm0ahyfbg7np9j…' terminated by signal SIGSEGV (Address boundary error)
puna@Yubel ~ [SIGSEGV]> /nix/store/p5s6ai4z34m72qr30174vwbdcq6qhc26-ghc-powerpc64-unknown-linux-gnuabielfv2-9.4.8/bin/ghci
fish: Job 1, '/nix/store/p5s6ai4z34m72qr30174…' terminated by signal SIGSEGV (Address boundary error)
puna@Yubel ~ [SIGSEGV]> /nix/store/lfqpkyr81rld6sb25z8h8lzhisssh88m-ghc-musl-powerpc64-unknown-linux-musl-9.4.8/bin/ghci
fish: Job 1, '/nix/store/lfqpkyr81rld6sb25z8h…' terminated by signal SIGSEGV (Address boundary error)

Identical to current behaviour of ppc64-elfv1 on master. I'm not gonna try it, but flipping enableUnregisterised to true might fix them. Noted in #439258 (comment), I think the suitability of cross-compiled ghc94 is still getting looked into though?

@OPNA2608 OPNA2608 marked this pull request as ready for review December 20, 2025 08:28
@wolfgangwalther
Copy link
Contributor

ghc94s build, but don't run.

I'm unsure about the patch for GHC 9.4, if we can't verify that it works. Should we postpone that until these run in the first place?

@OPNA2608
Copy link
Contributor Author

OPNA2608 commented Dec 29, 2025

Seems like ppc64le has similar issues with cross-compiled registerised GHC segfaulting. Maybe a general issue on (64-bit) POWER? #439258 (comment)

I'm fine with pulling the GHC 9.4 changes out for now until they're actually needed (bootstrapping off of cross-compiled GHC).

Edit: Extracted GHC 9.4 changes into #475036.

@OPNA2608 OPNA2608 force-pushed the add/ghc-ppc64-elfv2 branch from 4abca77 to fddddd0 Compare December 29, 2025 12:51
@OPNA2608 OPNA2608 changed the title haskell.compiler: Backport PPC64 ELFv2 support haskell.compiler: Apply patches to fix PPC64 ELFv2 support Dec 29, 2025
@wolfgangwalther wolfgangwalther added this pull request to the merge queue Jan 10, 2026
Merged via the queue into NixOS:staging with commit f57fd10 Jan 10, 2026
29 of 31 checks passed
@vcunat
Copy link
Member

vcunat commented Jan 21, 2026

Apparently you don't want to apply it to 9.12.3?

applying patch /nix/store/frl3xlnjgsiisd57qzhsl64ch3l7p8yk-ghc-rts-Fix-compile-on-powerpc64-elf-v1.patch
patching file rts/StgCRunAsm.S
Reversed (or previously applied) patch detected!  Assume -R? [n] 

It seems that it's the only version with this problem, at least among those built on Hydra:
https://hydra.nixos.org/eval/1822157?filter=haskell.compiler&compare=1822139#tabs-now-fail

@OPNA2608
Copy link
Contributor Author

OPNA2608 commented Jan 21, 2026

Looks like this was backported upstream, yeah.

https://gitlab.haskell.org/ghc/ghc/-/merge_requests/13894#note_642957
https://gitlab.haskell.org/ghc/ghc/-/merge_requests/14835

      ++ lib.optionals ((lib.versions.majorMinor haskell.compiler.ghc9123.version == "9.12" && lib.versionOlder haskell.compiler.ghc9123.version "9.12.3") || (lib.versions.majorMinor haskell.compiler.ghc9123.version != "9.12" && lib.versionOlder haskell.compiler.ghc9123.version "9.14.1")) [

I guess?

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

Labels

6.topic: haskell General-purpose, statically typed, purely functional programming language 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: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants