Unverified Commit 7caff6e6 authored by sternenseemann's avatar sternenseemann Committed by GitHub
Browse files

ghcWithPackages: expose targetPrefix; tests.haskell.ghcWithPackages: verify...

 ghcWithPackages: expose targetPrefix; tests.haskell.ghcWithPackages: verify -fllvm works with useLLVM (#441471)
parents fc6467f9 49ac23d7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ else
    + postBuild;
    preferLocalBuild = true;
    passthru = {
      inherit (ghc) version meta;
      inherit (ghc) version meta targetPrefix;

      hoogle = hoogleWithPackages';

+26 −5
Original line number Diff line number Diff line
{
  lib,
  runCommand,
  runCommandCC,
  haskellPackages,
}:

@@ -21,16 +22,19 @@ lib.recurseIntoAttrs {

  # See: https://github.com/NixOS/nixpkgs/pull/224542
  regression-224542 =
    let
      ghc = haskellPackages.ghcWithPackages (hsPkgs: [
        hsPkgs.hspec
      ]);
    in
    runCommand "regression-224542"
      {
        buildInputs = [
          (haskellPackages.ghcWithPackages (hsPkgs: [
            hsPkgs.hspec
          ]))
        nativeBuildInputs = [
          ghc
        ];
      }
      ''
        ghc --interactive \
        ${ghc.targetPrefix}ghc --interactive \
          -Werror=unrecognised-warning-flags \
          -Werror=missed-extra-shared-lib \
          2>&1 \
@@ -45,4 +49,21 @@ lib.recurseIntoAttrs {

        touch $out
      '';

  use-llvm =
    let
      ghc = (haskellPackages.ghcWithPackages.override { useLLVM = true; }) (_: [ ]);
    in
    runCommandCC "ghc-with-packages-use-llvm"
      {
        nativeBuildInputs = [ ghc ];
      }
      ''
        echo 'main = pure ()' > test.hs
        # -ddump-llvm is unnecessary, but nice for visual feedback in the build log
        ${ghc.targetPrefix}ghc --make -fllvm -keep-llvm-files -ddump-llvm test.hs
        # Did we actually use the LLVM backend?
        test -f test.ll
        touch $out
      '';
}