mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 23:36:17 +01:00
Fix GHCJS HEAD patch; support GHCJS libdir link; use full ghcEnv for GHCJS
Original:
f3110651c8
(With some tweaks from @cstrahan)
closes #23199
This commit is contained in:
parent
7d356ff696
commit
4b77d425aa
5 changed files with 31 additions and 15 deletions
|
@ -1,9 +1,10 @@
|
|||
{ stdenv, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
|
||||
{ stdenv, lib, fetchurl, fetchpatch, bootPkgs, perl, ncurses, libiconv, binutils, coreutils
|
||||
, hscolour, patchutils, sphinx
|
||||
|
||||
# If enabled GHC will be build with the GPL-free but slower integer-simple
|
||||
# library instead of the faster but GPLed integer-gmp library.
|
||||
, enableIntegerSimple ? false, gmp
|
||||
, cross ? null
|
||||
}:
|
||||
|
||||
let
|
||||
|
@ -44,7 +45,9 @@ stdenv.mkDerivation rec {
|
|||
"--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib"
|
||||
] ++ stdenv.lib.optional stdenv.isDarwin [
|
||||
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
|
||||
];
|
||||
] ++
|
||||
# fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
||||
lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space";
|
||||
|
||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
||||
# that in turn causes GHCi to abort
|
||||
|
|
|
@ -105,7 +105,9 @@ in stdenv.mkDerivation (rec {
|
|||
"RANLIB=${stdenv.binutilsCross}/bin/${cross.config}-ranlib"
|
||||
"--target=${cross.config}"
|
||||
"--enable-bootstrap-with-devel-snapshot"
|
||||
] ++ (lib.optional ("${cross.config}" == "aarch64-apple-darwin14") "--disable-large-address-space");
|
||||
] ++
|
||||
# fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
||||
lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space";
|
||||
|
||||
buildInputs = commonBuildInputs ++ [ stdenv.ccCross stdenv.binutilsCross ];
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{ mkDerivation
|
||||
, lib
|
||||
, broken ? false
|
||||
, test-framework
|
||||
, test-framework-hunit
|
||||
|
@ -94,6 +95,11 @@
|
|||
]
|
||||
|
||||
, stage2 ? import ./stage2.nix
|
||||
|
||||
, patches ? [ ./ghcjs.patch ]
|
||||
|
||||
# used for resolving compiler plugins
|
||||
, ghcLibdir ? null
|
||||
}:
|
||||
let
|
||||
inherit (bootPkgs) ghc;
|
||||
|
@ -122,7 +128,7 @@ in mkDerivation (rec {
|
|||
testDepends = [
|
||||
HUnit test-framework test-framework-hunit
|
||||
];
|
||||
patches = [ ./ghcjs.patch ];
|
||||
inherit patches;
|
||||
postPatch = ''
|
||||
substituteInPlace Setup.hs \
|
||||
--replace "/usr/bin/env" "${coreutils}/bin/env"
|
||||
|
@ -165,6 +171,8 @@ in mkDerivation (rec {
|
|||
--with-cabal ${cabal-install}/bin/cabal \
|
||||
--with-gmp-includes ${gmp.dev}/include \
|
||||
--with-gmp-libraries ${gmp.out}/lib
|
||||
'' + lib.optionalString (ghcLibdir != null) ''
|
||||
printf '%s' '${ghcLibdir}' > "$out/lib/ghcjs-${version}/ghc_libdir"
|
||||
'';
|
||||
passthru = {
|
||||
inherit bootPkgs;
|
||||
|
|
|
@ -193,11 +193,13 @@ stdenv.mkDerivation ({
|
|||
${jailbreak-cabal}/bin/jailbreak-cabal ${pname}.cabal
|
||||
'' + postPatch;
|
||||
|
||||
# for ghcjs, we want to put ghcEnv on PATH so compiler plugins will be available.
|
||||
# TODO(cstrahan): would the same be of benefit to native ghc?
|
||||
setupCompilerEnvironmentPhase = ''
|
||||
runHook preSetupCompilerEnvironment
|
||||
|
||||
echo "Build with ${ghc}."
|
||||
export PATH="${ghc}/bin:$PATH"
|
||||
export PATH="${if ghc.isGhcjs or false then ghcEnv else ghc}/bin:$PATH"
|
||||
${optionalString (hasActiveLibrary && hyperlinkSource) "export PATH=${hscolour}/bin:$PATH"}
|
||||
|
||||
packageConfDir="$TMPDIR/package.conf.d"
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
{ stdenv, lib, ghc, llvmPackages, packages, buildEnv, makeWrapper
|
||||
{ stdenv, lib, ghc, llvmPackages, packages, symlinkJoin, makeWrapper
|
||||
, ignoreCollisions ? false, withLLVM ? false
|
||||
, postBuild ? ""
|
||||
, haskellPackages
|
||||
, ghcLibdir ? null # only used by ghcjs, when resolving plugins
|
||||
}:
|
||||
|
||||
assert ghcLibdir != null -> (ghc.isGhcjs or false);
|
||||
|
||||
# This wrapper works only with GHC 6.12 or later.
|
||||
assert lib.versionOlder "6.12" ghc.version || ghc.isGhcjs;
|
||||
|
||||
|
@ -48,7 +51,7 @@ let
|
|||
++ lib.optional stdenv.isDarwin llvmPackages.clang);
|
||||
in
|
||||
if paths == [] && !withLLVM then ghc else
|
||||
buildEnv {
|
||||
symlinkJoin {
|
||||
# this makes computing paths from the name attribute impossible;
|
||||
# if such a feature is needed, the real compiler name should be saved
|
||||
# as a dedicated drv attribute, like `compiler-name`
|
||||
|
@ -59,14 +62,6 @@ buildEnv {
|
|||
postBuild = ''
|
||||
. ${makeWrapper}/nix-support/setup-hook
|
||||
|
||||
# Work around buildEnv sometimes deciding to make bin a symlink
|
||||
if test -L "$out/bin"; then
|
||||
binTarget="$(readlink -f "$out/bin")"
|
||||
rm "$out/bin"
|
||||
cp -r "$binTarget" "$out/bin"
|
||||
chmod u+w "$out/bin"
|
||||
fi
|
||||
|
||||
# wrap compiler executables with correct env variables
|
||||
|
||||
for prg in ${ghcCommand} ${ghcCommand}i ${ghcCommand}-${ghc.version} ${ghcCommand}i-${ghc.version}; do
|
||||
|
@ -102,6 +97,12 @@ buildEnv {
|
|||
done
|
||||
|
||||
${lib.optionalString hasLibraries "$out/bin/${ghcCommand}-pkg recache"}
|
||||
${# ghcjs will read the ghc_libdir file when resolving plugins.
|
||||
lib.optionalString (isGhcjs && ghcLibdir != null) ''
|
||||
mkdir -p "${libDir}"
|
||||
rm -f "${libDir}/ghc_libdir"
|
||||
printf '%s' '${ghcLibdir}' > "${libDir}/ghc_libdir"
|
||||
''}
|
||||
$out/bin/${ghcCommand}-pkg check
|
||||
'' + postBuild;
|
||||
passthru = {
|
||||
|
|
Loading…
Reference in a new issue