3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #209043 from sternenseemann/ghc-head-js-backend-try-1

haskellPackages.mkDerivation: make work in pkgsCross.ghcjs
This commit is contained in:
maralorn 2023-01-05 22:11:08 +01:00 committed by GitHub
commit bd2b543537
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 8 deletions

View file

@ -11,7 +11,12 @@ let
in
{ pname
, dontStrip ? (ghc.isGhcjs or false)
# Note that ghc.isGhcjs != stdenv.hostPlatform.isGhcjs.
# ghc.isGhcjs implies that we are using ghcjs, a project separate from GHC.
# (mere) stdenv.hostPlatform.isGhcjs means that we are using GHC's JavaScript
# backend. The latter is a normal cross compilation backend and needs little
# special accomodation.
, dontStrip ? (ghc.isGhcjs or false || stdenv.hostPlatform.isGhcjs)
, version, revision ? null
, sha256 ? null
, src ? fetchurl { url = "mirror://hackage/${pname}-${version}.tar.gz"; inherit sha256; }
@ -171,7 +176,7 @@ let
# Pass the "wrong" C compiler rather than none at all so packages that just
# use the C preproccessor still work, see
# https://github.com/haskell/cabal/issues/6466 for details.
"--with-gcc=${(if stdenv.hasCC then stdenv else buildPackages.stdenv).cc.targetPrefix}cc"
"--with-gcc=${if stdenv.hasCC then "$CC" else "$CC_FOR_BUILD"}"
] ++ optionals stdenv.hasCC [
"--with-ld=${stdenv.cc.bintools.targetPrefix}ld"
"--with-ar=${stdenv.cc.bintools.targetPrefix}ar"
@ -246,7 +251,10 @@ let
allPkgconfigDepends = pkg-configDepends ++ libraryPkgconfigDepends ++ executablePkgconfigDepends ++
optionals doCheck testPkgconfigDepends ++ optionals doBenchmark benchmarkPkgconfigDepends;
depsBuildBuild = [ nativeGhc ];
depsBuildBuild = [ nativeGhc ]
# CC_FOR_BUILD may be necessary if we have no C preprocessor for the host
# platform. See crossCabalFlags above for more details.
++ lib.optionals (!stdenv.hasCC) [ buildPackages.stdenv.cc ];
collectedToolDepends =
buildTools ++ libraryToolDepends ++ executableToolDepends ++
optionals doCheck testToolDepends ++
@ -316,7 +324,9 @@ stdenv.mkDerivation ({
inherit src;
inherit depsBuildBuild nativeBuildInputs;
buildInputs = otherBuildInputs ++ optionals (!isLibrary) propagatedBuildInputs;
buildInputs = otherBuildInputs ++ optionals (!isLibrary) propagatedBuildInputs
# For patchShebangsAuto in fixupPhase
++ optionals stdenv.hostPlatform.isGhcjs [ nodejs ];
propagatedBuildInputs = optionals isLibrary propagatedBuildInputs;
LANG = "en_US.UTF-8"; # GHC needs the locale configured during the Haddock phase.

View file

@ -14554,10 +14554,13 @@ with pkgs;
haskell = callPackage ./haskell-packages.nix { };
haskellPackages = dontRecurseIntoAttrs
# Prefer native-bignum to avoid linking issues with gmp
(if stdenv.hostPlatform.isStatic
then haskell.packages.native-bignum.ghc92
else haskell.packages.ghc92);
# JS backend is only available for GHC >= 9.6
(if stdenv.hostPlatform.isGhcjs
then haskell.packages.native-bignum.ghcHEAD
# Prefer native-bignum to avoid linking issues with gmp
else if stdenv.hostPlatform.isStatic
then haskell.packages.native-bignum.ghc92
else haskell.packages.ghc92);
# haskellPackages.ghc is build->host (it exposes the compiler used to build the
# set, similarly to stdenv.cc), but pkgs.ghc should be host->target to be more

View file

@ -159,6 +159,8 @@ in
/* Javacript */
ghcjs = mapTestOnCross lib.systems.examples.ghcjs {
haskell.packages.ghcjs.hello = nativePlatforms;
haskell.packages.native-bignum.ghcHEAD.hello = nativePlatforms;
haskellPackages.hello = nativePlatforms;
};
/* Linux on Raspberrypi */

View file

@ -345,6 +345,13 @@ let
;
};
};
pkgsCross.ghcjs.haskellPackages = {
inherit (packagePlatforms pkgs.pkgsCross.ghcjs.haskellPackages)
ghc
hello
;
};
})
(versionedCompilerJobs {
# Packages which should be checked on more than the