Commit 45aae5c2 authored by sternenseemann's avatar sternenseemann
Browse files

haskell.compiler.ghc9*: work around output cycles on aarch64-darwin

Due to link time dead code elimination not working on aarch64-darwin,
some unused store path references in Paths_* modules are retained. This
causes reference cycles when a separate `bin` output is used.

To prevent this, add a patch to Cabal as shipped by GHC which infers
based on the installation layout (which is influenced by
enableSeparateBinOutput, enableSeparateDataOutput etc. in a Nix build)
which references can be retained without causing a reference cycle. This
ensures that packages that were fine with a bin output will also work on
aarch64-darwin. Packages that cause a reference cycle anyways (by
actually using references that do cause one) fail due to a missing
symbol – here we are trading the overall benefit for a more confusing
error message.

For details, refer to the explanation comment in the patch.
parent 41c538f8
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -203,6 +203,14 @@ stdenv.mkDerivation (rec {
      extraPrefix = "libraries/Cabal/";
      sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY=";
    })
  ] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
    # Prevent the paths module from emitting symbols that we don't use
    # when building with separate outputs.
    #
    # These cause problems as they're not eliminated by GHC's dead code
    # elimination on aarch64-darwin. (see
    # https://github.com/NixOS/nixpkgs/issues/140774 for details).
    ./Cabal-3.6-paths-fix-cycle-aarch64-darwin.patch
  ];

  postPatch = "patchShebangs .";
+8 −0
Original line number Diff line number Diff line
@@ -203,6 +203,14 @@ stdenv.mkDerivation (rec {
      extraPrefix = "libraries/Cabal/";
      sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY=";
    })
  ] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
    # Prevent the paths module from emitting symbols that we don't use
    # when building with separate outputs.
    #
    # These cause problems as they're not eliminated by GHC's dead code
    # elimination on aarch64-darwin. (see
    # https://github.com/NixOS/nixpkgs/issues/140774 for details).
    ./Cabal-3.6-paths-fix-cycle-aarch64-darwin.patch
  ];

  postPatch = "patchShebangs .";
+8 −0
Original line number Diff line number Diff line
@@ -203,6 +203,14 @@ stdenv.mkDerivation (rec {
      extraPrefix = "libraries/Cabal/";
      sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY=";
    })
  ] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
    # Prevent the paths module from emitting symbols that we don't use
    # when building with separate outputs.
    #
    # These cause problems as they're not eliminated by GHC's dead code
    # elimination on aarch64-darwin. (see
    # https://github.com/NixOS/nixpkgs/issues/140774 for details).
    ./Cabal-3.6-paths-fix-cycle-aarch64-darwin.patch
  ];

  postPatch = "patchShebangs .";
+8 −0
Original line number Diff line number Diff line
@@ -210,6 +210,14 @@ stdenv.mkDerivation (rec {
      extraPrefix = "libraries/Cabal/";
      sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY=";
    })
  ] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
    # Prevent the paths module from emitting symbols that we don't use
    # when building with separate outputs.
    #
    # These cause problems as they're not eliminated by GHC's dead code
    # elimination on aarch64-darwin. (see
    # https://github.com/NixOS/nixpkgs/issues/140774 for details).
    ./Cabal-3.6-paths-fix-cycle-aarch64-darwin.patch
  ];

  postPatch = "patchShebangs .";
+602 −0

File added.

Preview size limit exceeded, changes collapsed.