on iko/ghcjs-patch-master help sign in
Capture files generated by ghc for ghcjs/ghc-boot (#698)
commite1589cc74baeeaf2c2613c0e4bebb150a70d1a06 authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateFri 19 Jun 2020, 14:13 (6 years ago) parent2852a95
2 files changed+44−2
compiler/ghc/default.nix+27−1 overlays/ghc-packages.nix+17−1
compiler/ghc/default.nix+27−1
@@ -277,7 +277,7 @@ in let configured-src = stdenv.mkDerivation (rec {
277277 enableParallelBuilding = true;
278278 postPatch = "patchShebangs .";
279279
280− outputs = [ "out" "doc" ];
280+ outputs = [ "out" "doc" "generated" ];
281281
282282 # Make sure we never relax`$PATH` and hooks support for compatability.
283283 strictDeps = true;
@@ -330,6 +330,32 @@ in let configured-src = stdenv.mkDerivation (rec {
330330 -e 's/ghcprog="ghc-/ghcprog="${targetPrefix}ghc-/' \
331331 $i
332332 done
333+
334+ # Save generated files for needed when building ghcjs
335+ mkdir -p $generated/includes/dist-derivedconstants/header
336+ cp includes/dist-derivedconstants/header/GHCConstantsHaskellExports.hs \
337+ includes/dist-derivedconstants/header/GHCConstantsHaskellType.hs \
338+ includes/dist-derivedconstants/header/GHCConstantsHaskellWrappers.hs \
339+ $generated/includes/dist-derivedconstants/header
340+ if [[ -f includes/ghcplatform.h ]]; then
341+ cp includes/ghcplatform.h $generated/includes
342+ elif [[ -f includes/dist-install/build/ghcplatform.h ]]; then
343+ cp includes/dist-install/build/ghcplatform.h $generated/includes
344+ fi
345+ mkdir -p $generated/compiler/stage2/build
346+ cp compiler/stage2/build/Config.hs $generated/compiler/stage2/build || true
347+ mkdir -p $generated/rts/build
348+ cp rts/build/config.hs-incl $generated/rts/build || true
349+
350+ # Save generated files for needed when building ghc-boot
351+ mkdir -p $generated/libraries/ghc-boot/dist-install/build/GHC/Platform
352+ if [[ -f libraries/ghc-boot/dist-install/build/GHC/Version.hs ]]; then
353+ cp libraries/ghc-boot/dist-install/build/GHC/Version.hs $generated/libraries/ghc-boot/dist-install/build/GHC/Version.hs
354+ fi
355+ if [[ -f libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs ]]; then
356+ cp libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs $generated/libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs
357+ fi
358+
333359 ${installDeps targetPrefix}
334360
335361 # Sanity checks for https://github.com/input-output-hk/haskell.nix/issues/660
overlays/ghc-packages.nix+17−1
@@ -100,7 +100,23 @@ in rec {
100100 ghc-boot-packages-src-and-nix = builtins.mapAttrs
101101 (ghcName: value: builtins.mapAttrs
102102 (pkgName: dir: rec {
103− src = "${value.passthru.configured-src}/${dir}";
103+ src =
104+ # Add in the generated files needed by ghc-boot
105+ if dir == "libraries/ghc-boot"
106+ then final.evalPackages.runCommand "ghc-boot-src" {} ''
107+ cp -Lr ${value.passthru.configured-src}/${dir} $out
108+ chmod -R +w $out/GHC
109+ cp -Lr ${value.generated}/libraries/ghc-boot/dist-install/build/GHC/* $out/GHC
110+ ''
111+ else if dir == "compiler"
112+ then final.evalPackages.runCommand "ghc-src" {} ''
113+ cp -Lr ${value.passthru.configured-src}/${dir} $out
114+ chmod -R +w $out
115+ if [[ -f ${value.generated}/compiler/stage2/build/Config.hs ]]; then
116+ cp -Lr ${value.generated}/compiler/stage2/build/Config.hs $out
117+ fi
118+ ''
119+ else "${value.passthru.configured-src}/${dir}";
104120 nix = callCabal2Nix "${ghcName}-${pkgName}" src;
105121 }) ghc-extra-pkgs)
106122 final.buildPackages.haskell-nix.compiler;