ghcWithPackages: expose targetPrefix; tests.haskell.ghcWithPackages: verify -fllvm works with useLLVM (#441471)

This commit is contained in:
sternenseemann
2025-09-11 12:49:20 +00:00
committed by GitHub
2 changed files with 27 additions and 6 deletions

View File

@@ -178,7 +178,7 @@ else
+ postBuild;
preferLocalBuild = true;
passthru = {
inherit (ghc) version meta;
inherit (ghc) version meta targetPrefix;
hoogle = hoogleWithPackages';

View File

@@ -1,6 +1,7 @@
{
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
'';
}