on iko/ghcjs-patch-master help sign in
Overlays (#261)

The Overlays branch This is a major reorganization in how haskell.nix is used, and marks our 1.0 release. The branch doesn't build due to numerous issues that we believe to be with the CI and not this branch. We expect only very minor adjustments prior to calling this the official 1.0 release. * Move iohk-nix patches into haskell.nix This moves the customizations we did in iohk-nix into haskell.nix via overlays and config. Add bootPkgs logic this moves the nuking of bootPkgs where it belongs. This should eventually still be removed and replaced by a proper solution, that doesn't require the nuking of bootPkgs. Allow us to bootstrap binary ghcs and a cabal-install With this we can do the following: ``` $ nix repl compiler/old-ghc-nix nix-repl> :b (let pkgs = import <nixpkgs> {}; in with import ./. {}; import ./compiler/bootstrap/cabal-install.nix { inherit (pkgs) fetchurl stdenv zlib; inherit hackage ; ghc = ghc844; src = pkgs.fetchurl { url = "https://github.com/haskell/cabal/archive/Cabal-v3.0.0.0-rc3.tar.gz"; sha256 = "1zl2mgg8307ykq3v8nmafc6zdhhj1cw7w8ffpap16dsm6 5lbnx33"; }; }) ``` which wile it may look daunting, will allow us to bootstrap a cabal-install with a ghc. From that point onwards, we should be able to build any hackage package via haskell.nix. Pass through cabal-install version Better threading of arguments. Add bootstrap overlay Allow alex + happy to be built This still has a wart: we need nix-tools, and for that we use the ghc865 from nixpkgs. Ideally we'd build nix-tools against a specific ghc, but then we'd need a build expression for that. Make ghcjs work Building something like this: ``` nix build '(with import ./. { nixpkgs = ../nixpkgs; nixpkgsArgs = { crossSystem = { config = "js-unknown-ghcjs"; }; }; }; (haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; })).components.exes.hello' ``` will now work. Assuming `nixpkgs` has been appropriately patched to support the `js-unknown-ghcjs` triple. Also: this will need an additional `Cabal` patch, to make `Cabal` understand what it needs to do with: `dist/build/hello/hello: copyFile: does not exist (No such file or directory)` It needs to learn that `dist/build/hello/hello.jsexe` is what it wants to copy and that that is a directory. Luckily we do have some code in Cabal already that does this for `.exe` on windows. Build `js-unknown-ghcjs` packages with haskell.nix Using the following expression: ``` with import ./. { nixpkgs = ../nixpkgs; nixpkgsArgs = { crossSystem = { config = "js-unknown-ghcjs"; }; }; }; let Cabal = buildPackages.haskell-nix.hackage-package { name = "Cabal"; version = "2.4.1.0"; modules = [ { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; } ]; }; in (haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; modules = [ ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; }) ];}).components.exes.hello ``` in a `test.nix` file. And running ``` nix build -f ./test.nix ``` on it, will produce ``` ./result ├── bin │ └── hello.jsexe │ ├── all.js │ ├── all.js.externs │ ├── index.html │ ├── lib.js │ ├── manifest.webapp │ ├── out.frefs.js │ ├── out.frefs.json │ ├── out.js │ ├── out.stats │ ├── rts.js │ └── runmain.js └── share └── doc └── x86_64-linux-ghc-8.6.5 └── hello-1.0.0.2 └── LICENSE 6 directories, 12 files ```

commit5884ab02be5e280d0fad0399b45b593395f1ea24 authorMoritz Angermann <moritz.angermann@gmail.com> dateMon 21 Oct 2019, 20:07 (7 years ago) parent6ad351e
107 files changed+33061−443
.gitattributes+1−1 README.org+40−5 build.nix+16−5 builder/comp-builder.nix+1−1 builder/default.nix+4−4 builder/ghc-for-component-wrapper.nix+4 builder/hspkg-builder.nix+5−5 builder/make-config-files.nix+5−2 builder/setup-builder.nix+9−4 ci.nix+399 compiler/bootstrap/cabal-install.nix+78 compiler/ghc/default.nix+326 compiler/ghcjs/ghcjs-src.json+6 compiler/ghcjs/ghcjs.nix+124 compiler/old-ghc-nix/default.nix+10 compiler/old-ghc-nix/old-ghc-nix.json+7 config.nix+22 default.nix+5−253 docs/dev/nixpkgs-pin.md+3−2 docs/user-guide.md+134−50 docs/user-guide/projects.md+17−5 examples/Cabal-install-folder.diff+41 examples/cardano-sl-mingw32.nix+38 examples/cardano-sl.nix+37 examples/cardano-wallet-ghcjs.nix+38 examples/cardano-wallet-mingw32.nix+38 examples/cardano-wallet-rpi.nix+38 examples/cardano-wallet.nix+36 lib/call-cabal-project-to-nix.nix+16−10 lib/call-stack-to-nix.nix+13−8 lib/clean-git.nix+101 lib/default.nix+18−5 lib/pkgconf-nixpkgs-map.nix+1 mk-local-hackage-repo/default.nix+2−2 modules/component-driver.nix+35−7 modules/plan.nix+15−3 nix-tools/default.nix+6−3 nix-tools/.plan-pkgs.nix → nix-tools/pkgs-8.4.4.nix+58−37 nixpkgs/default.nix+2−1 nixpkgs/release-18.09.json+7 nixpkgs/release-19.03.json+7 overlays/armv6l-linux.nix+73 overlays/bootstrap.nix+287 overlays/darwin.nix+3 overlays/default.nix+11 overlays/ghc-packages.nix+89 overlays/ghc.nix+31 overlays/ghcjs-asterius-triple.nix+35 overlays/haskell.nix+310 overlays/linux-cross.nix+72 overlays/mingw_w64.nix+81 overlays/patches/Cabal/fix-data-dir.patch+20 overlays/patches/clock-0.7.2.patch+59 overlays/patches/conduit-1.3.0.2.patch+15 overlays/patches/cryptonite-openssl-0.7.patch+13 overlays/patches/file-embed-lzma-0.patch+44 overlays/patches/ghc/0001-Stop-the-linker-panic.patch+122 overlays/patches/ghc/Cabal2201-allow-test-wrapper.patch+72 overlays/patches/ghc/Cabal2201-no-hackage-tests.patch+15 overlays/patches/ghc/MR148--T16104-GhcPlugins.patch+21 overlays/patches/ghc/MR196--ghc-pkg-shut-up.patch+13 overlays/patches/ghc/MR545--ghc-pkg-databases.patch+210 overlays/patches/ghc/MR948--32bit-cross-th.patch+143 overlays/patches/ghc/MR95--ghc-pkg-deadlock-fix.patch+61 overlays/patches/ghc/T16057--ghci-doa-on-windows.patch+70 overlays/patches/ghc/cabal-exe-ext-8.4.2.patch+440 overlays/patches/ghc/dll-loader-8.4.2.patch+34 overlays/patches/ghc/ghc-8.0.2-darwin-rec-link.patch+13 overlays/patches/ghc/ghc-8.4.3-Cabal2201-SMP-test-fix.patch+13 overlays/patches/ghc/ghc-8.4.3-Cabal2201-allow-test-wrapper.patch+72 overlays/patches/ghc/ghc-8.4.3-Cabal2201-no-hackage-tests.patch+15 overlays/patches/ghc/ghc-8.4.3-Cabal2201-response-file-support.patch+59 overlays/patches/ghc/ghc-8.4.4-backport-dylib-command-size-limit.patch+24 overlays/patches/ghc/ghc-8.4.4-darwin-rec-link.patch+13 overlays/patches/ghc/ghc-8.4.4-reinstallable-lib-ghc.patch+8711 overlays/patches/ghc/ghc-8.6-Cabal-fix-datadir.patch+21 overlays/patches/ghc/ghc-8.6.1-iserv-changes.patch+811 overlays/patches/ghc/ghc-8.6.3-reinstallable-lib-ghc.patch+5539 overlays/patches/ghc/ghc-8.6.4-better-plusSimplCountErrors.patch+26 overlays/patches/ghc/ghc-8.6.4-reenable-th-qq-in-stage1.patch+19 overlays/patches/ghc/ghc-8.6.4-reinstallable-lib-ghc.patch+4879 overlays/patches/ghc/ghc-8.6.5-reinstallable-lib-ghc.patch+4879 overlays/patches/ghc/ghc-add-keepCAFs-to-rts.patch+12 overlays/patches/ghc/hsc2hs-8.4.2.patch+1197 overlays/patches/ghc/iserv-proxy-cleanup.patch+912 overlays/patches/ghc/lowercase-8.4.2.patch+57 overlays/patches/ghc/lowercase-8.6.patch+37 overlays/patches/ghc/mistuke-ghc-err_clean_up_error_handler-8ab1a89af89848f1713e6849f189de66c0ed7898.diff+98 overlays/patches/ghc/move-iserv-8.4.2.patch+1001 overlays/patches/ghc/outputtable-assert-8.4.patch+30 overlays/patches/ghc/outputtable-assert-8.6.patch+13 overlays/patches/ghc/various-8.4.2.patch+57 overlays/patches/http-client-0.5.14.patch+18 overlays/patches/streaming-commons-0.2.0.0.patch+15 overlays/patches/x509-system-1.6.6.patch+13 overlays/python.nix+11 overlays/release-19.03.nix+14 overlays/windows.nix+128 package-set.nix+19−4 patches/darcs-setup.patch+120 pkgs/rocksdb-prebuilt.nix+30 snapshots.nix+7−2 test-ghcjs.nix+12 test-mingw32.nix+12 test-rpi.nix+12 test.nix+12 test/default.nix+23−24
.gitattributes+1−1
@@ -2,5 +2,5 @@
22# Hide stuff that is generated by nix-tools plan-to-nix
33
44nix-tools/.plan.nix/*.nix linguist-generated=true
5−nix-tools/.plan-pkgs.nix linguist-generated=true
5+nix-tools/pkgs.nix linguist-generated=true
66.stack-to-nix.cache linguist-generated=true
README.org+40−5
@@ -8,18 +8,53 @@
88=haskell.nix= is an experimental new builder for Haskell packages.
99
1010It works by automatically translating your Cabal or Stack project and
11−its dependencies into Nix code. Most of your dependencies are already
12−translated, so you generally won't have too much generated code.
11+its dependencies into Nix code. It provides IFD (imports from derviation)
12+functions that can minimize the amount of nix code you need to add.
1313
1414For the documentation, see https://input-output-hk.github.io/haskell.nix/.
1515
1616** Quickstart
1717
18−This will download and build =nix-tools=.
18+For =cabal.project= project add a =default.nix=:
1919
2020#+begin_src sh
21−nix build -f https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz nix-tools -o nt
22−./nt/bin/stack-to-nix
21+{ pkgs ? import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz))
22+, haskellCompiler ? "ghc865"
23+}:
24+ pkgs.haskell-nix.cabalProject {
25+ src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
26+ ghc = pkgs.buildPackages.pkgs.haskell.compiler.${haskellCompiler};
27+ }
28+#+end_src
29+
30+For a =stack.yaml= project add a =default.nix=:
31+
32+#+begin_src sh
33+{ pkgs ? import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz))
34+}:
35+ pkgs.haskell-nix.stackProject {
36+ src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
37+ }
38+#+end_src
39+
40+To build the library component of a package in the project run:
41+
42+#+begin_src sh
43+nix build -f . your-package-name.components.library
44+#+end_src
45+
46+To build an executable:
47+
48+#+begin_src sh
49+nix build -f . your-package-name.components.exes.your-exe-name
50+#+end_src
51+
52+To open a shell for use with `cabal` run:
53+
54+#+begin_src sh
55+nix-shell -A shellFor
56+cabal new-build your-package-name
57+cabal new-repl your-package-name:library:your-package-name
2358#+end_src
2459
2560** Related repos
build.nix+16−5
@@ -3,21 +3,32 @@
33# It is separate from default.nix because that file is the public API
44# of Haskell.nix, which shouldn't have tests, etc.
55
6−{ pkgs ? import nixpkgs nixpkgsArgs
7−, nixpkgs ? ./nixpkgs
6+{ nixpkgs ? ./nixpkgs
87# Provide args to the nixpkgs instantiation.
98, system ? builtins.currentSystem
109, crossSystem ? null
1110, config ? {}
12−, nixpkgsArgs ? { inherit system crossSystem config; }
11+, nixpkgsArgs ? { inherit system crossSystem; }
1312}:
1413
1514let
16− haskell = import ./default.nix { inherit pkgs; };
15+ haskellNixArgs = import ./default.nix;
16+ pkgs = import nixpkgs ({
17+ config = haskellNixArgs.config // config;
18+ overlays = haskellNixArgs.overlays ++
19+ [(self: super: {
20+ darcs = (self.haskell-nix.hackage-package {
21+ name = "darcs";
22+ version = "2.14.2";
23+ # Apply the latest darcs.net Setup.hs patches
24+ modules = [{packages.darcs.patches = [ ./patches/darcs-setup.patch ];}];
25+ }).components.exes.darcs;
26+ })]; } // nixpkgsArgs);
27+ haskell = pkgs.haskell-nix;
1728
1829in {
1930 inherit (haskell) nix-tools source-pins;
20− tests = import ./test/default.nix { inherit haskell; };
31+ tests = import ./test/default.nix { inherit nixpkgs nixpkgsArgs; };
2132
2233 # Scripts for keeping Hackage and Stackage up to date, and CI tasks.
2334 maintainer-scripts = pkgs.dontRecurseIntoAttrs {
builder/comp-builder.nix+1−1
@@ -191,7 +191,7 @@ stdenv.mkDerivation ({
191191 buildPhase = ''
192192 runHook preBuild
193193 # https://gitlab.haskell.org/ghc/ghc/issues/9221
194− $SETUP_HS build -j$(($NIX_BUILD_CORES > 4 ? 4 : $NIX_BUILD_CORES)) ${lib.concatStringsSep " " (component.setupBuildFlags ++ setupGhcOptions)}
194+ $SETUP_HS build ${haskellLib.componentTarget componentId} -j$(($NIX_BUILD_CORES > 4 ? 4 : $NIX_BUILD_CORES)) ${lib.concatStringsSep " " (component.setupBuildFlags ++ setupGhcOptions)}
195195 runHook postBuild
196196 '';
197197
builder/default.nix+4−4
@@ -1,4 +1,4 @@
1−{ pkgs, buildPackages, stdenv, lib, haskellLib, ghc, buildGHC, fetchurl, pkgconfig, nonReinstallablePkgs, hsPkgs }:
1+{ pkgs, buildPackages, stdenv, lib, haskellLib, ghc, fetchurl, pkgconfig, nonReinstallablePkgs, hsPkgs }:
22
33let
44 # Builds a single component of a package.
@@ -7,7 +7,7 @@ let
77 };
88
99 setup-builder = haskellLib.weakCallPackage pkgs ./setup-builder.nix {
10− ghc = buildGHC;
10+ ghc = (ghc.passthru.buildGHC or ghc);
1111 hsPkgs = hsPkgs.buildPackages;
1212 inherit haskellLib nonReinstallablePkgs makeSetupConfigFiles;
1313 };
@@ -28,7 +28,7 @@ let
2828 # When building setup depends we need to use the build systems GHC and Packages
2929 makeSetupConfigFiles = haskellLib.weakCallPackage buildPackages ./make-config-files.nix {
3030 inherit haskellLib nonReinstallablePkgs;
31− ghc = buildGHC;
31+ ghc = (ghc.passthru.buildGHC or ghc);
3232 };
3333
3434
@@ -57,7 +57,7 @@ in {
5757 # Build a Haskell package from its config.
5858 # TODO: this pkgs is the adjusted pkgs, but pkgs.pkgs is unadjusted
5959 build-package = haskellLib.weakCallPackage pkgs ./hspkg-builder.nix {
60− inherit haskellLib ghc buildGHC comp-builder setup-builder;
60+ inherit haskellLib ghc comp-builder setup-builder;
6161 };
6262
6363 inherit shellFor;
builder/ghc-for-component-wrapper.nix+4
@@ -40,6 +40,10 @@ in runCommand "${componentName}-${ghc.name}" {
4040 rm -rf ${libDir}/*/
4141 # ... but retain the lib/ghc/bin directory. This contains `unlit' and friends.
4242 ln -s ${ghc}/lib/${ghcCommand}-${ghc.version}/bin ${libDir}
43+ # ... and the ghcjs shim's if they are available
44+ if [ -d ${ghc}/lib/${ghcCommand}-${ghc.version}/shims ]; then
45+ ln -s ${ghc}/lib/${ghcCommand}-${ghc.version}/shims ${libDir}
46+ fi
4347 # Replace the package database with the one from target package config.
4448 ln -s ${configFiles}/package.conf.d ${packageCfgDir}
4549
builder/hspkg-builder.nix+5−5
@@ -1,4 +1,4 @@
1−{ pkgs, buildPackages, stdenv, lib, haskellLib, ghc, buildGHC, fetchurl, runCommand, comp-builder, setup-builder }:
1+{ pkgs, buildPackages, stdenv, lib, haskellLib, ghc, fetchurl, runCommand, comp-builder, setup-builder }:
22
33
44{ flags
@@ -30,17 +30,17 @@ let
3030 import Distribution.Simple
3131 main = defaultMain
3232 '';
33− defaultSetup = buildPackages.runCommand "default-Setup" { nativeBuildInputs = [buildGHC]; } ''
33+ defaultSetup = buildPackages.runCommand "default-Setup" { nativeBuildInputs = [(ghc.passthru.buildGHC or ghc)]; } ''
3434 cat ${defaultSetupSrc} > Setup.hs
3535 mkdir -p $out/bin
36− ${buildGHC.targetPrefix}ghc Setup.hs --make -o $out/bin/Setup
36+ ${(ghc.passthru.buildGHC or ghc).targetPrefix}ghc Setup.hs --make -o $out/bin/Setup
3737 '';
3838
39− setup = if package.buildType == "Simple"
39+ setup = if package.buildType == "Simple" && package.setup-depends == []
4040 then defaultSetup
4141 else setup-builder {
4242 setup-depends = package.setup-depends;
43− inherit package name src flags;
43+ inherit package name src flags revision patches defaultSetupSrc;
4444 };
4545
4646 buildComp = componentId: component: comp-builder {
builder/make-config-files.nix+5−2
@@ -28,7 +28,7 @@ let
2828 # so we are dealing with a sublib. As we build sublibs separately, the above
2929 # query should be safe.
3030 echo "--dependency=''${name#z-${p}-z-}=$id" >> $out/configure-flags
31− fi
31+ fi
3232 if ver=$(target-pkg ${pdbArg} field ${p} version --simple-output); then
3333 echo "constraint: ${p} == $ver" >> $out/cabal.config
3434 echo "constraint: ${p} installed" >> $out/cabal.config
@@ -105,6 +105,9 @@ in { identifier, component, fullName, flags ? {} }:
105105 #
106106 # TODO: Fix Cabal.
107107 # TODO: this is only needed if we do dynamic libraries.
108+ #
109+ # NOTE [ln -s -f]: we force link, as we may have dependencies that contain shared deps
110+ # (e.g. libiconv), and thus we don't want to fail, but just link it again.
108111 + lib.optionalString stdenv.isDarwin ''
109112 # Work around a limit in the macOS Sierra linker on the number of paths
110113 # referenced by any one dynamic library:
@@ -114,7 +117,7 @@ in { identifier, component, fullName, flags ? {} }:
114117 local dynamicLinksDir="$out/lib/links"
115118 mkdir -p $dynamicLinksDir
116119 for d in $(grep dynamic-library-dirs "$out/package.conf.d/"*|awk '{print $2}'|sort -u); do
117− ln -s "$d/"*.dylib $dynamicLinksDir
120+ ln -f -s "$d/"*.dylib $dynamicLinksDir
118121 done
119122 # Edit the local package DB to reference the links directory.
120123 for f in "$out/package.conf.d/"*.conf; do
builder/setup-builder.nix+9−4
@@ -1,6 +1,6 @@
11{ stdenv, lib, buildPackages, haskellLib, ghc, nonReinstallablePkgs, hsPkgs, makeSetupConfigFiles }:
22
3−{ setup-depends, package, name, src, flags }:
3+{ setup-depends, package, name, src, flags, revision, patches, defaultSetupSrc }:
44
55let
66 component = {
@@ -34,7 +34,7 @@ let
3434
3535in
3636 stdenv.lib.fix (drv:
37− stdenv.mkDerivation {
37+ stdenv.mkDerivation ({
3838 name = "${fullName}";
3939 src = cleanSrc;
4040 nativeBuildInputs = [ghc];
@@ -45,8 +45,11 @@ in
4545 inherit configFiles cleanSrc;
4646 };
4747
48− phases = ["unpackPhase" "buildPhase" "installPhase"];
48+ phases = ["unpackPhase" "patchPhase" "buildPhase" "installPhase"];
4949 buildPhase = ''
50+ if [[ ! -f ./Setup.hs && ! -f ./Setup.lhs ]]; then
51+ cat ${defaultSetupSrc} > Setup.hs
52+ fi
5053 for f in Setup.hs Setup.lhs; do
5154 if [ -f $f ]; then
5255 echo Compiling package $f
@@ -62,4 +65,6 @@ in
6265 mkdir -p $out/bin
6366 install ./Setup $out/bin/Setup
6467 '';
65− })
68+ }
69+ // lib.optionalAttrs (patches != []) { patches = map (p: if builtins.isFunction p then p { inherit (package.identifier) version; inherit revision; } else p) patches; }
70+ ))
ci.nixnew file+399
@@ -0,0 +1,399 @@
1+# these are patched nixpkgs that include the following PRs:
2+# - https://github.com/NixOS/nixpkgs/pull/71216
3+# - https://github.com/NixOS/nixpkgs/pull/68398
4+
5+let
6+ nixpkgsVersions = {
7+# "release-18.09" = builtins.fetchTarball "https://github.com/input-output-hk/nixpkgs/archive/7e4dcacbf066a8e2d12693a9de1fb30c77081c5d.tar.gz";
8+ "release-19.03" = builtins.fetchTarball "https://github.com/input-output-hk/nixpkgs/archive/a8f81dc037a5977414a356dd068f2621b3c89b60.tar.gz";
9+ # "release-19.09" = builtins.fetchTarball "https://github.com/input-output-hk/nixpkgs/archive/3d623a406cec9052ae0a16a79ce3ce9de11236bb.tar.gz";
10+ };
11+ haskellNixArgs = import ./.;
12+ defaultNixpkgs = import (nixpkgsVersions."release-19.03") {};
13+ recRecurseIntoAttrs = with defaultNixpkgs; pred: x: if pred x then recurseIntoAttrs (lib.mapAttrs (n: v: if n == "buildPackages" then v else recRecurseIntoAttrs pred v) x) else x;
14+in
15+ recRecurseIntoAttrs (x: with defaultNixpkgs; lib.isAttrs x && !lib.isDerivation x) (
16+ builtins.mapAttrs (nixpkgsName: nixpkgsSrc: with (import nixpkgsSrc {}); {
17+ x86_64-linux = {
18+ hello = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; }));
19+ (haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2";}).components.exes.hello;
20+ x86_64-pc-mingw32-hello = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; crossSystem.config = "x86_64-pc-mingw32"; }));
21+ (haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2";}).components.exes.hello;
22+
23+ iserv-proxy = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; }));
24+ (ghc-extra-packages.ghc865.iserv-proxy.components.exes).iserv-proxy;
25+
26+ x86_64-pc-mingw32-iserv-proxy = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; crossSystem.config = "x86_64-pc-mingw32"; }));
27+ (buildPackages.ghc-extra-packages.ghc865.iserv-proxy.components.exes).iserv-proxy;
28+
29+ x86_64-pc-mingw32-remote-iserv = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; crossSystem.config = "x86_64-pc-mingw32"; }));
30+ (ghc-extra-packages.ghc865.remote-iserv.components.exes).remote-iserv;
31+
32+ };
33+ x86_64-darwin = {
34+ hello = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; }));
35+ (haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2";}).components.exes.hello;
36+ x86_64-pc-mingw32-hello = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; crossSystem.config = "x86_64-pc-mingw32"; }));
37+ (haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2";}).components.exes.hello;
38+
39+ iserv-proxy = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; }));
40+ (ghc-extra-packages.ghc865.iserv-proxy.components.exes).iserv-proxy;
41+
42+ x86_64-pc-mingw32-iserv-proxy = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; crossSystem.config = "x86_64-pc-mingw32"; }));
43+ (buildPackages.ghc-extra-packages.ghc865.iserv-proxy.components.exes).iserv-proxy;
44+
45+ x86_64-pc-mingw32-remote-iserv = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; crossSystem.config = "x86_64-pc-mingw32"; }));
46+ (ghc-extra-packages.ghc865.remote-iserv.components.exes).remote-iserv;
47+
48+ };
49+ haskell.compiler = {
50+ x86_64-linux = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; }));
51+ haskell.compiler;
52+ x86_64-darwin = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin";}));
53+ haskell.compiler;
54+ };
55+ tests = {
56+ x86_64-linux = (import ./test { nixpkgs = nixpkgsSrc; nixpkgsArgs = { system = "x86_64-linux"; }; });
57+ # x86_64-darwin = (import ./test { nixpkgs = nixpkgsSrc; nixpkgsArgs = { system = "x86_64-darwin"; }; });
58+ };
59+ examples = let
60+ iohk-archive = name: hash: "https://github.com/input-output-hk/${name}/archive/${hash}.tar.gz";
61+ mkCacheModule = cache:
62+ # for each item in the `cache`, set
63+ # packages.$name.src = fetchgit ...
64+ # and
65+ # packages.$name.postUnpack = ...
66+ # if subdir is given.
67+ #
68+ # We need to do this, as cabal-to-nix will generate
69+ # src = /nix/store/... paths, and when we build the
70+ # package we won't have access to the /nix/store
71+ # path. As such we regenerate the fetchgit command
72+ # we used in the first place, and thus have a proper
73+ # src value.
74+ #
75+ # TODO: this should be moved into `call-stack-to-nix`
76+ # it should be automatic and not the burden of
77+ # the end user to work around nix peculiarities.
78+ { packages = builtins.foldl' (x: y: x // y) {}
79+ (builtins.map ({ name, url, rev, sha256, subdir ? null, ... }:
80+ { ${name} = { src = fetchgit { inherit url rev sha256; }; }
81+ // lib.optionalAttrs (subdir != null) { postUnpack = "sourceRoot+=/${subdir}; echo source root reset to $sourceRoot"; };
82+ }) cache);
83+ };
84+ cardano-sl-args = rec {
85+ src = builtins.fetchTarball (iohk-archive "cardano-sl" "1a792d7cd0f0c93a0f0c28f66372bce3c3808dbd");
86+ pkgs = [
87+ "cardano-sl-crypto-test"
88+ "cardano-sl-crypto"
89+ "cardano-sl-cluster"
90+ "cardano-sl-infra"
91+ "cardano-sl-infra-test"
92+ "cardano-sl-tools"
93+ "cardano-sl-tools-post-mortem"
94+ "cardano-sl-core"
95+ "cardano-sl-core-test"
96+ "cardano-sl-util-test"
97+ "cardano-sl-util"
98+ "cardano-sl-script-runner"
99+ "cardano-sl-auxx"
100+ "cardano-sl-networking"
101+ "cardano-sl-explorer"
102+ "cardano-sl-chain-test"
103+ "cardano-sl-chain"
104+ "cardano-sl-mnemonic"
105+ "cardano-sl-generator"
106+ "cardano-sl-x509"
107+ "cardano-sl-utxo"
108+ "cardano-sl-node-ipc"
109+ "cardano-wallet"
110+ "cardano-sl"
111+ "cardano-sl-db-test"
112+ "cardano-sl-db"
113+ "cardano-sl-faucet"
114+ "cardano-sl-binary-test"
115+ "cardano-sl-binary"
116+ "cardano-sl-node"
117+ "cardano-sl-client"
118+ ];
119+ cache = [
120+ { name = "cardano-crypto";
121+ url = "https://github.com/input-output-hk/cardano-crypto";
122+ rev = "4590efa638397e952a51a8994b5543e4ea3c1ecd";
123+ sha256 = "0hl2n3bba5v2j0lmxhs7hs01z3aznh2bwf9cb434icq2g0bl8ms3"; }
124+ { name = "haskell-ip";
125+ cabal-file = "ip.cabal";
126+ url = "https://github.com/andrewthad/haskell-ip";
127+ rev = "9bb453139aa82cc973125091800422a523e1eb8f";
128+ sha256 = "199mfpbgca7rvwvwk2zsmcpibc0sk0ni7c5zlf4gk3cps8s85gyr"; }
129+ { name = "time-units";
130+ url = "https://github.com/serokell/time-units.git";
131+ rev = "6c3747c1ac794f952de996dd7ba8a2f6d63bf132";
132+ sha256 = "0psdr1if0rgnn24698x3583m0603rwd3sd7yb9whj03hskmkwpgs";
133+ }
134+ { name = "kademlia";
135+ url = "https://github.com/serokell/kademlia.git";
136+ rev = "7120bb4d28e708acd52dfd61d3dca7914fac7d7f";
137+ sha256 = "1k1wp9dwhzzqfivxc28vhxfqplnyh916crr7bhsiv829d6qifhw1";
138+ }
139+ { name = "network-transport";
140+ url = "https://github.com/serokell/network-transport";
141+ rev = "018a50b9042c2115c3ec9c9fd5ca5f28737dd29c";
142+ sha256 = "0lqa26l2ikpq6a4s7qm9b2favx59w82i0wngakhfyax66fpixp8q";
143+ }
144+ { name = "network-transport-tcp";
145+ url = "https://github.com/avieth/network-transport-tcp";
146+ rev = "2634e5e32178bb0456d800d133f8664321daa2ef";
147+ sha256 = "03shp9prflhgqzw7pymw1pq2q7s1wf46pyjm2csx8646snrhf35i";
148+ }
149+ { name = "network-transport-inmemory";
150+ url = "https://github.com/avieth/network-transport-inmemory";
151+ rev = "5d8ff2b07b9df35cf61329a3d975e2c8cf95c12a";
152+ sha256 = "0ak64rks3lk3kk5wyndrrk2swmd84h9diribzix305xwz1jhjj9w";
153+ }
154+ { name = "acid-state";
155+ url = "https://github.com/parsonsmatt/acid-state";
156+ rev = "a1b23e2056f134e53f705a694ab85deeecabec5c";
157+ sha256 = "0mgdk8252g7wbb0afyn21pcn3bwh4vainy3h2d0xsv4hlpgqgnw8";
158+ }
159+ { name = "socket-io";
160+ url = "https://github.com/input-output-hk/engine.io";
161+ rev = "d3c55f51bb81cee7d0d551de930ce65fe7d76756";
162+ sha256 = "139c0yfnj57cpwg4k0am2rp35sh959394nvlb98011rjy68200qc";
163+ subdir = "socket-io";
164+ }
165+ { name = "engine-io";
166+ url = "https://github.com/input-output-hk/engine.io";
167+ rev = "d3c55f51bb81cee7d0d551de930ce65fe7d76756";
168+ sha256 = "139c0yfnj57cpwg4k0am2rp35sh959394nvlb98011rjy68200qc";
169+ subdir = "engine-io";
170+ }
171+ { name = "engine-io-wai";
172+ url = "https://github.com/input-output-hk/engine.io";
173+ rev = "d3c55f51bb81cee7d0d551de930ce65fe7d76756";
174+ sha256 = "139c0yfnj57cpwg4k0am2rp35sh959394nvlb98011rjy68200qc";
175+ subdir = "engine-io-wai";
176+ }
177+ { name = "canonical-json";
178+ url = "https://github.com/well-typed/canonical-json.git";
179+ rev = "ddfe3593b80b5ceb88842bb7a6f2268df75d2c2f";
180+ sha256 = "02fzn1xskis1lc1pkz0j92v6ipd89ww0k2p3dvwpm3yap5dpnm7k";
181+ }
182+ { name = "clock";
183+ url = "https://github.com/corsis/clock.git";
184+ rev = "ef60bd51a3587a173adf565c33bf2886df6e3842";
185+ sha256 = "1r4n9imls483f7wd61fi1jk16z2k7w36gpx798sqidvwbnc831q1";
186+ }
187+ { name = "rocksdb-haskell-ng";
188+ url = "https://github.com/input-output-hk/rocksdb-haskell-ng.git";
189+ rev = "49f501a082d745f3b880677220a29cafaa181452";
190+ sha256 = "02jvri8ik8jgrxwa6qmh3xcwqvm4s27iv3sxpjpny79nlhlxvfzp";
191+ }
192+ { name = "log-warper";
193+ url = "https://github.com/input-output-hk/log-warper";
194+ rev = "5271ab6c33541b8155ca203e714875974ec116be";
195+ sha256 = "1h14004a8iwr8nw31pqq6kfdhfsyzzl8a50hrmj2acjqq6mbdl2m";
196+ }
197+ { name = "universum";
198+ url = "https://github.com/input-output-hk/universum";
199+ rev = "15f7db758ff5a24b874de2247f6f7a4576562da5";
200+ sha256 = "127bs29zpjcc40777dv7figk05gd00b9ja57sp11w440qr5h72hk";
201+ }
202+ { name = "serokell-util";
203+ url = "https://github.com/input-output-hk/serokell-util";
204+ rev = "457f1d149c6e238841f283a1faf7bc8fb021b27d";
205+ sha256 = "0llbryqna9p03db3ka4933vzf4jw1yxdbsf7cqi2pivsy1vp6kp0";
206+ }
207+ { name = "inspector";
208+ url = "https://github.com/primetype/inspector.git";
209+ rev = "c975f4329365f0379c04358138e616fb96fb0b79";
210+ sha256 = "12q1v7a8kcw7qi4lws4j3mvxwfkhni6zmp870kmnkgbgwvrax9gs";
211+ }
212+ ];
213+ # This is needed due to some deficiencies in stackage snapshots.
214+ # maybe we should make this part of some `stack-default-pkg-def-extras`?
215+ # We have similar logic in the snapshots.nix file to deal with this in
216+ # snapshots.
217+ #
218+ # TODO: move this somewhere into stackProject
219+ pkg-def-extras = [
220+ (hackage: {
221+ packages = {
222+ "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
223+ "process" = (((hackage.process)."1.6.5.0").revisions).default;
224+ };
225+ })
226+ (hackage: {
227+ packages = {
228+ "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
229+ };
230+ })
231+ ];
232+ modules = [ (mkCacheModule cache) ];
233+ };
234+ cardano-wallet-args = rec {
235+ src = builtins.fetchTarball (iohk-archive "cardano-wallet" "d525e85fe19a37d8b5648ac783ef35474be38bcc");
236+ pkgs = [
237+ "bech32"
238+ "text-class"
239+ "cardano-wallet-http-bridge"
240+ "cardano-wallet-launcher"
241+ "cardano-wallet-test-utils"
242+ "cardano-wallet-core"
243+ "cardano-wallet-jormungandr"
244+ "cardano-wallet-cli"
245+ "cardano-crypto"
246+ "cardano-wallet-core-integration"
247+ ];
248+ # wee need these, as they are referenced in the stack.yaml file; however we can't
249+ # fetch them at IFD time as they don't provide the sha256. Hence we use the cache-file
250+ # facility on stack-to-nix and pre-populate the cache file with the relevant hashes.
251+ cache = [
252+ { name = "cardano-crypto";
253+ url = "https://github.com/input-output-hk/cardano-crypto";
254+ rev = "3c5db489c71a4d70ee43f5f9b979fcde3c797f2a";
255+ sha256 = "0lss4x41m0ylhximqjc56ps0y3pag3x58wm480pzfa48lpk4gqpk"; }
256+ { name = "persistent-sqlite";
257+ url = "https://github.com/KtorZ/persistent";
258+ rev = "79f2ece07eafae005a703c8eda1bd2420b5e07b5";
259+ sha256 = "081bhdg52wn7vgxsgl4aimy73ccai05j64r24hwkdnjj4kz96lia";
260+ subdir = "persistent-sqlite"; }
261+ { name = "iohk-monitoring";
262+ url = "https://github.com/input-output-hk/iohk-monitoring-framework";
263+ rev = "bd31cd2f3922010ddb76bb869f29c4e63bb8001b";
264+ subdir = "iohk-monitoring";
265+ sha256 = "1dfk505qbpk6p3gcpxa31wmg98qvx9hlrxlf0khaj7hizf3b8b60"; }
266+ { name = "contra-tracer";
267+ url = "https://github.com/input-output-hk/iohk-monitoring-framework";
268+ rev = "bd31cd2f3922010ddb76bb869f29c4e63bb8001b";
269+ subdir = "contra-tracer";
270+ sha256 = "1dfk505qbpk6p3gcpxa31wmg98qvx9hlrxlf0khaj7hizf3b8b60"; }
271+ ];
272+ # This is needed due to some deficiencies in stackage snapshots.
273+ # maybe we should make this part of some `stack-default-pkg-def-extras`?
274+ # We have similar logic in the snapshots.nix file to deal with this in
275+ # snapshots.
276+ #
277+ # TODO: move this somewhere into stackProject
278+ pkg-def-extras = [
279+ (hackage: {
280+ packages = {
281+ "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
282+ "process" = (((hackage.process)."1.6.5.0").revisions).default;
283+ };
284+ })
285+ (hackage: {
286+ packages = {
287+ "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
288+ };
289+ })
290+ ];
291+ modules = [ (mkCacheModule cache) ];
292+ };
293+ plutus-args = rec {
294+ src = builtins.fetchTarball (iohk-archive "plutus" "0d76e98ab267d621ad15002b5f824cad71797754");
295+ cache = [
296+ { name = "row-types";
297+ url = "https://github.com/target/row-types";
298+ rev = "1e8d5e084ffd46f6c7842826a1f62c60820885df";
299+ sha256 = "0ly5m4r8wkm8gdqyrqzsjfmp189yxsd4qp0zi3idrbgfaf45sk9k"; }
300+ { name = "purescript-bridge";
301+ url = "https://github.com/shmish111/purescript-bridge.git";
302+ rev = "0042602f8a195b1fe185138f9ccca02020b8dd62";
303+ sha256 = "1vl88g41f4vvgw9iyn7zd7i52qshpnk02z0y6czg4zy7wk3q12gz"; }
304+ { name = "servant-purescript";
305+ url = "https://github.com/shmish111/servant-purescript.git";
306+ rev = "ece5d1dad16a5731ac22040075615803796c7c21";
307+ sha256 = "1axcbsaym64q67hvjc7b3izd48cgqwi734l7f7m22jpdc80li5f6"; }
308+ { name = "cardano-crypto";
309+ url = "https://github.com/input-output-hk/cardano-crypto.git";
310+ rev = "f5cecb6e424cc84f85b6a3e1f803517bb7b4cfb1";
311+ sha256 = "1jyzai4sn9hi3p6r97h54f9a7an7vk38lwrbl4mds9zmdsw5f5ad"; }
312+ { name = "unlit";
313+ url = "https://github.com/michaelpj/unlit.git";
314+ rev = "9ca1112093c5ffd356fc99c7dafa080e686dd748";
315+ sha256 = "145sffn8gbdn6xp9q5b75yd3m46ql5bnc02arzmpfs6wgjslfhff"; }
316+ { name = "prometheus";
317+ url = "https://github.com/bitnomial/prometheus.git";
318+ rev = "69e4cefeb7d04d61a54cb0ae9fd57e2de134badb";
319+ sha256 = "0h836qp0ic587gfyfkj9a53p8rczja50sfy2y8ymx8wwkmq9zdgc"; }
320+ { name = "github";
321+ url = "https://github.com/shmish111/github.git";
322+ rev = "cc27b9de4d5d0939235fa9a8b418de3ea4807bab";
323+ sha256 = "0jx65x4c8s561nbxa0hv7mp8fvndfhs8i8gzxng7ym808n4n538i"; }
324+ ];
325+ # This is needed due to some deficiencies in stackage snapshots.
326+ # maybe we should make this part of some `stack-default-pkg-def-extras`?
327+ # We have similar logic in the snapshots.nix file to deal with this in
328+ # snapshots.
329+ #
330+ # TODO: move this somewhere into stackProject
331+ pkg-def-extras = [
332+ (hackage: {
333+ packages = {
334+ "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
335+ "process" = (((hackage.process)."1.6.5.0").revisions).default;
336+ };
337+ })
338+ (hackage: {
339+ packages = {
340+ "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
341+ };
342+ })
343+ ];
344+ modules = [ (mkCacheModule cache) ];
345+ };
346+ in {
347+ x86_64-linux = {
348+ # cardano-sl
349+ cardano-sl = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; }));
350+ (lib.filterAttrs (k: _: builtins.elem k cardano-sl-args.pkgs)
351+ (haskell-nix.stackProject cardano-sl-args));
352+ x86_64-pc-mingw32-cardano-sl = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; crossSystem.config = "x86_64-pc-mingw32"; }));
353+ (lib.filterAttrs (k: _: builtins.elem k cardano-sl-args.pkgs)
354+ (haskell-nix.stackProject cardano-sl-args));
355+
356+ # cardano-wallet
357+ cardano-wallet = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; }));
358+ (lib.filterAttrs (k: _: builtins.elem k cardano-wallet-args.pkgs)
359+ (haskell-nix.stackProject cardano-wallet-args));
360+ x86_64-pc-mingw32-cardano-wallet = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; crossSystem.config = "x86_64-pc-mingw32"; }));
361+ (lib.filterAttrs (k: _: builtins.elem k cardano-wallet-args.pkgs)
362+ (haskell-nix.stackProject cardano-wallet-args));
363+ plutus = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; }));
364+ (haskell-nix.stackProject plutus-args).language-plutus-core.components.all;
365+ x86_64-pc-mingw32-plutus = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; crossSystem.config = "x86_64-pc-mingw32"; }));
366+ (haskell-nix.stackProject plutus-args).language-plutus-core.components.all;
367+ };
368+ x86_64-darwin = {
369+ # cardano-sl
370+ cardano-sl = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; }));
371+ (lib.filterAttrs (k: _: builtins.elem k cardano-sl-args.pkgs)
372+ (haskell-nix.stackProject cardano-sl-args));
373+ x86_64-pc-mingw32-cardano-sl = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; crossSystem.config = "x86_64-pc-mingw32"; }));
374+ (lib.filterAttrs (k: _: builtins.elem k cardano-sl-args.pkgs)
375+ (haskell-nix.stackProject cardano-sl-args));
376+
377+ # cardano-wallet
378+ cardano-wallet = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; }));
379+ (lib.filterAttrs (k: _: builtins.elem k cardano-wallet-args.pkgs)
380+ (haskell-nix.stackProject cardano-wallet-args));
381+ x86_64-pc-mingw32-cardano-wallet = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; crossSystem.config = "x86_64-pc-mingw32"; }));
382+ (lib.filterAttrs (k: _: builtins.elem k cardano-wallet-args.pkgs)
383+ (haskell-nix.stackProject cardano-wallet-args));
384+ plutus = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; }));
385+ (haskell-nix.stackProject plutus-args).language-plutus-core.components.all;
386+ x86_64-pc-mingw32-plutus = with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; crossSystem.config = "x86_64-pc-mingw32"; }));
387+ (haskell-nix.stackProject plutus-args).language-plutus-core.components.all;
388+ };
389+ };
390+
391+# Don't build (all of) stackage on linux for now.
392+# stackage = {
393+# x86_64-linux = (with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-linux"; }));
394+# haskell-nix.snapshots."lts-13.29");
395+# # x86_64-darwin = (with (import nixpkgsSrc (haskellNixArgs // { system = "x86_64-darwin"; }));
396+# # haskell-nix.snapshots."lts-13.29");
397+# };
398+
399+}) nixpkgsVersions)
compiler/bootstrap/cabal-install.nixnew file+78
@@ -0,0 +1,78 @@
1+{ fetchurl, hackage, stdenv, ghc, zlib, src, version }:
2+let dependencies =
3+ [ { name = "deepseq"; version = "1.4.3.0"; }
4+ { name = "binary"; version = "0.8.5.1"; }
5+ { name = "time"; version = "1.9.1"; }
6+ { name = "transformers"; version = "0.5.5.0"; }
7+ { name = "mtl"; version = "2.2.2"; }
8+ { name = "text"; version = "1.2.3.0"; }
9+ { name = "parsec"; version = "3.1.13.0"; }
10+ { name = "network-uri"; version = "2.6.1.0"; }
11+ { name = "network"; version = "2.7.0.0"; }
12+ { name = "HTTP"; version = "4000.3.12"; }
13+ { name = "zlib"; version = "0.6.2"; }
14+ { name = "random"; version = "1.1"; }
15+ { name = "stm"; version = "2.4.5.0"; }
16+ { name = "hashable"; version = "1.2.7.0"; }
17+ { name = "async"; version = "2.2.1"; }
18+ { name = "base16-bytestring"; version = "0.1.1.6"; }
19+ { name = "base64-bytestring"; version = "1.0.0.1"; }
20+ { name = "cryptohash-sha256"; version = "0.11.101.0";}
21+ { name = "resolv"; version = "0.1.1.1"; }
22+ { name = "mintty"; version = "0.1.2"; }
23+ { name = "echo"; version = "0.1.3"; }
24+ { name = "edit-distance"; version = "0.2.2.1"; }
25+ { name = "ed25519"; version = "0.0.5.0"; }
26+ { name = "tar"; version = "0.5.1.0"; }
27+ { name = "digest"; version = "0.0.1.2"; }
28+ { name = "zip-archive"; version = "0.3.3"; }
29+ { name = "hackage-security"; version = "0.5.3.0"; }
30+ ]; in
31+let depPaths = builtins.map ({name, version}:
32+ fetchurl {
33+ url = "mirror://hackage/${name}-${version}.tar.gz";
34+ inherit (hackage.${name}.${version}) sha256; }) dependencies;
35+in stdenv.mkDerivation ({
36+ name = "cabal-install";
37+
38+ inherit version;
39+
40+ passthru = {
41+ inherit version;
42+ };
43+
44+ nativeBuildInputs = [ ghc zlib ];
45+
46+ inherit src;
47+
48+ configurePhase = "";
49+
50+ buildPhase = ''
51+ # We need the .git directory to make the ./bootstrap command use ../Cabal.
52+ mkdir .git
53+
54+ cd cabal-install
55+ # unpack dependencies, so we can bootstrap without network.
56+ for dep in ${builtins.concatStringsSep " " depPaths}; do
57+ tar xzf $dep
58+ done
59+
60+ # make sure we have the patched (revised) .cabal files.
61+ ${builtins.concatStringsSep "\n"
62+ (builtins.map ({name, version}:
63+ let revInfo = hackage.${name}.${version}.revisions.default; in
64+ if revInfo.revNum == null || revInfo.revNum == 0
65+ then ""
66+ else let revision = fetchurl { url = "https://hackage.haskell.org/package/${name}-${version}/revision/${toString revInfo.revNum}.cabal"; inherit (revInfo) sha256; }; in
67+ ''cp "${revision}" "${name}-${version}/${name}.cabal"''
68+ ) dependencies)
69+ }
70+ mkdir $out
71+ ghc-pkg init $out/packages.conf.d
72+ EXTRA_CONFIGURE_OPTS="" SCOPE_OF_INSTALLATION="--package-db=$out/packages.conf.d" PREFIX="$out" ./bootstrap.sh --no-doc -j
73+ '';
74+
75+ installPhase = ''
76+
77+ '';
78+})
compiler/ghc/default.nixnew file+326
@@ -0,0 +1,326 @@
1+# This is the nix expression to build ghc. The Glasgow Haskell Compiler. It is
2+# heavily inspired (and based) upon the ghc expression from nixos/nixpkgs.
3+# haskell.nix ships its own version of the ghc expression as it needs more
4+# control over the expression to isolate it against varying <nixpkgs> and
5+# allow us to customize it to the way haskell.nix works.
6+{ stdenv, targetPackages
7+
8+# build-tools
9+, bootPkgs
10+, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4, sphinx
11+, autoreconfHook
12+, bash
13+
14+, libiconv ? null, ncurses
15+
16+, # GHC can be built with system libffi or a bundled one.
17+ libffi ? null
18+
19+, useLLVM ? !stdenv.targetPlatform.isx86
20+, # LLVM is conceptually a run-time-only depedendency, but for
21+ # non-x86, we need LLVM to bootstrap later stages, so it becomes a
22+ # build-time dependency too.
23+ buildLlvmPackages, llvmPackages
24+
25+, # If enabled, GHC will be built with the GPL-free but slower integer-simple
26+ # library instead of the faster but GPLed integer-gmp library.
27+ enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
28+
29+, # If enabled, use -fPIC when compiling static libs.
30+ enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform && !stdenv.targetPlatform.isAarch32
31+
32+, # Whether to build dynamic libs for the standard library (on the target
33+ # platform). Static libs are always built.
34+ enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
35+
36+, # Whetherto build terminfo.
37+ enableTerminfo ? !stdenv.targetPlatform.isWindows
38+
39+, # What flavour to build. An empty string indicates no
40+ # specific flavour and falls back to ghc default values.
41+ ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
42+ (if useLLVM then "perf-cross" else "perf-cross-ncg")
43+
44+, # Whether to disable the large address space allocator
45+ # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
46+ disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64
47+
48+, ghc-version ? src-spec.version
49+, src-spec
50+, ghc-patches ? []
51+
52+# extra values we want to have available as passthru values.
53+, extra-passthru ? {}
54+}:
55+
56+assert !enableIntegerSimple -> gmp != null;
57+
58+let
59+ inherit (stdenv) buildPlatform hostPlatform targetPlatform;
60+
61+ inherit (bootPkgs) ghc;
62+
63+ # TODO(@Ericson2314) Make unconditional
64+ targetPrefix = stdenv.lib.optionalString
65+ (targetPlatform != hostPlatform)
66+ "${targetPlatform.config}-";
67+
68+ buildMK = ''
69+ BuildFlavour = ${ghcFlavour}
70+ ifneq \"\$(BuildFlavour)\" \"\"
71+ include mk/flavours/\$(BuildFlavour).mk
72+ endif
73+ DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
74+ INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
75+ '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
76+ Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
77+ CrossCompilePrefix = ${targetPrefix}
78+ HADDOCK_DOCS = NO
79+ BUILD_SPHINX_HTML = NO
80+ BUILD_SPHINX_PDF = NO
81+ '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
82+ GhcLibHcOpts += -fPIC
83+ GhcRtsHcOpts += -fPIC
84+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
85+ EXTRA_CC_OPTS += -std=gnu99
86+ '' + stdenv.lib.optionalString useLLVM ''
87+ GhcStage2HcOpts += -fast-llvm
88+ GhcLibHcOpts += -fast-llvm
89+ '';
90+
91+ # Splicer will pull out correct variations
92+ libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ]
93+ ++ [libffi]
94+ ++ stdenv.lib.optional (!enableIntegerSimple) gmp
95+ ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
96+
97+ toolsForTarget =
98+ if hostPlatform == buildPlatform then
99+ [ targetPackages.stdenv.cc ] ++ stdenv.lib.optional useLLVM llvmPackages.llvm
100+ else assert targetPlatform == hostPlatform; # build != host == target
101+ [ stdenv.cc ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
102+
103+ targetCC = builtins.head toolsForTarget;
104+
105+in let configured-src = stdenv.mkDerivation (rec {
106+
107+ version = ghc-version;
108+
109+ patches = ghc-patches;
110+
111+ name = "${targetPrefix}ghc-${ghc-version}-configured-src";
112+
113+
114+ nativeBuildInputs = [
115+ perl autoconf automake m4 python3 sphinx
116+ ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
117+ ] ++ stdenv.lib.optional (patches != []) autoreconfHook;
118+
119+ # For building runtime libs
120+ depsBuildTarget = toolsForTarget;
121+
122+ buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
123+
124+ propagatedBuildInputs = [ targetPackages.stdenv.cc ]
125+ ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
126+
127+ depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
128+ depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
129+
130+ postPatch = "patchShebangs .";
131+
132+ src = fetchurl { inherit (src-spec) url sha256; };
133+
134+ # GHC is a bit confused on its cross terminology.
135+ preConfigure = ''
136+ for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
137+ export "''${env#TARGET_}=''${!env}"
138+ done
139+ # GHC is a bit confused on its cross terminology, as these would normally be
140+ # the *host* tools.
141+ export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
142+ export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
143+ # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
144+ export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString targetPlatform.isAarch32 ".gold"}"
145+ export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
146+ export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
147+ export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
148+ export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
149+ export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
150+ export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
151+
152+ echo -n "${buildMK}" > mk/build.mk
153+ sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
154+ '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
155+ export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
156+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
157+ export NIX_LDFLAGS+=" -no_dtrace_dof"
158+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
159+ sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
160+ '' + stdenv.lib.optionalString targetPlatform.isMusl ''
161+ echo "patching llvm-targets for musl targets..."
162+ echo "Cloning these existing '*-linux-gnu*' targets:"
163+ grep linux-gnu llvm-targets | sed 's/^/ /'
164+ echo "(go go gadget sed)"
165+ sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
166+ echo "llvm-targets now contains these '*-linux-musl*' targets:"
167+ grep linux-musl llvm-targets | sed 's/^/ /'
168+
169+ echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
170+ # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
171+ for x in configure aclocal.m4; do
172+ substituteInPlace $x \
173+ --replace '*-android*|*-gnueabi*)' \
174+ '*-android*|*-gnueabi*|*-musleabi*)'
175+ done
176+ '';
177+
178+ # TODO(@Ericson2314): Always pass "--target" and always prefix.
179+ configurePlatforms = [ "build" "host" ]
180+ ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
181+ # `--with` flags for libraries needed for RTS linker
182+ configureFlags = [
183+ "--datadir=$doc/share/doc/ghc"
184+ "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
185+ ] ++ stdenv.lib.optionals (libffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetPackages.libffi.dev}/include" "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
186+ ] ++ stdenv.lib.optional (!enableIntegerSimple) [
187+ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
188+ ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
189+ "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
190+ ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
191+ "--enable-bootstrap-with-devel-snapshot"
192+ ] ++ stdenv.lib.optionals (targetPlatform.isAarch32) [
193+ "CFLAGS=-fuse-ld=gold"
194+ "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
195+ "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
196+ ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
197+ "--disable-large-address-space"
198+ ];
199+
200+ outputs = [ "out" ];
201+ phases = [ "unpackPhase" "patchPhase" ]
202+ ++ stdenv.lib.optional (ghc-patches != []) "autoreconfPhase"
203+ ++ [ "configurePhase" "installPhase" ];
204+ installPhase = "cp -r . $out";
205+ });
206+
207+in stdenv.mkDerivation (rec {
208+ version = ghc-version;
209+ name = "${targetPrefix}ghc-${version}";
210+
211+ patches = ghc-patches;
212+
213+ # for this to properly work (with inheritance of patches, postPatch, ...)
214+ # this needs to be a function over the values we want to inherit and then called
215+ # accordingly. Most trivial might be to just have args, and mash them into the
216+ # attrset.
217+ src = configured-src;
218+
219+ # configure was run by configured-src already.
220+ phases = [ "unpackPhase" "buildPhase"
221+ "checkPhase" "installPhase"
222+ "fixupPhase"
223+ "installCheckPhase"
224+ "distPhase"
225+ ];
226+
227+ # ghc hardcodes the TOP dir durcing config, this breaks when
228+ # splitting the configured src from the the build process.
229+ postUnpack = ''
230+ (cd $sourceRoot
231+ TOP=$(cat mk/config.mk|grep ^TOP|awk -F\ '{ print $3 }')
232+ PREFIX=$(cat mk/install.mk|grep ^prefix|awk -F\ '{ print $3 }')
233+
234+ # these two are required
235+ substituteInPlace mk/config.mk --replace "$TOP" "$PWD" \
236+ --replace "$PREFIX" "$out"
237+
238+ substituteInPlace mk/install.mk --replace "$TOP" "$PWD" \
239+ --replace "$PREFIX" "$out"
240+
241+ # these two only for convencience.
242+ substituteInPlace config.log --replace "$TOP" "$PWD"\
243+ --replace "$PREFIX" "$out"
244+ substituteInPlace config.status --replace "$TOP" "$PWD"\
245+ --replace "$PREFIX" "$out")
246+
247+
248+ '';
249+
250+ enableParallelBuilding = true;
251+ postPatch = "patchShebangs .";
252+
253+ outputs = [ "out" "doc" ];
254+
255+ # Make sure we never relax`$PATH` and hooks support for compatability.
256+ strictDeps = true;
257+
258+ # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
259+ dontAddExtraLibs = true;
260+
261+ nativeBuildInputs = [
262+ perl autoconf automake m4 python3 sphinx
263+ ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
264+ ] ++ stdenv.lib.optional (patches != []) autoreconfHook;
265+
266+ # For building runtime libs
267+ depsBuildTarget = toolsForTarget;
268+
269+ buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
270+
271+ propagatedBuildInputs = [ targetPackages.stdenv.cc ]
272+ ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
273+
274+ depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
275+ depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
276+
277+ # required, because otherwise all symbols from HSffi.o are stripped, and
278+ # that in turn causes GHCi to abort
279+ stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
280+
281+ # See #63511 - the only unstripped file is the debug rts which isn't meant to
282+ # be stripped.
283+ stripDebugList = [ "lib/${name}/bin" ];
284+
285+ checkTarget = "test";
286+
287+ hardeningDisable = [ "format" ]
288+ ++ stdenv.lib.optional stdenv.targetPlatform.isAarch32 "pic"
289+ ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
290+
291+ postInstall = ''
292+ # Install the bash completion file.
293+ install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
294+
295+ # Patch scripts to include "readelf" and "cat" in $PATH.
296+ for i in "$out/bin/"*; do
297+ test ! -h $i || continue
298+ egrep --quiet '^#!' <(head -n 1 $i) || continue
299+ sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
300+ done
301+ '';
302+
303+ passthru = {
304+ inherit bootPkgs targetPrefix;
305+
306+ inherit llvmPackages;
307+ inherit enableShared;
308+
309+ # Our Cabal compiler name
310+ haskellCompilerName = "ghc-${version}";
311+
312+ configured-src = configured-src;
313+ } // extra-passthru;
314+
315+ meta = {
316+ homepage = http://haskell.org/ghc;
317+ description = "The Glasgow Haskell Compiler";
318+ maintainers = with stdenv.lib.maintainers; [ angerman ];
319+ inherit (ghc.meta) license platforms;
320+ };
321+
322+} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
323+ dontStrip = true;
324+ dontPatchELF = true;
325+ noAuditTmpdir = true;
326+})
compiler/ghcjs/ghcjs-src.jsonnew file+6
@@ -0,0 +1,6 @@
1+{
2+ "url": "https://github.com/ghcjs/ghcjs",
3+ "rev": "d97caeb07757e09f7402429532c14d20eab79bd2",
4+ "sha256": "0025pjgbmr34f2wadrnm9crnx966scc7ja8n9gy93jcqzzmvgj6x",
5+ "fetchSubmodules": true
6+}
compiler/ghcjs/ghcjs.nixnew file+124
@@ -0,0 +1,124 @@
1+{ pkgs
2+, ghcjsSrcJson ? ./ghcjs-src.json
3+, ghcjsSrc ? pkgs.buildPackages.fetchgit (builtins.fromJSON (builtins.readFile ghcjsSrcJson))
4+, ghcjsVersion ? "8.6.0.1"
5+, ghcVersion ? "8.6.5"
6+, ghc ? pkgs.buildPackages.ghc
7+, happy ? pkgs.buildPackages.haskellPackages.happy
8+, alex ? pkgs.buildPackages.haskellPackages.alex
9+, cabal-install ? pkgs.buildPackages.cabal-install
10+}:
11+let
12+ configured-src = pkgs.buildPackages.runCommand "configured-ghcjs-src" {
13+ buildInputs = with pkgs.buildPackages; [
14+ perl
15+ autoconf
16+ automake
17+ python3
18+ ] ++ [
19+ ghc
20+ happy
21+ alex
22+ cabal-install
23+ ];
24+ inherit ghcjsSrc;
25+ } ''
26+ export HOME=$(pwd)
27+ mkdir $HOME/.cabal
28+ touch $HOME/.cabal/config
29+ cp -r "$ghcjsSrc" "$out"
30+ chmod -R +w "$out"
31+ cd "$out"
32+
33+ # TODO: Find a better way to avoid impure version numbers
34+ sed -i 's/RELEASE=NO/RELEASE=YES/' ghc/configure.ac
35+ sed -i 's/${ghcjsVersion}/${ghcVersion}/' ghcjs.cabal
36+
37+ # TODO: How to actually fix this?
38+ # Seems to work fine and produce the right files.
39+ touch ghc/includes/ghcautoconf.h
40+ mkdir -p ghc/compiler/vectorise
41+ mkdir -p ghc/utils/haddock/haddock-library/vendor
42+
43+ patchShebangs .
44+ sed -i 's/gcc /cc /g' utils/makePackages.sh
45+ cat utils/makePackages.sh
46+ ./utils/makePackages.sh copy
47+
48+ echo " build-tool-depends: alex:alex, happy:happy <= 1.19.9" >> lib/ghc-api-ghcjs/ghc-api-ghcjs.cabal
49+ '';
50+ # see https://github.com/ghcjs/ghcjs/issues/751 for the happy upper bound.
51+ ghcjs = (pkgs.buildPackages.haskell-nix.cabalProject {
52+ src = configured-src;
53+ inherit ghc;
54+ modules = [
55+ {
56+ # we need ghc-boot in here for ghcjs.
57+ nonReinstallablePkgs = [ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base"
58+ "deepseq" "array" "ghc-boot-th" "pretty" "template-haskell"
59+ "ghc-boot" "binary" "bytestring" "filepath" "directory" "containers"
60+ "time" "unix" "Win32" ];
61+ }
62+ {
63+ packages.Cabal.patches = [ ./../../overlays/patches/Cabal/fix-data-dir.patch ];
64+ packages.ghcjs.doHaddock = false;
65+ packages.haddock-ghcjs.doHaddock = false;
66+ packages.haddock-api-ghcjs.doHaddock = false;
67+ packages.ghcjs.flags = { no-wrapper-install = true; };
68+ # packages.ghcjs.components.library.configureFlags = [ "-fno-wrapper-install" ];
69+ }
70+ ];
71+ }).ghcjs; # <- we are only interested in the `ghcjs` package.
72+
73+ all-ghcjs = pkgs.buildPackages.symlinkJoin {
74+ name = "ghcjs-${ghcjsVersion}-symlinked";
75+ paths = [
76+ ghcjs.components.exes.ghcjs
77+ ghcjs.components.exes.ghcjs-pkg
78+ ghcjs.components.exes.haddock-ghcjs
79+ ghcjs.components.exes.hsc2hs-ghcjs
80+ ghcjs.components.exes.ghcjs-boot
81+ ghcjs.components.exes.ghcjs-run
82+ ];
83+ };
84+ libexec = "${all-ghcjs}/libexec/${builtins.replaceStrings ["darwin" "i686"] ["osx" "i386"] pkgs.stdenv.buildPlatform.system}-${ghc.name}/ghcjs-${ghcVersion}";
85+in pkgs.stdenv.mkDerivation {
86+ name = "ghcjs-${ghcVersion}";
87+ src = configured-src;
88+
89+ nativeBuildInputs = with pkgs.buildPackages; [
90+ nodejs
91+ makeWrapper
92+ xorg.lndir
93+ gmp
94+ pkgconfig
95+ ]
96+ ++ [ ghc cabal-install ]
97+ ++ lib.optionals stdenv.isDarwin [
98+ pkgs.buildPackages.gcc # https://github.com/ghcjs/ghcjs/issues/663
99+ ];
100+ passthru = {
101+ inherit all-ghcjs;
102+ } // ghcjs.components.exes;
103+ dontConfigure = true;
104+ dontInstall = true;
105+ buildPhase = ''
106+ export HOME=$TMP
107+ mkdir $HOME/.cabal
108+ touch $HOME/.cabal/config
109+ cd lib/boot
110+
111+ mkdir -p $out/bin
112+ mkdir -p $out/lib/ghcjs-${ghcVersion}
113+ lndir ${libexec} $out/bin
114+
115+ wrapProgram $out/bin/ghcjs --add-flags "-B$out/lib/ghcjs-${ghcVersion}"
116+ wrapProgram $out/bin/haddock-ghcjs --add-flags "-B$out/lib/ghcjs-${ghcVersion}"
117+ wrapProgram $out/bin/ghcjs-pkg --add-flags "--global-package-db=$out/lib/ghcjs-${ghcVersion}/package.conf.d"
118+
119+ env PATH=$out/bin:$PATH $out/bin/ghcjs-boot -j1 --with-ghcjs-bin $out/bin
120+ '';
121+ # We hard code -j1 as a temporary workaround for
122+ # https://github.com/ghcjs/ghcjs/issues/654
123+ # enableParallelBuilding = true;
124+}
compiler/old-ghc-nix/default.nixnew file+10
@@ -0,0 +1,10 @@
1+{ pkgs ? import <nixpkgs> {} }:
2+let
3+ fetch = jsonFile:
4+ with builtins;
5+ let spec = fromJSON (readFile jsonFile);
6+ in pkgs.fetchgit {
7+ name = "old-ghc-nix";
8+ inherit (spec) sha256 url rev;
9+ };
10+in import (fetch ./old-ghc-nix.json) { inherit pkgs; }
compiler/old-ghc-nix/old-ghc-nix.jsonnew file+7
@@ -0,0 +1,7 @@
1+{
2+ "url": "https://github.com/angerman/old-ghc-nix",
3+ "rev": "cda937215e85ef5f8064a9f97fc5dce948d028a2",
4+ "date": "2019-07-26T23:00:31+08:00",
5+ "sha256": "00zgkmd7g2rafa2gfz7nx3ahv89qf2jwr8i8r4g7bvykxvh8ga8v",
6+ "fetchSubmodules": false
7+}
config.nixnew file+22
@@ -0,0 +1,22 @@
1+{
2+ # allow building for windows
3+ allowUnsupportedSystem = true;
4+ # we want the 64bit wine version
5+ wine.build = "wine64";
6+ # once https://github.com/NixOS/nixpkgs/pull/71216 is
7+ # merged, we can use `series3`; wine4 seems to suffer
8+ # from some non-obvious regression :(
9+ # This will also need to be backported to 19.03 and 19.09
10+ # at least...
11+ wine.release = "series3";
12+
13+ # sadly we need to patch GHC a bit.
14+ packageOverrides = ps: with ps; let
15+ in rec {
16+ rocksdb = with ps.stdenv;
17+ if hostPlatform.isWindows
18+ then pkgs.callPackage ./pkgs/rocksdb-prebuilt.nix { inherit (buildPackages) fetchurl unzip; }
19+ else ps.rocksdb;
20+ };
21+}
22+
default.nix+5−253
@@ -1,253 +1,5 @@
1−{ pkgs ? import nixpkgs nixpkgsArgs
2−# Use a pinned nixpkgs rather than the one on NIX_PATH
3−, nixpkgs ? ./nixpkgs
4−# Provide args to the nixpkgs instantiation.
5−, nixpkgsArgs ? {}
6−# You can provide different pins for hackage.nix and stackage.nix if required.
7−# It's also possible to override these sources with NIX_PATH.
8−, hackageSourceJSON ? ./hackage-src.json
9−, stackageSourceJSON ? ./stackage-src.json
10−}:
11−
12−let
13− # pkg-def's may reference boot packages, but those
14− # are not guaranteed to be available on hackage, as
15− # it is a manual process. They might eventually show
16− # up much later on hackage; but are not installable
17− # anyway. Therefore we just strip them out of the
18− # pkg-def's packages.
19− #
20− # Note: these will need to be provided by alternative
21− # means outside of hackage.
22− boot-pkgs = [ "rts" "ghc" "ghc-boot-th" "ghc-boot" "ghci"
23− "ghc-heap" # since ghc 8.6.
24− "iserv" "libiserv" "iserv-proxy"
25− ];
26− strip-pkg-def = pkgs: pkg-def: hackage: with pkgs.lib;
27− mapAttrs (k: v: if k == "packages"
28− then filterAttrs (k: _: !(builtins.elem k boot-pkgs)) v
29− else v)
30− (pkg-def hackage);
31−
32− # ghc hackage patches.
33− # these are patches that turn hackage packages into the same as the ones
34− # ghc ships with the supposedly same version. See GHC Track Issue: 16199
35− ghcHackagePatches = import ./patches;
36−
37− compat = import ./lib/compat.nix;
38−
39− # Utility function for downloading a pinned git repo, that can be
40− # overridden with NIX_PATH.
41− fetchExternal = import ./lib/fetch-external.nix;
42−
43− # Function for cleaning haskell source directories pulled from iohk-nix
44− cleanSourceHaskell = pkgs.callPackage ./lib/clean-source-haskell.nix {};
45−
46− # All packages from Hackage as Nix expressions
47− hackageSrc = fetchExternal {
48− name = "hackage-exprs-source";
49− specJSON = hackageSourceJSON;
50− override = "hackage";
51− };
52− hackage = import hackageSrc;
53−
54− # Contains the hashes of the cabal 01-index.tar.gz for given
55− # index states. Starting from April 1st 2019.
56− indexStateHashesPath = hackageSrc + "/index-state-hashes.nix";
57−
58− # The set of all Stackage snapshots
59− stackageSrc = fetchExternal {
60− name = "stackage-snapshot-source";
61− specJSON = stackageSourceJSON;
62− override = "stackage";
63− };
64− stackage = import stackageSrc;
65−
66− packages = pkgs: self: (rec {
67− inherit pkgs; # Make pkgs available (it is the underlying nixpkgs)
68−
69− # Packages built to run on the build platform, not the host platform
70− buildPackages = pkgs.buildPackages.lib.makeScope pkgs.buildPackages.newScope
71− (packages pkgs.buildPackages);
72−
73− # Utility functions for working with the component builder.
74− haskellLib = let hl = import ./lib { inherit (pkgs) lib; haskellLib = hl; }; in hl;
75−
76− # Create a Haskell package set based on a cabal build plan (plan-to-nix)
77− # and Nix expressions representing cabal packages (cabal-to-nix).
78− mkPkgSet =
79− { pkg-def # Base package set. Either from stackage (via stack-to-nix) or from a cabal projects plan file (via plan-to-nix)
80− , pkg-def-extras ? [] # Additional packages to augment the Base package set `pkg-def` with.
81− , modules ? []
82− }@args:
83−
84− import ./package-set.nix (args // {
85− inherit hackage pkgs;
86− pkg-def = strip-pkg-def pkgs pkg-def;
87− });
88−
89− # Create a Haskell package set based on a Stack configuration.
90− mkStackPkgSet =
91− { stack-pkgs # Path to the output of stack-to-nix
92− , pkg-def-extras ? []
93− , modules ? []
94− }@args:
95−
96− let
97− # The Stackage release referenced in the stack config
98− pkg-def = stackage.${stack-pkgs.resolver} or (throw ''
99− This version of stackage.nix does not know about the Stackage resolver ${stack-pkgs.resolver}.
100− You may need to update haskell.nix to one that includes a newer stackage.nix.
101− '');
102− # The compiler referenced in the stack config
103− compiler = (stack-pkgs.extras hackage).compiler or (pkg-def hackage).compiler;
104− patchesModule = ghcHackagePatches.${compiler.nix-name} or {};
105− in self.mkPkgSet {
106− inherit pkg-def;
107− pkg-def-extras = [ stack-pkgs.extras ] ++ pkg-def-extras;
108− # set doExactConfig = true. The stackage set should be consistent
109− # and we should trust stackage here!
110− modules = [ { doExactConfig = true; } patchesModule ] ++ stack-pkgs.modules or [] ++ modules;
111− };
112−
113− # Create a Haskell package set based on a Cabal configuration.
114− mkCabalProjectPkgSet =
115− { plan-pkgs # Path to the output of plan-to-nix
116− , pkg-def-extras ? []
117− , modules ? []
118− }@args:
119−
120− let
121− pkg-def = plan-pkgs.pkgs;
122− # The compiler referenced in the stack config
123− compiler = (plan-pkgs.extras hackage).compiler or (pkg-def hackage).compiler;
124− patchesModule = ghcHackagePatches.${compiler.nix-name} or {};
125− in self.mkPkgSet {
126− inherit pkg-def;
127− pkg-def-extras = [ plan-pkgs.extras ] ++ pkg-def-extras;
128− # set doExactConfig = true, as we trust cabals resolution for
129− # the plan.
130− modules = [ { doExactConfig = true; } patchesModule ] ++ plan-pkgs.modules or [] ++ modules;
131− };
132−
133− # Package sets for all stackage snapshots.
134− snapshots = self.callPackage ./snapshots.nix {};
135− # Pick a recent LTS snapshot to be our "default" package set.
136− haskellPackages = self.snapshots."lts-13.26";
137−
138− # Programs for generating Nix expressions from Cabal and Stack
139− # files. This version of nix-tools may be cross compiled.
140− # We probably never want to actually cross compile nix-tools on
141− # it's own.
142− nix-tools-cross-compiled = pkgs.callPackage ./nix-tools {
143− inherit fetchExternal cleanSourceHaskell;
144− hpack = pkgs.haskell.lib.justStaticExecutables
145− (pkgs.haskellPackages.hpack);
146− inherit (self) mkCabalProjectPkgSet;
147− };
148− # While `nix-tools-cross-compiled` may be cross compiled,
149− # getting it from `buildPackages` we should get
150− # nix-tools suitable for running on the build system.
151− nix-tools = buildPackages.nix-tools-cross-compiled;
152− # TODO perhaps there is a cleaner way to get a suitable nix-tools.
153−
154− # Snapshots of Hackage and Stackage, converted to Nix expressions,
155− # regularly updated.
156− inherit hackageSrc stackageSrc;
157− inherit hackage stackage;
158− inherit indexStateHashesPath;
159−
160− # Make this handy overridable fetch function available.
161− inherit fetchExternal;
162−
163− # Function for cleaning haskell source diretories.
164− inherit cleanSourceHaskell;
165−
166− # Produce a fixed output derivation from a moving target (hackage index tarball)
167− hackageTarball = { index-state, sha256 }:
168− assert sha256 != null;
169− pkgs.fetchurl {
170− name = "01-index.tar.gz-at-${builtins.replaceStrings [":"] [""] index-state}";
171− url = "https://hackage.haskell.org/01-index.tar.gz";
172− downloadToTemp = true;
173− postFetch = "${self.nix-tools}/bin/truncate-index -o $out -i $downloadedFile -s ${index-state}";
174−
175− outputHashAlgo = "sha256";
176− outputHash = sha256;
177− };
178−
179− mkLocalHackageRepo = import ./mk-local-hackage-repo { inherit (self) hackageTarball; inherit pkgs; };
180−
181− dotCabal = { index-state, sha256, cabal-install ? pkgs.cabal-install }@args:
182− pkgs.runCommand "dot-cabal-at-${builtins.replaceStrings [":"] [""] index-state}" { nativeBuildInputs = [ cabal-install ]; } ''
183− mkdir -p $out/.cabal
184− cat <<EOF > $out/.cabal/config
185− repository cached
186− url: file:${self.mkLocalHackageRepo
187− (builtins.removeAttrs args ["cabal-install"])}
188− secure: True
189− root-keys:
190− key-threshold: 0
191− EOF
192− mkdir -p $out/.cabal/packages/cached
193− HOME=$out cabal new-update cached
194− '';
195−
196− update-index-state-hashes = self.callPackage ./scripts/update-index-state-hashes.nix {};
197−
198− # Function to call stackToNix
199− callStackToNix = import ./lib/call-stack-to-nix.nix {
200− pkgs = buildPackages.pkgs;
201− inherit (buildPackages.pkgs) runCommand;
202− inherit (buildPackages) nix-tools;
203− };
204−
205− # Takes a haskell src directory runs cabal new-configure and plan-to-nix.
206− # Resulting nix files are added to nix-plan subdirectory.
207− callCabalProjectToNix = import ./lib/call-cabal-project-to-nix.nix {
208− index-state-hashes = import indexStateHashesPath;
209− inherit (buildPackages) dotCabal haskellLib;
210− pkgs = buildPackages.pkgs;
211− inherit (buildPackages.pkgs.haskellPackages) hpack;
212− inherit (buildPackages.pkgs) runCommand cabal-install ghc symlinkJoin cacert;
213− inherit (buildPackages) nix-tools;
214− };
215−
216− # Loads a plan and filters the package directories using cleanSourceWith
217− importAndFilterProject = import ./lib/import-and-filter-project.nix {
218− inherit pkgs haskellLib;
219− };
220−
221− # References to the unpacked sources, for caching in a Hydra jobset.
222− source-pins = self.callPackage ./lib/make-source-pins.nix {
223− sources = [ hackageSrc stackageSrc pkgs.path ];
224− };
225−
226− # Build a specific package (name, version) against a given index-stage
227− # from hackage. This is useful if you want to build an executable from
228− # a given package.
229− # NB: If no explicit index-state is provided the most recent one from
230− # the index-state-hashes is used. This guarantees reproducability wrt
231− # to the haskell.nix revision. If reproducability beyond haskell.nix
232− # is required, a specific index-state should be provided!
233− hackage-package =
234− { name
235− , version
236− , index-state ? builtins.trace "Using latest index state!" pkgs.lib.last (builtins.attrNames (import indexStateHashesPath))
237− }:
238− let tarball = pkgs.fetchurl {
239− url = "mirror://hackage/${name}-${version}.tar.gz";
240− inherit (hackage.${name}.${version}) sha256; };
241− in let src = buildPackages.pkgs.runCommand "${name}-${version}-src" { } ''
242− tmp=$(mktemp -d)
243− cd $tmp
244− tar xzf ${tarball}
245− mv "${name}-${version}" $out
246− '';
247− in let plan-pkgs = (callCabalProjectToNix { inherit src; index-state = builtins.trace "Using index-state: ${index-state}" index-state; }).pkgs;
248− in let pkg-set = mkCabalProjectPkgSet { inherit plan-pkgs; };
249− in pkg-set.config.hsPkgs.${name};
250− });
251−
252−in
253− pkgs.lib.makeScope pkgs.newScope (packages pkgs)
1+# This default.nix is designed to be passed directly nixpkgs with something like:
2+# import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz))
3+{ config = import ./config.nix;
4+ overlays = import ./overlays;
5+}
docs/dev/nixpkgs-pin.md+3−2
@@ -5,8 +5,9 @@ Haskell.nix contains a Nixpkgs pin in
55This is the version of Nixpkgs used for builds of `nix-tools` and
66running the tests.
77
8−Users should pass their own version of Nixpkgs to Haskell.nix,
9−although things might not work for them if their Nixpkgs version is
8+To use haskell.nix the `config` and `overlays` need to be applied to
9+Nixpkgs. Users should probably pin a suitable version of nixpkgs
10+although, although things might not work for them if their Nixpkgs version is
1011too different.
1112
1213We aim to keep this pin somewhere on the channel of the **NixOS latest
docs/user-guide.md+134−50
@@ -2,39 +2,39 @@
22
33[Haskell.nix][] can be use for two different use cases:
44
5−1. to build a specific package from hackage or a [stackage][] lts or nightly set.
6−
7− To build a package, say [lens][], from a stackage snapshot, say [lts-13.28][],
8− you could run
9− ```bash
10− nix build '(with import ./. {}; snapshots."lts-13.28").lens.components.library'
11− ```
12− which would build the [lens][] library component from the lens package as fixed
13− by the [lts-13.28][] stackage snapshot.
5+### Use 1 : to build a specific package from hackage or a [stackage][] lts or nightly set.
6+
7+To build a package, say [lens][], from a stackage snapshot, say [lts-13.28][],
8+you could run
9+```bash
10+nix build '(with import <nixpkgs> (import ./.); haskell-nix.snapshots."lts-13.28").lens.components.library'
11+```
12+which would build the [lens][] library component from the lens package as fixed
13+by the [lts-13.28][] stackage snapshot.
1414
15− To build any package from hackage, say [lens][], in version, say 4.17.1, you
16− could run
17− ```bash
18− nix build '(with import ./. {}; (hackage-package { name = "lens"; version = "4.17.1"; })).components.library'
19− ```
20− which would build the [lens][] library component from the [lens-4.17.1][] package
21− from hackage. The dependencies would be solved against the most recent
22− [hackage-index-state][] that comes via the [hackage.nix][] pin with your
23− [haskell.nix][] checkout. A specific one can be specified as well:
24− ```bash
25− nix build '(with import ./. {}; (hackage-package { name = "lens"; version = "4.17.1"; index-state = "2019-07-14T00:00:00Z"; })).components.library'
26− ```
27− which would use the hackage index as of `2019-07-14T00:00:00Z` to produce a build plan
28− for the [lens-4.17.1][] package.
15+To build any package from hackage, say [lens][], in version, say 4.17.1, you
16+could run
17+```bash
18+nix build '(with import <nixpkgs> (import ./.); (haskell-nix.hackage-package { name = "lens"; version = "4.17.1"; })).components.library'
19+```
20+which would build the [lens][] library component from the [lens-4.17.1][] package
21+from hackage. The dependencies would be solved against the most recent
22+[hackage-index-state][] that comes via the [hackage.nix][] pin with your
23+[haskell.nix][] checkout. A specific one can be specified as well:
24+```bash
25+nix build '(with import <nixpkgs> (import ./.); (haskell-nix.hackage-package { name = "lens"; version = "4.17.1"; index-state = "2019-07-14T00:00:00Z"; })).components.library'
26+```
27+which would use the hackage index as of `2019-07-14T00:00:00Z` to produce a build plan
28+for the [lens-4.17.1][] package.
2929
3030
31−2. to build a stack or cabal project.
31+### Use 2 : to build a stack or cabal project.
3232
33− So you want to use [Haskell.nix][] with your stack or cabal project. The
34− general approach will be to pick the right tool from `nix-tools` and
35− produce a `pkgs.nix` expression. Getting a copy of the `nix-tools`
36− (and potentially the [Haskell.nix][] source), will then equip us to
37− produce derivations that we can `nix build`.
33+So you want to use [Haskell.nix][] with your stack or cabal project. The
34+general approach will be to pick the right tool from `nix-tools` and
35+produce a `pkgs.nix` expression. Getting a copy of the `nix-tools`
36+(and potentially the [Haskell.nix][] source), will then equip us to
37+produce derivations that we can `nix build`.
3838
3939[haskell.nix]: https://github.com/input-output-hk/haskell.nix
4040[stackage]: https://stackage.org
@@ -49,7 +49,7 @@
4949To build the latest `nix-tools` and store the result at `./nt`, run:
5050
5151```bash
52−nix build -f https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz nix-tools --out-link nt
52+nix build '(with import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz)); haskell-nix.nix-tools)' --out-link nt
5353```
5454
5555If you would like to then install `nix-tools` into your profile, run:
@@ -68,25 +68,106 @@ understand something that the documentation doesn't cover.
6868git clone https://github.com/input-output-hk/nix-tools
6969git clone https://github.com/input-output-hk/haskell.nix
7070cd haskell.nix
71−nix build -f . nix-tools --out-link nt
71+nix build -f . haskell-nix.nix-tools --out-link nt
7272```
7373
74−## Importing [Haskell.nix][] into your project
74+## Using [Haskell.nix][] with your project
7575
7676The easiest way to get a hold of [Haskell.nix][] is with
7777[`fetchTarball`](https://nixos.org/nix/manual/#ssec-builtins).
7878
7979```nix
80−import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {}
80+import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz))
8181```
8282
83−If you have your own `pkgs` variable, pass it to [Haskell.nix][] to
84−prevent double-evaluation of the Nixpkgs collection.
83+### Using your cabal.project file
84+
85+If your project has a `cabal.project` you can add a `default.nix` like this:
8586
8687```nix
87−{ pkgs ? import <nixpkgs> {} }:
88+{ pkgs ? import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz))
89+, haskellCompiler ? "ghc865"
90+}:
91+ pkgs.haskell-nix.cabalProject {
92+ src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
93+ ghc = pkgs.buildPackages.pkgs.haskell.compiler.${haskellCompiler};
94+ # pkg-def-extras = [
95+ # # Additional packages ontop of all those listed in `cabal.project`
96+ # ];
97+ # modules = [
98+ # # Specific package overrides would go here for example:
99+ # packages.cbors.package.ghcOptions = "-Werror";
100+ # packages.cbors.patches = [ ./one.patch ];
101+ # packages.cbors.flags.optimize-gmp = false;
102+ # # It may be better to set flags in `cabal.project` instead
103+ # # (`plan-to-nix` will include them as defaults).
104+ # ];
105+ }
106+```
107+
108+Note: The `cleanGit` call will exclude any files not in the index file
109+in the local `.git` directory. This is extremely useful as it avoids
110+unwanted builds (for instance when the contents of `dist-newstyle` are
111+modified by cabal).
112+
113+You can build a component from your project with `nix-build` (in this
114+case the `hello` executable in a `helloworld` package):
115+
116+```bash
117+nix-build -A helloworld.components.exes.hello
118+```
88119
89−import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) { inherit pkgs; }
120+For interactive development you can run:
121+
122+```bash
123+nix-shell -A shellFor
124+```
125+
126+The resulting shell will include all the dependencies of the local packages
127+listed in your `cabal.project` file (but it will not build those local
128+packages).
129+
130+Inside the shell use `cabal new-build` and `cabal new-repl` to work on the
131+cabal project as you normally would. They will use the packages provided
132+by nix whenever possible.
133+
134+It is a good idea to add `write-ghc-environment-files: never` to your
135+`cabal.project` file to prevent unwanted `.ghc.environment.*` files
136+(they will prevent subsequent `nix-shell` invocations from working
137+properly).
138+
139+Adding an `index-state` to your `cabal.project` can pin the plan used so that
140+the same packages will be built each time (until you change the index-state
141+or one of the constraints in your local `.cabal` files).
142+
143+### Using your stack.yaml file
144+
145+If your project has a `stack.yaml` you can add a `default.nix` like this:
146+
147+```nix
148+{ pkgs ? import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz))
149+}:
150+ pkgs.haskell-nix.stackProject {
151+ src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
152+ # pkg-def-extras = [
153+ # # Additional packages ontop of all those listed in `stack.yaml`
154+ # ];
155+ # modules = [
156+ # # Specific package overrides would go here for example:
157+ # packages.cbors.package.ghcOptions = "-Werror";
158+ # packages.cbors.patches = [ ./one.patch ];
159+ # packages.cbors.flags.optimize-gmp = false;
160+ # # It may be better to set flags in `stack.yaml` instead
161+ # # (`stack-to-nix` will include them as defaults).
162+ # ];
163+ }
164+```
165+
166+You can build a component from your project with `nix-build` (in this
167+case the `hello` executable in a `helloworld` package):
168+
169+```bash
170+nix-build -A helloworld.components.exes.hello
90171```
91172
92173### Pinning the [Haskell.nix][] version
@@ -117,16 +198,16 @@ $ nix-prefetch-git --quiet https://github.com/input-output-hk/haskell.nix | tee
117198Use the following expression to import that version:
118199
119200```nix
120−{ pkgs ? import <nixpkgs> {} }:
201+{ nixpkgs ? <nixpkgs> }:
121202
122203let
123204 spec = builtins.fromJSON (builtins.readFile ./haskell-nix-src.json);
124− haskell-nix-src = pkgs.fetchgit {
205+ haskell-nix-src = (import nixpkgs {}).fetchgit {
125206 name = "haskell-lib";
126207 inherit (spec) url rev sha256 fetchSubmodules;
127208 };
128209in
129− import haskell-nix-src { inherit pkgs; }
210+ import nixpkgs (import haskell-nix-src)
130211```
131212
132213There are other possible schemes for pinning. See
@@ -153,13 +234,16 @@ these Git repositories correspond to the actual Hackage and Stackage.
153234[stackage.nix]: https://github.com/input-output-hk/stackage.nix
154235
155236```nix
156−{ pkgs ? import <nixpkgs> {} }:
157−
158−import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {
159− inherit pkgs;
160− hackageSourceJSON = ./hackage-src.json;
161− stackageSourceJSON = ./stackage-src.json;
162−}
237+{ pkgs ? import <nixpkgs> (haskellNixArgs // { overlays = haskellNixArgs.overlays ++ [
238+ (self: super: {
239+ haskell-nix = super.haskell-nix // {
240+ hackageSourceJSON = ./hackage-src.json;
241+ stackageSourceJSON = ./stackage-src.json;
242+ };
243+ })]; })
244+, haskellNixArgs ? import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz)
245+}:
246+ pkgs
163247```
164248
165249## Using `nix repl`
@@ -169,10 +253,10 @@ attrsets and try examples.
169253
170254```
171255# example.nix
172−{ pkgs ? import <nixpkgs> {} }:
256+{ nixpkgs ? <nixpkgs> }:
173257rec {
174− haskell = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) { inherit pkgs; };
175− pkgNames = pkgs.lib.attrNames haskell.snapshots."lts-13.18";
258+ haskell = import nixpkgs (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz));
259+ pkgNames = haskell.pkgs.lib.attrNames haskell.haskell-nix.snapshots."lts-13.18";
176260}
177261```
178262
docs/user-guide/projects.md+17−5
@@ -1,22 +1,34 @@
1−# How to create Nix builds for your own private Haskell packages
1+# How to replace IFDs with intermediate nix files
2+
3+We believe that imports from derivations (IFDs) provide tremendous
4+value in nix and the aversion towards them stems mostly from
5+poor tooling and ci support for them. We do not believe
6+that poor tooling or ci support should cripple nix capability
7+of abstraction. Hence haskell.nix makes excessive use of
8+IFDs.
9+
10+We do note however that there are users who prefer to
11+have IFD-free expressions. For this group of users we
12+detail how to expand the IFD dependent high level functions
13+into their IFD free building blocks.
214
315The general structure will be the same, independent of the use of
416Stack or Cabal.
517
618Let us assume for now that we have already generated a `pkgs.nix`
7−expression. The following file then produces a package set:
19+expression (see the links bellow). The following file then produces a package set:
820
921```nix
1022# default.nix
1123let
1224 # Import the Haskell.nix library,
13− haskell = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};
25+ pkgs = import <nixpkgs> (import builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz);
1426
1527 # Import the file you will create in the stack-to-nix or cabal-to-nix step.
1628 my-pkgs = import ./pkgs.nix;
1729
1830 # Stack projects use this:
19− pkgSet = haskell.mkStackPkgSet {
31+ pkgSet = pkgs.haskell-nix.mkStackPkgSet {
2032 stack-pkgs = my-pkgs;
2133 pkg-def-extras = [
2234 # these extras will provide additional packages
@@ -36,7 +48,7 @@ let
3648 };
3749
3850 # Cabal projects use this:
39− pkgSet = haskell.mkCabalProjectPkgSet {
51+ pkgSet = pkgs.haskell-nix.mkCabalProjectPkgSet {
4052 plan-pkgs = my-pkgs;
4153 pkg-def-extras = [];
4254 modules = [
examples/Cabal-install-folder.diffnew file+41
@@ -0,0 +1,41 @@
1+diff --git a/Distribution/Simple/GHC.hs b/Distribution/Simple/GHC.hs
2+index 547776046..176e59111 100644
3+--- a/Distribution/Simple/GHC.hs
4++++ b/Distribution/Simple/GHC.hs
5+@@ -1,6 +1,7 @@
6+ {-# LANGUAGE FlexibleContexts #-}
7+ {-# LANGUAGE RankNTypes #-}
8+ {-# LANGUAGE TupleSections #-}
9++{-# LANGUAGE LambdaCase #-}
10+ {-# LANGUAGE CPP #-}
11+
12+ -----------------------------------------------------------------------------
13+@@ -1755,13 +1756,27 @@ installExe verbosity lbi binDir buildPref
14+ let exeName' = unUnqualComponentName $ exeName exe
15+ exeFileName = exeTargetName (hostPlatform lbi) exe
16+ fixedExeBaseName = progprefix ++ exeName' ++ progsuffix
17+- installBinary dest = do
18++ exePath = buildPref </> exeName' </> exeFileName
19++ installBinary dest = doesFileExist exePath >>= \case
20++ True -> do
21+ installExecutableFile verbosity
22+ (buildPref </> exeName' </> exeFileName)
23+ (dest <.> exeExtension (hostPlatform lbi))
24+ when (stripExes lbi) $
25+ Strip.stripExe verbosity (hostPlatform lbi) (withPrograms lbi)
26+ (dest <.> exeExtension (hostPlatform lbi))
27++ False -> do
28++ putStrLn "Hello!"
29++ -- The executable exists but is not a simple file.
30++ -- Deligate installation to the compiler
31++ runDbProgram verbosity ghcProgram (withPrograms lbi) $
32++ [ "--install-executable"
33++ , buildPref </> exeName' </> exeFileName
34++ , "-o", dest
35++ ] ++
36++ case (stripExes lbi, lookupProgram stripProgram $ withPrograms lbi) of
37++ (True, Just strip) -> ["-strip-program", programPath strip]
38++ _ -> []
39+ installBinary (binDir </> fixedExeBaseName)
40+
41+ -- |Install foreign library for GHC.
examples/cardano-sl-mingw32.nixnew file+38
@@ -0,0 +1,38 @@
1+with import ../. { nixpkgs = ../nixpkgs; nixpkgsArgs = { crossSystem = { config = "x86_64-pc-mingw32"; }; }; };
2+let Cabal = buildPackages.haskell-nix.hackage-package {
3+ name = "Cabal"; version = "2.4.1.0";
4+ modules = [
5+ { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
6+ ];
7+}; in
8+# (haskell-nix.stackProject {
9+# src = ../cardano-wallet;
10+# modules = [
11+# ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
12+# ];}).cardano-wallet.components.all
13+(let stack-pkgs = import ../cardano-sl/flags-test/pkgs.nix;
14+ in let pkg-set = haskell-nix.mkStackPkgSet
15+ { inherit stack-pkgs;
16+ pkg-def-extras = [(hackage: {
17+ packages = {
18+ # "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
19+ "process" = (((hackage.process)."1.6.5.0").revisions).default;
20+ Win32 = hackage.Win32."2.6.1.0".revisions.default;
21+ };
22+ })
23+ (hackage: {
24+ packages = {
25+ "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
26+ };
27+ })];
28+ modules = [
29+ { packages.Cabal.patches = [ ./overlays/patches/Cabal/fix-data-dir.patch ]; }
30+ { packages.alex.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
31+ { packages.happy.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
32+ { doHaddock = false; }
33+ ];
34+ # ++ (args.modules or [])
35+ # ++ self.lib.optional (args ? ghc) { ghc.package = args.ghc; };
36+ };
37+ in pkg-set.config.hsPkgs
38+).cardano-sl.components.all
examples/cardano-sl.nixnew file+37
@@ -0,0 +1,37 @@
1+with import ../. { nixpkgs = ../nixpkgs; nixpkgsArgs = { }; };
2+let Cabal = buildPackages.haskell-nix.hackage-package {
3+ name = "Cabal"; version = "2.4.1.0";
4+ modules = [
5+ { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
6+ ];
7+}; in
8+# (haskell-nix.stackProject {
9+# src = ../cardano-wallet;
10+# modules = [
11+# ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
12+# ];}).cardano-wallet.components.all
13+(let stack-pkgs = import ../cardano-sl/flags-test/pkgs.nix;
14+ in let pkg-set = haskell-nix.mkStackPkgSet
15+ { inherit stack-pkgs;
16+ pkg-def-extras = [(hackage: {
17+ packages = {
18+ # "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
19+ "process" = (((hackage.process)."1.6.5.0").revisions).default;
20+ };
21+ })
22+ (hackage: {
23+ packages = {
24+ "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
25+ };
26+ })];
27+ modules = [
28+ { packages.Cabal.patches = [ ./overlays/patches/Cabal/fix-data-dir.patch ]; }
29+ { packages.alex.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
30+ { packages.happy.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
31+ { doHaddock = false; }
32+ ];
33+ # ++ (args.modules or [])
34+ # ++ self.lib.optional (args ? ghc) { ghc.package = args.ghc; };
35+ };
36+ in pkg-set.config.hsPkgs
37+).cardano-sl.components.all
examples/cardano-wallet-ghcjs.nixnew file+38
@@ -0,0 +1,38 @@
1+with import ../. { nixpkgs = ../nixpkgs; nixpkgsArgs = { crossSystem = { config = "js-unknown-ghcjs"; }; }; };
2+let Cabal = buildPackages.haskell-nix.hackage-package {
3+ name = "Cabal"; version = "2.4.1.0";
4+ modules = [
5+ { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
6+ ];
7+}; in
8+# (haskell-nix.stackProject {
9+# src = ../cardano-wallet;
10+# modules = [
11+# ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
12+# ];}).cardano-wallet.components.all
13+(let stack-pkgs = import ../cardano-wallet/flags-test/pkgs.nix;
14+ in let pkg-set = haskell-nix.mkStackPkgSet
15+ { inherit stack-pkgs;
16+ pkg-def-extras = [(hackage: {
17+ packages = {
18+ "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
19+ "process" = (((hackage.process)."1.6.5.0").revisions).default;
20+ Win32 = hackage.Win32."2.8.3.0".revisions.default;
21+ };
22+ })
23+ (hackage: {
24+ packages = {
25+ "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
26+ };
27+ })];
28+ modules = [
29+ { packages.Cabal.patches = [ ./overlays/patches/Cabal/fix-data-dir.patch ]; }
30+ { packages.alex.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
31+ { packages.happy.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
32+ { doHaddock = false; }
33+ ];
34+ # ++ (args.modules or [])
35+ # ++ self.lib.optional (args ? ghc) { ghc.package = args.ghc; };
36+ };
37+ in pkg-set.config.hsPkgs
38+).cardano-wallet.components.all
examples/cardano-wallet-mingw32.nixnew file+38
@@ -0,0 +1,38 @@
1+with import ../. { nixpkgs = ../../nixpkgs; nixpkgsArgs = { crossSystem = { config = "x86_64-pc-mingw32"; }; }; };
2+let Cabal = buildPackages.haskell-nix.hackage-package {
3+ name = "Cabal"; version = "2.4.1.0";
4+ modules = [
5+ { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
6+ ];
7+}; in
8+# (haskell-nix.stackProject {
9+# src = ../cardano-wallet;
10+# modules = [
11+# ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
12+# ];}).cardano-wallet.components.all
13+(let stack-pkgs = import ../../cardano-wallet/flags-test/pkgs.nix;
14+ in let pkg-set = haskell-nix.mkStackPkgSet
15+ { inherit stack-pkgs;
16+ pkg-def-extras = [(hackage: {
17+ packages = {
18+ "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
19+ "process" = (((hackage.process)."1.6.5.0").revisions).default;
20+ Win32 = hackage.Win32."2.8.3.0".revisions.default;
21+ };
22+ })
23+ (hackage: {
24+ packages = {
25+ "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
26+ };
27+ })];
28+ modules = [
29+ { packages.Cabal.patches = [ ./overlays/patches/Cabal/fix-data-dir.patch ]; }
30+ { packages.alex.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
31+ { packages.happy.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
32+ { doHaddock = false; }
33+ ];
34+ # ++ (args.modules or [])
35+ # ++ self.lib.optional (args ? ghc) { ghc.package = args.ghc; };
36+ };
37+ in pkg-set.config.hsPkgs
38+).cardano-wallet.components.all
examples/cardano-wallet-rpi.nixnew file+38
@@ -0,0 +1,38 @@
1+with import ../. { nixpkgs = ../nixpkgs; nixpkgsArgs = { crossSystem = { config = "armv6l-unknown-linux-gnueabihf"; }; }; };
2+let Cabal = buildPackages.haskell-nix.hackage-package {
3+ name = "Cabal"; version = "2.4.1.0";
4+ modules = [
5+ { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
6+ ];
7+}; in
8+# (haskell-nix.stackProject {
9+# src = ../cardano-wallet;
10+# modules = [
11+# ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
12+# ];}).cardano-wallet.components.all
13+(let stack-pkgs = import ../cardano-wallet/flags-test/pkgs.nix;
14+ in let pkg-set = haskell-nix.mkStackPkgSet
15+ { inherit stack-pkgs;
16+ pkg-def-extras = [(hackage: {
17+ packages = {
18+ "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
19+ "process" = (((hackage.process)."1.6.5.0").revisions).default;
20+ Win32 = hackage.Win32."2.8.3.0".revisions.default;
21+ };
22+ })
23+ (hackage: {
24+ packages = {
25+ "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
26+ };
27+ })];
28+ modules = [
29+ { packages.Cabal.patches = [ ./overlays/patches/Cabal/fix-data-dir.patch ]; }
30+ { packages.alex.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
31+ { packages.happy.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
32+ { doHaddock = false; }
33+ ];
34+ # ++ (args.modules or [])
35+ # ++ self.lib.optional (args ? ghc) { ghc.package = args.ghc; };
36+ };
37+ in pkg-set.config.hsPkgs
38+).cardano-wallet.components.all
examples/cardano-wallet.nixnew file+36
@@ -0,0 +1,36 @@
1+with import ../. { nixpkgs = ../../nixpkgs; nixpkgsArgs = { }; };
2+let Cabal = buildPackages.haskell-nix.hackage-package {
3+ name = "Cabal"; version = "2.4.1.0";
4+ modules = [
5+ { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
6+ ];
7+}; in
8+# (haskell-nix.stackProject {
9+# src = ../cardano-wallet;
10+# modules = [
11+# ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
12+# ];}).cardano-wallet.components.all
13+(let stack-pkgs = import ../../cardano-wallet/flags-test/pkgs.nix;
14+ in let pkg-set = haskell-nix.mkStackPkgSet
15+ { inherit stack-pkgs;
16+ pkg-def-extras = [(hackage: {
17+ packages = {
18+ "transformers" = (((hackage.transformers)."0.5.6.2").revisions).default;
19+ "process" = (((hackage.process)."1.6.5.0").revisions).default;
20+ };
21+ })
22+ (hackage: {
23+ packages = {
24+ "hsc2hs" = (((hackage.hsc2hs)."0.68.4").revisions).default;
25+ };
26+ })];
27+ modules = [
28+ { packages.Cabal.patches = [ ../overlays/patches/Cabal/fix-data-dir.patch ]; }
29+ { packages.alex.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
30+ { packages.happy.package.setup-depends = [pkg-set.config.hsPkgs.Cabal]; }
31+ ];
32+ # ++ (args.modules or [])
33+ # ++ self.lib.optional (args ? ghc) { ghc.package = args.ghc; };
34+ };
35+ in pkg-set.config.hsPkgs
36+).cardano-wallet.components.all
lib/call-cabal-project-to-nix.nix+16−10
@@ -1,9 +1,14 @@
1−{ dotCabal, pkgs, runCommand, nix-tools, cabal-install, ghc, hpack, symlinkJoin, cacert, index-state-hashes, haskellLib }:
2−let defaultGhc = ghc;
3− defaultCabalInstall = cabal-install;
4−in { index-state ? null, index-sha256 ? null, src, ghc ? defaultGhc,
5− cabal-install ? defaultCabalInstall, cabalProject ? null }:
6−
1+{ dotCabal, pkgs, runCommand, nix-tools, cabal-install, ghc, hpack, symlinkJoin, cacert, index-state-hashes, haskellLib }@defaults:
2+{ src
3+, index-state ? null
4+, index-sha256 ? null
5+, cabalProject ? null
6+, ghc ? defaults.ghc
7+, nix-tools ? defaults.nix-tools
8+, hpack ? defaults.hpack
9+, cabal-install ? defaults.cabal-install
10+, ...
11+}@args:
712# cabal-install versions before 2.4 will generate insufficient plan information.
813assert (if (builtins.compareVersions cabal-install.version "2.4.0.0") < 0
914 then throw "cabal-install (current version: ${cabal-install.version}) needs to be at least 2.4 for plan-to-nix to work without cabal-to-nix"
@@ -139,6 +144,8 @@ let
139144
140145 plan-nix = runCommand "plan-to-nix-pkgs" {
141146 nativeBuildInputs = [ nix-tools ghc hpack cabal-install pkgs.rsync pkgs.git ];
147+ # Needed or stack-to-nix will die on unicode inputs
148+ LANG = "en_US.UTF-8";
142149 } (''
143150 tmp=$(mktemp -d)
144151 cd $tmp
@@ -153,14 +160,13 @@ let
153160 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
154161 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
155162 HOME=${dotCabal {
163+ inherit cabal-install nix-tools;
156164 index-state = index-state-found;
157− sha256 = index-sha256-found;
158− inherit cabal-install; }} cabal new-configure \
165+ sha256 = index-sha256-found; }} cabal new-configure \
159166 --with-ghc=${ghc.targetPrefix}ghc \
160167 --with-ghc-pkg=${ghc.targetPrefix}ghc-pkg \
161168 --enable-tests
162169
163− export LANG=C.utf8 # Needed or stack-to-nix will die on unicode inputs
164170 mkdir -p $out
165171
166172 # ensure we have all our .cabal files (also those generated from package.yaml) files.
@@ -186,4 +192,4 @@ let
186192 # move pkgs.nix to default.nix ensure we can just nix `import` the result.
187193 mv $out/pkgs.nix $out/default.nix
188194 '');
189−in { projectNix = plan-nix; inherit src; inherit (fixedProject) sourceRepos; }
195+in { projectNix = plan-nix; inherit src; inherit (fixedProject) sourceRepos; }
lib/call-stack-to-nix.nix+13−8
@@ -5,9 +5,9 @@
55 *
66 * see also `call-cabal-project-to-nix`!
77 */
8−{ runCommand, nix-tools, pkgs }:
9−{ src, stackYaml ? null, ignorePackageYaml ? false }:
10−let
8+{ runCommand, nix-tools, pkgs, mkCacheFile }:
9+{ src, stackYaml ? null, ignorePackageYaml ? false, cache ? null, ... }:
10+let
1111 stackToNixArgs = builtins.concatStringsSep " " [
1212 "--full"
1313 "--stack-yaml=${src}/${if stackYaml == null then "stack.yaml" else stackYaml}"
@@ -15,11 +15,16 @@ let
1515 "-o ."
1616 ];
1717 stack = runCommand "stack-to-nix-pkgs" {
18− nativeBuildInputs = [ nix-tools pkgs.nix-prefetch-git ];
19− } ''
20− export LANG=C.utf8 # Needed or stack-to-nix will die on unicode inputs
18+ nativeBuildInputs = [ nix-tools pkgs.nix-prefetch-git pkgs.cacert ];
19+ # Needed or stack-to-nix will die on unicode inputs
20+ LOCALE_ARCHIVE = pkgs.lib.optionalString (pkgs.stdenv.hostPlatform.libc == "glibc") "${pkgs.glibcLocales}/lib/locale/locale-archive";
21+ LANG = "en_US.UTF-8";
22+ LC_ALL = "en_US.UTF-8";
23+ } (''
2124 mkdir -p $out
22−
25+ '' + pkgs.lib.optionalString (cache != null) ''
26+ cp ${mkCacheFile cache} $out/.stack-to-nix.cache
27+ '' + ''
2328 (cd $out && stack-to-nix ${stackToNixArgs})
2429
2530 # We need to strip out any references to $src, as those won't
@@ -30,5 +35,5 @@ let
3035
3136 # move pkgs.nix to default.nix ensure we can just nix `import` the result.
3237 mv $out/pkgs.nix $out/default.nix
33− '';
38+ '');
3439in { projectNix = stack; inherit src; sourceRepos = []; }
lib/clean-git.nixnew file+101
@@ -0,0 +1,101 @@
1+# From https://github.com/NixOS/nix/issues/2944
2+{ lib, runCommand, git, cleanSourceWith }:
3+{ src }:
4+
5+# The function call
6+#
7+# gitSource ./toplevel subpath
8+#
9+# creates a Nix store path of ./toplevel/subpath that includes only those files
10+# tracked by git. More precisely: mentioned in the git index (i.e. git add is enough
11+# to get them to be included, you do not have to commit).
12+#
13+# This is a whitelist-based alternative to manually listing files or using
14+# nix-gitignore.
15+
16+# Internally, it works by calling git ls-files at evaluation time. To
17+# avoid copying all of `.git` to the git store, it only copies the least amount
18+# of files necessary for `git ls-files` to work; this is a bit fragile, but
19+# very fast.
20+
21+with builtins;
22+
23+# We read the git index once, before getting the subdir parameter, so that it
24+# is shared among multiple invocations of gitSource:
25+
26+let
27+ filter_from_list = root: files:
28+ let
29+ all_paren_dirs = p:
30+ if p == "." || p == "/"
31+ then []
32+ else [ p ] ++ all_paren_dirs (dirOf p);
33+
34+ whitelist_set = listToAttrs (
35+ concatMap (p:
36+ let full_path = toString (root + "/${p}"); in
37+ map (p': { name = p'; value = true; }) (all_paren_dirs full_path)
38+ ) files
39+ );
40+ in
41+ p: t: hasAttr (toString p) whitelist_set;
42+
43+ has_prefix = prefix: s:
44+ prefix == builtins.substring 0 (builtins.stringLength prefix) s;
45+ remove_prefix = prefix: s:
46+ builtins.substring
47+ (builtins.stringLength prefix)
48+ (builtins.stringLength s - builtins.stringLength prefix)
49+ s;
50+
51+ lines = s: filter (x : x != [] && x != "") (split "\n" s);
52+in
53+
54+if builtins.pathExists (toString src + "/.git")
55+then
56+ let
57+ git_dir =
58+ if builtins.pathExists (toString src + "/.git/index")
59+ then (toString src + "/.git")
60+ else # likely a git worktree, so follow the indirection
61+ let
62+ git_content = lines (readFile (toString src + "/.git"));
63+ first_line = head git_content;
64+ prefix = "gitdir: ";
65+ ok = length git_content == 1 && has_prefix prefix first_line;
66+ in
67+ if ok
68+ then /. + remove_prefix prefix first_line
69+ else abort "gitSource.nix: Cannot parse ${toString src + "/.git"}";
70+
71+ gitFiles = cleanSourceWith {
72+ inherit src;
73+ filter = path: type:
74+ type == "directory" ||
75+ lib.any (i: (lib.hasSuffix i path)) [
76+ ".gitmodules" ".git/config" ".git/index" ".git/HEAD" ".git/objects" ".git/refs" ] ||
77+ (lib.strings.hasInfix ".git/modules/" path &&
78+ lib.any (i: (lib.hasSuffix i path)) [
79+ "config" "index" "HEAD" "objects" "refs" ]);
80+ };
81+
82+ whitelist_file =
83+ runCommand "git-ls-files" {envVariable = true;} ''
84+ cd ${gitFiles}
85+ ${git}/bin/git ls-files --recurse-submodules > $out
86+ '';
87+
88+ whitelist = lines (readFile (whitelist_file.out));
89+
90+ filter = filter_from_list src whitelist;
91+ in
92+ cleanSourceWith {
93+ inherit src filter;
94+ }
95+
96+else
97+ trace "gitSource.nix: ${toString src} does not seem to be a git repository,\nassuming it is a clean checkout." (
98+ cleanSourceWith {
99+ inherit src;
100+ }
101+ )
lib/default.nix+18−5
@@ -1,4 +1,4 @@
1−{ lib, haskellLib }:
1+{ lib, haskellLib, runCommand, git }:
22
33with haskellLib;
44
@@ -97,13 +97,21 @@ with haskellLib;
9797 ## flatLibDepends :: Component -> [Package]
9898 flatLibDepends = component:
9999 let
100− makePairs = map (p: rec { key="${val}"; val=(p.components.library or p); });
100+ # this is a minor improvement over the "cannot coerce set to string"
101+ # error. It will now say:
102+ #
103+ # > The option `packages.Win32.package.identifier.name' is used but not defined.
104+ #
105+ # which indicates that the package.Win32 is missing and not defined.
106+ getKey = x: if x ? "outPath" then "${x}" else (throw x.identifier.name);
107+ makePairs = map (p: rec { key=getKey val; val=(p.components.library or p); });
101108 closure = builtins.genericClosure {
102109 startSet = makePairs component.depends;
103110 operator = {val,...}: makePairs val.config.depends;
104111 };
105112 in map ({val,...}: val) closure;
106113
114+
107115 # Extracts a selection of components from a Haskell package set.
108116 #
109117 # This can be used to filter out all test suites or benchmarks of
@@ -118,14 +126,19 @@ with haskellLib;
118126 # to: tests.mypackage.unit-tests
119127 #
120128 collectComponents = group: packageSel: haskellPackages:
121− (mapAttrs (_: package: package.components.${group} // { recurseForDerivations = true; })
122− (filterAttrs (name: package: (package.isHaskell or false) && packageSel package) haskellPackages))
129+ (lib.mapAttrs (_: package: package.components.${group} // { recurseForDerivations = true; })
130+ (lib.filterAttrs (name: package: (package.isHaskell or false) && packageSel package) haskellPackages))
123131 // { recurseForDerivations = true; };
124132
125133 # Replacement for lib.cleanSourceWith that has a subDir argument.
126134 inherit (import ./clean-source-with.nix { inherit lib; }) cleanSourceWith canCleanSource;
127−
135+
128136 # Use cleanSourceWith to filter just the files needed for a particular
129137 # component of a package
130138 cleanCabalComponent = import ./clean-cabal-component.nix { inherit lib cleanSourceWith; };
139+
140+ # Clean git directory based on `git ls-files --recurse-submodules`
141+ cleanGit = import ./clean-git.nix {
142+ inherit lib runCommand git cleanSourceWith;
143+ };
131144}
lib/pkgconf-nixpkgs-map.nix+1
@@ -81,6 +81,7 @@ pkgs:
8181 "libpcre" = [ pkgs."pcre" ];
8282 "libqrencode" = [ pkgs."qrencode" ];
8383 "libR" = [ pkgs."R" ];
84+ "librsvg-2.0" = [ pkgs."librsvg" ];
8485 "libsoup-2.4" = [ pkgs."libsoup" ];
8586 "libsoup-gnome-2.4" = [ pkgs."libsoup" ];
8687 "libsystemd" = [ pkgs."systemd" ];
mk-local-hackage-repo/default.nix+2−2
@@ -15,9 +15,9 @@
1515# reproducably.
1616#
1717{ pkgs, hackageTarball }:
18−{ index-state, sha256 }@args:
18+{ index-state, sha256, ... }@args:
1919let index = hackageTarball args; in
20−pkgs.runCommand "hackage-repo-${builtins.replaceStrings [":"] [""] index-state}" { nativeBuildInputs = [ pkgs.nix ]; } ''
20+pkgs.runCommand "hackage-repo-${builtins.replaceStrings [":"] [""] index-state}" { nativeBuildInputs = [ pkgs.buildPackages.nix ]; } ''
2121mkdir -p $out
2222export expires="4000-01-01T00:00:00Z"
2323
modules/component-driver.nix+35−7
@@ -3,16 +3,24 @@ let
33 builder = haskellLib.weakCallPackage pkgs ../builder {
44 inherit haskellLib;
55 ghc = config.ghc.package;
6− buildGHC = buildModules.config.ghc.package;
76 inherit (config) nonReinstallablePkgs hsPkgs;
87 };
98
109in
1110
1211{
12+ # this has a slightly modified option type. we will *overwrite* any previous
13+ # setting of nonRelocatablePkgs, instead of merging them. Otherwise you
14+ # have no chance of removing packages retroacively. We might improvie this
15+ # by implementing a logic that would allow +xxx to be added, -xxx to be removed
16+ # and if it's not a list of -/+ prefixed strings, be assumed to be overwriting.
17+ # This seems ugly.
1318 options.nonReinstallablePkgs = lib.mkOption {
14− type = lib.types.listOf lib.types.str;
19+ type = (lib.types.listOf lib.types.str) // {
20+ merge = loc: defs: lib.last (lib.getValues defs);
21+ };
1522 };
23+
1624 options.reinstallableLibGhc = lib.mkOption {
1725 type = lib.types.bool;
1826 default = false;
@@ -20,14 +28,14 @@ in
2028 };
2129
2230 # Dependencies (with reinstallable-lib:ghc)
23− #
31+ #
2432 # .--------. .------------------.
2533 # | pretty | < ------- | template-haskell |
2634 # '--------' '------------------'
2735 # v |
2836 # .---------. .-------. |
29− # | deepseq | - > | array | |
30− # '---------' '-------' v
37+ # | deepseq | - > | array | |
38+ # '---------' '-------' v
3139 # v v .-------------.
3240 # .----------. .----------. .------. .- | ghc-boot-th |
3341 # | ghc-heap | | ghc-prim | | base |< -' '-------------'
@@ -41,7 +49,27 @@ in
4149
4250 config.nonReinstallablePkgs =
4351 [ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base"
44− "deepseq" "array" "ghc-boot" "ghc-boot-th" "pretty" "template-haskell" ]
52+ "deepseq" "array" "ghc-boot-th" "pretty" "template-haskell"
53+ # ghcjs custom packages
54+ "ghcjs-prim" "ghcjs-th"
55+"ghc" "Cabal" "Win32" "array" "base" "binary" "bytestring" "containers" "deepseq"
56+"directory" "filepath" "ghc-boot" "ghc-compact" "ghc-prim"
57+# "ghci" "haskeline"
58+"hpc"
59+"integer-gmp" "mtl" "parsec" "process" "template-haskell" "text" "time" "transformers"
60+"unix" "xhtml"
61+# "stm" "terminfo"
62+ ]
63+ ++ lib.optionals (!config.reinstallableLibGhc) [ "ghc" "ghc-boot" ];
64+
65+ options.bootPkgs = lib.mkOption {
66+ type = lib.types.listOf lib.types.str;
67+ };
68+
69+ config.bootPkgs = [
70+ "rts" "ghc-boot-th"
71+ "ghc-heap" # since ghc 8.6.
72+ ]
4573 ++ lib.optional (!config.reinstallableLibGhc) "ghc";
4674
4775 options.hsPkgs = lib.mkOption {
@@ -54,5 +82,5 @@ in
5482 } //
5583 lib.mapAttrs
5684 (name: pkg: if pkg == null then null else builder.build-package pkg)
57− (config.packages // lib.genAttrs config.nonReinstallablePkgs (_: null));
85+ (config.packages // lib.genAttrs (config.nonReinstallablePkgs ++ config.bootPkgs) (_: null));
5886}
modules/plan.nix+15−3
@@ -22,7 +22,15 @@ let
2222 # without raising an error. And a way to fetch default options that will retain `null` if the
2323 # option is not defined or "".
2424 getDefaultOrNull = def: key: if def ? ${key} && def.${key} != "" then def.${key} else null;
25− mergeUniqueOption = locs: defs: mergeOneOption locs (lists.unique defs);
25+ mergeUniqueOption = locs: defs: let
26+ mergeOneOption = loc: defs':
27+ # we ignore "" as optionalString, will default to "".
28+ let defs = filter (x: x.value != "") defs'; in
29+ if defs == [] then null
30+ else if length defs != 1 then
31+ throw "The unique option `${showOption loc}' is defined multiple times, in ${showFiles (getFiles defs)}; with values `${concatStringsSep "', `" (map (x: x.value) defs)}'."
32+ else (head defs).value;
33+ in mergeOneOption locs (lists.unique defs);
2634 uniqueStr = str // { merge = mergeUniqueOption; };
2735
2836 # This is just like listOf, except that it filters out all null elements.
@@ -43,6 +51,10 @@ let
4351 };
4452
4553 componentOptions = def: {
54+ buildable = mkOption {
55+ type = bool;
56+ default = true;
57+ };
4658 configureFlags = mkOption {
4759 type = listOfFilteringNulls str;
4860 default = (def.configureFlags or []);
@@ -138,8 +150,8 @@ let
138150 };
139151 # Wrapper for test executable run in checkPhase
140152 testWrapper = mkOption {
141− type = nullOr str;
142− default = def.testWrapper or null;
153+ type = listOfFilteringNulls str;
154+ default = def.testWrapper or [];
143155 description = "A command to run for executing tests in checkPhase, which takes the original test command as its arguments.";
144156 example = "echo";
145157 };
nix-tools/default.nix+6−3
@@ -1,6 +1,7 @@
11{ pkgs, lib, symlinkJoin, makeWrapper
22, hpack, git, nix, nix-prefetch-git
3−, fetchExternal, cleanSourceHaskell, mkCabalProjectPkgSet }:
3+, fetchExternal, cleanSourceHaskell, mkCabalProjectPkgSet
4+, ... }@args:
45
56let
67 src = cleanSourceHaskell (fetchExternal {
@@ -18,7 +19,9 @@ let
1819 };
1920
2021 pkgSet = mkCabalProjectPkgSet {
21− plan-pkgs = import ./pkgs.nix;
22+ plan-pkgs = if args ? ghc
23+ then import (./pkgs + "-${args.ghc.version}.nix")
24+ else import ./pkgs.nix;
2225 pkg-def-extras = [];
2326 modules = [
2427 {
@@ -36,7 +39,7 @@ let
3639 Cabal.patches = [ cabalPatch ];
3740 };
3841 })
39− ];
42+ ] ++ pkgs.lib.optional (args ? ghc) { ghc.package = args.ghc; };
4043 };
4144
4245 hsPkgs = pkgSet.config.hsPkgs;
nix-tools/.plan-pkgs.nix → nix-tools/pkgs-8.4.4.nixrenamed+58−37
@@ -7,7 +7,7 @@
77 "test-framework-hunit".revision = (((hackage."test-framework-hunit")."0.3.0.2").revisions).default;
88 "test-framework-hunit".flags.base4 = true;
99 "test-framework-hunit".flags.base3 = false;
10− "http-client".revision = (((hackage."http-client")."0.6.1").revisions).default;
10+ "http-client".revision = (((hackage."http-client")."0.6.4").revisions).default;
1111 "http-client".flags.network-uri = true;
1212 "cookie".revision = (((hackage."cookie")."0.4.4").revisions).default;
1313 "void".revision = (((hackage."void")."0.7.2").revisions).default;
@@ -21,15 +21,15 @@
2121 "semigroupoids".flags.containers = true;
2222 "semigroupoids".flags.contravariant = true;
2323 "free".revision = (((hackage."free")."5.1").revisions).default;
24− "tf-random".revision = (((hackage."tf-random")."0.5").revisions).default;
2524 "Only".revision = (((hackage."Only")."0.1").revisions).default;
2625 "cereal".revision = (((hackage."cereal")."0.5.8.0").revisions).default;
2726 "cereal".flags.bytestring-builder = false;
28− "exceptions".revision = (((hackage."exceptions")."0.10.0").revisions).default;
27+ "exceptions".revision = (((hackage."exceptions")."0.10.1").revisions).default;
2928 "cryptohash-sha256".revision = (((hackage."cryptohash-sha256")."0.11.101.0").revisions).default;
3029 "cryptohash-sha256".flags.exe = false;
3130 "binary".revision = (((hackage."binary")."0.8.5.1").revisions).default;
3231 "interpolate".revision = (((hackage."interpolate")."0.2.0").revisions).default;
32+ "generic-random".revision = (((hackage."generic-random")."1.2.0.0").revisions).default;
3333 "tar".revision = (((hackage."tar")."0.5.1.0").revisions).default;
3434 "tar".flags.old-time = false;
3535 "tar".flags.old-bytestring = false;
@@ -39,18 +39,19 @@
3939 "text-metrics".revision = (((hackage."text-metrics")."0.3.0").revisions).default;
4040 "text-metrics".flags.dev = false;
4141 "utf8-string".revision = (((hackage."utf8-string")."1.0.1.1").revisions).default;
42− "bifunctors".revision = (((hackage."bifunctors")."5.5.3").revisions).default;
42+ "bifunctors".revision = (((hackage."bifunctors")."5.5.4").revisions).default;
4343 "bifunctors".flags.semigroups = true;
4444 "bifunctors".flags.tagged = true;
4545 "hashing".revision = (((hackage."hashing")."0.1.0.1").revisions).default;
46− "extra".revision = (((hackage."extra")."1.6.14").revisions).default;
46+ "extra".revision = (((hackage."extra")."1.6.15").revisions).default;
4747 "haskeline".revision = (((hackage."haskeline")."0.7.4.2").revisions).default;
48− "logict".revision = (((hackage."logict")."0.6.0.2").revisions).default;
48+ "logict".revision = (((hackage."logict")."0.6.0.3").revisions).default;
4949 "x509-validation".revision = (((hackage."x509-validation")."1.6.11").revisions).default;
5050 "dense-linear-algebra".revision = (((hackage."dense-linear-algebra")."0.1.0.0").revisions).default;
5151 "split".revision = (((hackage."split")."0.2.3.3").revisions).default;
5252 "data-fix".revision = (((hackage."data-fix")."0.2.0").revisions).default;
5353 "stm".revision = (((hackage."stm")."2.4.5.1").revisions).default;
54+ "tasty-th".revision = (((hackage."tasty-th")."0.1.7").revisions).default;
5455 "text-short".revision = (((hackage."text-short")."0.1.2").revisions).default;
5556 "text-short".flags.asserts = false;
5657 "microstache".revision = (((hackage."microstache")."1.0.1.1").revisions).default;
@@ -59,7 +60,9 @@
5960 "case-insensitive".revision = (((hackage."case-insensitive")."1.2.0.11").revisions).default;
6061 "extensible-exceptions".revision = (((hackage."extensible-exceptions")."0.1.1.4").revisions).default;
6162 "unix".revision = (((hackage."unix")."2.7.2.2").revisions).default;
63+ "tasty-quickcheck".revision = (((hackage."tasty-quickcheck")."0.10").revisions).default;
6264 "mtl".revision = (((hackage."mtl")."2.2.2").revisions).default;
65+ "lifted-async".revision = (((hackage."lifted-async")."0.10.0.3").revisions).default;
6366 "network-uri".revision = (((hackage."network-uri")."2.6.1.0").revisions).default;
6467 "asn1-parse".revision = (((hackage."asn1-parse")."0.9.4").revisions).default;
6568 "regex-base".revision = (((hackage."regex-base")."0.93.2").revisions).default;
@@ -69,6 +72,7 @@
6972 "zlib".flags.non-blocking-ffi = false;
7073 "zlib".flags.pkg-config = false;
7174 "rts".revision = (((hackage."rts")."1.0").revisions).default;
75+ "mmorph".revision = (((hackage."mmorph")."1.1.3").revisions).default;
7276 "js-flot".revision = (((hackage."js-flot")."0.8.3").revisions).default;
7377 "statistics".revision = (((hackage."statistics")."0.15.0.0").revisions).default;
7478 "th-expand-syns".revision = (((hackage."th-expand-syns")."0.4.4.0").revisions).default;
@@ -85,12 +89,12 @@
8589 "cryptonite".flags.check_alignment = false;
8690 "cryptonite".flags.old_toolchain_inliner = false;
8791 "microlens-aeson".revision = (((hackage."microlens-aeson")."2.3.0.1").revisions).default;
88− "clock".revision = (((hackage."clock")."0.7.2").revisions).default;
92+ "clock".revision = (((hackage."clock")."0.8").revisions).default;
8993 "clock".flags.llvm = false;
9094 "adjunctions".revision = (((hackage."adjunctions")."4.4").revisions).default;
9195 "cryptohash-md5".revision = (((hackage."cryptohash-md5")."0.11.100.1").revisions).default;
92− "invariant".revision = (((hackage."invariant")."0.5.1").revisions).default;
93− "th-orphans".revision = (((hackage."th-orphans")."0.13.6").revisions).default;
96+ "invariant".revision = (((hackage."invariant")."0.5.2").revisions).default;
97+ "th-orphans".revision = (((hackage."th-orphans")."0.13.7").revisions).default;
9498 "pem".revision = (((hackage."pem")."0.2.4").revisions).default;
9599 "megaparsec".revision = (((hackage."megaparsec")."7.0.4").revisions).default;
96100 "megaparsec".flags.dev = false;
@@ -100,11 +104,14 @@
100104 "distributive".flags.tagged = true;
101105 "asn1-encoding".revision = (((hackage."asn1-encoding")."0.9.5").revisions).default;
102106 "vector-th-unbox".revision = (((hackage."vector-th-unbox")."0.2.1.6").revisions).default;
103− "QuickCheck".revision = (((hackage."QuickCheck")."2.12.6.1").revisions).default;
107+ "QuickCheck".revision = (((hackage."QuickCheck")."2.13.1").revisions).default;
104108 "QuickCheck".flags.templatehaskell = true;
105109 "scientific".revision = (((hackage."scientific")."0.3.6.2").revisions).default;
106110 "scientific".flags.integer-simple = false;
107111 "scientific".flags.bytestring-builder = false;
112+ "tasty".revision = (((hackage."tasty")."1.2.1").revisions).default;
113+ "tasty".flags.clock = true;
114+ "hspec-discover".revision = (((hackage."hspec-discover")."2.7.1").revisions).default;
108115 "monadlist".revision = (((hackage."monadlist")."0.0.2").revisions).default;
109116 "half".revision = (((hackage."half")."0.3").revisions).default;
110117 "parallel".revision = (((hackage."parallel")."3.2.2.0").revisions).default;
@@ -112,14 +119,16 @@
112119 "random".revision = (((hackage."random")."1.1").revisions).default;
113120 "uuid-types".revision = (((hackage."uuid-types")."1.0.3").revisions).default;
114121 "optparse-applicative".revision = (((hackage."optparse-applicative")."0.14.3.0").revisions).default;
115− "network".revision = (((hackage."network")."2.8.0.0").revisions).default;
116− "connection".revision = (((hackage."connection")."0.2.8").revisions).default;
122+ "network".revision = (((hackage."network")."3.1.0.0").revisions).default;
123+ "connection".revision = (((hackage."connection")."0.3.0").revisions).default;
124+ "splitmix".revision = (((hackage."splitmix")."0.0.2").revisions).default;
117125 "async".revision = (((hackage."async")."2.2.1").revisions).default;
118126 "async".flags.bench = false;
119− "dlist".revision = (((hackage."dlist")."0.8.0.5").revisions).default;
120− "conduit".revision = (((hackage."conduit")."1.3.1").revisions).default;
127+ "dlist".revision = (((hackage."dlist")."0.8.0.6").revisions).default;
128+ "conduit".revision = (((hackage."conduit")."1.3.1.1").revisions).default;
121129 "ref-tf".revision = (((hackage."ref-tf")."0.4.0.1").revisions).default;
122130 "x509-store".revision = (((hackage."x509-store")."1.6.7").revisions).default;
131+ "constraints".revision = (((hackage."constraints")."0.10.1").revisions).default;
123132 "lens-family-th".revision = (((hackage."lens-family-th")."0.5.0.2").revisions).default;
124133 "semigroups".revision = (((hackage."semigroups")."0.18.5").revisions).default;
125134 "semigroups".flags.bytestring = true;
@@ -135,15 +144,16 @@
135144 "HUnit".revision = (((hackage."HUnit")."1.6.0.0").revisions).default;
136145 "vector-instances".revision = (((hackage."vector-instances")."3.4").revisions).default;
137146 "vector-instances".flags.hashable = true;
147+ "lifted-base".revision = (((hackage."lifted-base")."0.2.3.12").revisions).default;
138148 "parsec".revision = (((hackage."parsec")."3.1.13.0").revisions).default;
139− "th-reify-many".revision = (((hackage."th-reify-many")."0.1.8").revisions).default;
149+ "th-reify-many".revision = (((hackage."th-reify-many")."0.1.9").revisions).default;
140150 "hsc2hs".revision = (((hackage."hsc2hs")."0.68.3").revisions).default;
141151 "hsc2hs".flags.in-ghc-tree = false;
142152 "directory".revision = (((hackage."directory")."1.3.1.5").revisions).default;
143153 "yaml".revision = (((hackage."yaml")."0.11.0.0").revisions).default;
144154 "yaml".flags.no-exe = true;
145155 "yaml".flags.no-examples = true;
146− "transformers-compat".revision = (((hackage."transformers-compat")."0.6.2").revisions).default;
156+ "transformers-compat".revision = (((hackage."transformers-compat")."0.6.4").revisions).default;
147157 "transformers-compat".flags.five = false;
148158 "transformers-compat".flags.generic-deriving = true;
149159 "transformers-compat".flags.two = false;
@@ -151,10 +161,10 @@
151161 "transformers-compat".flags.mtl = true;
152162 "transformers-compat".flags.four = false;
153163 "transformers-compat".flags.three = false;
154− "hpack".revision = (((hackage."hpack")."0.31.1").revisions).default;
164+ "hpack".revision = (((hackage."hpack")."0.31.2").revisions).default;
155165 "template-haskell".revision = (((hackage."template-haskell")."2.13.0.0").revisions).default;
156166 "mono-traversable".revision = (((hackage."mono-traversable")."1.0.11.0").revisions).default;
157− "vector".revision = (((hackage."vector")."0.12.0.2").revisions).default;
167+ "vector".revision = (((hackage."vector")."0.12.0.3").revisions).default;
158168 "vector".flags.unsafechecks = false;
159169 "vector".flags.internalchecks = false;
160170 "vector".flags.wall = false;
@@ -168,6 +178,7 @@
168178 "blaze-builder".revision = (((hackage."blaze-builder")."0.4.1.0").revisions).default;
169179 "base-compat".revision = (((hackage."base-compat")."0.10.5").revisions).default;
170180 "js-jquery".revision = (((hackage."js-jquery")."3.3.1").revisions).default;
181+ "terminal-size".revision = (((hackage."terminal-size")."0.3.2.1").revisions).default;
171182 "math-functions".revision = (((hackage."math-functions")."0.3.1.0").revisions).default;
172183 "math-functions".flags.system-expm1 = false;
173184 "x509-system".revision = (((hackage."x509-system")."1.6.6").revisions).default;
@@ -182,7 +193,7 @@
182193 "cassava".revision = (((hackage."cassava")."0.5.1.0").revisions).default;
183194 "cassava".flags.bytestring--lt-0_10_4 = false;
184195 "haskell-src-exts".revision = (((hackage."haskell-src-exts")."1.20.3").revisions).default;
185− "lens".revision = (((hackage."lens")."4.17").revisions).default;
196+ "lens".revision = (((hackage."lens")."4.17.1").revisions).default;
186197 "lens".flags.j = false;
187198 "lens".flags.test-properties = true;
188199 "lens".flags.old-inline-pragmas = false;
@@ -196,16 +207,17 @@
196207 "lens".flags.safe = false;
197208 "unliftio-core".revision = (((hackage."unliftio-core")."0.1.2.0").revisions).default;
198209 "containers".revision = (((hackage."containers")."0.5.11.0").revisions).default;
199− "integer-logarithms".revision = (((hackage."integer-logarithms")."1.0.2.2").revisions).default;
210+ "wl-pprint-annotated".revision = (((hackage."wl-pprint-annotated")."0.1.0.1").revisions).default;
211+ "integer-logarithms".revision = (((hackage."integer-logarithms")."1.0.3").revisions).default;
200212 "integer-logarithms".flags.check-bounds = false;
201213 "integer-logarithms".flags.integer-gmp = true;
202214 "reflection".revision = (((hackage."reflection")."2.1.4").revisions).default;
203215 "reflection".flags.slow = false;
204216 "reflection".flags.template-haskell = true;
205− "these".revision = (((hackage."these")."0.7.6").revisions).default;
217+ "these".revision = (((hackage."these")."0.8").revisions).default;
206218 "regex-tdfa-text".revision = (((hackage."regex-tdfa-text")."1.0.0.3").revisions).default;
207− "dependent-sum".revision = (((hackage."dependent-sum")."0.4").revisions).default;
208− "socks".revision = (((hackage."socks")."0.5.6").revisions).default;
219+ "dependent-sum".revision = (((hackage."dependent-sum")."0.5").revisions).default;
220+ "socks".revision = (((hackage."socks")."0.6.0").revisions).default;
209221 "streaming-commons".revision = (((hackage."streaming-commons")."0.2.1.0").revisions).default;
210222 "streaming-commons".flags.use-bytestring-builder = false;
211223 "haskell-lexer".revision = (((hackage."haskell-lexer")."1.0.2").revisions).default;
@@ -217,13 +229,16 @@
217229 "ansi-wl-pprint".revision = (((hackage."ansi-wl-pprint")."0.6.8.2").revisions).default;
218230 "ansi-wl-pprint".flags.example = false;
219231 "mwc-random".revision = (((hackage."mwc-random")."0.14.0.0").revisions).default;
220− "basement".revision = (((hackage."basement")."0.0.9").revisions).default;
232+ "basement".revision = (((hackage."basement")."0.0.10").revisions).default;
221233 "test-framework".revision = (((hackage."test-framework")."0.8.2.0").revisions).default;
222234 "cryptohash-sha1".revision = (((hackage."cryptohash-sha1")."0.11.100.1").revisions).default;
223235 "serialise".revision = (((hackage."serialise")."0.2.1.0").revisions).default;
224236 "serialise".flags.newtime15 = true;
225237 "hostname".revision = (((hackage."hostname")."1.0").revisions).default;
226238 "old-locale".revision = (((hackage."old-locale")."1.0.0.7").revisions).default;
239+ "wcwidth".revision = (((hackage."wcwidth")."0.0.2").revisions).default;
240+ "wcwidth".flags.split-base = true;
241+ "wcwidth".flags.cli = false;
227242 "StateVar".revision = (((hackage."StateVar")."1.1.1.1").revisions).default;
228243 "mime-types".revision = (((hackage."mime-types")."0.1.0.9").revisions).default;
229244 "http-client-tls".revision = (((hackage."http-client-tls")."0.3.5.3").revisions).default;
@@ -242,20 +257,23 @@
242257 "pointed".flags.tagged = true;
243258 "pointed".flags.containers = true;
244259 "pointed".flags.transformers = true;
245− "parser-combinators".revision = (((hackage."parser-combinators")."1.0.1").revisions).default;
260+ "parser-combinators".revision = (((hackage."parser-combinators")."1.0.2").revisions).default;
246261 "parser-combinators".flags.dev = false;
247− "deriving-compat".revision = (((hackage."deriving-compat")."0.5.4").revisions).default;
262+ "deriving-compat".revision = (((hackage."deriving-compat")."0.5.5").revisions).default;
248263 "deriving-compat".flags.base-4-9 = true;
249264 "deriving-compat".flags.template-haskell-2-11 = true;
250265 "deriving-compat".flags.new-functor-classes = true;
251266 "text".revision = (((hackage."text")."1.2.3.1").revisions).default;
252267 "Cabal".revision = (((hackage."Cabal")."2.4.1.0").revisions).default;
253268 "Cabal".flags.bundled-binary-generic = false;
269+ "assoc".revision = (((hackage."assoc")."1").revisions).default;
270+ "Diff".revision = (((hackage."Diff")."0.3.4").revisions).default;
254271 "unordered-containers".revision = (((hackage."unordered-containers")."0.2.10.0").revisions).default;
255272 "unordered-containers".flags.debug = false;
256273 "base".revision = (((hackage."base")."4.11.1.0").revisions).default;
257274 "abstract-deque".revision = (((hackage."abstract-deque")."0.3").revisions).default;
258275 "abstract-deque".flags.usecas = false;
276+ "tasty-hedgehog".revision = (((hackage."tasty-hedgehog")."0.2.0.0").revisions).default;
259277 "comonad".revision = (((hackage."comonad")."5.0.4").revisions).default;
260278 "comonad".flags.distributive = true;
261279 "comonad".flags.test-doctests = true;
@@ -275,6 +293,7 @@
275293 "prettyprinter".revision = (((hackage."prettyprinter")."1.2.1").revisions).default;
276294 "prettyprinter".flags.buildreadme = false;
277295 "cryptohash-sha512".revision = (((hackage."cryptohash-sha512")."0.11.100.1").revisions).default;
296+ "tasty-hunit".revision = (((hackage."tasty-hunit")."0.10.0.1").revisions).default;
278297 "pretty-show".revision = (((hackage."pretty-show")."1.8.2").revisions).default;
279298 "transformers".revision = (((hackage."transformers")."0.5.5.0").revisions).default;
280299 "hashable".revision = (((hackage."hashable")."1.2.7.0").revisions).default;
@@ -290,24 +309,26 @@
290309 "transformers-base".flags.orphaninstances = true;
291310 "happy".revision = (((hackage."happy")."1.19.9").revisions).default;
292311 "happy".flags.small_base = true;
293− "byteable".revision = (((hackage."byteable")."0.1.1").revisions).default;
294− "criterion".revision = (((hackage."criterion")."1.5.3.0").revisions).default;
312+ "criterion".revision = (((hackage."criterion")."1.5.4.0").revisions).default;
295313 "criterion".flags.embed-data-files = false;
296314 "criterion".flags.fast = false;
297315 "monad-par-extras".revision = (((hackage."monad-par-extras")."0.3.3").revisions).default;
298316 "filepath".revision = (((hackage."filepath")."1.4.2").revisions).default;
299317 "code-page".revision = (((hackage."code-page")."0.2").revisions).default;
300318 "asn1-types".revision = (((hackage."asn1-types")."0.3.2").revisions).default;
319+ "unbounded-delays".revision = (((hackage."unbounded-delays")."0.1.1.0").revisions).default;
320+ "hedgehog".revision = (((hackage."hedgehog")."0.6.1").revisions).default;
301321 "cborg".revision = (((hackage."cborg")."0.2.1.0").revisions).default;
302322 "cborg".flags.optimize-gmp = true;
323+ "monad-control".revision = (((hackage."monad-control")."1.0.2.3").revisions).default;
303324 "process".revision = (((hackage."process")."1.6.3.0").revisions).default;
304325 "tls".revision = (((hackage."tls")."1.4.1").revisions).default;
305326 "tls".flags.compat = true;
306327 "tls".flags.network = true;
307328 "tls".flags.hans = false;
308329 "kan-extensions".revision = (((hackage."kan-extensions")."5.2").revisions).default;
309− "th-lift".revision = (((hackage."th-lift")."0.7.11").revisions).default;
310− "libyaml".revision = (((hackage."libyaml")."0.1.0.0").revisions).default;
330+ "th-lift".revision = (((hackage."th-lift")."0.8").revisions).default;
331+ "libyaml".revision = (((hackage."libyaml")."0.1.1.0").revisions).default;
311332 "libyaml".flags.system-libyaml = false;
312333 "libyaml".flags.no-unicode = false;
313334 "resourcet".revision = (((hackage."resourcet")."1.2.2").revisions).default;
@@ -315,26 +336,26 @@
315336 "cabal-doctest".revision = (((hackage."cabal-doctest")."1.0.6").revisions).default;
316337 "Glob".revision = (((hackage."Glob")."0.10.0").revisions).default;
317338 "microlens".revision = (((hackage."microlens")."0.4.10").revisions).default;
318− "aeson".revision = (((hackage."aeson")."1.4.2.0").revisions).default;
339+ "aeson".revision = (((hackage."aeson")."1.4.3.0").revisions).default;
319340 "aeson".flags.cffi = false;
320341 "aeson".flags.fast = false;
321342 "aeson".flags.bytestring-builder = false;
322343 "aeson".flags.developer = false;
323344 "abstract-par".revision = (((hackage."abstract-par")."0.3.3").revisions).default;
324− "http-types".revision = (((hackage."http-types")."0.12.2").revisions).default;
345+ "http-types".revision = (((hackage."http-types")."0.12.3").revisions).default;
325346 "ghc-boot-th".revision = (((hackage."ghc-boot-th")."8.4.4").revisions).default;
326− "th-lift-instances".revision = (((hackage."th-lift-instances")."0.1.12").revisions).default;
327− "base-orphans".revision = (((hackage."base-orphans")."0.8").revisions).default;
328− "th-abstraction".revision = (((hackage."th-abstraction")."0.2.10.0").revisions).default;
347+ "th-lift-instances".revision = (((hackage."th-lift-instances")."0.1.13").revisions).default;
348+ "base-orphans".revision = (((hackage."base-orphans")."0.8.1").revisions).default;
349+ "th-abstraction".revision = (((hackage."th-abstraction")."0.3.1.0").revisions).default;
329350 "memory".revision = (((hackage."memory")."0.14.18").revisions).default;
330351 "memory".flags.support_bytestring = true;
331352 "memory".flags.support_basement = true;
332353 "memory".flags.support_foundation = true;
333354 "memory".flags.support_deepseq = true;
355+ "concurrent-output".revision = (((hackage."concurrent-output")."1.10.9").revisions).default;
334356 "array".revision = (((hackage."array")."0.5.2.0").revisions).default;
335357 "repline".revision = (((hackage."repline")."0.2.0.0").revisions).default;
336358 "xml".revision = (((hackage."xml")."1.3.14").revisions).default;
337− "erf".revision = (((hackage."erf")."2.0.0.0").revisions).default;
338359 "lens-family-core".revision = (((hackage."lens-family-core")."1.2.3").revisions).default;
339360 "integer-gmp".revision = (((hackage."integer-gmp")."1.0.2.0").revisions).default;
340361 };
@@ -378,4 +399,4 @@
378399 haskell-src-meta = ./.plan.nix/haskell-src-meta.nix;
379400 };
380401 };
381− }
402+ }
nixpkgs/default.nix+2−1
@@ -1,3 +1,4 @@
1+{ nixpkgs-pin ? "github", ... }@args:
12let
23 fetch = jsonFile:
34 with builtins;
@@ -7,4 +8,4 @@ let
78 inherit (spec) sha256;
89 url = "${spec.url}/archive/${spec.rev}.tar.gz";
910 };
10−in import (fetch ./github.json)
11+in import (fetch (./. + "/${nixpkgs-pin}.json")) (builtins.removeAttrs args [ "nixpkgs-pin" ])
nixpkgs/release-18.09.jsonnew file+7
@@ -0,0 +1,7 @@
1+{
2+ "url": "https://github.com/nixos/nixpkgs",
3+ "rev": "68b3bff32da3fadb16d5fdcbca2b4b69f6b97eb6",
4+ "date": "2019-07-29T20:46:01-04:00",
5+ "sha256": "129w6rk6brdmq0m8l2py5qkpzzzy7zwd1h03cqlbjq2ff6zh49nc",
6+ "fetchSubmodules": false
7+}
nixpkgs/release-19.03.jsonnew file+7
@@ -0,0 +1,7 @@
1+{
2+ "url": "https://github.com/nixos/nixpkgs",
3+ "rev": "49ac77d07eb9757244b776e35b9eb68d63943b12",
4+ "date": "2019-07-30T15:46:41+02:00",
5+ "sha256": "0xsmh17z5bl17dnpwf23m53a432651ylvk8qnjlmj43blxgiwrs5",
6+ "fetchSubmodules": false
7+}
overlays/armv6l-linux.nixnew file+73
@@ -0,0 +1,73 @@
1+self: super:
2+{
3+ haskell-nix = super.haskell-nix // ({
4+ defaultModules = super.haskell-nix.defaultModules ++ [
5+ ({ pkgs, buildModules, config, lib, ... }:
6+ let
7+ withTH = import ./linux-cross.nix {
8+ inherit (pkgs.stdenv) hostPlatform buildPlatform;
9+ inherit (pkgs) stdenv lib writeScriptBin;
10+ # qemu for linux
11+ qemu = pkgs.buildPackages.qemu;
12+
13+# wine = pkgs.buildPackages.winePackages.minimal;
14+# inherit (pkgs.windows) mingw_w64_pthreads;
15+ inherit (pkgs) gmp;
16+ # iserv-proxy needs to come from the buildPackages, as it needs to run on the
17+ # build host.
18+ inherit (config.hsPkgs.buildPackages.iserv-proxy.components.exes) iserv-proxy;
19+ # remote-iserv however needs to come from the regular packages as it has to
20+ # run on the target host.
21+ inherit (config.hsPkgs.remote-iserv.components.exes) remote-iserv;
22+ # we need to use openssl.bin here, because the .dll's are in the .bin expression.
23+ extra-test-libs = [
24+ # pkgs.rocksdb
25+ pkgs.openssl.bin
26+ pkgs.libffi
27+ pkgs.gmp
28+ ];
29+ } // {
30+ # we can perform testing of cross compiled test-suites by using wine.
31+ # Therfore let's enable doCrossCheck here!
32+ doCrossCheck = pkgs.stdenv.hostPlatform.isWindows;
33+ };
34+ in {
35+ packages = {
36+ # clock 0.7.2 needs to be patche to support cross compilation.
37+ clock.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isAarch32 [ ({ version, revision }: (if version == "0.7.2" then ./patches/clock-0.7.2.patch else null)) ];
38+ # nix calles this package crypto
39+ # cryptonite-openssl.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if version == "0.7" then ./patches/cryptonite-openssl-0.7.patch else null) ];
40+
41+ # http-client.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if version == "0.5.14" then ./patches/http-client-0.5.14.patch else null) ];
42+
43+ # conduit.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ({ version, revision }: if builtins.compareVersions version "1.3.1.1" < 0 then ./patches/conduit-1.3.0.2.patch else null) ];
44+ # streaming-commons.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/streaming-commons-0.2.0.0.patch ];
45+ # x509-system.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/x509-system-1.6.6.patch ];
46+ # file-embed-lzma.patches = pkgs.stdenv.lib.optionals pkgs.stdenv.hostPlatform.isWindows [ ./patches/file-embed-lzma-0.patch ];
47+
48+ # Set all of these to [], as these form the
49+ # dependency graph of the libiserv, iserv-proxy, and iserv-remote
50+ # packages. Subsequently we do not want the defaults that `withTH`
51+ # `-fexternal-interpreter` would install here. That would ultimately
52+ # result in cyclic dependencies as it injects `remote-iserv` and
53+ # `iserv-proxy` as a dependency into every package.
54+ bytestring.setupBuildFlags = [];
55+ containers.setupBuildFlags = [];
56+ binary.setupBuildFlags = [];
57+ filepath.setupBuildFlags = [];
58+ time.setupBuildFlags = [];
59+ Win32.setupBuildFlags = [];
60+ libiserv.setupBuildFlags = [];
61+ remote-iserv.setupBuildFlags = [];
62+ directory.setupBuildFlags = [];
63+ ghc-boot.setupBuildFlags = [];
64+ transformers.setupBuildFlags = [];
65+ ghci.setupBuildFlags = [];
66+ network.setupBuildFlags = [];
67+ unix.setupBuildFlags = [];
68+ };
69+ }// withTH
70+ )
71+ ];
72+ });
73+}
overlays/bootstrap.nixnew file+287
@@ -0,0 +1,287 @@
1+self: super: rec {
2+ # Use this to disable the existing haskell infra structure for testing purposes
3+ haskell.compiler =
4+ let bootPkgs = with self.buildPackages; {
5+ ghc = buildPackages.bootstrap.haskell.compiler.ghc844;
6+ inherit (bootstrap.haskell.packages) alex happy hscolour;
7+ };
8+ sphinx = with self.buildPackages; (python3Packages.sphinx_1_7_9 or python3Packages.sphinx);
9+ hsc2hs-align-conditionals-patch = self.fetchpatch {
10+ url = "https://git.haskell.org/hsc2hs.git/patch/738f3666c878ee9e79c3d5e819ef8b3460288edf";
11+ sha256 = "0plzsbfaq6vb1023lsarrjglwgr9chld4q3m99rcfzx0yx5mibp3";
12+ extraPrefix = "utils/hsc2hs/";
13+ stripLen = 1;
14+ };
15+ D5123-patch = self.fetchpatch rec { # https://phabricator.haskell.org/D5123
16+ url = "http://tarballs.nixos.org/sha256/${sha256}";
17+ name = "D5123.diff";
18+ sha256 = "0nhqwdamf2y4gbwqxcgjxs0kqx23w9gv5kj0zv6450dq19rji82n";
19+ };
20+ haddock-900-patch = self.fetchpatch rec { # https://github.com/haskell/haddock/issues/900
21+ url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/983.diff";
22+ name = "loadpluginsinmodules.diff";
23+ sha256 = "0bvvv0zsfq2581zsir97zfkggc1kkircbbajc2fz3b169ycpbha1";
24+ extraPrefix = "utils/haddock/";
25+ stripLen = 1;
26+ };
27+ ghc-patches = version: let
28+ # Returns true iff this derivation's version is strictly older than ver.
29+ versionOlder = ver: builtins.compareVersions ver version == 1;
30+ # Returns true iff this derivation's verion is greater than or equal to ver.
31+ versionAtLeast = ver: !versionOlder ver;
32+ # Patches for which we know they have been merged into a public release already
33+ in self.lib.optional (versionAtLeast "8.4.4" && versionOlder "8.6") ./patches/ghc/ghc-8.4.4-reinstallable-lib-ghc.patch
34+ ++ self.lib.optional (versionOlder "8.6") ./patches/ghc/move-iserv-8.4.2.patch
35+ ++ self.lib.optional (versionOlder "8.6") ./patches/ghc/hsc2hs-8.4.2.patch
36+ ++ self.lib.optional (versionOlder "8.6") ./patches/ghc/various-8.4.2.patch
37+ ++ self.lib.optional (versionOlder "8.6") ./patches/ghc/lowercase-8.4.2.patch
38+ ++ self.lib.optional (versionOlder "8.6") ./patches/ghc/cabal-exe-ext-8.4.2.patch
39+ ++ self.lib.optional (versionOlder "8.6") ./patches/ghc/ghc-8.4.3-Cabal2201-SMP-test-fix.patch
40+ ++ self.lib.optional (versionOlder "8.6") ./patches/ghc/outputtable-assert-8.4.patch
41+ ++ self.lib.optional (versionAtLeast "8.6" && versionOlder "8.6.4") ./patches/ghc/MR148--T16104-GhcPlugins.patch
42+ ++ self.lib.optional (versionOlder "8.6.4") ./patches/ghc/MR95--ghc-pkg-deadlock-fix.patch
43+
44+ # Patches for which we only know a lower bound.
45+ ++ self.lib.optional (versionAtLeast "8.6") ./patches/ghc/iserv-proxy-cleanup.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/250 -- merged; ghc-8.8.1
46+ ++ self.lib.optional (versionAtLeast "8.2") ./patches/ghc/MR545--ghc-pkg-databases.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/545 -- merged; ghc-8.8.1
47+ ++ self.lib.optional (versionAtLeast "8.6") ./patches/ghc/outputtable-assert-8.6.patch
48+ ++ self.lib.optional (versionAtLeast "8.6") ./patches/ghc/mistuke-ghc-err_clean_up_error_handler-8ab1a89af89848f1713e6849f189de66c0ed7898.diff # this is part of Phyx- revamped io-manager.
49+ ++ self.lib.optional (versionAtLeast "8.6.4") ./patches/ghc/ghc-8.6.4-reenable-th-qq-in-stage1.patch
50+ ++ [
51+ ./patches/ghc/ghc-add-keepCAFs-to-rts.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/950 -- open
52+ ./patches/ghc/lowercase-8.6.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/949 -- merged; ghc-8.8.1
53+ ./patches/ghc/dll-loader-8.4.2.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/949 -- open
54+ ./patches/ghc/0001-Stop-the-linker-panic.patch # https://phabricator.haskell.org/D5012 -- merged; ghc-8.8.1
55+ ./patches/ghc/ghc-8.4.3-Cabal2201-no-hackage-tests.patch # ?
56+ ./patches/ghc/ghc-8.4.3-Cabal2201-allow-test-wrapper.patch # https://github.com/haskell/cabal/pulls/5995 -- merged; cabal-3.0.0 (ghc-8.8.1)
57+ ./patches/ghc/ghc-8.4.3-Cabal2201-response-file-support.patch # https://github.com/haskell/cabal/pulls/5996 -- merged; cabal-3.0.0 (ghc-8.8.1)
58+ ./patches/ghc/ghc-8.6-Cabal-fix-datadir.patch # https://github.com/haskell/cabal/issues/5862
59+ ./patches/ghc/MR196--ghc-pkg-shut-up.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/196 -- merged; ghc-8.8.1
60+ ./patches/ghc/MR948--32bit-cross-th.patch # https://gitlab.haskell.org/ghc/ghc/merge_requests/948 -- open
61+ ]
62+
63+ # Patches for specific ghc versions.
64+ ++ self.lib.optional (version == "8.6.3") ./patches/ghc/T16057--ghci-doa-on-windows.patch
65+ ++ self.lib.optional (version == "8.6.3") ./patches/ghc/ghc-8.6.3-reinstallable-lib-ghc.patch
66+ ++ self.lib.optional (version == "8.6.4") ./patches/ghc/ghc-8.6.4-reinstallable-lib-ghc.patch
67+ ++ self.lib.optional (version == "8.6.5") ./patches/ghc/ghc-8.6.5-reinstallable-lib-ghc.patch
68+ ++ self.lib.optional (version == "8.6.4") ./patches/ghc/ghc-8.6.4-better-plusSimplCountErrors.patch
69+ ;
70+ in ({
71+ ghc844 = self.callPackage ../compiler/ghc {
72+ extra-passthru = { buildGHC = self.buildPackages.haskell.compiler.ghc844; };
73+
74+ inherit bootPkgs sphinx;
75+
76+ buildLlvmPackages = self.buildPackages.llvmPackages_5;
77+ llvmPackages = self.llvmPackages_5;
78+
79+ src-spec = rec {
80+ version = "8.4.4";
81+ url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz";
82+ sha256 = "1ch4j2asg7pr52ai1hwzykxyj553wndg7wq93i47ql4fllspf48i";
83+ };
84+
85+ ghc-patches = ghc-patches "8.4.4"
86+ ++ [ hsc2hs-align-conditionals-patch D5123-patch ]
87+ ++ self.lib.optional self.stdenv.isDarwin ./patches/ghc/ghc-8.4.4-backport-dylib-command-size-limit.patch;
88+ };
89+ ghc861 = self.callPackage ../compiler/ghc {
90+ extra-passthru = { buildGHC = self.buildPackages.haskell.compiler.ghc861; };
91+
92+ inherit bootPkgs sphinx;
93+
94+ buildLlvmPackages = self.buildPackages.llvmPackages_5;
95+ llvmPackages = self.llvmPackages_5;
96+
97+ src-spec = rec {
98+ version = "8.6.1";
99+ url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz";
100+ sha256 = "0dkh7idgrqr567fq94a0f5x3w0r4cm2ydn51nb5wfisw3rnw499c";
101+ };
102+
103+ ghc-patches = [ D5123-patch ];
104+ };
105+ ghc862 = self.callPackage ../compiler/ghc {
106+ extra-passthru = { buildGHC = self.buildPackages.haskell.compiler.ghc862; };
107+
108+ inherit bootPkgs sphinx;
109+
110+ buildLlvmPackages = self.buildPackages.llvmPackages_5;
111+ llvmPackages = self.llvmPackages_5;
112+
113+ src-spec = rec {
114+ version = "8.6.2";
115+ url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz";
116+ sha256 = "1mbn3n2ynmpfpb7jfnhpzzli31qqxqyi8ws71blws3i846fq3ana";
117+ };
118+
119+ ghc-patches = ghc-patches "8.6.2"
120+ ++ [ D5123-patch ];
121+ };
122+ ghc863 = self.callPackage ../compiler/ghc {
123+ extra-passthru = { buildGHC = self.buildPackages.haskell.compiler.ghc863; };
124+
125+ inherit bootPkgs sphinx;
126+
127+ buildLlvmPackages = self.buildPackages.llvmPackages_5;
128+ llvmPackages = self.llvmPackages_5;
129+
130+ src-spec = rec {
131+ version = "8.6.3";
132+ url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz";
133+ sha256 = "08vzq0dpg4a39bs61j6rq4z0n7jby5mc69h4m25xhd8rjyvkg7lz";
134+ };
135+
136+ ghc-patches = ghc-patches "8.6.3"
137+ ++ [ D5123-patch ];
138+ };
139+ ghc864 = self.callPackage ../compiler/ghc {
140+ extra-passthru = { buildGHC = self.buildPackages.haskell.compiler.ghc864; };
141+
142+ inherit bootPkgs sphinx;
143+
144+ buildLlvmPackages = self.buildPackages.llvmPackages_5;
145+ llvmPackages = self.llvmPackages_5;
146+
147+ src-spec = rec {
148+ version = "8.6.4";
149+ url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz";
150+ sha256 = "0fihs1sr0hpk67dn9cmrsav13kkcp9hz8ggdqcrs80rj8vj0fpav";
151+ };
152+
153+ ghc-patches = ghc-patches "8.6.4"
154+ ++ [ D5123-patch ];
155+ };
156+ ghc865 = self.callPackage ../compiler/ghc {
157+ extra-passthru = { buildGHC = self.buildPackages.haskell.compiler.ghc865; };
158+
159+ inherit bootPkgs sphinx;
160+
161+ buildLlvmPackages = self.buildPackages.llvmPackages_5;
162+ llvmPackages = self.llvmPackages_5;
163+
164+ src-spec = rec {
165+ version = "8.6.5";
166+ url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz";
167+ sha256 = "0qg3zsmbk4rkwkc3jpas3zs74qaxmw4sp4v1mhsbj0a0dzls2jjd";
168+ };
169+
170+ ghc-patches = ghc-patches "8.6.5"
171+ ++ [ D5123-patch haddock-900-patch ];
172+ };
173+ } // self.lib.optionalAttrs (self.targetPlatform.isGhcjs or false) {
174+ ghc865 = let ghcjs865 = self.callPackage ../compiler/ghcjs/ghcjs.nix {
175+ ghcjsSrcJson = ../compiler/ghcjs/ghcjs-src.json;
176+ ghcjsVersion = "8.6.0.1";
177+ ghc = self.buildPackages.haskell.compiler.ghc865;
178+ }; in let targetPrefix = "js-unknown-ghcjs-"; in self.runCommand "${targetPrefix}ghc-8.6.5" {
179+ passthru = {
180+ inherit targetPrefix;
181+ version = "8.6.5";
182+ };
183+ } ''
184+ mkdir -p $out/bin
185+ cd $out/bin
186+ ln -s ${ghcjs865}/bin/ghcjs ${targetPrefix}ghc
187+ ln -s ${ghcjs865}/bin/ghcjs-pkg ${targetPrefix}ghc-pkg
188+ ln -s ${ghcjs865}/bin/hsc2hs-ghcjs ${targetPrefix}hsc2hs
189+ cd ..
190+ mkdir lib
191+ cd lib
192+ cp -R ${ghcjs865}/lib/ghcjs-8.6.5 ${targetPrefix}ghc-8.6.5
193+ '';
194+ });
195+
196+ ghc = haskell.compiler.ghc865;
197+ cabal-install = self.buildPackages.bootstrap.haskell.packages.cabal-install;
198+
199+ # see below
200+ haskellPackages.hpack = null;
201+ haskellPackages.hoogle = self.haskell-nix.haskellPackages.hoogle.components.exes.hoogle;
202+ haskellPackages.happy = self.haskell-nix.haskellPackages.happy.components.exes.happy;
203+ haskellPackages.alex = self.haskell-nix.haskellPackages.alex.components.exes.alex;
204+
205+ # WARN: The `import ../. {}` will prevent
206+ # any cross to work, as we will loose
207+ # the `config` value.
208+ # As such the folloing sadly won't work :(
209+ # haskellPackages = with import ../. {}; {
210+ # hpack = null;
211+ # hello = (hackage-package {
212+ # inherit (self) cabal-install;
213+ # name = "hello"; version = "1.0.0.2";
214+ # }).components.exes.hello;
215+ # };
216+
217+ # stub out lib stuff.
218+ haskell.lib = {
219+ justStaticExecutables = x: x;
220+ };
221+
222+ # NOTE: 8.6.5 prebuilt binaries on macOS, will yield:
223+ #
224+ # > Linking dist/build/cabal/cabal ...
225+ # > Undefined symbols for architecture x86_64:
226+ # > "_utimensat", referenced from:
227+ # > _cazW_info in libHSdirectory-1.3.3.0.a(Posix.o)
228+ # > ld: symbol(s) not found for architecture x86_64
229+ # > clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation)
230+ # > `clang' failed in phase `Linker'. (Exit code: 1)
231+ #
232+ # hence we'll use 844 for bootstrapping for now.
233+
234+
235+ # the bootstrap infra structure (pre-compiled ghc; bootstrapped cabal-install, ...)
236+ bootstrap = {
237+ # XXX: import ../. will throw away all other overlays, config values, ...
238+ # this is not ideal!
239+ haskell = with self.haskell-nix; let ghc = self.buildPackages.bootstrap.haskell.compiler.ghc844; in {
240+ # get binary compilers for bootstrapping. We'll put the eventual proper
241+ # compilers into the same place where nix expects them.
242+ compiler = import ../compiler/old-ghc-nix { pkgs = self; };
243+
244+ packages = {
245+ # cabal has it's own bootstrap script which we'll use.
246+ cabal-install = import ../compiler/bootstrap/cabal-install.nix {
247+ inherit (self) fetchurl stdenv zlib;
248+ inherit hackage ghc;
249+ src = self.fetchurl {
250+ url = "https://github.com/haskell/cabal/archive/Cabal-v3.0.0.0-rc3.tar.gz";
251+ sha256 = "1zl2mgg8307ykq3v8nmafc6zdhhj1cw7w8ffpap16dsm65lbnx33";
252+ };
253+ version = "3.0.0.0";
254+ };
255+
256+ # disable hpack support during bootstrap
257+ hpack = null;
258+ nix-tools = nix-tools.override {
259+ inherit ghc;
260+ inherit (bootstrap.haskell.packages) hpack;
261+ };
262+
263+ # now that we have nix-tools and hpack, we can just
264+ # use `hackage-package` to build any package from
265+ # hackage with haskell.nix. For alex and happy we
266+ # need to use the boot strap compiler as we need them
267+ # to build ghcs from source.
268+ alex = (hackage-package {
269+ inherit ghc;
270+ inherit (bootstrap.haskell.packages) cabal-install nix-tools hpack;
271+ name = "alex"; version = "3.2.4";
272+ }).components.exes.alex;
273+ happy = (hackage-package {
274+ inherit ghc;
275+ inherit (bootstrap.haskell.packages) cabal-install nix-tools hpack;
276+ name = "happy"; version = "1.19.11";
277+ }).components.exes.happy;
278+
279+ hscolour = (hackage-package {
280+ inherit ghc;
281+ inherit (bootstrap.haskell.packages) cabal-install nix-tools hpack;
282+ name = "hscolour"; version = "1.24.4";
283+ }).components.exes.HsColour;
284+ };
285+ };
286+ };
287+}
overlays/darwin.nixnew file+3
@@ -0,0 +1,3 @@
1+self: super: {
2+
3+}
overlays/default.nixnew file+11
@@ -0,0 +1,11 @@
1+[
2+ (import ./release-19.03.nix)
3+ #(import ./ghcjs-asterius-triple.nix)
4+ #(import ./python.nix)
5+ (import ./haskell.nix)
6+ (import ./bootstrap.nix)
7+ (import ./ghc.nix)
8+ (import ./ghc-packages.nix)
9+ (import ./windows.nix)
10+ (import ./armv6l-linux.nix)
11+]
overlays/ghc-packages.nixnew file+89
@@ -0,0 +1,89 @@
1+self: super:
2+let
3+ emptyDotCabal = self.runCommand "empty-dot-cabal" {} ''
4+ mkdir -p $out/.cabal
5+ cat <<EOF > $out/.cabal/config
6+ EOF
7+ '';
8+ callCabalSdist = name: src: self.runCommand "${name}-sdist.tar.gz" {
9+ nativeBuildInputs = [ self.cabal-install ];
10+ } ''
11+ tmp=$(mktemp -d)
12+ cp -r ${src}/* $tmp
13+ cd $tmp
14+ tmp2=$(mktemp -d)
15+ HOME=${emptyDotCabal} cabal new-sdist -o $tmp2
16+ cp $tmp2/*.tar.gz $out
17+ '';
18+ callCabal2Nix = src: self.stdenv.mkDerivation {
19+ name = "package-nix";
20+ inherit src;
21+ nativeBuildInputs = [ self.haskell-nix.nix-tools ];
22+ phases = [ "unpackPhase" "buildPhase" ];
23+
24+ LOCALE_ARCHIVE = self.lib.optionalString (self.stdenv.hostPlatform.libc == "glibc") "${self.glibcLocales}/lib/locale/locale-archive";
25+ LANG = "en_US.UTF-8";
26+ LC_ALL = "en_US.UTF-8";
27+
28+ buildPhase = ''
29+ cabal-to-nix *.cabal > $out
30+ '';
31+ };
32+ importCabal = name: src:
33+ # build the source dist
34+ let sdist = callCabalSdist name src;
35+ # and generate the nix expression corresponding to the source dist
36+ # but fixing the src to the sdist as well.
37+ in args: (import (callCabal2Nix sdist) args) // { src = sdist; };
38+
39+ ghc-extra-pkgs = {
40+ ghc = "compiler";
41+ ghci = "libraries/ghci";
42+ ghc-boot = "libraries/ghc-boot";
43+ libiserv = "libraries/libiserv";
44+ iserv = "utils/iserv";
45+ remote-iserv = "utils/remote-iserv";
46+ iserv-proxy = "utils/iserv-proxy";
47+ };
48+
49+# Given the ghc-extra-pkgs, we'll create a cabal.project
50+# that contains all of them. And then we call cabalProject
51+# on it to generate the necessary cabal project exposing all
52+# the package components.
53+#
54+# The motivation here is that we can build primarily
55+# remote-iserv and iserv-proxy as standalone applications, as
56+# derived from the configured (and potentially patched) ghc
57+# source code.
58+#
59+# This is a bit like how we treat hsc2hs, alex, happy as external
60+# programs we need to build from hackage, but iserv-remote and
61+# iserv-proxy are not on hackage (and might have been patched)
62+# as part of patches we applied to the GHC tree.
63+
64+in rec {
65+ ghc-boot-packages = builtins.mapAttrs
66+ (name: value: builtins.mapAttrs
67+ (pkgName: dir: importCabal "${name}-${pkgName}" "${value.passthru.configured-src}/${dir}") ghc-extra-pkgs)
68+ self.buildPackages.haskell.compiler;
69+
70+ ghc-extra-pkgs-cabal-projects = builtins.mapAttrs (name: value: let package-locs = builtins.mapAttrs (_: dir: "${value.passthru.configured-src}/${dir}") ghc-extra-pkgs; in
71+ self.writeTextFile {
72+ name = "ghc-extra-pkgs-cabal-project-${name}";
73+ destination = "/cabal.project";
74+ text = ''
75+ packages: ${self.lib.concatStringsSep " " (self.lib.attrValues package-locs)}
76+ -- need this for libiserve as it doesn't build against 3.0 yet.
77+ constraints: network < 3.0,
78+ ghc +ghci,
79+ ghci +ghci,
80+ libiserv +network
81+ '';
82+ }) self.buildPackages.haskell.compiler;
83+
84+ ghc-extra-packages = builtins.mapAttrs (name: proj: self.haskell-nix.cabalProject {
85+ src = proj;
86+ ghc = self.buildPackages.haskell.compiler.${name};
87+ })
88+ ghc-extra-pkgs-cabal-projects;
89+}
overlays/ghc.nixnew file+31
@@ -0,0 +1,31 @@
1+self: super: with super;
2+ # sadly we need to patch GHC a bit.
3+ let
4+ ghcPkgOverrides = {
5+ enableShared = super.stdenv.targetPlatform == super.stdenv.hostPlatform;
6+ enableIntegerSimple = false;
7+ };
8+ ghcDrvOverrides = drv: {
9+ hardeningDisable = (drv.hardeningDisable or []) ++ [ "stackprotector" "format" ];
10+ };
11+ in {
12+ haskell = let
13+ # These patches (ghcPkgOverrides and ghcDrvOverrides) only apply to vanilla source ghcs.
14+ # Not ghcjs or binary distributions.
15+ # We also ignore ghc82. And are only concerned with ghc84+
16+ # we want to apply this only to non-ghcjs ones.
17+ # As we do some ghc <- ghcjs mapping for ghcjs.
18+ needsPatches = name:
19+ !(super.stdenv.targetPlatform.isGhcjs or false)
20+ && lib.hasPrefix "ghc" name
21+ && !lib.hasPrefix "ghc82" name
22+ && !lib.hasPrefix "ghcjs" name
23+ && !lib.hasSuffix "Binary" name;
24+ overrideCompiler = compiler:
25+ (compiler.override ghcPkgOverrides).overrideAttrs ghcDrvOverrides;
26+ in
27+ lib.recursiveUpdate super.haskell {
28+ compiler = lib.mapAttrs (_name: overrideCompiler)
29+ (lib.filterAttrs (name: _value: needsPatches name) super.haskell.compiler);
30+ };
31+ }
overlays/ghcjs-asterius-triple.nixnew file+35
@@ -0,0 +1,35 @@
1+# This overlay does *not* work as expected.
2+# See https://github.com/NixOS/nixpkgs/issues/65589
3+self: super: super.lib.recursiveUpdate super {
4+ lib.systems.examples = {
5+ # Ghcjs
6+ ghcjs = {
7+ config = "js-unknown-ghcjs";
8+ platform = {};
9+ };
10+ # Asterius
11+ asterius32 = {
12+ config = "wasm32-unknown-asterius";
13+ platform = {};
14+ };
15+ asterius64 = {
16+ config = "wasm64-unknown-asterius";
17+ platform = {};
18+ };
19+ };
20+ # gcc = if self.targetPlatform.isGhcjs then null else super.gcc;
21+ lib.systems.parse = with self.lib.systems.parse; {
22+ cpuTypes.js = cpuTypes.wasm32 // { name = "js"; family = "js"; };
23+ kernels.ghcjs = kernels.none // { name = "ghcjs"; };
24+ kernels.asterius = kernels.none // { name = "asterius"; };
25+ mkSkeletonFromList = l: builtins.trace l (super.lib.systems.parse.mkSkeletonFromList l);
26+ mkSystemFromString = s: builtins.trace s (super.lib.systems.parse.mkSystemFromString s);
27+ };
28+ lib.systems.inspect.patterns = with self.lib.systems.parse; {
29+ isJavaScript = { cpu = cpuTypes.js; };
30+ isWasm32 = { cpu = cpuTypes.wasm32; };
31+ isWasm64 = { cpu = cpuTypes.wasm64; };
32+ isGhcjs = { kernel = kernels.ghcjs; };
33+ isAsterius = { kernel = kernels.asterius; };
34+ };
35+}
overlays/haskell.nixnew file+310
@@ -0,0 +1,310 @@
1+# The haskell.nix infrastructure
2+#
3+# for hygenic reasons we'll use haskell-nix as a prefix.
4+# Using haskell.nix in nix is awkward as I needs to be quoted.
5+self: super: {
6+ haskell-nix = with self.haskell-nix; {
7+
8+ # Default modules, these will always be included.
9+ # They are here to be overridden/added to by other
10+ # overlays.
11+ defaultModules = [];
12+
13+ # We provide a `callPackage` function to consumers for
14+ # convenience. We will however refrain from using it
15+ # here and be explicit about imports and dependencies.
16+ callPackage = super.lib.callPackageWith (self // self.haskell-nix);
17+
18+ # You can provide different pins for hackage.nix and stackage.nix if required.
19+ # It's also possible to override these sources with NIX_PATH.
20+ hackageSourceJSON = ../hackage-src.json;
21+ stackageSourceJSON = ../stackage-src.json;
22+
23+ # ghc hackage patches.
24+ # these are patches that turn hackage packages into the same as the ones
25+ # ghc ships with the supposedly same version. See GHC Track Issue: 16199
26+ ghcHackagePatches = import ../patches;
27+
28+ compat = import ../lib/compat.nix;
29+
30+ # Utility function for downloading a pinned git repo, that can be
31+ # overridden with NIX_PATH.
32+ fetchExternal = import ../lib/fetch-external.nix;
33+
34+ # Function for cleaning haskell source directories pulled from iohk-nix
35+ cleanSourceHaskell = import ../lib/clean-source-haskell.nix { pkgs = self; };
36+
37+ # All packages from Hackage as Nix expressions
38+ hackageSrc = fetchExternal {
39+ name = "hackage-exprs-source";
40+ specJSON = hackageSourceJSON;
41+ override = "hackage";
42+ };
43+ hackage = import hackageSrc;
44+
45+ # Contains the hashes of the cabal 01-index.tar.gz for given
46+ # index states. Starting from April 1st 2019.
47+ indexStateHashesPath = hackageSrc + "/index-state-hashes.nix";
48+
49+ # The set of all Stackage snapshots
50+ stackageSrc = fetchExternal {
51+ name = "stackage-snapshot-source";
52+ specJSON = stackageSourceJSON;
53+ override = "stackage";
54+ };
55+
56+ stackage = import stackageSrc;
57+
58+ # Utility functions for working with the component builder.
59+ haskellLib = let hl = import ../lib {
60+ inherit (self) lib runCommand;
61+ inherit (self.buildPackages) git;
62+ haskellLib = hl;
63+ }; in hl;
64+
65+ # Create a Haskell package set based on a cabal build plan (plan-to-nix)
66+ # and Nix expressions representing cabal packages (cabal-to-nix).
67+ mkPkgSet =
68+ { pkg-def # Base package set. Either from stackage (via stack-to-nix) or from a cabal projects plan file (via plan-to-nix)
69+ , pkg-def-extras ? [] # Additional packages to augment the Base package set `pkg-def` with.
70+ , modules ? []
71+ }@args:
72+
73+ import ../package-set.nix (args // {
74+ modules = defaultModules ++ modules;
75+ pkgs = self;
76+ inherit hackage pkg-def;
77+ });
78+
79+ # Create a Haskell package set based on a Stack configuration.
80+ mkStackPkgSet =
81+ { stack-pkgs # Path to the output of stack-to-nix
82+ , pkg-def-extras ? []
83+ , modules ? []
84+ }@args:
85+ let
86+ # The Stackage release referenced in the stack config
87+ pkg-def = stackage.${stack-pkgs.resolver} or (throw ''
88+ This version of stackage.nix does not know about the Stackage resolver ${stack-pkgs.resolver}.
89+ You may need to update haskell.nix to one that includes a newer stackage.nix.
90+ '');
91+ # The compiler referenced in the stack config
92+ compiler = (stack-pkgs.extras hackage).compiler or (pkg-def hackage).compiler;
93+ patchesModule = ghcHackagePatches.${compiler.nix-name} or {};
94+ in mkPkgSet {
95+ inherit pkg-def;
96+ pkg-def-extras = [ stack-pkgs.extras
97+ self.ghc-boot-packages.${compiler.nix-name}
98+ ]
99+ ++ pkg-def-extras;
100+ # set doExactConfig = true. The stackage set should be consistent
101+ # and we should trust stackage here!
102+ modules = [ { doExactConfig = true; } patchesModule ]
103+ ++ modules
104+ ++ stack-pkgs.modules or [];
105+ };
106+
107+ # Create a Haskell package set based on a Cabal configuration.
108+ mkCabalProjectPkgSet =
109+ { plan-pkgs # Path to the output of plan-to-nix
110+ , pkg-def-extras ? []
111+ , modules ? []
112+ }@args:
113+
114+ let
115+ pkg-def = plan-pkgs.pkgs;
116+ # The compiler referenced in the stack config
117+ compiler = (plan-pkgs.extras hackage).compiler or (pkg-def hackage).compiler;
118+ patchesModule = ghcHackagePatches.${compiler.nix-name} or {};
119+ in mkPkgSet {
120+ inherit pkg-def;
121+ pkg-def-extras = [ plan-pkgs.extras
122+ self.ghc-boot-packages.${compiler.nix-name}
123+ ]
124+ ++ pkg-def-extras;
125+ # set doExactConfig = true, as we trust cabals resolution for
126+ # the plan.
127+ modules = [ { doExactConfig = true; } patchesModule ]
128+ ++ modules
129+ ++ plan-pkgs.modules or [];
130+ };
131+
132+ # Package sets for all stackage snapshots.
133+ snapshots = import ../snapshots.nix { inherit (self) lib; inherit mkPkgSet stackage; };
134+ # Pick a recent LTS snapshot to be our "default" package set.
135+ haskellPackages = snapshots."lts-13.26";
136+
137+ # Programs for generating Nix expressions from Cabal and Stack
138+ # files. This version of nix-tools may be cross compiled.
139+ # We probably never want to actually cross compile nix-tools on
140+ # it's own.
141+ nix-tools-cross-compiled = self.lib.makeOverridable (import ../nix-tools) {
142+ inherit (self) pkgs lib symlinkJoin makeWrapper
143+ git nix nix-prefetch-git;
144+ inherit (self.haskell-nix) fetchExternal cleanSourceHaskell mkCabalProjectPkgSet;
145+ hpack = self.haskell.lib.justStaticExecutables
146+ (self.haskellPackages.hpack);
147+ };
148+ # While `nix-tools-cross-compiled` may be cross compiled,
149+ # getting it from `buildPackages` we should get
150+ # nix-tools suitable for running on the build system.
151+ nix-tools = self.buildPackages.haskell-nix.nix-tools-cross-compiled;
152+ # TODO perhaps there is a cleaner way to get a suitable nix-tools.
153+
154+ # Produce a fixed output derivation from a moving target (hackage index tarball)
155+ hackageTarball = { index-state, sha256, nix-tools ? self.nix-tools, ... }:
156+ assert sha256 != null;
157+ self.fetchurl {
158+ name = "01-index.tar.gz-at-${builtins.replaceStrings [":"] [""] index-state}";
159+ url = "https://hackage.haskell.org/01-index.tar.gz";
160+ downloadToTemp = true;
161+ postFetch = "${nix-tools}/bin/truncate-index -o $out -i $downloadedFile -s ${index-state}";
162+
163+ outputHashAlgo = "sha256";
164+ outputHash = sha256;
165+ };
166+
167+ mkLocalHackageRepo = import ../mk-local-hackage-repo { inherit hackageTarball; pkgs = self; };
168+
169+ dotCabal = { index-state, sha256, cabal-install, ... }@args:
170+ self.runCommand "dot-cabal-at-${builtins.replaceStrings [":"] [""] index-state}" { nativeBuildInputs = [ cabal-install ]; } ''
171+ mkdir -p $out/.cabal
172+ cat <<EOF > $out/.cabal/config
173+ repository cached
174+ url: file:${mkLocalHackageRepo args}
175+ secure: True
176+ root-keys:
177+ key-threshold: 0
178+ EOF
179+ mkdir -p $out/.cabal/packages/cached
180+ HOME=$out cabal new-update cached
181+ '';
182+
183+ update-index-state-hashes = import ../scripts/update-index-state-hashes.nix {
184+ inherit (self.haskell-nix) indexStateHashesPath nix-tools;
185+ inherit (self) coreutils nix writeShellScriptBin stdenv;
186+ };
187+
188+ # Function to call stackToNix
189+ callStackToNix = import ../lib/call-stack-to-nix.nix {
190+ pkgs = self.buildPackages.pkgs;
191+ inherit (self.buildPackages.pkgs) runCommand;
192+ inherit (self.buildPackages.haskell-nix) nix-tools mkCacheFile;
193+ };
194+
195+ # given a source location call `cabal-to-nix` (from nix-tools) on it
196+ # to produce the nix representation of it.
197+ callCabalToNix = { name, src, cabal-file ? "${name}.cabal" }:
198+ self.buildPackages.pkgs.runCommand "${name}.nix" {
199+ nativeBuildInputs = [ self.buildPackages.haskell-nix.nix-tools ];
200+
201+ LOCALE_ARCHIVE = self.lib.optionalString (self.stdenv.buildPlatform.libc == "glibc") "${self.buildPackages.glibcLocales}/lib/locale/locale-archive";
202+ LANG = "en_US.UTF-8";
203+ LC_ALL = "en_US.UTF-8";
204+ } ''
205+ cabal-to-nix "${src}" "${src}/${cabal-file}" > "$out"
206+ '';
207+
208+ # Given a list of repos:
209+ # [ { name = ...; url = ...; rev = ...; sha256 = ... } ]
210+ # produce a cache file that can be used for
211+ # stack-to-nix or plan-to-nix to prevent them
212+ # from needing network access.
213+ mkCacheFile = repos: let
214+ fetchRepo = repo: (self.buildPackages.pkgs.fetchgit {
215+ url = repo.url;
216+ rev = repo.rev;
217+ sha256 = repo.sha256;
218+ }) + (if repo.subdir or "." == "." then "" else "/" + repo.subdir);
219+
220+ f = { name, url, rev, subdir ? ".", sha256, cabal-file ? "${name}.cabal" }@repo:
221+ let nix-expr = self.buildPackages.haskell-nix.callCabalToNix { src = (fetchRepo repo); inherit name cabal-file; };
222+ in "${url} ${rev} ${subdir} ${sha256} ${name} ${nix-expr}";
223+ in
224+ self.buildPackages.pkgs.writeTextFile {
225+ name = "cache-file";
226+ text = self.buildPackages.lib.concatMapStringsSep "\n" f repos;
227+ };
228+
229+ # Takes a haskell src directory runs cabal new-configure and plan-to-nix.
230+ # Resulting nix files are added to nix-plan subdirectory.
231+ callCabalProjectToNix = import ../lib/call-cabal-project-to-nix.nix {
232+ index-state-hashes = import indexStateHashesPath;
233+ inherit (self.buildPackages.haskell-nix) dotCabal nix-tools haskellLib;
234+ pkgs = self.buildPackages.pkgs;
235+ inherit (self.buildPackages.haskell-nix.haskellPackages.hpack.components.exes) hpack;
236+ inherit (self.buildPackages.pkgs) runCommand cabal-install ghc symlinkJoin cacert;
237+ };
238+
239+ # Loads a plan and filters the package directories using cleanSourceWith
240+ importAndFilterProject = import ../lib/import-and-filter-project.nix {
241+ inherit (self.buildPackages.haskell-nix) haskellLib;
242+ pkgs = self.buildPackages.pkgs;
243+ };
244+
245+ # References to the unpacked sources, for caching in a Hydra jobset.
246+ source-pins = import ../lib/make-source-pins.nix {
247+ inherit (self) lib writeTextFile;
248+ sources = [ hackageSrc stackageSrc self.path ];
249+ };
250+
251+ # -- IFDs --
252+ # Build a specific package (name, version) against a given index-stage
253+ # from hackage. This is useful if you want to build an executable from
254+ # a given package.
255+ # NB: If no explicit index-state is provided the most recent one from
256+ # the index-state-hashes is used. This guarantees reproducability wrt
257+ # to the haskell.nix revision. If reproducability beyond haskell.nix
258+ # is required, a specific index-state should be provided!
259+ hackage-package = { name, ... }@args: (hackage-project args).${name};
260+ hackage-project =
261+ { name
262+ , version
263+ , index-state ? builtins.trace "Using latest index state!" self.lib.last (builtins.attrNames (import indexStateHashesPath))
264+ , ... }@args:
265+ let tarball = self.pkgs.fetchurl {
266+ url = "mirror://hackage/${name}-${version}.tar.gz";
267+ inherit (hackage.${name}.${version}) sha256; };
268+ in let src = self.buildPackages.pkgs.runCommand "${name}-${version}-src" { } ''
269+ tmp=$(mktemp -d)
270+ cd $tmp
271+ tar xzf ${tarball}
272+ mv "${name}-${version}" $out
273+ '';
274+ in cabalProject (builtins.removeAttrs args [ "name" "version" ] // { inherit index-state src; });
275+
276+ cabalProject' =
277+ { index-state ? builtins.trace "Using latest index state!" self.lib.last (builtins.attrNames (import indexStateHashesPath))
278+ , ... }@args:
279+ let plan = (importAndFilterProject
280+ (callCabalProjectToNix
281+ (builtins.trace "Using index-state: ${index-state}"
282+ (args // { inherit index-state; }))));
283+ in let pkg-set = mkCabalProjectPkgSet
284+ { plan-pkgs = plan.pkgs;
285+ pkg-def-extras = args.pkg-def-extras or [];
286+ modules = (args.modules or [])
287+ ++ self.lib.optional (args ? ghc) { ghc.package = args.ghc; };
288+ };
289+ in {inherit (pkg-set.config) hsPkgs; plan-nix = plan.nix; };
290+
291+ cabalProject = args: let p = cabalProject' args;
292+ in p.hsPkgs // {
293+ inherit (p) plan-nix;
294+ # Provide `nix-shell -A shells.ghc` for users migrating from the reflex-platform.
295+ # But we should encourage use of `nix-shell -A shellFor`
296+ shells.ghc = p.hsPkgs.shellFor {};
297+ };
298+
299+ stackProject =
300+ { ... }@args:
301+ let stack-pkgs = (importAndFilterProject (callStackToNix args)).pkgs;
302+ in let pkg-set = mkStackPkgSet
303+ { inherit stack-pkgs;
304+ pkg-def-extras = (args.pkg-def-extras or []);
305+ modules = (args.modules or [])
306+ ++ self.lib.optional (args ? ghc) { ghc.package = args.ghc; };
307+ };
308+ in pkg-set.config.hsPkgs;
309+ };
310+}
overlays/linux-cross.nixnew file+72
@@ -0,0 +1,72 @@
1+let
2+ # Here we try to figure out which qemu to use based on the host platform.
3+ # This guess can be overriden by passing qemuSuffix
4+ qemuByHostPlatform = hostPlatform:
5+ # I'd prefer this was a dictionary lookup, with a fall through into abort,
6+ # that would make this more readable I guess. I think there is some similar
7+ # mapping somewhere in haskell.nix
8+ if hostPlatform.isAarch32
9+ then "arm"
10+ else if hostPlatform.isAarch64
11+ then "aarch64"
12+ else abort "Don't know which QEMU to use for hostPlatform ${hostPlatform.config}. Please provide qemuSuffix";
13+in
14+{ stdenv
15+, lib
16+, writeScriptBin
17+, qemu
18+, qemuSuffix ? (qemuByHostPlatform hostPlatform)
19+, iserv-proxy
20+, remote-iserv
21+, gmp
22+, extra-test-libs ? []
23+, buildPlatform
24+, hostPlatform
25+, ...
26+}:
27+let
28+
29+ # we want this to hold only for arm (32 and 64bit) for now.
30+ isLinuxCross = buildPlatform != hostPlatform && hostPlatform.isLinux && (hostPlatform.isAarch32 || hostPlatform.isAarch64);
31+ qemuIservWrapper = writeScriptBin "iserv-wrapper" ''
32+ #!${stdenv.shell}
33+ set -euo pipefail
34+ # Unset configure flags as configure should have run already
35+ unset configureFlags
36+ PORT=$((5000 + $RANDOM % 5000))
37+ (>&2 echo "---> Starting remote-iserv on port $PORT")
38+ ${qemu}/bin/qemu-${qemuSuffix} ${remote-iserv}/bin/remote-iserv tmp $PORT &
39+ (>&2 echo "---| remote-iserv should have started on $PORT")
40+ RISERV_PID="$!"
41+ ${iserv-proxy}/bin/iserv-proxy $@ 127.0.0.1 "$PORT"
42+ (>&2 echo "---> killing remote-iserve...")
43+ kill $RISERV_PID
44+ '';
45+ configureFlags = lib.optional hostPlatform.isAarch32 "--disable-split-sections";
46+ setupBuildFlags = map (opt: "--ghc-option=" + opt) (lib.optionals isLinuxCross
47+ [ "-fexternal-interpreter"
48+ "-pgmi" "${qemuIservWrapper}/bin/iserv-wrapper"
49+ "-L${gmp}/lib"
50+ ]) ++ lib.optionals hostPlatform.isAarch32 (map (opt: "--gcc-option=" + opt) [ "-fno-pic" "-fno-plt" ]);
51+ qemuTestWrapper = writeScriptBin "test-wrapper" ''
52+ #!${stdenv.shell}
53+ set -euo pipefail
54+ ${qemu}/bin/qemu-${qemuSuffix} $@*
55+ '';
56+ testFlags = lib.optionals isLinuxCross [ "--test-wrapper ${qemuTestWrapper}/bin/test-wrapper" ];
57+ preCheck = lib.optionalString isLinuxCross ''
58+ echo "================================================================="
59+ echo "RUNNING TESTS for $name via qemu-${qemuSuffix}"
60+ echo "================================================================="
61+ echo "Copying extra test libraries"
62+ for p in ${lib.concatStringsSep " " extra-test-libs}; do
63+ find "$p" -iname '*.so*' -exec cp {} . \;
64+ done
65+ '';
66+ postCheck = lib.optionalString isLinuxCross ''
67+ echo "================================================================="
68+ echo "END RUNNING TESTS"
69+ echo "================================================================="
70+ '';
71+
72+in { inherit preCheck postCheck configureFlags setupBuildFlags testFlags; }
overlays/mingw_w64.nixnew file+81
@@ -0,0 +1,81 @@
1+# Cross compilation logic.
2+# Returns override fields for use with nix-tools.
3+{ stdenv
4+, lib
5+, writeScriptBin
6+, wine
7+, mingw_w64_pthreads
8+, iserv-proxy
9+, remote-iserv
10+, gmp
11+# extra libraries. Their dlls are copied
12+# when tests are run.
13+, extra-test-libs ? []
14+, hostPlatform
15+}:
16+let
17+
18+ wineIservWrapper = writeScriptBin "iserv-wrapper" ''
19+ #!${stdenv.shell}
20+ set -euo pipefail
21+ # unset the configureFlags.
22+ # configure should have run already
23+ # without restting it, wine might fail
24+ # due to a too large environment.
25+ unset configureFlags
26+ PORT=$((5000 + $RANDOM % 5000))
27+ (>&2 echo "---> Starting remote-iserv on port $PORT")
28+ WINEDLLOVERRIDES="winemac.drv=d" WINEDEBUG=warn-all,fixme-all,-menubuilder,-mscoree,-ole,-secur32,-winediag WINEPREFIX=$TMP ${wine}/bin/wine64 ${remote-iserv}/bin/remote-iserv.exe tmp $PORT &
29+ (>&2 echo "---| remote-iserv should have started on $PORT")
30+ RISERV_PID="$!"
31+ ${iserv-proxy}/bin/iserv-proxy $@ 127.0.0.1 "$PORT"
32+ (>&2 echo "---> killing remote-iserv...")
33+ kill $RISERV_PID
34+ '';
35+ ################################################################################
36+ # Build logic (TH support via remote iserv via wine)
37+ #
38+ setupBuildFlags = map (opt: "--ghc-option=" + opt) (lib.optionals hostPlatform.isWindows [
39+ "-fexternal-interpreter"
40+ "-pgmi" "${wineIservWrapper}/bin/iserv-wrapper"
41+ # TODO: this should be automatically injected based on the extraLibrary.
42+ "-L${mingw_w64_pthreads}/lib"
43+ "-L${mingw_w64_pthreads}/bin"
44+ "-L${gmp}/lib"
45+ ]);
46+
47+ ################################################################################
48+ # Test logic via wine
49+ #
50+ wineTestWrapper = writeScriptBin "test-wrapper" ''
51+ #!${stdenv.shell}
52+ set -euo pipefail
53+ WINEDLLOVERRIDES="winemac.drv=d" WINEDEBUG=warn-all,fixme-all,-menubuilder,-mscoree,-ole,-secur32,-winediag LC_ALL=en_US.UTF-8 WINEPREFIX=$TMP ${wine}/bin/wine64 $@
54+ '';
55+ testWrapper = lib.optional hostPlatform.isWindows "${wineTestWrapper}/bin/test-wrapper";
56+
57+ preCheck = lib.optionalString hostPlatform.isWindows ''
58+ echo "================================================================================"
59+ echo "RUNNING TESTS for $name via wine64"
60+ echo "================================================================================"
61+ echo "Copying extra test libraries ..."
62+ for p in ${lib.concatStringsSep " "extra-test-libs}; do
63+ find "$p" -iname '*.dll' -exec cp {} . \;
64+ done
65+ # copy all .dlls into the local directory.
66+ # we ask ghc-pkg for *all* dynamic-library-dirs and then iterate over the unique set
67+ # to copy over dlls as needed.
68+ echo "Copying library dependencies..."
69+ for libdir in $(x86_64-pc-mingw32-ghc-pkg --package-db=$packageConfDir field "*" dynamic-library-dirs --simple-output|xargs|sed 's/ /\n/g'|sort -u); do
70+ if [ -d "$libdir" ]; then
71+ find "$libdir" -iname '*.dll' -exec cp {} . \;
72+ fi
73+ done
74+ '';
75+ postCheck = lib.optionalString hostPlatform.isWindows ''
76+ echo "================================================================================"
77+ echo "END RUNNING TESTS"
78+ echo "================================================================================"
79+ '';
80+
81+in { inherit preCheck testWrapper postCheck setupBuildFlags; }
overlays/patches/Cabal/fix-data-dir.patchnew file+20
@@ -0,0 +1,20 @@
1+diff --git a/Distribution/Simple/Build/PathsModule.hs b/Distribution/Simple/Build/PathsModule.hs
2+index f6a203874..2aa406f74 100644
3+--- a/Distribution/Simple/Build/PathsModule.hs
4++++ b/Distribution/Simple/Build/PathsModule.hs
5+@@ -192,10 +192,14 @@ generate pkg_descr lbi clbi =
6+ bindir = flat_bindir,
7+ libdir = flat_libdir,
8+ dynlibdir = flat_dynlibdir,
9+- datadir = flat_datadir,
10+ libexecdir = flat_libexecdir,
11+ sysconfdir = flat_sysconfdir
12+ } = absoluteComponentInstallDirs pkg_descr lbi cid NoCopyDest
13++
14++ InstallDirs {
15++ datadir = flat_datadir
16++ } = absoluteInstallDirs pkg_descr lbi NoCopyDest
17++
18+ InstallDirs {
19+ bindir = flat_bindirrel,
20+ libdir = flat_libdirrel,
overlays/patches/clock-0.7.2.patchnew file+59
@@ -0,0 +1,59 @@
1+diff --git a/System/Clock.hsc b/System/Clock.hsc
2+index 297607b..c21196b 100644
3+--- a/System/Clock.hsc
4++++ b/System/Clock.hsc
5+@@ -41,7 +41,9 @@ import GHC.Generics (Generic)
6+ # endif
7+ #endif
8+
9+-#let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
10++#if __GLASGOW_HASKELL__ < 800
11++# let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
12++#endif
13+
14+ -- | Clock types. A clock may be system-wide (that is, visible to all processes)
15+ -- or per-process (measuring time that is meaningful only within a process).
16+diff --git a/cbits/hs_clock_win32.c b/cbits/hs_clock_win32.c
17+index 5dcc2a9..ebdb7fe 100644
18+--- a/cbits/hs_clock_win32.c
19++++ b/cbits/hs_clock_win32.c
20+@@ -28,12 +28,22 @@ static void to_timespec_from_100ns(ULONGLONG t_100ns, long long *t)
21+ t[1] = 100*(long)(t_100ns % 10000000UL);
22+ }
23+
24++/* See https://ghc.haskell.org/trac/ghc/ticket/15094 */
25++#if defined(_WIN32) && !defined(_WIN64)
26++__attribute__((optimize("-fno-expensive-optimizations")))
27++#endif
28+ void hs_clock_win32_gettime_monotonic(long long* t)
29+ {
30+ LARGE_INTEGER time;
31+- LARGE_INTEGER frequency;
32++ static LARGE_INTEGER frequency;
33++ static int hasFreq = 0;
34++
35+ QueryPerformanceCounter(&time);
36+- QueryPerformanceFrequency(&frequency);
37++ if (!hasFreq)
38++ {
39++ hasFreq = 1;
40++ QueryPerformanceFrequency(&frequency);
41++ }
42+ // seconds
43+ t[0] = time.QuadPart / frequency.QuadPart;
44+ // nanos =
45+diff --git a/clock.cabal b/clock.cabal
46+index 0f2d18a..67d232e 100644
47+--- a/clock.cabal
48++++ b/clock.cabal
49+@@ -41,8 +41,8 @@ description: A package for convenient access to high-resolution clock and
50+ copyright: Copyright © Cetin Sert 2009-2016, Eugene Kirpichov 2010, Finn Espen Gundersen 2013, Gerolf Seitz 2013, Mathieu Boespflug 2014 2015, Chris Done 2015, Dimitri Sabadie 2015, Christian Burger 2015, Mario Longobardi 2016
51+ license: BSD3
52+ license-file: LICENSE
53+-author: Cetin Sert <cetin@corsis.eu>, Corsis Research
54+-maintainer: Cetin Sert <cetin@corsis.eu>, Corsis Research
55++author: Cetin Sert <cetin@corsis.tech>, Corsis Research
56++maintainer: Cetin Sert <cetin@corsis.tech>, Corsis Research
57+ homepage: https://github.com/corsis/clock
58+ bug-reports: https://github.com/corsis/clock/issues
59+ category: System
overlays/patches/conduit-1.3.0.2.patchnew file+15
@@ -0,0 +1,15 @@
1+diff --git a/src/System/Win32File.hsc b/src/System/Win32File.hsc
2+index a524c77..8e8071d 100644
3+--- a/src/System/Win32File.hsc
4++++ b/src/System/Win32File.hsc
5+@@ -31,8 +31,8 @@ import Data.ByteString.Lazy.Internal (defaultChunkSize)
6+
7+
8+ #include <fcntl.h>
9+-#include <Share.h>
10+-#include <SYS/Stat.h>
11++#include <share.h>
12++#include <sys/stat.h>
13+ #include <errno.h>
14+
15+ newtype OFlag = OFlag CInt
overlays/patches/cryptonite-openssl-0.7.patchnew file+13
@@ -0,0 +1,13 @@
1+diff --git a/cryptonite-openssl.cabal b/cryptonite-openssl.cabal
2+index ceb275a..96994b2 100644
3+--- a/cryptonite-openssl.cabal
4++++ b/cryptonite-openssl.cabal
5+@@ -39,7 +39,7 @@ Library
6+ ghc-options: -Wall -fwarn-tabs -optc-O3
7+ default-language: Haskell2010
8+ if os(mingw32) || os(windows)
9+- extra-libraries: eay32, ssl32
10++ extra-libraries: crypto
11+ else
12+ if os(osx)
13+ include-dirs: /usr/local/opt/openssl/include
overlays/patches/file-embed-lzma-0.patchnew file+44
@@ -0,0 +1,44 @@
1+diff --git a/src/FileEmbedLzma.hs b/src/FileEmbedLzma.hs
2+index ca0c394..bc1960f 100644
3+--- a/src/FileEmbedLzma.hs
4++++ b/src/FileEmbedLzma.hs
5+@@ -36,7 +36,6 @@ import Data.Foldable (for_)
6+ import Data.Functor.Compose (Compose (..))
7+ import Data.Int (Int64)
8+ import Language.Haskell.TH
9+-import Language.Haskell.TH.Syntax (qAddDependentFile)
10+ import System.Directory
11+ (doesDirectoryExist, getDirectoryContents)
12+ import System.FilePath (makeRelative, (</>))
13+@@ -124,7 +123,6 @@ concatEntries xs = (bslEndo BSL.empty, ys)
14+ embedDir :: FilePath -> Q Exp
15+ embedDir topdir = do
16+ pairs' <- runIO $ listDirectoryFiles topdir
17+- for_ pairs' $ qAddDependentFile . fst
18+ let pairs = makeAllRelative topdir pairs'
19+ embedPairs pairs
20+
21+@@ -151,7 +149,6 @@ embedPairs pairs = do
22+ embedRecursiveDir :: FilePath -> Q Exp
23+ embedRecursiveDir topdir = do
24+ pairs' <- runIO $ listRecursiveDirectoryFiles topdir
25+- for_ pairs' $ qAddDependentFile . fst
26+ let pairs = makeAllRelative topdir pairs'
27+ embedPairs pairs
28+
29+@@ -162,7 +159,6 @@ embedRecursiveDir topdir = do
30+ -- | Embed a lazy 'Data.ByteString.Lazy.ByteString' from a file.
31+ embedLazyByteString :: FilePath -> Q Exp
32+ embedLazyByteString fp = do
33+- qAddDependentFile fp
34+ bsl <- runIO $ BSL.readFile fp
35+ lazyBytestringE bsl
36+
37+@@ -173,7 +169,6 @@ embedByteString fp = [| BSL.toStrict $(embedLazyByteString fp) :: BS.ByteString
38+ -- | Embed a lazy 'Data.Text.Lazy.Text' from a UTF8-encoded file.
39+ embedLazyText :: FilePath -> Q Exp
40+ embedLazyText fp = do
41+- qAddDependentFile fp
42+ bsl <- runIO $ BSL.readFile fp
43+ case TLE.decodeUtf8' bsl of
44+ Left e -> reportError (show e)
overlays/patches/ghc/0001-Stop-the-linker-panic.patchnew file+122
@@ -0,0 +1,122 @@
1+From c010cc3a5ec03a0bfcae777bf37223b91f46d7d3 Mon Sep 17 00:00:00 2001
2+From: Moritz Angermann <moritz.angermann@gmail.com>
3+Date: Fri, 27 Jul 2018 10:23:57 +0800
4+Subject: [PATCH] Stop the linker panic
5+
6+If we fail to initialize the liker properly, we still set the `initLinkerDone`. In fact we even set that prior to actually initializing the linker. However if the linker initialization fails, we the `Done` state is still true. As such we run into the `Dynamic Linker not initialised` error. Which while technically corret is confusing as it pulls the attation away from the real issue.
7+
8+This change puts the Done state into an MVar, and as such ensureing that all parallel access needs to wait for the linker to be actually initialized, or try to re-initilize if it fails.
9+---
10+ compiler/ghci/Linker.hs | 29 +++++++++++++++--------------
11+ compiler/utils/Panic.hs | 13 +++++++++++++
12+ 2 files changed, 28 insertions(+), 14 deletions(-)
13+
14+diff --git a/compiler/ghci/Linker.hs b/compiler/ghci/Linker.hs
15+index 150f2af4c7..20038f8101 100644
16+--- a/compiler/ghci/Linker.hs
17++++ b/compiler/ghci/Linker.hs
18+@@ -94,7 +94,7 @@ interpreted code only), for use during linking.
19+ -}
20+ #if STAGE < 2
21+ GLOBAL_VAR_M(v_PersistentLinkerState, newMVar (panic "Dynamic linker not initialised"), MVar PersistentLinkerState)
22+-GLOBAL_VAR(v_InitLinkerDone, False, Bool) -- Set True when dynamic linker is initialised
23++GLOBAL_VAR_M(v_InitLinkerDone, newMVar False, MVar Bool) -- Set True when dynamic linker is initialised
24+ #else
25+ SHARED_GLOBAL_VAR_M( v_PersistentLinkerState
26+ , getOrSetLibHSghcPersistentLinkerState
27+@@ -102,11 +102,11 @@ SHARED_GLOBAL_VAR_M( v_PersistentLinkerState
28+ , newMVar (panic "Dynamic linker not initialised")
29+ , MVar PersistentLinkerState)
30+ -- Set True when dynamic linker is initialised
31+-SHARED_GLOBAL_VAR( v_InitLinkerDone
32+- , getOrSetLibHSghcInitLinkerDone
33+- , "getOrSetLibHSghcInitLinkerDone"
34+- , False
35+- , Bool)
36++SHARED_GLOBAL_VAR_M( v_InitLinkerDone
37++ , getOrSetLibHSghcInitLinkerDone
38++ , "getOrSetLibHSghcInitLinkerDone"
39++ , newMVar False
40++ , MVar Bool)
41+ #endif
42+
43+ modifyPLS_ :: (PersistentLinkerState -> IO PersistentLinkerState) -> IO ()
44+@@ -115,6 +115,9 @@ modifyPLS_ f = readIORef v_PersistentLinkerState >>= flip modifyMVar_ f
45+ modifyPLS :: (PersistentLinkerState -> IO (PersistentLinkerState, a)) -> IO a
46+ modifyPLS f = readIORef v_PersistentLinkerState >>= flip modifyMVar f
47+
48++modifyILD :: (Bool -> IO (Bool, a)) -> IO a
49++modifyILD f = readIORef v_InitLinkerDone >>= flip modifyMVar f
50++
51+ data PersistentLinkerState
52+ = PersistentLinkerState {
53+
54+@@ -289,10 +292,9 @@ showLinkerState dflags
55+ initDynLinker :: HscEnv -> IO ()
56+ initDynLinker hsc_env =
57+ modifyPLS_ $ \pls0 -> do
58+- done <- readIORef v_InitLinkerDone
59+- if done then return pls0
60+- else do writeIORef v_InitLinkerDone True
61+- reallyInitDynLinker hsc_env
62++ modifyILD $ \done -> do
63++ if done then return (done, pls0)
64++ else (True,) <$> reallyInitDynLinker hsc_env
65+
66+ reallyInitDynLinker :: HscEnv -> IO PersistentLinkerState
67+ reallyInitDynLinker hsc_env = do
68+@@ -1324,8 +1326,7 @@ load_dyn hsc_env dll = do
69+ r <- loadDLL hsc_env dll
70+ case r of
71+ Nothing -> return ()
72+- Just err -> throwGhcExceptionIO (CmdLineError ("can't load .so/.DLL for: "
73+- ++ dll ++ " (" ++ err ++ ")" ))
74++ Just err -> cmdLineErrorIO ("can't load .so/.DLL for: " ++ dll ++ " (" ++ err ++ ")")
75+
76+ loadFrameworks :: HscEnv -> Platform -> PackageConfig -> IO ()
77+ loadFrameworks hsc_env platform pkg
78+@@ -1337,8 +1338,8 @@ loadFrameworks hsc_env platform pkg
79+ load fw = do r <- loadFramework hsc_env fw_dirs fw
80+ case r of
81+ Nothing -> return ()
82+- Just err -> throwGhcExceptionIO (CmdLineError ("can't load framework: "
83+- ++ fw ++ " (" ++ err ++ ")" ))
84++ Just err -> cmdLineErrorIO ("can't load framework: "
85++ ++ fw ++ " (" ++ err ++ ")" )
86+
87+ -- Try to find an object file for a given library in the given paths.
88+ -- If it isn't present, we assume that addDLL in the RTS can find it,
89+diff --git a/compiler/utils/Panic.hs b/compiler/utils/Panic.hs
90+index ebf830385c..0a91c39b35 100644
91+--- a/compiler/utils/Panic.hs
92++++ b/compiler/utils/Panic.hs
93+@@ -20,6 +20,8 @@ module Panic (
94+ panic, sorry, assertPanic, trace,
95+ panicDoc, sorryDoc, pgmErrorDoc,
96+
97++ cmdLineError, cmdLineErrorIO,
98++
99+ Exception.Exception(..), showException, safeShowException,
100+ try, tryMost, throwTo,
101+
102+@@ -195,6 +197,17 @@ panicDoc x doc = throwGhcException (PprPanic x doc)
103+ sorryDoc x doc = throwGhcException (PprSorry x doc)
104+ pgmErrorDoc x doc = throwGhcException (PprProgramError x doc)
105+
106++cmdLineError :: String -> a
107++cmdLineError = unsafeDupablePerformIO . cmdLineErrorIO
108++
109++cmdLineErrorIO :: String -> IO a
110++cmdLineErrorIO x = do
111++ stack <- ccsToStrings =<< getCurrentCCS x
112++ if null stack
113++ then throwGhcException (CmdLineError x)
114++ else throwGhcException (CmdLineError (x ++ '\n' : renderStack stack))
115++
116++
117+
118+ -- | Throw a failed assertion exception for a given filename and line number.
119+ assertPanic :: String -> Int -> a
120+--
121+2.18.0
122+
overlays/patches/ghc/Cabal2201-allow-test-wrapper.patchnew file+72
@@ -0,0 +1,72 @@
1+diff --git a/Distribution/Simple/Setup.hs b/Distribution/Simple/Setup.hs
2+index 5fa0e99..fc429b6 100644
3+--- a/Distribution/Simple/Setup.hs
4++++ b/Distribution/Simple/Setup.hs
5+@@ -1919,6 +1919,7 @@ data TestFlags = TestFlags {
6+ testMachineLog :: Flag PathTemplate,
7+ testShowDetails :: Flag TestShowDetails,
8+ testKeepTix :: Flag Bool,
9++ testWrapper :: Flag FilePath,
10+ -- TODO: think about if/how options are passed to test exes
11+ testOptions :: [PathTemplate]
12+ } deriving (Generic)
13+@@ -1931,6 +1932,7 @@ defaultTestFlags = TestFlags {
14+ testMachineLog = toFlag $ toPathTemplate $ "$pkgid.log",
15+ testShowDetails = toFlag Failures,
16+ testKeepTix = toFlag False,
17++ testWrapper = NoFlag,
18+ testOptions = []
19+ }
20+
21+@@ -1991,6 +1993,11 @@ testCommand = CommandUI
22+ "keep .tix files for HPC between test runs"
23+ testKeepTix (\v flags -> flags { testKeepTix = v})
24+ trueArg
25++ , option [] ["test-wrapper"]
26++ "Run test through a wrapper."
27++ testWrapper (\v flags -> flags { testWrapper = v })
28++ (reqArg' "FILE" (toFlag :: FilePath -> Flag FilePath)
29++ (pure . fromFlag :: Flag FilePath -> [FilePath]))
30+ , option [] ["test-options"]
31+ ("give extra options to test executables "
32+ ++ "(name templates can use $pkgid, $compiler, "
33+diff --git a/Distribution/Simple/Test/ExeV10.hs b/Distribution/Simple/Test/ExeV10.hs
34+index 707ab74..87bfefe 100644
35+--- a/Distribution/Simple/Test/ExeV10.hs
36++++ b/Distribution/Simple/Test/ExeV10.hs
37+@@ -98,7 +98,12 @@ runTest pkg_descr lbi clbi flags suite = do
38+ return (addLibraryPath os paths shellEnv)
39+ else return shellEnv
40+
41+- exit <- rawSystemIOWithEnv verbosity cmd opts Nothing (Just shellEnv')
42++ exit <- case testWrapper flags of
43++ Flag path -> rawSystemIOWithEnv verbosity path (cmd:opts) Nothing (Just shellEnv')
44++ -- these handles are automatically closed
45++ Nothing (Just wOut) (Just wErr)
46++
47++ NoFlag -> rawSystemIOWithEnv verbosity cmd opts Nothing (Just shellEnv')
48+ -- these handles are automatically closed
49+ Nothing (Just wOut) (Just wErr)
50+
51+diff --git a/Distribution/Simple/Test/LibV09.hs b/Distribution/Simple/Test/LibV09.hs
52+index 861e91a..66316fa 100644
53+--- a/Distribution/Simple/Test/LibV09.hs
54++++ b/Distribution/Simple/Test/LibV09.hs
55+@@ -99,9 +99,14 @@ runTest pkg_descr lbi clbi flags suite = do
56+ cpath <- canonicalizePath $ LBI.componentBuildDir lbi clbi
57+ return (addLibraryPath os (cpath : paths) shellEnv)
58+ else return shellEnv
59+- createProcessWithEnv verbosity cmd opts Nothing (Just shellEnv')
60+- -- these handles are closed automatically
61+- CreatePipe (UseHandle wOut) (UseHandle wOut)
62++ case testWrapper flags of
63++ Flag path -> createProcessWithEnv verbosity path (cmd:opts) Nothing (Just shellEnv')
64++ -- these handles are closed automatically
65++ CreatePipe (UseHandle wOut) (UseHandle wOut)
66++
67++ NoFlag -> createProcessWithEnv verbosity cmd opts Nothing (Just shellEnv')
68++ -- these handles are closed automatically
69++ CreatePipe (UseHandle wOut) (UseHandle wOut)
70+
71+ hPutStr wIn $ show (tempLog, PD.testName suite)
72+ hClose wIn
overlays/patches/ghc/Cabal2201-no-hackage-tests.patchnew file+15
@@ -0,0 +1,15 @@
1+diff --git a/Cabal.cabal b/Cabal.cabal
2+index 2b680ca..7320b40 100644
3+--- a/Cabal.cabal
4++++ b/Cabal.cabal
5+@@ -568,9 +568,7 @@ test-suite hackage-tests
6+ type: exitcode-stdio-1.0
7+ main-is: HackageTests.hs
8+
9+- -- TODO: need to get 01-index.tar on appveyor
10+- if os(windows)
11+- buildable: False
12++ buildable: False
13+
14+ hs-source-dirs: tests
15+
overlays/patches/ghc/MR148--T16104-GhcPlugins.patchnew file+21
@@ -0,0 +1,21 @@
1+diff --git a/compiler/simplCore/CoreMonad.hs b/compiler/simplCore/CoreMonad.hs
2+index 912ff9949c..86706d344e 100644
3+--- a/compiler/simplCore/CoreMonad.hs
4++++ b/compiler/simplCore/CoreMonad.hs
5+@@ -64,6 +64,7 @@ import Module
6+ import DynFlags
7+ import BasicTypes ( CompilerPhase(..) )
8+ import Annotations
9++import IfaceEnv ( lookupOrigIO )
10+
11+ import IOEnv hiding ( liftIO, failM, failWithM )
12+ import qualified IOEnv ( liftIO )
13+@@ -821,6 +822,6 @@ thNameToGhcName th_name
14+ | Just n <- isExact_maybe rdr_name -- This happens in derived code
15+ = return $ if isExternalName n then Just n else Nothing
16+ | Just (rdr_mod, rdr_occ) <- isOrig_maybe rdr_name
17+- = do { cache <- getOrigNameCache
18+- ; return $ lookupOrigNameCache cache rdr_mod rdr_occ }
19++ = do { hsc_env <- getHscEnv
20++ ; Just <$> liftIO (lookupOrigIO hsc_env rdr_mod rdr_occ) }
21+ | otherwise = return Nothing
overlays/patches/ghc/MR196--ghc-pkg-shut-up.patchnew file+13
@@ -0,0 +1,13 @@
1+diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs
2+index 69137eb4e4..d7411a7c75 100644
3+--- a/utils/ghc-pkg/Main.hs
4++++ b/utils/ghc-pkg/Main.hs
5+@@ -1834,7 +1834,7 @@ liftIO k = V (k >>= \a -> return (a,[],[]))
6+ reportValidateErrors :: Verbosity -> [ValidateError] -> [ValidateWarning]
7+ -> String -> Maybe Force -> IO Bool
8+ reportValidateErrors verbosity es ws prefix mb_force = do
9+- mapM_ (warn . (prefix++)) ws
10++ when (verbosity >= Normal) $ mapM_ (warn . (prefix++)) ws
11+ oks <- mapM report es
12+ return (and oks)
13+ where
overlays/patches/ghc/MR545--ghc-pkg-databases.patchnew file+210
@@ -0,0 +1,210 @@
1+From 01060db6d19c08d37e03675944339fe1ff598546 Mon Sep 17 00:00:00 2001
2+From: Michael Peyton Jones <me@michaelpj.com>
3+Date: Wed, 13 Mar 2019 11:46:56 +0000
4+Subject: [PATCH] Visibility: handle multiple units with the same name
5+
6+Fixes #16228. The included test case is adapted from the reproduction in
7+the issue, and fails without this patch.
8+
9+------
10+
11+We compute an initial visilibity mapping for units based on what is
12+present in the package databases. To seed this, we compute a set of all
13+the package configs to add visibilities for.
14+
15+However, this set was keyed off the unit's *package name*. This is
16+correct, since we compare packages across databases by version. However,
17+we would only ever consider a single, most-preferable unit from the
18+database in which it was found.
19+
20+The effect of this was that only one of the libraries in a Cabal package
21+would be added to this initial set. This would cause attempts to use
22+modules from the omitted libraries to fail, claiming that the package
23+was hidden (even though `ghc-pkg` would correctly show it as visible).
24+
25+The solution is simple: consider all units that are equi-preferable
26+with the most-preferable unit.
27+
28+------
29+
30+Why wasn't this bug apparent to all people trying to use sub-libraries
31+in Cabal? The answer is that Cabal explicitly passes `-package` and
32+`-package-id` flags for all the packages it wants to use, rather than
33+relying on the state of the package database. So this bug only really
34+affects people who are trying to use package databases produced by Cabal
35+outside of Cabal itself.
36+
37+One particular example of this is the way that the
38+Nixpkgs Haskell infrastructure provides wrapped GHCs: typically these
39+are equipped with a package database containing all the needed
40+package dependencies, and the user is not expected to pass
41+`-package` flags explicitly.
42+---
43+ compiler/main/Packages.hs | 29 ++++++++++++++-----
44+ testsuite/tests/cabal/cabal10/Makefile | 21 ++++++++++++++
45+ testsuite/tests/cabal/cabal10/Setup.hs | 2 ++
46+ testsuite/tests/cabal/cabal10/Use.hs | 3 ++
47+ testsuite/tests/cabal/cabal10/all.T | 9 ++++++
48+ testsuite/tests/cabal/cabal10/cabal10.stdout | 1 +
49+ .../tests/cabal/cabal10/internal-lib.cabal | 13 +++++++++
50+ testsuite/tests/cabal/cabal10/src/TestLib.hs | 1 +
51+ 8 files changed, 72 insertions(+), 7 deletions(-)
52+ create mode 100644 testsuite/tests/cabal/cabal10/Makefile
53+ create mode 100644 testsuite/tests/cabal/cabal10/Setup.hs
54+ create mode 100644 testsuite/tests/cabal/cabal10/Use.hs
55+ create mode 100644 testsuite/tests/cabal/cabal10/all.T
56+ create mode 100644 testsuite/tests/cabal/cabal10/cabal10.stdout
57+ create mode 100644 testsuite/tests/cabal/cabal10/internal-lib.cabal
58+ create mode 100644 testsuite/tests/cabal/cabal10/src/TestLib.hs
59+
60+diff --git a/compiler/main/Packages.hs b/compiler/main/Packages.hs
61+index 44258de70c..47e4481ed8 100644
62+--- a/compiler/main/Packages.hs
63++++ b/compiler/main/Packages.hs
64+@@ -1458,21 +1458,36 @@ mkPackageState dflags dbs preload0 = do
65+ --
66+ -- Calculate the initial set of packages, prior to any package flags.
67+ -- This set contains the latest version of all valid (not unusable) packages,
68+- -- or is empty if we have -hide-all-packages
69++ -- or is empty if we have -hide-all-packages.
70++ --
71++ -- Then create an initial visibility map with default visibilities for all
72++ -- exposed, definite units.
73+ --
74+ let preferLater pkg pkg' =
75+ case compareByPreference prec_map pkg pkg' of
76+ GT -> pkg
77+ _ -> pkg'
78+- calcInitial m pkg = addToUDFM_C preferLater m (fsPackageName pkg) pkg
79+- initial = if gopt Opt_HideAllPackages dflags
80++ -- Inter-database comparisons are keyed by package name. Consequently we
81++ -- key this map by the package name, storing a representative "winning" package
82++ -- by preference.
83++ addIfMorePreferable m pkg = addToUDFM_C preferLater m (fsPackageName pkg) pkg
84++ maximallyPreferableReps = if gopt Opt_HideAllPackages dflags
85+ then emptyUDFM
86+- else foldl' calcInitial emptyUDFM pkgs1
87+- vis_map1 = foldUDFM (\p vm ->
88++ else foldl' addIfMorePreferable emptyUDFM pkgs1
89++ maximallyPreferable p =
90++ case lookupUDFM maximallyPreferableReps (fsPackageName p) of
91++ Nothing -> False
92++ Just p' -> compareByPreference prec_map p p' == EQ
93++ vis_map1 = foldl' (\vm p ->
94+ -- Note: we NEVER expose indefinite packages by
95+ -- default, because it's almost assuredly not
96+ -- what you want (no mix-in linking has occurred).
97+- if exposed p && unitIdIsDefinite (packageConfigId p)
98++ -- Note: we consider all units that are equally
99++ -- preferable to the maximally preferable unit
100++ -- with that package name. This means we include
101++ -- other units in the same package in the same db,
102++ -- see #16228.
103++ if exposed p && unitIdIsDefinite (packageConfigId p) && maximallyPreferable p
104+ then Map.insert (packageConfigId p)
105+ UnitVisibility {
106+ uv_expose_all = True,
107+@@ -1483,7 +1498,7 @@ mkPackageState dflags dbs preload0 = do
108+ }
109+ vm
110+ else vm)
111+- Map.empty initial
112++ Map.empty pkgs1
113+
114+ --
115+ -- Compute a visibility map according to the command-line flags (-package,
116+diff --git a/testsuite/tests/cabal/cabal10/Makefile b/testsuite/tests/cabal/cabal10/Makefile
117+new file mode 100644
118+index 0000000000..b59c964db4
119+--- /dev/null
120++++ b/testsuite/tests/cabal/cabal10/Makefile
121+@@ -0,0 +1,21 @@
122++TOP=../../..
123++include $(TOP)/mk/boilerplate.mk
124++include $(TOP)/mk/test.mk
125++
126++SETUP = ./Setup -v0
127++
128++# This test is for packages in internal libraries
129++
130++cabal10: clean
131++ $(MAKE) clean
132++ '$(TEST_HC)' $(TEST_HC_OPTS) -v0 --make Setup
133++ $(SETUP) clean
134++ $(SETUP) configure $(CABAL_MINIMAL_BUILD) --with-ghc='$(TEST_HC)' --ghc-options='$(TEST_HC_OPTS)'
135++ $(SETUP) build
136++ '$(TEST_HC)' $(TEST_HC_OPTS) -package-db dist/package.conf.inplace Use.hs
137++ifneq "$(CLEANUP)" ""
138++ $(MAKE) clean
139++endif
140++
141++clean :
142++ $(RM) -r */dist Setup$(exeext) *.o *.hi
143+diff --git a/testsuite/tests/cabal/cabal10/Setup.hs b/testsuite/tests/cabal/cabal10/Setup.hs
144+new file mode 100644
145+index 0000000000..9a994af677
146+--- /dev/null
147++++ b/testsuite/tests/cabal/cabal10/Setup.hs
148+@@ -0,0 +1,2 @@
149++import Distribution.Simple
150++main = defaultMain
151+diff --git a/testsuite/tests/cabal/cabal10/Use.hs b/testsuite/tests/cabal/cabal10/Use.hs
152+new file mode 100644
153+index 0000000000..b770515501
154+--- /dev/null
155++++ b/testsuite/tests/cabal/cabal10/Use.hs
156+@@ -0,0 +1,3 @@
157++module Use where
158++
159++import TestLib
160+diff --git a/testsuite/tests/cabal/cabal10/all.T b/testsuite/tests/cabal/cabal10/all.T
161+new file mode 100644
162+index 0000000000..778637d948
163+--- /dev/null
164++++ b/testsuite/tests/cabal/cabal10/all.T
165+@@ -0,0 +1,9 @@
166++if config.cleanup:
167++ cleanup = 'CLEANUP=1'
168++else:
169++ cleanup = 'CLEANUP=0'
170++
171++test('cabal10',
172++ extra_files(['Use.hs', 'Setup.hs', 'src/', 'internal-lib.cabal']),
173++ run_command,
174++ ['$MAKE -s --no-print-directory cabal10 ' + cleanup])
175+diff --git a/testsuite/tests/cabal/cabal10/cabal10.stdout b/testsuite/tests/cabal/cabal10/cabal10.stdout
176+new file mode 100644
177+index 0000000000..b7ea26c0d1
178+--- /dev/null
179++++ b/testsuite/tests/cabal/cabal10/cabal10.stdout
180+@@ -0,0 +1 @@
181++[1 of 1] Compiling Use ( Use.hs, Use.o )
182+diff --git a/testsuite/tests/cabal/cabal10/internal-lib.cabal b/testsuite/tests/cabal/cabal10/internal-lib.cabal
183+new file mode 100644
184+index 0000000000..27e8ded0bf
185+--- /dev/null
186++++ b/testsuite/tests/cabal/cabal10/internal-lib.cabal
187+@@ -0,0 +1,13 @@
188++name: internal-lib
189++version: 0.1.0.0
190++license: BSD3
191++build-type: Simple
192++cabal-version: >=2.0
193++
194++library
195++ hs-source-dirs: src
196++ exposed-modules: TestLib
197++ build-depends: base
198++ default-language: Haskell2010
199++
200++library sublib
201+diff --git a/testsuite/tests/cabal/cabal10/src/TestLib.hs b/testsuite/tests/cabal/cabal10/src/TestLib.hs
202+new file mode 100644
203+index 0000000000..c031432cb1
204+--- /dev/null
205++++ b/testsuite/tests/cabal/cabal10/src/TestLib.hs
206+@@ -0,0 +1 @@
207++module TestLib where
208+--
209+2.19.2
210+
overlays/patches/ghc/MR948--32bit-cross-th.patchnew file+143
@@ -0,0 +1,143 @@
1+From ece40a78cfa9295f76237cd2b2aae57cff079084 Mon Sep 17 00:00:00 2001
2+From: Luite Stegeman <stegeman@gmail.com>
3+Date: Mon, 8 Jan 2018 08:42:30 +0000
4+Subject: [PATCH] fix Template Haskell cross compilation on 64 bit compiler
5+ with 32 bit target
6+
7+---
8+ compiler/deSugar/DsMeta.hs | 5 ++++-
9+ compiler/hsSyn/Convert.hs | 4 ++--
10+ compiler/typecheck/TcSplice.hs | 7 ++++---
11+ libraries/template-haskell/Language/Haskell/TH/PprLib.hs | 6 +++---
12+ libraries/template-haskell/Language/Haskell/TH/Syntax.hs | 8 ++++----
13+ 5 files changed, 17 insertions(+), 13 deletions(-)
14+
15+diff --git a/compiler/deSugar/DsMeta.hs b/compiler/deSugar/DsMeta.hs
16+index 5de954ae7d..09a4fecbd5 100644
17+--- a/compiler/deSugar/DsMeta.hs
18++++ b/compiler/deSugar/DsMeta.hs
19+@@ -1947,7 +1947,7 @@ globalVar name
20+ ; rep2 mk_varg [pkg,mod,occ] }
21+ | otherwise
22+ = do { MkC occ <- nameLit name
23+- ; MkC uni <- coreIntLit (getKey (getUnique name))
24++ ; MkC uni <- coreIntegerLit (toInteger $ getKey (getUnique name))
25+ ; rep2 mkNameLName [occ,uni] }
26+ where
27+ mod = ASSERT( isExternalName name) nameModule name
28+@@ -2744,6 +2744,9 @@ coreIntLit :: Int -> DsM (Core Int)
29+ coreIntLit i = do dflags <- getDynFlags
30+ return (MkC (mkIntExprInt dflags i))
31+
32++coreIntegerLit :: Integer -> DsM (Core Integer)
33++coreIntegerLit i = fmap MkC (mkIntegerExpr i)
34++
35+ coreVar :: Id -> Core TH.Name -- The Id has type Name
36+ coreVar id = MkC (Var id)
37+
38+diff --git a/compiler/hsSyn/Convert.hs b/compiler/hsSyn/Convert.hs
39+index 77ffebe021..cb660df6d2 100644
40+--- a/compiler/hsSyn/Convert.hs
41++++ b/compiler/hsSyn/Convert.hs
42+@@ -1831,8 +1831,8 @@ thRdrName loc ctxt_ns th_occ th_name
43+ = case th_name of
44+ TH.NameG th_ns pkg mod -> thOrigRdrName th_occ th_ns pkg mod
45+ TH.NameQ mod -> (mkRdrQual $! mk_mod mod) $! occ
46+- TH.NameL uniq -> nameRdrName $! (((Name.mkInternalName $! mk_uniq uniq) $! occ) loc)
47+- TH.NameU uniq -> nameRdrName $! (((Name.mkSystemNameAt $! mk_uniq uniq) $! occ) loc)
48++ TH.NameL uniq -> nameRdrName $! (((Name.mkInternalName $! mk_uniq (fromInteger uniq)) $! occ) loc)
49++ TH.NameU uniq -> nameRdrName $! (((Name.mkSystemNameAt $! mk_uniq (fromInteger uniq)) $! occ) loc)
50+ TH.NameS | Just name <- isBuiltInOcc_maybe occ -> nameRdrName $! name
51+ | otherwise -> mkRdrUnqual $! occ
52+ -- We check for built-in syntax here, because the TH
53+diff --git a/compiler/typecheck/TcSplice.hs b/compiler/typecheck/TcSplice.hs
54+index 845e2029ed..3434b68615 100644
55+--- a/compiler/typecheck/TcSplice.hs
56++++ b/compiler/typecheck/TcSplice.hs
57+@@ -922,7 +922,7 @@ To call runQ in the Tc monad, we need to make TcM an instance of Quasi:
58+
59+ instance TH.Quasi TcM where
60+ qNewName s = do { u <- newUnique
61+- ; let i = getKey u
62++ ; let i = toInteger (getKey u)
63+ ; return (TH.mkNameU s i) }
64+
65+ -- 'msg' is forced to ensure exceptions don't escape,
66+@@ -1947,8 +1947,9 @@ reify_tc_app tc tys
67+ ------------------------------
68+ reifyName :: NamedThing n => n -> TH.Name
69+ reifyName thing
70+- | isExternalName name = mk_varg pkg_str mod_str occ_str
71+- | otherwise = TH.mkNameU occ_str (getKey (getUnique name))
72++ | isExternalName name
73++ = mk_varg pkg_str mod_str occ_str
74++ | otherwise = TH.mkNameU occ_str (toInteger $ getKey (getUnique name))
75+ -- Many of the things we reify have local bindings, and
76+ -- NameL's aren't supposed to appear in binding positions, so
77+ -- we use NameU. When/if we start to reify nested things, that
78+diff --git a/libraries/template-haskell/Language/Haskell/TH/PprLib.hs b/libraries/template-haskell/Language/Haskell/TH/PprLib.hs
79+index 7e05d05d83..ac0679a93e 100644
80+--- a/libraries/template-haskell/Language/Haskell/TH/PprLib.hs
81++++ b/libraries/template-haskell/Language/Haskell/TH/PprLib.hs
82+@@ -36,14 +36,14 @@ module Language.Haskell.TH.PprLib (
83+
84+
85+ import Language.Haskell.TH.Syntax
86+- (Name(..), showName', NameFlavour(..), NameIs(..))
87++ (Uniq, Name(..), showName', NameFlavour(..), NameIs(..))
88+ import qualified Text.PrettyPrint as HPJ
89+ import Control.Monad (liftM, liftM2, ap)
90+ import Language.Haskell.TH.Lib.Map ( Map )
91+ import qualified Language.Haskell.TH.Lib.Map as Map ( lookup, insert, empty )
92+ import Prelude hiding ((<>))
93+
94+-infixl 6 <>
95++infixl 6 <>
96+ infixl 6 <+>
97+ infixl 5 $$, $+$
98+
99+@@ -117,7 +117,7 @@ punctuate :: Doc -> [Doc] -> [Doc]
100+ -- ---------------------------------------------------------------------------
101+ -- The "implementation"
102+
103+-type State = (Map Name Name, Int)
104++type State = (Map Name Name, Uniq)
105+ data PprM a = PprM { runPprM :: State -> (a, State) }
106+
107+ pprName :: Name -> Doc
108+diff --git a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
109+index 14b9de263c..4ee11e68f4 100644
110+--- a/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
111++++ b/libraries/template-haskell/Language/Haskell/TH/Syntax.hs
112+@@ -155,7 +155,7 @@ badIO op = do { qReport True ("Can't do `" ++ op ++ "' in the IO monad")
113+ ; fail "Template Haskell failure" }
114+
115+ -- Global variable to generate unique symbols
116+-counter :: IORef Int
117++counter :: IORef Uniq
118+ {-# NOINLINE counter #-}
119+ counter = unsafePerformIO (newIORef 0)
120+
121+@@ -1299,8 +1299,8 @@ instance Ord Name where
122+ data NameFlavour
123+ = NameS -- ^ An unqualified name; dynamically bound
124+ | NameQ ModName -- ^ A qualified name; dynamically bound
125+- | NameU !Int -- ^ A unique local name
126+- | NameL !Int -- ^ Local name bound outside of the TH AST
127++ | NameU !Uniq -- ^ A unique local name
128++ | NameL !Uniq -- ^ Local name bound outside of the TH AST
129+ | NameG NameSpace PkgName ModName -- ^ Global name bound outside of the TH AST:
130+ -- An original name (occurrences only, not binders)
131+ -- Need the namespace too to be sure which
132+@@ -1313,7 +1313,7 @@ data NameSpace = VarName -- ^ Variables
133+ -- in the same name space for now.
134+ deriving( Eq, Ord, Show, Data, Generic )
135+
136+-type Uniq = Int
137++type Uniq = Integer
138+
139+ -- | The name without its module prefix.
140+ --
141+--
142+2.19.2
143+
overlays/patches/ghc/MR95--ghc-pkg-deadlock-fix.patchnew file+61
@@ -0,0 +1,61 @@
1+diff --git a/rts/posix/itimer/Pthread.c b/rts/posix/itimer/Pthread.c
2+index d8f2497e3f21bc23038c4fa871b1739104825d12..6f9cd8f4b3b94692ac9c4f7cb2462a242742408d 100644
3+--- a/rts/posix/itimer/Pthread.c
4++++ b/rts/posix/itimer/Pthread.c
5+@@ -134,12 +134,12 @@ static void *itimer_thread_func(void *_handle_tick)
6+
7+ // first try a cheap test
8+ if (stopped) {
9+- ACQUIRE_LOCK(&mutex);
10++ OS_ACQUIRE_LOCK(&mutex);
11+ // should we really stop?
12+ if (stopped) {
13+ waitCondition(&start_cond, &mutex);
14+ }
15+- RELEASE_LOCK(&mutex);
16++ OS_RELEASE_LOCK(&mutex);
17+ } else {
18+ handle_tick(0);
19+ }
20+@@ -147,8 +147,6 @@ static void *itimer_thread_func(void *_handle_tick)
21+
22+ if (USE_TIMERFD_FOR_ITIMER)
23+ close(timerfd);
24+- closeMutex(&mutex);
25+- closeCondition(&start_cond);
26+ return NULL;
27+ }
28+
29+@@ -178,19 +176,19 @@ initTicker (Time interval, TickProc handle_tick)
30+ void
31+ startTicker(void)
32+ {
33+- ACQUIRE_LOCK(&mutex);
34++ OS_ACQUIRE_LOCK(&mutex);
35+ stopped = 0;
36+ signalCondition(&start_cond);
37+- RELEASE_LOCK(&mutex);
38++ OS_RELEASE_LOCK(&mutex);
39+ }
40+
41+ /* There may be at most one additional tick fired after a call to this */
42+ void
43+ stopTicker(void)
44+ {
45+- ACQUIRE_LOCK(&mutex);
46++ OS_ACQUIRE_LOCK(&mutex);
47+ stopped = 1;
48+- RELEASE_LOCK(&mutex);
49++ OS_RELEASE_LOCK(&mutex);
50+ }
51+
52+ /* There may be at most one additional tick fired after a call to this */
53+@@ -207,6 +205,8 @@ exitTicker (bool wait)
54+ if (pthread_join(thread, NULL)) {
55+ sysErrorBelch("Itimer: Failed to join");
56+ }
57++ closeMutex(&mutex);
58++ closeCondition(&start_cond);
59+ } else {
60+ pthread_detach(thread);
61+ }
overlays/patches/ghc/T16057--ghci-doa-on-windows.patchnew file+70
@@ -0,0 +1,70 @@
1+diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
2+index 6d2e5b7e84..92e3455521 100644
3+--- a/compiler/main/DriverPipeline.hs
4++++ b/compiler/main/DriverPipeline.hs
5+@@ -1337,11 +1337,6 @@ runPhase (RealPhase (As with_cpp)) input_fn dflags
6+ (local_includes ++ global_includes
7+ -- See Note [-fPIC for assembler]
8+ ++ map SysTools.Option pic_c_flags
9+- -- See Note [Produce big objects on Windows]
10+- ++ [ SysTools.Option "-Wa,-mbig-obj"
11+- | platformOS (targetPlatform dflags) == OSMinGW32
12+- , not $ target32Bit (targetPlatform dflags)
13+- ]
14+
15+ -- We only support SparcV9 and better because V8 lacks an atomic CAS
16+ -- instruction so we have to make sure that the assembler accepts the
17+@@ -2154,32 +2149,6 @@ generateMacros prefix name version =
18+ -- ---------------------------------------------------------------------------
19+ -- join object files into a single relocatable object file, using ld -r
20+
21+-{-
22+-Note [Produce big objects on Windows]
23+-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24+-
25+-The Windows Portable Executable object format has a limit of 32k sections, which
26+-we tend to blow through pretty easily. Thankfully, there is a "big object"
27+-extension, which raises this limit to 2^32. However, it must be explicitly
28+-enabled in the toolchain:
29+-
30+- * the assembler accepts the -mbig-obj flag, which causes it to produce a
31+- bigobj-enabled COFF object.
32+-
33+- * the linker accepts the --oformat pe-bigobj-x86-64 flag. Despite what the name
34+- suggests, this tells the linker to produce a bigobj-enabled COFF object, no a
35+- PE executable.
36+-
37+-We must enable bigobj output in a few places:
38+-
39+- * When merging object files (DriverPipeline.joinObjectFiles)
40+-
41+- * When assembling (DriverPipeline.runPhase (RealPhase As ...))
42+-
43+-Unfortunately the big object format is not supported on 32-bit targets so
44+-none of this can be used in that case.
45+--}
46+-
47+ joinObjectFiles :: DynFlags -> [FilePath] -> FilePath -> IO ()
48+ joinObjectFiles dflags o_files output_fn = do
49+ let mySettings = settings dflags
50+@@ -2189,7 +2158,7 @@ joinObjectFiles dflags o_files output_fn = do
51+ SysTools.Option "-nostdlib",
52+ SysTools.Option "-Wl,-r"
53+ ]
54+- -- See Note [No PIE while linking] in DynFlags
55++ -- See Note [No PIE while linking] in SysTools
56+ ++ (if sGccSupportsNoPie mySettings
57+ then [SysTools.Option "-no-pie"]
58+ else [])
59+@@ -2208,11 +2177,6 @@ joinObjectFiles dflags o_files output_fn = do
60+ && ldIsGnuLd
61+ then [SysTools.Option "-Wl,-no-relax"]
62+ else [])
63+- -- See Note [Produce big objects on Windows]
64+- ++ [ SysTools.Option "-Wl,--oformat,pe-bigobj-x86-64"
65+- | OSMinGW32 == osInfo
66+- , not $ target32Bit (targetPlatform dflags)
67+- ]
68+ ++ map SysTools.Option ld_build_id
69+ ++ [ SysTools.Option "-o",
70+ SysTools.FileOption "" output_fn ]
overlays/patches/ghc/cabal-exe-ext-8.4.2.patchnew file+440
@@ -0,0 +1,440 @@
1+Submodule libraries/Cabal cc9210818e..276922d3a8:
2+diff --git a/libraries/Cabal/Cabal/Distribution/Simple/Bench.hs b/libraries/Cabal/Cabal/Distribution/Simple/Bench.hs
3+index 775733f5f..3f720ffa0 100644
4+--- a/libraries/Cabal/Cabal/Distribution/Simple/Bench.hs
5++++ b/libraries/Cabal/Cabal/Distribution/Simple/Bench.hs
6+@@ -53,7 +53,7 @@ bench args pkg_descr lbi flags = do
7+ doBench bm =
8+ case PD.benchmarkInterface bm of
9+ PD.BenchmarkExeV10 _ _ -> do
10+- let cmd = LBI.buildDir lbi </> name </> name <.> exeExtension
11++ let cmd = LBI.buildDir lbi </> name </> name <.> exeExtension (LBI.hostPlatform lbi)
12+ options = map (benchOption pkg_descr lbi bm) $
13+ benchmarkOptions flags
14+ -- Check that the benchmark executable exists.
15+diff --git a/libraries/Cabal/Cabal/Distribution/Simple/Build.hs b/libraries/Cabal/Cabal/Distribution/Simple/Build.hs
16+index 252124355..90d441bc4 100644
17+--- a/libraries/Cabal/Cabal/Distribution/Simple/Build.hs
18++++ b/libraries/Cabal/Cabal/Distribution/Simple/Build.hs
19+@@ -569,7 +569,7 @@ addInternalBuildTools pkg lbi bi progs =
20+ [ simpleConfiguredProgram toolName' (FoundOnSystem toolLocation)
21+ | toolName <- getAllInternalToolDependencies pkg bi
22+ , let toolName' = unUnqualComponentName toolName
23+- , let toolLocation = buildDir lbi </> toolName' </> toolName' <.> exeExtension ]
24++ , let toolLocation = buildDir lbi </> toolName' </> toolName' <.> exeExtension (hostPlatform lbi) ]
25+
26+
27+ -- TODO: build separate libs in separate dirs so that we can build
28+diff --git a/libraries/Cabal/Cabal/Distribution/Simple/BuildPaths.hs b/libraries/Cabal/Cabal/Distribution/Simple/BuildPaths.hs
29+index c22b00b8e..d7aeabab1 100644
30+--- a/libraries/Cabal/Cabal/Distribution/Simple/BuildPaths.hs
31++++ b/libraries/Cabal/Cabal/Distribution/Simple/BuildPaths.hs
32+@@ -199,23 +199,23 @@ mkProfLibName lib = mkGenericStaticLibName (getHSLibraryName lib ++ "_p")
33+ -- | Create a library name for a shared lirbary from a given name.
34+ -- Prepends 'lib' and appends the '-<compilerFlavour><compilerVersion>'
35+ -- as well as the shared library extension.
36+-mkGenericSharedLibName :: CompilerId -> String -> String
37+-mkGenericSharedLibName (CompilerId compilerFlavor compilerVersion) lib
38+- = mconcat [ "lib", lib, "-", comp <.> dllExtension ]
39++mkGenericSharedLibName :: Platform -> CompilerId -> String -> String
40++mkGenericSharedLibName platform (CompilerId compilerFlavor compilerVersion) lib
41++ = mconcat [ "lib", lib, "-", comp <.> dllExtension platform ]
42+ where comp = display compilerFlavor ++ display compilerVersion
43+
44+ -- Implement proper name mangling for dynamical shared objects
45+ -- libHS<packagename>-<compilerFlavour><compilerVersion>
46+ -- e.g. libHSbase-2.1-ghc6.6.1.so
47+-mkSharedLibName :: CompilerId -> UnitId -> String
48+-mkSharedLibName comp lib
49+- = mkGenericSharedLibName comp (getHSLibraryName lib)
50++mkSharedLibName :: Platform -> CompilerId -> UnitId -> String
51++mkSharedLibName platform comp lib
52++ = mkGenericSharedLibName platform comp (getHSLibraryName lib)
53+
54+ -- Static libs are named the same as shared libraries, only with
55+ -- a different extension.
56+-mkStaticLibName :: CompilerId -> UnitId -> String
57+-mkStaticLibName (CompilerId compilerFlavor compilerVersion) lib
58+- = "lib" ++ getHSLibraryName lib ++ "-" ++ comp <.> staticLibExtension
59++mkStaticLibName :: Platform -> CompilerId -> UnitId -> String
60++mkStaticLibName platform (CompilerId compilerFlavor compilerVersion) lib
61++ = "lib" ++ getHSLibraryName lib ++ "-" ++ comp <.> staticLibExtension platform
62+ where comp = display compilerFlavor ++ display compilerVersion
63+
64+ -- ------------------------------------------------------------
65+@@ -224,8 +224,8 @@ mkStaticLibName (CompilerId compilerFlavor compilerVersion) lib
66+
67+ -- | Default extension for executable files on the current platform.
68+ -- (typically @\"\"@ on Unix and @\"exe\"@ on Windows or OS\/2)
69+-exeExtension :: String
70+-exeExtension = case buildOS of
71++exeExtension :: Platform -> String
72++exeExtension (Platform _arch os) = case os of
73+ Windows -> "exe"
74+ _ -> ""
75+
76+@@ -235,8 +235,8 @@ objExtension = "o"
77+
78+ -- | Extension for dynamically linked (or shared) libraries
79+ -- (typically @\"so\"@ on Unix and @\"dll\"@ on Windows)
80+-dllExtension :: String
81+-dllExtension = case buildOS of
82++dllExtension :: Platform -> String
83++dllExtension (Platform _arch os)= case os of
84+ Windows -> "dll"
85+ OSX -> "dylib"
86+ _ -> "so"
87+@@ -245,7 +245,7 @@ dllExtension = case buildOS of
88+ --
89+ -- TODO: Here, as well as in dllExtension, it's really the target OS that we're
90+ -- interested in, not the build OS.
91+-staticLibExtension :: String
92+-staticLibExtension = case buildOS of
93++staticLibExtension :: Platform -> String
94++staticLibExtension (Platform _arch os) = case os of
95+ Windows -> "lib"
96+ _ -> "a"
97+diff --git a/libraries/Cabal/Cabal/Distribution/Simple/GHC.hs b/libraries/Cabal/Cabal/Distribution/Simple/GHC.hs
98+index 37a94ddc5..5fcefb470 100644
99+--- a/libraries/Cabal/Cabal/Distribution/Simple/GHC.hs
100++++ b/libraries/Cabal/Cabal/Distribution/Simple/GHC.hs
101+@@ -224,11 +224,11 @@ guessToolFromGhcPath tool ghcProg verbosity searchpath
102+ versionSuffix path = takeVersionSuffix (dropExeExtension path)
103+ given_suf = versionSuffix given_path
104+ real_suf = versionSuffix real_path
105+- guessNormal dir = dir </> toolname <.> exeExtension
106++ guessNormal dir = dir </> toolname <.> exeExtension buildPlatform
107+ guessGhcVersioned dir suf = dir </> (toolname ++ "-ghc" ++ suf)
108+- <.> exeExtension
109++ <.> exeExtension buildPlatform
110+ guessVersioned dir suf = dir </> (toolname ++ suf)
111+- <.> exeExtension
112++ <.> exeExtension buildPlatform
113+ mkGuesses dir suf | null suf = [guessNormal dir]
114+ | otherwise = [guessGhcVersioned dir suf,
115+ guessVersioned dir suf,
116+@@ -731,11 +731,11 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
117+ compiler_id = compilerId (compiler lbi)
118+ vanillaLibFilePath = libTargetDir </> mkLibName uid
119+ profileLibFilePath = libTargetDir </> mkProfLibName uid
120+- sharedLibFilePath = libTargetDir </> mkSharedLibName compiler_id uid
121+- staticLibFilePath = libTargetDir </> mkStaticLibName compiler_id uid
122++ sharedLibFilePath = libTargetDir </> mkSharedLibName (hostPlatform lbi) compiler_id uid
123++ staticLibFilePath = libTargetDir </> mkStaticLibName (hostPlatform lbi) compiler_id uid
124+ ghciLibFilePath = libTargetDir </> Internal.mkGHCiLibName uid
125+ libInstallPath = libdir $ absoluteComponentInstallDirs pkg_descr lbi uid NoCopyDest
126+- sharedLibInstallPath = libInstallPath </> mkSharedLibName compiler_id uid
127++ sharedLibInstallPath = libInstallPath </> mkSharedLibName (hostPlatform lbi) compiler_id uid
128+
129+ stubObjs <- catMaybes <$> sequenceA
130+ [ findFileWithExtension [objExtension] [libTargetDir]
131+@@ -932,13 +932,13 @@ gbuildName (GBuildFLib flib) = unUnqualComponentName $ foreignLibName flib
132+ gbuildName (GReplFLib flib) = unUnqualComponentName $ foreignLibName flib
133+
134+ gbuildTargetName :: LocalBuildInfo -> GBuildMode -> String
135+-gbuildTargetName _lbi (GBuildExe exe) = exeTargetName exe
136+-gbuildTargetName _lbi (GReplExe exe) = exeTargetName exe
137+-gbuildTargetName lbi (GBuildFLib flib) = flibTargetName lbi flib
138+-gbuildTargetName lbi (GReplFLib flib) = flibTargetName lbi flib
139++gbuildTargetName lbi (GBuildExe exe) = exeTargetName (hostPlatform lbi) exe
140++gbuildTargetName lbi (GReplExe exe) = exeTargetName (hostPlatform lbi) exe
141++gbuildTargetName lbi (GBuildFLib flib) = flibTargetName lbi flib
142++gbuildTargetName lbi (GReplFLib flib) = flibTargetName lbi flib
143+
144+-exeTargetName :: Executable -> String
145+-exeTargetName exe = unUnqualComponentName (exeName exe) `withExt` exeExtension
146++exeTargetName :: Platform -> Executable -> String
147++exeTargetName platform exe = unUnqualComponentName (exeName exe) `withExt` exeExtension platform
148+
149+ -- | Target name for a foreign library (the actual file name)
150+ --
151+@@ -955,8 +955,8 @@ flibTargetName lbi flib =
152+ (Windows, ForeignLibNativeShared) -> nm <.> "dll"
153+ (Windows, ForeignLibNativeStatic) -> nm <.> "lib"
154+ (Linux, ForeignLibNativeShared) -> "lib" ++ nm <.> versionedExt
155+- (_other, ForeignLibNativeShared) -> "lib" ++ nm <.> dllExtension
156+- (_other, ForeignLibNativeStatic) -> "lib" ++ nm <.> staticLibExtension
157++ (_other, ForeignLibNativeShared) -> "lib" ++ nm <.> dllExtension (hostPlatform lbi)
158++ (_other, ForeignLibNativeStatic) -> "lib" ++ nm <.> staticLibExtension (hostPlatform lbi)
159+ (_any, ForeignLibTypeUnknown) -> cabalBug "unknown foreign lib type"
160+ where
161+ nm :: String
162+@@ -1639,15 +1639,15 @@ installExe verbosity lbi binDir buildPref
163+ (progprefix, progsuffix) _pkg exe = do
164+ createDirectoryIfMissingVerbose verbosity True binDir
165+ let exeName' = unUnqualComponentName $ exeName exe
166+- exeFileName = exeTargetName exe
167++ exeFileName = exeTargetName (hostPlatform lbi) exe
168+ fixedExeBaseName = progprefix ++ exeName' ++ progsuffix
169+ installBinary dest = do
170+ installExecutableFile verbosity
171+ (buildPref </> exeName' </> exeFileName)
172+- (dest <.> exeExtension)
173++ (dest <.> exeExtension (hostPlatform lbi))
174+ when (stripExes lbi) $
175+ Strip.stripExe verbosity (hostPlatform lbi) (withPrograms lbi)
176+- (dest <.> exeExtension)
177++ (dest <.> exeExtension (hostPlatform lbi))
178+ installBinary (binDir </> fixedExeBaseName)
179+
180+ -- |Install foreign library for GHC.
181+@@ -1753,7 +1753,7 @@ installLib verbosity lbi targetDir dynlibTargetDir _builtDir _pkg lib clbi = do
182+ uid = componentUnitId clbi
183+ profileLibName = mkProfLibName uid
184+ ghciLibName = Internal.mkGHCiLibName uid
185+- sharedLibName = (mkSharedLibName compiler_id) uid
186++ sharedLibName = (mkSharedLibName (hostPlatform lbi) compiler_id) uid
187+
188+ hasLib = not $ null (allLibModules lib clbi)
189+ && null (cSources (libBuildInfo lib))
190+diff --git a/libraries/Cabal/Cabal/Distribution/Simple/GHCJS.hs b/libraries/Cabal/Cabal/Distribution/Simple/GHCJS.hs
191+index 831ead6d8..b342b8776 100644
192+--- a/libraries/Cabal/Cabal/Distribution/Simple/GHCJS.hs
193++++ b/libraries/Cabal/Cabal/Distribution/Simple/GHCJS.hs
194+@@ -150,12 +150,12 @@ guessToolFromGhcjsPath tool ghcjsProg verbosity searchpath
195+ path = programPath ghcjsProg
196+ dir = takeDirectory path
197+ versionSuffix = takeVersionSuffix (dropExeExtension path)
198+- guessNormal = dir </> toolname <.> exeExtension
199++ guessNormal = dir </> toolname <.> exeExtension buildPlatform
200+ guessGhcjsVersioned = dir </> (toolname ++ "-ghcjs" ++ versionSuffix)
201+- <.> exeExtension
202++ <.> exeExtension buildPlatform
203+ guessGhcjs = dir </> (toolname ++ "-ghcjs")
204+- <.> exeExtension
205+- guessVersioned = dir </> (toolname ++ versionSuffix) <.> exeExtension
206++ <.> exeExtension buildPlatform
207++ guessVersioned = dir </> (toolname ++ versionSuffix) <.> exeExtension buildPlatform
208+ guesses | null versionSuffix = [guessGhcjs, guessNormal]
209+ | otherwise = [guessGhcjsVersioned,
210+ guessGhcjs,
211+@@ -427,7 +427,7 @@ buildOrReplLib forRepl verbosity numJobs pkg_descr lbi lib clbi = do
212+ compiler_id = compilerId (compiler lbi)
213+ vanillaLibFilePath = libTargetDir </> mkLibName uid
214+ profileLibFilePath = libTargetDir </> mkProfLibName uid
215+- sharedLibFilePath = libTargetDir </> mkSharedLibName compiler_id uid
216++ sharedLibFilePath = libTargetDir </> mkSharedLibName (hostPlatform lbi) compiler_id uid
217+ ghciLibFilePath = libTargetDir </> Internal.mkGHCiLibName uid
218+
219+ hObjs <- Internal.getHaskellObjects implInfo lib lbi clbi
220+@@ -524,8 +524,8 @@ buildOrReplExe forRepl verbosity numJobs _pkg_descr lbi
221+ let exeName'' = unUnqualComponentName exeName'
222+ -- exeNameReal, the name that GHC really uses (with .exe on Windows)
223+ let exeNameReal = exeName'' <.>
224+- (if takeExtension exeName'' /= ('.':exeExtension)
225+- then exeExtension
226++ (if takeExtension exeName'' /= ('.':exeExtension buildPlatform)
227++ then exeExtension buildPlatform
228+ else "")
229+
230+ let targetDir = (buildDir lbi) </> exeName''
231+@@ -735,7 +735,7 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do
232+ vanillaLibName = mkLibName uid
233+ profileLibName = mkProfLibName uid
234+ ghciLibName = Internal.mkGHCiLibName uid
235+- sharedLibName = (mkSharedLibName compiler_id) uid
236++ sharedLibName = (mkSharedLibName (hostPlatform lbi) compiler_id) uid
237+
238+ hasLib = not $ null (allLibModules lib clbi)
239+ && null (cSources (libBuildInfo lib))
240+diff --git a/libraries/Cabal/Cabal/Distribution/Simple/JHC.hs b/libraries/Cabal/Cabal/Distribution/Simple/JHC.hs
241+index ced5a92d1..52e072652 100644
242+--- a/libraries/Cabal/Cabal/Distribution/Simple/JHC.hs
243++++ b/libraries/Cabal/Cabal/Distribution/Simple/JHC.hs
244+@@ -44,7 +44,7 @@ import Distribution.Text
245+ import System.FilePath ( (</>) )
246+ import Distribution.Compat.ReadP
247+ ( readP_to_S, string, skipSpaces )
248+-import Distribution.System ( Platform )
249++import Distribution.System ( Platform, buildPlatform )
250+
251+ import qualified Data.Map as Map ( empty )
252+
253+@@ -189,7 +189,7 @@ installLib verb _lbi dest _dyn_dest build_dir pkg_descr _lib _clbi = do
254+ installExe :: Verbosity -> FilePath -> FilePath -> (FilePath,FilePath) -> PackageDescription -> Executable -> IO ()
255+ installExe verb dest build_dir (progprefix,progsuffix) _ exe = do
256+ let exe_name = display $ exeName exe
257+- src = exe_name </> exeExtension
258+- out = (progprefix ++ exe_name ++ progsuffix) </> exeExtension
259++ src = exe_name </> exeExtension buildPlatform
260++ out = (progprefix ++ exe_name ++ progsuffix) </> exeExtension buildPlatform
261+ createDirectoryIfMissingVerbose verb True dest
262+ installExecutableFile verb (build_dir </> src) (dest </> out)
263+diff --git a/libraries/Cabal/Cabal/Distribution/Simple/LHC.hs b/libraries/Cabal/Cabal/Distribution/Simple/LHC.hs
264+index 1697d2d9f..98ed44f9d 100644
265+--- a/libraries/Cabal/Cabal/Distribution/Simple/LHC.hs
266++++ b/libraries/Cabal/Cabal/Distribution/Simple/LHC.hs
267+@@ -348,10 +348,10 @@ buildLib verbosity pkg_descr lbi lib clbi = do
268+ let cObjs = map (`replaceExtension` objExtension) (cSources libBi)
269+ cSharedObjs = map (`replaceExtension` ("dyn_" ++ objExtension)) (cSources libBi)
270+ cid = compilerId (compiler lbi)
271+- vanillaLibFilePath = libTargetDir </> mkLibName lib_name
272+- profileLibFilePath = libTargetDir </> mkProfLibName lib_name
273+- sharedLibFilePath = libTargetDir </> mkSharedLibName cid lib_name
274+- ghciLibFilePath = libTargetDir </> mkGHCiLibName lib_name
275++ vanillaLibFilePath = libTargetDir </> mkLibName lib_name
276++ profileLibFilePath = libTargetDir </> mkProfLibName lib_name
277++ sharedLibFilePath = libTargetDir </> mkSharedLibName (hostPlatform lbi) cid lib_name
278++ ghciLibFilePath = libTargetDir </> mkGHCiLibName lib_name
279+
280+ stubObjs <- fmap catMaybes $ sequenceA
281+ [ findFileWithExtension [objExtension] [libTargetDir]
282+@@ -470,7 +470,7 @@ buildExe verbosity _pkg_descr lbi
283+
284+ -- exeNameReal, the name that GHC really uses (with .exe on Windows)
285+ let exeNameReal = exeName'' <.>
286+- (if null $ takeExtension exeName'' then exeExtension else "")
287++ (if null $ takeExtension exeName'' then exeExtension buildPlatform else "")
288+
289+ let targetDir = pref </> exeName''
290+ let exeDir = targetDir </> (exeName'' ++ "-tmp")
291+@@ -677,13 +677,13 @@ installExe :: Verbosity
292+ -> IO ()
293+ installExe verbosity lbi binDir buildPref (progprefix, progsuffix) _pkg exe = do
294+ createDirectoryIfMissingVerbose verbosity True binDir
295+- let exeFileName = unUnqualComponentName (exeName exe) <.> exeExtension
296++ let exeFileName = unUnqualComponentName (exeName exe) <.> exeExtension (hostPlatform lbi)
297+ fixedExeBaseName = progprefix ++ unUnqualComponentName (exeName exe) ++ progsuffix
298+ installBinary dest = do
299+ installExecutableFile verbosity
300+ (buildPref </> unUnqualComponentName (exeName exe) </> exeFileName)
301+- (dest <.> exeExtension)
302+- stripExe verbosity lbi exeFileName (dest <.> exeExtension)
303++ (dest <.> exeExtension (hostPlatform lbi))
304++ stripExe verbosity lbi exeFileName (dest <.> exeExtension (hostPlatform lbi))
305+ installBinary (binDir </> fixedExeBaseName)
306+
307+ stripExe :: Verbosity -> LocalBuildInfo -> FilePath -> FilePath -> IO ()
308+@@ -735,10 +735,10 @@ installLib verbosity lbi targetDir dynlibTargetDir builtDir _pkg lib clbi = do
309+ where
310+ cid = compilerId (compiler lbi)
311+ lib_name = componentUnitId clbi
312+- vanillaLibName = mkLibName lib_name
313+- profileLibName = mkProfLibName lib_name
314+- ghciLibName = mkGHCiLibName lib_name
315+- sharedLibName = mkSharedLibName cid lib_name
316++ vanillaLibName = mkLibName lib_name
317++ profileLibName = mkProfLibName lib_name
318++ ghciLibName = mkGHCiLibName lib_name
319++ sharedLibName = mkSharedLibName (hostPlatform lbi) cid lib_name
320+
321+ hasLib = not $ null (allLibModules lib clbi)
322+ && null (cSources (libBuildInfo lib))
323+diff --git a/libraries/Cabal/Cabal/Distribution/Simple/Test/ExeV10.hs b/libraries/Cabal/Cabal/Distribution/Simple/Test/ExeV10.hs
324+index 707ab74d5..3f814feae 100644
325+--- a/libraries/Cabal/Cabal/Distribution/Simple/Test/ExeV10.hs
326++++ b/libraries/Cabal/Cabal/Distribution/Simple/Test/ExeV10.hs
327+@@ -50,7 +50,7 @@ runTest pkg_descr lbi clbi flags suite = do
328+ existingEnv <- getEnvironment
329+
330+ let cmd = LBI.buildDir lbi </> testName'
331+- </> testName' <.> exeExtension
332++ </> testName' <.> exeExtension (LBI.hostPlatform lbi)
333+ -- Check that the test executable exists.
334+ exists <- doesFileExist cmd
335+ unless exists $ die' verbosity $ "Error: Could not find test program \"" ++ cmd
336+diff --git a/libraries/Cabal/Cabal/Distribution/Simple/Test/LibV09.hs b/libraries/Cabal/Cabal/Distribution/Simple/Test/LibV09.hs
337+index 861e91a17..b1d91c078 100644
338+--- a/libraries/Cabal/Cabal/Distribution/Simple/Test/LibV09.hs
339++++ b/libraries/Cabal/Cabal/Distribution/Simple/Test/LibV09.hs
340+@@ -58,7 +58,7 @@ runTest pkg_descr lbi clbi flags suite = do
341+ existingEnv <- getEnvironment
342+
343+ let cmd = LBI.buildDir lbi </> stubName suite
344+- </> stubName suite <.> exeExtension
345++ </> stubName suite <.> exeExtension (LBI.hostPlatform lbi)
346+ -- Check that the test executable exists.
347+ exists <- doesFileExist cmd
348+ unless exists $
349+diff --git a/libraries/Cabal/cabal-install/Distribution/Client/Install.hs b/libraries/Cabal/cabal-install/Distribution/Client/Install.hs
350+index b873c12b9..880f6d655 100644
351+--- a/libraries/Cabal/cabal-install/Distribution/Client/Install.hs
352++++ b/libraries/Cabal/cabal-install/Distribution/Client/Install.hs
353+@@ -162,7 +162,7 @@ import Distribution.Client.Utils
354+ ( determineNumJobs, logDirChange, mergeBy, MergeResult(..)
355+ , tryCanonicalizePath )
356+ import Distribution.System
357+- ( Platform, OS(Windows), buildOS )
358++ ( Platform, OS(Windows), buildOS, buildPlatform )
359+ import Distribution.Text
360+ ( display )
361+ import Distribution.Verbosity as Verbosity
362+@@ -1593,7 +1593,7 @@ withWin32SelfUpgrade verbosity uid configFlags cinfo platform pkg action = do
363+ (CompilerId compFlavor _) = compilerInfoId cinfo
364+
365+ exeInstallPaths defaultDirs =
366+- [ InstallDirs.bindir absoluteDirs </> exeName <.> exeExtension
367++ [ InstallDirs.bindir absoluteDirs </> exeName <.> exeExtension buildPlatform
368+ | exe <- PackageDescription.executables pkg
369+ , PackageDescription.buildable (PackageDescription.buildInfo exe)
370+ , let exeName = prefix ++ display (PackageDescription.exeName exe) ++ suffix
371+diff --git a/libraries/Cabal/cabal-install/Distribution/Client/Run.hs b/libraries/Cabal/cabal-install/Distribution/Client/Run.hs
372+index 027907484..d3b55c275 100644
373+--- a/libraries/Cabal/cabal-install/Distribution/Client/Run.hs
374++++ b/libraries/Cabal/cabal-install/Distribution/Client/Run.hs
375+@@ -125,7 +125,7 @@ run verbosity lbi exe exeArgs = do
376+ return (cmd, cmdArgs ++ [script'])
377+ _ -> do
378+ p <- tryCanonicalizePath $
379+- buildPref </> exeName' </> (exeName' <.> exeExtension)
380++ buildPref </> exeName' </> (exeName' <.> exeExtension (hostPlatform lbi))
381+ return (p, [])
382+
383+ env <- (dataDirEnvVar:) <$> getEnvironment
384+diff --git a/libraries/Cabal/cabal-install/Distribution/Client/SetupWrapper.hs b/libraries/Cabal/cabal-install/Distribution/Client/SetupWrapper.hs
385+index ee845d7dc..08ebe324f 100644
386+--- a/libraries/Cabal/cabal-install/Distribution/Client/SetupWrapper.hs
387++++ b/libraries/Cabal/cabal-install/Distribution/Client/SetupWrapper.hs
388+@@ -537,7 +537,7 @@ externalSetupMethod path verbosity options _ args = do
389+ doInvoke
390+
391+ moveOutOfTheWay tmpDir path' = do
392+- let newPath = tmpDir </> "setup" <.> exeExtension
393++ let newPath = tmpDir </> "setup" <.> exeExtension buildPlatform
394+ Win32.moveFile path' newPath
395+ return newPath
396+
397+@@ -589,7 +589,7 @@ getExternalSetupMethod verbosity options pkg bt = do
398+ setupDir = workingDir options </> useDistPref options </> "setup"
399+ setupVersionFile = setupDir </> "setup" <.> "version"
400+ setupHs = setupDir </> "setup" <.> "hs"
401+- setupProgFile = setupDir </> "setup" <.> exeExtension
402++ setupProgFile = setupDir </> "setup" <.> exeExtension buildPlatform
403+ platform = fromMaybe buildPlatform (usePlatform options)
404+
405+ useCachedSetupExecutable = (bt == Simple || bt == Configure || bt == Make)
406+@@ -782,7 +782,7 @@ getExternalSetupMethod verbosity options pkg bt = do
407+ ++ cabalVersionString ++ "-"
408+ ++ platformString ++ "-"
409+ ++ compilerVersionString)
410+- <.> exeExtension
411++ <.> exeExtension buildPlatform
412+ return (setupCacheDir, cachedSetupProgFile)
413+ where
414+ buildTypeString = show bt
415+diff --git a/libraries/Cabal/cabal-testsuite/PackageTests/InternalLibraries/Executable/setup-static.test.hs b/libraries/Cabal/cabal-testsuite/PackageTests/InternalLibraries/Executable/setup-static.test.hs
416+index 34fec34f3..f3e9d1979 100644
417+--- a/libraries/Cabal/cabal-testsuite/PackageTests/InternalLibraries/Executable/setup-static.test.hs
418++++ b/libraries/Cabal/cabal-testsuite/PackageTests/InternalLibraries/Executable/setup-static.test.hs
419+@@ -1,6 +1,7 @@
420+ import Test.Cabal.Prelude
421+ import Control.Monad.IO.Class
422+ import Control.Monad
423++import Distribution.System (buildPlatform)
424+ import Distribution.Package
425+ import Distribution.Simple.Configure
426+ import Distribution.Simple.BuildPaths
427+@@ -41,11 +42,11 @@ main = setupAndCabalTest $ do
428+ then
429+ assertBool "dynamic library MUST be installed"
430+ =<< liftIO (doesFileExist (dyndir </> mkSharedLibName
431+- compiler_id uid))
432++ buildPlatform compiler_id uid))
433+ else
434+ assertBool "dynamic library should be installed"
435+ =<< liftIO (doesFileExist (dyndir </> mkSharedLibName
436+- compiler_id uid))
437++ buildPlatform compiler_id uid))
438+ fails $ ghcPkg "describe" ["foo"]
439+ -- clean away the dist directory so that we catch accidental
440+ -- dependence on the inplace files
overlays/patches/ghc/dll-loader-8.4.2.patchnew file+34
@@ -0,0 +1,34 @@
1+diff --git a/rts/linker/PEi386.c b/rts/linker/PEi386.c
2+index 3dcf8c4281..a1474b57bd 100644
3+--- a/rts/linker/PEi386.c
4++++ b/rts/linker/PEi386.c
5+@@ -221,10 +221,12 @@ static IndirectAddr* indirects = NULL;
6+ /* Adds a DLL instance to the list of DLLs in which to search for symbols. */
7+ static void addDLLHandle(pathchar* dll_name, HINSTANCE instance) {
8+
9++ IF_DEBUG(linker, debugBelch("addDLLHandle(%" PATH_FMT ")...\n", dll_name));
10+ /* At this point, we actually know what was loaded.
11+ So bail out if it's already been loaded. */
12+ if (checkIfDllLoaded(instance))
13+ {
14++ IF_DEBUG(linker, debugBelch("already loaded: addDLLHandle(%" PATH_FMT ")\n", dll_name));
15+ return;
16+ }
17+
18+@@ -259,7 +261,7 @@ static void addDLLHandle(pathchar* dll_name, HINSTANCE instance) {
19+ do {
20+ pathchar* module = mkPath((char*)(BYTE *)instance + imports->Name);
21+ HINSTANCE module_instance = GetModuleHandleW(module);
22+- if (0 != wcsncmp(module, ms_dll, len)
23++ if ((true || 0 != wcsncmp(module, ms_dll, len))
24+ && module_instance
25+ && !checkIfDllLoaded(module_instance))
26+ {
27+@@ -270,6 +272,7 @@ static void addDLLHandle(pathchar* dll_name, HINSTANCE instance) {
28+ stgFree(module);
29+ imports++;
30+ } while (imports->Name);
31++ IF_DEBUG(linker, debugBelch("done: addDLLHandle(%" PATH_FMT ")\n", dll_name));
32+ }
33+
34+ static OpenedDLL* findLoadedDll(HINSTANCE instance)
overlays/patches/ghc/ghc-8.0.2-darwin-rec-link.patchnew file+13
@@ -0,0 +1,13 @@
1+diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
2+index acd0d61..3e83c15 100644
3+--- a/compiler/main/DriverPipeline.hs
4++++ b/compiler/main/DriverPipeline.hs
5+@@ -1916,5 +1916,5 @@ linkBinary' staticLink dflags o_files dep_packages = do
6+ ++ pkg_framework_opts
7+ ++ debug_opts
8+ ++ thread_opts
9+- ++ (if (platformOS platform `elem` [OSDarwin]) then [ "-Wl,-dead_strip_dylibs" ] else [])
10++ ++ (if (platformOS platform `elem` [OSDarwin, OSiOS]) then [ "-Wl,-dead_strip_dylibs", "-Wl,-dead_strip" ] else [])
11+ ))
12+
13+ exeFileName :: Bool -> DynFlags -> FilePath
overlays/patches/ghc/ghc-8.4.3-Cabal2201-SMP-test-fix.patchnew file+13
@@ -0,0 +1,13 @@
1+diff --git a/libraries/Cabal/Cabal/tests/HackageTests.hs b/libraries/Cabal/Cabal/tests/HackageTests.hs
2+index 3b32147..d3e2f31 100644
3+--- a/libraries/Cabal/Cabal/tests/HackageTests.hs
4++++ b/libraries/Cabal/Cabal/tests/HackageTests.hs
5+@@ -89,6 +89,8 @@ readFieldTest fpath bsl = case Parsec.readFields $ bslToStrict bsl of
6+ -- | Map with unionWith monoid
7+ newtype M k v = M (Map.Map k v)
8+ deriving (Show)
9++instance (Ord k, Semigroup v) => Semigroup (M k v) where
10++ M a <> M b = M (Map.unionWith (<>) a b)
11+ instance (Ord k, Monoid v) => Monoid (M k v) where
12+ mempty = M Map.empty
13+ mappend (M a) (M b) = M (Map.unionWith mappend a b)
overlays/patches/ghc/ghc-8.4.3-Cabal2201-allow-test-wrapper.patchnew file+72
@@ -0,0 +1,72 @@
1+diff --git a/libraries/Cabal/Cabal/Distribution/Simple/Setup.hs b/libraries/Cabal/Cabal/Distribution/Simple/Setup.hs
2+index 5fa0e99..fc429b6 100644
3+--- a/libraries/Cabal/Cabal/Distribution/Simple/Setup.hs
4++++ b/libraries/Cabal/Cabal/Distribution/Simple/Setup.hs
5+@@ -1919,6 +1919,7 @@ data TestFlags = TestFlags {
6+ testMachineLog :: Flag PathTemplate,
7+ testShowDetails :: Flag TestShowDetails,
8+ testKeepTix :: Flag Bool,
9++ testWrapper :: Flag FilePath,
10+ -- TODO: think about if/how options are passed to test exes
11+ testOptions :: [PathTemplate]
12+ } deriving (Generic)
13+@@ -1931,6 +1932,7 @@ defaultTestFlags = TestFlags {
14+ testMachineLog = toFlag $ toPathTemplate $ "$pkgid.log",
15+ testShowDetails = toFlag Failures,
16+ testKeepTix = toFlag False,
17++ testWrapper = NoFlag,
18+ testOptions = []
19+ }
20+
21+@@ -1991,6 +1993,11 @@ testCommand = CommandUI
22+ "keep .tix files for HPC between test runs"
23+ testKeepTix (\v flags -> flags { testKeepTix = v})
24+ trueArg
25++ , option [] ["test-wrapper"]
26++ "Run test through a wrapper."
27++ testWrapper (\v flags -> flags { testWrapper = v })
28++ (reqArg' "FILE" (toFlag :: FilePath -> Flag FilePath)
29++ (pure . fromFlag :: Flag FilePath -> [FilePath]))
30+ , option [] ["test-options"]
31+ ("give extra options to test executables "
32+ ++ "(name templates can use $pkgid, $compiler, "
33+diff --git a/libraries/Cabal/Cabal/Distribution/Simple/Test/ExeV10.hs b/libraries/Cabal/Cabal/Distribution/Simple/Test/ExeV10.hs
34+index 707ab74..87bfefe 100644
35+--- a/libraries/Cabal/Cabal/Distribution/Simple/Test/ExeV10.hs
36++++ b/libraries/Cabal/Cabal/Distribution/Simple/Test/ExeV10.hs
37+@@ -98,7 +98,12 @@ runTest pkg_descr lbi clbi flags suite = do
38+ return (addLibraryPath os paths shellEnv)
39+ else return shellEnv
40+
41+- exit <- rawSystemIOWithEnv verbosity cmd opts Nothing (Just shellEnv')
42++ exit <- case testWrapper flags of
43++ Flag path -> rawSystemIOWithEnv verbosity path (cmd:opts) Nothing (Just shellEnv')
44++ -- these handles are automatically closed
45++ Nothing (Just wOut) (Just wErr)
46++
47++ NoFlag -> rawSystemIOWithEnv verbosity cmd opts Nothing (Just shellEnv')
48+ -- these handles are automatically closed
49+ Nothing (Just wOut) (Just wErr)
50+
51+diff --git a/libraries/Cabal/Cabal/Distribution/Simple/Test/LibV09.hs b/libraries/Cabal/Cabal/Distribution/Simple/Test/LibV09.hs
52+index 861e91a..66316fa 100644
53+--- a/libraries/Cabal/Cabal/Distribution/Simple/Test/LibV09.hs
54++++ b/libraries/Cabal/Cabal/Distribution/Simple/Test/LibV09.hs
55+@@ -99,9 +99,14 @@ runTest pkg_descr lbi clbi flags suite = do
56+ cpath <- canonicalizePath $ LBI.componentBuildDir lbi clbi
57+ return (addLibraryPath os (cpath : paths) shellEnv)
58+ else return shellEnv
59+- createProcessWithEnv verbosity cmd opts Nothing (Just shellEnv')
60+- -- these handles are closed automatically
61+- CreatePipe (UseHandle wOut) (UseHandle wOut)
62++ case testWrapper flags of
63++ Flag path -> createProcessWithEnv verbosity path (cmd:opts) Nothing (Just shellEnv')
64++ -- these handles are closed automatically
65++ CreatePipe (UseHandle wOut) (UseHandle wOut)
66++
67++ NoFlag -> createProcessWithEnv verbosity cmd opts Nothing (Just shellEnv')
68++ -- these handles are closed automatically
69++ CreatePipe (UseHandle wOut) (UseHandle wOut)
70+
71+ hPutStr wIn $ show (tempLog, PD.testName suite)
72+ hClose wIn
overlays/patches/ghc/ghc-8.4.3-Cabal2201-no-hackage-tests.patchnew file+15
@@ -0,0 +1,15 @@
1+diff --git a/libraries/Cabal/Cabal/Cabal.cabal b/libraries/Cabal/Cabal/Cabal.cabal
2+index 2b680ca..7320b40 100644
3+--- a/libraries/Cabal/Cabal/Cabal.cabal
4++++ b/libraries/Cabal/Cabal/Cabal.cabal
5+@@ -568,9 +568,7 @@ test-suite hackage-tests
6+ type: exitcode-stdio-1.0
7+ main-is: HackageTests.hs
8+
9+- -- TODO: need to get 01-index.tar on appveyor
10+- if os(windows)
11+- buildable: False
12++ buildable: False
13+
14+ hs-source-dirs: tests
15+
overlays/patches/ghc/ghc-8.4.3-Cabal2201-response-file-support.patchnew file+59
@@ -0,0 +1,59 @@
1+diff --git a/libraries/Cabal/Cabal/Distribution/Simple.hs b/libraries/Cabal/Cabal/Distribution/Simple.hs
2+index e45c831..19e553e 100644
3+--- a/libraries/Cabal/Cabal/Distribution/Simple.hs
4++++ b/libraries/Cabal/Cabal/Distribution/Simple.hs
5+@@ -1,6 +1,6 @@
6+ {-# LANGUAGE FlexibleContexts #-}
7+ {-# LANGUAGE RankNTypes #-}
8+-
9++{-# LANGUAGE LambdaCase #-}
10+ -----------------------------------------------------------------------------
11+ -- |
12+ -- Module : Distribution.Simple
13+@@ -57,7 +57,7 @@ module Distribution.Simple (
14+ defaultHookedPackageDesc
15+ ) where
16+
17+-import Prelude ()
18++import Prelude (mapM)
19+ import Control.Exception (try)
20+ import Distribution.Compat.Prelude
21+
22+@@ -108,6 +108,10 @@ import Data.List (unionBy, (\\))
23+
24+ import Distribution.PackageDescription.Parsec
25+
26++-- | Monadic version of concatMap
27++concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b]
28++concatMapM f xs = liftM concat (mapM f xs)
29++
30+ -- | A simple implementation of @main@ for a Cabal setup script.
31+ -- It reads the package description file using IO, and performs the
32+ -- action specified on the command line.
33+@@ -148,8 +152,9 @@ defaultMainWithHooksNoReadArgs hooks pkg_descr =
34+ defaultMainHelper hooks { readDesc = return (Just pkg_descr) }
35+
36+ defaultMainHelper :: UserHooks -> Args -> IO ()
37+-defaultMainHelper hooks args = topHandler $
38+- case commandsRun (globalCommand commands) commands args of
39++defaultMainHelper hooks args = topHandler $ do
40++ args' <- expandResponseFiles args
41++ case commandsRun (globalCommand commands) commands args' of
42+ CommandHelp help -> printHelp help
43+ CommandList opts -> printOptionsList opts
44+ CommandErrors errs -> printErrors errs
45+@@ -163,6 +168,14 @@ defaultMainHelper hooks args = topHandler $
46+ CommandReadyToGo action -> action
47+
48+ where
49++ expandResponseFiles :: [String] -> IO [String]
50++ expandResponseFiles = concatMapM expandResponseFile
51++ expandResponseFile :: String -> IO [String]
52++ expandResponseFile arg@('@':file) = doesFileExist file >>= \case
53++ True -> concatMap words . lines <$> readFile file
54++ False -> pure [arg]
55++ expandResponseFile arg = pure [arg]
56++
57+ printHelp help = getProgName >>= putStr . help
58+ printOptionsList = putStr . unlines
59+ printErrors errs = do
overlays/patches/ghc/ghc-8.4.4-backport-dylib-command-size-limit.patchnew file+24
@@ -0,0 +1,24 @@
1+diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
2+index acd0d61..3e83c15 100644
3+--- a/compiler/main/DriverPipeline.hs
4++++ b/compiler/main/DriverPipeline.hs
5+@@ -1916,6 +1916,7 @@ linkBinary' staticLink dflags o_files dep_packages = do
6+ ++ pkg_framework_opts
7+ ++ debug_opts
8+ ++ thread_opts
9++ ++ (if (platformOS platform `elem` [OSDarwin]) then [ "-Wl,-dead_strip_dylibs" ] else [])
10+ ))
11+
12+ exeFileName :: Bool -> DynFlags -> FilePath
13+diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs
14+index 1ab5b13..2ebbf51 100644
15+--- a/compiler/main/SysTools.hs
16++++ b/compiler/main/SysTools.hs
17+@@ -1737,6 +1737,7 @@ linkDynLib dflags0 o_files dep_packages
18+ ++ map Option pkg_lib_path_opts
19+ ++ map Option pkg_link_opts
20+ ++ map Option pkg_framework_opts
21++ ++ [ Option "-Wl,-dead_strip_dylibs" ]
22+ )
23+ OSiOS -> throwGhcExceptionIO (ProgramError "dynamic libraries are not supported on iOS target")
24+ _ -> do
overlays/patches/ghc/ghc-8.4.4-darwin-rec-link.patchnew file+13
@@ -0,0 +1,13 @@
1+diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
2+index acd0d61..3e83c15 100644
3+--- a/compiler/main/DriverPipeline.hs
4++++ b/compiler/main/DriverPipeline.hs
5+@@ -1916,5 +1916,5 @@ linkBinary' staticLink dflags o_files dep_packages = do
6+ ++ pkg_framework_opts
7+ ++ debug_opts
8+ ++ thread_opts
9+- ++ (if (platformOS platform `elem` [OSDarwin]) then [ "-Wl,-dead_strip_dylibs" ] else [])
10++ ++ (if (platformOS platform `elem` [OSDarwin]) then [ "-Wl,-dead_strip_dylibs", "-Wl,-dead_strip" ] else [])
11+ ))
12+
13+ exeFileName :: Bool -> DynFlags -> FilePath
overlays/patches/ghc/ghc-8.4.4-reinstallable-lib-ghc.patchnew file+8711
@@ -0,0 +1,8711 @@
1+diff --git a/GIT_COMMIT_ID b/GIT_COMMIT_ID
2+index b28416b..d739f3b 100644
3+--- a/GIT_COMMIT_ID
4++++ b/GIT_COMMIT_ID
5+@@ -1 +1 @@
6+-3bed09b2efd3df678c5d0752d2cdfba20d7c4863
7+\ No newline at end of file
8++-n 39e711436400ecde05961224fa37759f2c2ff862
9+diff --git a/boot b/boot
10+index 7dc2983..7bf2196 100755
11+--- a/boot
12++++ b/boot
13+@@ -113,12 +113,13 @@ def boot_pkgs():
14+ elif len(cabals) == 1:
15+ cabal = cabals[0]
16+
17+- if os.path.isfile(cabal):
18++ ghc_mk = os.path.join(package, 'ghc.mk')
19++
20++ if os.path.isfile(cabal) and not os.path.isfile(ghc_mk):
21+ # strip both .cabal and .in
22+ pkg = os.path.splitext(os.path.splitext(os.path.basename(cabal))[0])[0]
23+ top = package
24+
25+- ghc_mk = os.path.join(package, 'ghc.mk')
26+ print('Creating %s' % ghc_mk)
27+ with open(ghc_mk, 'w') as f:
28+ f.write(dedent(
29+diff --git a/compiler/HsVersions.h b/compiler/HsVersions.h
30+deleted file mode 100644
31+index a4ec3e4..0000000
32+--- a/compiler/HsVersions.h
33++++ /dev/null
34+@@ -1,65 +0,0 @@
35+-#pragma once
36+-
37+-#if 0
38+-
39+-IMPORTANT! If you put extra tabs/spaces in these macro definitions,
40+-you will screw up the layout where they are used in case expressions!
41+-
42+-(This is cpp-dependent, of course)
43+-
44+-#endif
45+-
46+-/* Useful in the headers that we share with the RTS */
47+-#define COMPILING_GHC 1
48+-
49+-/* Pull in all the platform defines for this build (foo_TARGET_ARCH etc.) */
50+-#include "ghc_boot_platform.h"
51+-
52+-/* Pull in the autoconf defines (HAVE_FOO), but don't include
53+- * ghcconfig.h, because that will include ghcplatform.h which has the
54+- * wrong platform settings for the compiler (it has the platform
55+- * settings for the target plat instead). */
56+-#include "ghcautoconf.h"
57+-
58+-#define GLOBAL_VAR(name,value,ty) \
59+-{-# NOINLINE name #-}; \
60+-name :: IORef (ty); \
61+-name = Util.global (value);
62+-
63+-#define GLOBAL_VAR_M(name,value,ty) \
64+-{-# NOINLINE name #-}; \
65+-name :: IORef (ty); \
66+-name = Util.globalM (value);
67+-
68+-
69+-#define SHARED_GLOBAL_VAR(name,accessor,saccessor,value,ty) \
70+-{-# NOINLINE name #-}; \
71+-name :: IORef (ty); \
72+-name = Util.sharedGlobal (value) (accessor); \
73+-foreign import ccall unsafe saccessor \
74+- accessor :: Ptr (IORef a) -> IO (Ptr (IORef a));
75+-
76+-#define SHARED_GLOBAL_VAR_M(name,accessor,saccessor,value,ty) \
77+-{-# NOINLINE name #-}; \
78+-name :: IORef (ty); \
79+-name = Util.sharedGlobalM (value) (accessor); \
80+-foreign import ccall unsafe saccessor \
81+- accessor :: Ptr (IORef a) -> IO (Ptr (IORef a));
82+-
83+-
84+-#define ASSERT(e) if debugIsOn && not (e) then (assertPanic __FILE__ __LINE__) else
85+-#define ASSERT2(e,msg) if debugIsOn && not (e) then (assertPprPanic __FILE__ __LINE__ (msg)) else
86+-#define WARN( e, msg ) (warnPprTrace (e) __FILE__ __LINE__ (msg)) $
87+-
88+--- Examples: Assuming flagSet :: String -> m Bool
89+---
90+--- do { c <- getChar; MASSERT( isUpper c ); ... }
91+--- do { c <- getChar; MASSERT2( isUpper c, text "Bad" ); ... }
92+--- do { str <- getStr; ASSERTM( flagSet str ); .. }
93+--- do { str <- getStr; ASSERTM2( flagSet str, text "Bad" ); .. }
94+--- do { str <- getStr; WARNM2( flagSet str, text "Flag is set" ); .. }
95+-#define MASSERT(e) ASSERT(e) return ()
96+-#define MASSERT2(e,msg) ASSERT2(e,msg) return ()
97+-#define ASSERTM(e) do { bool <- e; MASSERT(bool) }
98+-#define ASSERTM2(e,msg) do { bool <- e; MASSERT2(bool,msg) }
99+-#define WARNM2(e,msg) do { bool <- e; WARN(bool, msg) return () }
100+diff --git a/compiler/cmm/Bitmap.hs b/compiler/cmm/Bitmap.hs
101+index 6ff6193..a432c58 100644
102+--- a/compiler/cmm/Bitmap.hs
103++++ b/compiler/cmm/Bitmap.hs
104+@@ -16,7 +16,7 @@ module Bitmap (
105+ ) where
106+
107+ #include "HsVersions.h"
108+-#include "../includes/MachDeps.h"
109++#include "MachDeps.h"
110+
111+ import GhcPrelude
112+
113+diff --git a/compiler/cmm/CmmParse.hs b/compiler/cmm/CmmParse.hs
114+index 64514ff..70f891e 100644
115+--- a/compiler/cmm/CmmParse.hs
116++++ b/compiler/cmm/CmmParse.hs
117+@@ -3157,11 +3157,9 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
118+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
119+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
120+ {-# LINE 1 "<built-in>" #-}
121+-{-# LINE 1 "<command-line>" #-}
122+-{-# LINE 11 "<command-line>" #-}
123+-# 1 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 1 3 4
124++{-# LINE 18 "<built-in>" #-}
125++{-# LINE 1 "/usr/local/Cellar/ghc/8.4.4/lib/ghc-8.4.4/include/ghcversion.h" #-}
126+
127+-# 17 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 3 4
128+
129+
130+
131+@@ -3177,6 +3175,8 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
132+
133+
134+
135++{-# LINE 19 "<built-in>" #-}
136++{-# LINE 1 "/var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc91389_0/ghc_2.h" #-}
137+
138+
139+
140+@@ -3208,8 +3208,6 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
141+
142+
143+
144+-{-# LINE 11 "<command-line>" #-}
145+-{-# LINE 1 "/nix/store/n5i1zdpmk2b1s3z96649xh8f9kr3g96s-ghc-8.4.3/lib/ghc-8.4.3/include/ghcversion.h" #-}
146+
147+
148+
149+@@ -3225,8 +3223,6 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
150+
151+
152+
153+-{-# LINE 11 "<command-line>" #-}
154+-{-# LINE 1 "/build/ghc1653_0/ghc_2.h" #-}
155+
156+
157+
158+@@ -3362,52 +3358,7 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
159+
160+
161+
162+-
163+-
164+-
165+-
166+-
167+-
168+-
169+-
170+-
171+-
172+-
173+-
174+-
175+-
176+-
177+-
178+-
179+-
180+-
181+-
182+-
183+-
184+-
185+-
186+-
187+-
188+-
189+-
190+-
191+-
192+-
193+-
194+-
195+-
196+-
197+-
198+-
199+-
200+-
201+-
202+-
203+-
204+-
205+-
206+-
207+-{-# LINE 11 "<command-line>" #-}
208++{-# LINE 20 "<built-in>" #-}
209+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
210+ -- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp
211+
212+@@ -3433,6 +3384,7 @@ parseCmmFile dflags filename = withTiming (pure dflags) (text "ParseCmm"<+>brack
213+ #define GTE(n,m) (n Happy_GHC_Exts.>=# m)
214+ #define EQ(n,m) (n Happy_GHC_Exts.==# m)
215+ #endif
216++
217+ {-# LINE 43 "templates/GenericTemplate.hs" #-}
218+
219+ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
220+@@ -3443,11 +3395,20 @@ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
221+
222+
223+
224++
225+ {-# LINE 65 "templates/GenericTemplate.hs" #-}
226+
227++
228+ {-# LINE 75 "templates/GenericTemplate.hs" #-}
229+
230+-{-# LINE 84 "templates/GenericTemplate.hs" #-}
231++
232++
233++
234++
235++
236++
237++
238++
239+
240+ infixr 9 `HappyStk`
241+ data HappyStk a = HappyStk a (HappyStk a)
242+@@ -3475,7 +3436,7 @@ happyAccept j tk st sts (HappyStk ans _) =
243+
244+ happyDoAction i tk st
245+ = {- nothing -}
246+-
247++
248+
249+ case action of
250+ 0# -> {- nothing -}
251+@@ -3483,11 +3444,11 @@ happyDoAction i tk st
252+ -1# -> {- nothing -}
253+ happyAccept i tk st
254+ n | LT(n,(0# :: Happy_GHC_Exts.Int#)) -> {- nothing -}
255+-
256++
257+ (happyReduceArr Happy_Data_Array.! rule) i tk st
258+ where rule = (Happy_GHC_Exts.I# ((Happy_GHC_Exts.negateInt# ((n Happy_GHC_Exts.+# (1# :: Happy_GHC_Exts.Int#))))))
259+ n -> {- nothing -}
260+-
261++
262+
263+ happyShift new_state i tk st
264+ where new_state = (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#))
265+@@ -3533,6 +3494,7 @@ data HappyAddr = HappyA# Happy_GHC_Exts.Addr#
266+ -----------------------------------------------------------------------------
267+ -- HappyState data type (not arrays)
268+
269++
270+ {-# LINE 180 "templates/GenericTemplate.hs" #-}
271+
272+ -----------------------------------------------------------------------------
273+@@ -3698,3 +3660,4 @@ happyDontSeq a b = b
274+ {-# NOINLINE happyFail #-}
275+
276+ -- end of Happy Template.
277++
278+diff --git a/compiler/cmm/PprCmmDecl.hs b/compiler/cmm/PprCmmDecl.hs
279+index 968e872..1ed0d6e 100644
280+--- a/compiler/cmm/PprCmmDecl.hs
281++++ b/compiler/cmm/PprCmmDecl.hs
282+@@ -54,7 +54,7 @@ import System.IO
283+
284+ -- Temp Jan08
285+ import SMRep
286+-#include "../includes/rts/storage/FunTypes.h"
287++#include "rts/storage/FunTypes.h"
288+
289+
290+ pprCmms :: (Outputable info, Outputable g)
291+diff --git a/compiler/cmm/SMRep.hs b/compiler/cmm/SMRep.hs
292+index 1469ae1..c8ae5c0 100644
293+--- a/compiler/cmm/SMRep.hs
294++++ b/compiler/cmm/SMRep.hs
295+@@ -47,8 +47,8 @@ module SMRep (
296+ pprWord8String, stringToWord8s
297+ ) where
298+
299+-#include "../HsVersions.h"
300+-#include "../includes/MachDeps.h"
301++#include "HsVersions.h"
302++#include "MachDeps.h"
303+
304+ import GhcPrelude
305+
306+@@ -424,8 +424,8 @@ cardTableSizeW dflags elems =
307+ -----------------------------------------------------------------------------
308+ -- deriving the RTS closure type from an SMRep
309+
310+-#include "../includes/rts/storage/ClosureTypes.h"
311+-#include "../includes/rts/storage/FunTypes.h"
312++#include "rts/storage/ClosureTypes.h"
313++#include "rts/storage/FunTypes.h"
314+ -- Defines CONSTR, CONSTR_1_0 etc
315+
316+ -- | Derives the RTS closure type from an 'SMRep'
317+diff --git a/compiler/codeGen/CodeGen/Platform/ARM.hs b/compiler/codeGen/CodeGen/Platform/ARM.hs
318+index a2cb476..f1ea503 100644
319+--- a/compiler/codeGen/CodeGen/Platform/ARM.hs
320++++ b/compiler/codeGen/CodeGen/Platform/ARM.hs
321+@@ -6,5 +6,5 @@ import GhcPrelude
322+
323+ #define MACHREGS_NO_REGS 0
324+ #define MACHREGS_arm 1
325+-#include "../../../../includes/CodeGen.Platform.hs"
326++#include "CodeGen.Platform.hs"
327+
328+diff --git a/compiler/codeGen/CodeGen/Platform/ARM64.hs b/compiler/codeGen/CodeGen/Platform/ARM64.hs
329+index 6ace181..7a25fb8 100644
330+--- a/compiler/codeGen/CodeGen/Platform/ARM64.hs
331++++ b/compiler/codeGen/CodeGen/Platform/ARM64.hs
332+@@ -6,5 +6,5 @@ import GhcPrelude
333+
334+ #define MACHREGS_NO_REGS 0
335+ #define MACHREGS_aarch64 1
336+-#include "../../../../includes/CodeGen.Platform.hs"
337++#include "CodeGen.Platform.hs"
338+
339+diff --git a/compiler/codeGen/CodeGen/Platform/NoRegs.hs b/compiler/codeGen/CodeGen/Platform/NoRegs.hs
340+index 4c074ee..4a34c78 100644
341+--- a/compiler/codeGen/CodeGen/Platform/NoRegs.hs
342++++ b/compiler/codeGen/CodeGen/Platform/NoRegs.hs
343+@@ -5,5 +5,5 @@ module CodeGen.Platform.NoRegs where
344+ import GhcPrelude
345+
346+ #define MACHREGS_NO_REGS 1
347+-#include "../../../../includes/CodeGen.Platform.hs"
348++#include "CodeGen.Platform.hs"
349+
350+diff --git a/compiler/codeGen/CodeGen/Platform/PPC.hs b/compiler/codeGen/CodeGen/Platform/PPC.hs
351+index f7eae6b..7dd4587 100644
352+--- a/compiler/codeGen/CodeGen/Platform/PPC.hs
353++++ b/compiler/codeGen/CodeGen/Platform/PPC.hs
354+@@ -6,5 +6,5 @@ import GhcPrelude
355+
356+ #define MACHREGS_NO_REGS 0
357+ #define MACHREGS_powerpc 1
358+-#include "../../../../includes/CodeGen.Platform.hs"
359++#include "CodeGen.Platform.hs"
360+
361+diff --git a/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs b/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs
362+index 91923fd..b0eb097 100644
363+--- a/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs
364++++ b/compiler/codeGen/CodeGen/Platform/PPC_Darwin.hs
365+@@ -7,5 +7,5 @@ import GhcPrelude
366+ #define MACHREGS_NO_REGS 0
367+ #define MACHREGS_powerpc 1
368+ #define MACHREGS_darwin 1
369+-#include "../../../../includes/CodeGen.Platform.hs"
370++#include "CodeGen.Platform.hs"
371+
372+diff --git a/compiler/codeGen/CodeGen/Platform/SPARC.hs b/compiler/codeGen/CodeGen/Platform/SPARC.hs
373+index 5d8dbb1..2eeb55c 100644
374+--- a/compiler/codeGen/CodeGen/Platform/SPARC.hs
375++++ b/compiler/codeGen/CodeGen/Platform/SPARC.hs
376+@@ -6,5 +6,5 @@ import GhcPrelude
377+
378+ #define MACHREGS_NO_REGS 0
379+ #define MACHREGS_sparc 1
380+-#include "../../../../includes/CodeGen.Platform.hs"
381++#include "CodeGen.Platform.hs"
382+
383+diff --git a/compiler/codeGen/CodeGen/Platform/X86.hs b/compiler/codeGen/CodeGen/Platform/X86.hs
384+index 84d52c1..fc3e384 100644
385+--- a/compiler/codeGen/CodeGen/Platform/X86.hs
386++++ b/compiler/codeGen/CodeGen/Platform/X86.hs
387+@@ -6,5 +6,5 @@ import GhcPrelude
388+
389+ #define MACHREGS_NO_REGS 0
390+ #define MACHREGS_i386 1
391+-#include "../../../../includes/CodeGen.Platform.hs"
392++#include "CodeGen.Platform.hs"
393+
394+diff --git a/compiler/codeGen/CodeGen/Platform/X86_64.hs b/compiler/codeGen/CodeGen/Platform/X86_64.hs
395+index 1b2b554..0a26a1f 100644
396+--- a/compiler/codeGen/CodeGen/Platform/X86_64.hs
397++++ b/compiler/codeGen/CodeGen/Platform/X86_64.hs
398+@@ -6,5 +6,5 @@ import GhcPrelude
399+
400+ #define MACHREGS_NO_REGS 0
401+ #define MACHREGS_x86_64 1
402+-#include "../../../../includes/CodeGen.Platform.hs"
403++#include "CodeGen.Platform.hs"
404+
405+diff --git a/compiler/codeGen/StgCmmClosure.hs b/compiler/codeGen/StgCmmClosure.hs
406+index 2501ec9..6c80c6e 100644
407+--- a/compiler/codeGen/StgCmmClosure.hs
408++++ b/compiler/codeGen/StgCmmClosure.hs
409+@@ -62,7 +62,7 @@ module StgCmmClosure (
410+ staticClosureNeedsLink,
411+ ) where
412+
413+-#include "../includes/MachDeps.h"
414++#include "MachDeps.h"
415+
416+ #include "HsVersions.h"
417+
418+diff --git a/compiler/codeGen/StgCmmLayout.hs b/compiler/codeGen/StgCmmLayout.hs
419+index a0a64e5..37a1075 100644
420+--- a/compiler/codeGen/StgCmmLayout.hs
421++++ b/compiler/codeGen/StgCmmLayout.hs
422+@@ -527,7 +527,7 @@ mkVirtConstrSizes dflags field_reps
423+ -------------------------------------------------------------------------
424+
425+ -- bring in ARG_P, ARG_N, etc.
426+-#include "../includes/rts/storage/FunTypes.h"
427++#include "rts/storage/FunTypes.h"
428+
429+ mkArgDescr :: DynFlags -> [Id] -> ArgDescr
430+ mkArgDescr dflags args
431+diff --git a/compiler/ghc.cabal.in b/compiler/ghc.cabal.in
432+index 9205648..edf1612 100644
433+--- a/compiler/ghc.cabal.in
434++++ b/compiler/ghc.cabal.in
435+@@ -20,31 +20,37 @@ Category: Development
436+ Build-Type: Simple
437+ Cabal-Version: >=1.10
438+
439++extra-source-files:
440++ utils/md5.h
441++ Unique.h
442++ nativeGen/NCG.h
443++ parser/cutils.h
444++
445+ Flag ghci
446+ Description: Build GHCi support.
447+ Default: False
448+ Manual: True
449+
450++Flag terminfo
451++ Description: Build GHC with terminfo support on non-Windows platforms.
452++ Default: True
453++ Manual: True
454++
455+ Flag stage1
456+- Description: Is this stage 1?
457++ Description: Build Stage1 GHC (STAGE=1)
458+ Default: False
459+ Manual: True
460+
461+ Flag stage2
462+- Description: Is this stage 2?
463+- Default: False
464++ Description: Build Stage1 GHC (STAGE=2)
465++ Default: True
466+ Manual: True
467+
468+ Flag stage3
469+- Description: Is this stage 3?
470++ Description: Build Stage1 GHC (STAGE=3)
471+ Default: False
472+ Manual: True
473+
474+-Flag terminfo
475+- Description: Build GHC with terminfo support on non-Windows platforms.
476+- Default: True
477+- Manual: True
478+-
479+ Library
480+ Default-Language: Haskell2010
481+ Exposed: False
482+@@ -66,6 +72,9 @@ Library
483+ ghc-boot-th == @ProjectVersionMunged@,
484+ ghci == @ProjectVersionMunged@
485+
486++ build-tool-depends: alex:alex,
487++ happy:happy
488++
489+ if os(windows)
490+ Build-Depends: Win32 >= 2.3 && < 2.7
491+ else
492+@@ -79,6 +88,15 @@ Library
493+ -Wnoncanonical-monadfail-instances
494+ -Wnoncanonical-monoid-instances
495+
496++ if flag(stage1)
497++ ghc-options: -DSTAGE=1
498++ else
499++ if flag(stage2)
500++ ghc-options: -DSTAGE=2
501++ else
502++ if flag(stage3)
503++ ghc-options: -DSTAGE=3
504++
505+ if flag(ghci)
506+ CPP-Options: -DGHCI
507+ Include-Dirs: ../rts/dist/build @FFIIncludeDir@
508+@@ -118,17 +136,6 @@ Library
509+ -- as it's magic.
510+ GHC-Options: -this-unit-id ghc
511+
512+- if flag(stage1)
513+- Include-Dirs: stage1
514+- else
515+- if flag(stage2)
516+- Include-Dirs: stage2
517+- else
518+- if flag(stage3)
519+- Include-Dirs: stage2
520+-
521+- Install-Includes: HsVersions.h, ghc_boot_platform.h
522+-
523+ c-sources:
524+ parser/cutils.c
525+ ghci/keepCAFsForGHCi.c
526+diff --git a/compiler/ghc.mk b/compiler/ghc.mk
527+index 9bc6b3f..710ac64 100644
528+--- a/compiler/ghc.mk
529++++ b/compiler/ghc.mk
530+@@ -30,9 +30,7 @@ compiler_stage1_C_FILES_NODEPS = compiler/parser/cutils.c
531+ compiler_NO_CHECK = YES
532+
533+ ifneq "$(BINDIST)" "YES"
534+-compiler/stage1/package-data.mk : compiler/stage1/build/Config.hs
535+-compiler/stage2/package-data.mk : compiler/stage2/build/Config.hs
536+-compiler/stage3/package-data.mk : compiler/stage3/build/Config.hs
537++compiler/main/Config.hs : rts/build/config.hs-incl
538+
539+ compiler/stage1/build/PlatformConstants.o: $(includes_GHCCONSTANTS_HASKELL_TYPE)
540+ compiler/stage2/build/PlatformConstants.o: $(includes_GHCCONSTANTS_HASKELL_TYPE)
541+@@ -45,276 +43,6 @@ compiler/stage2/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
542+ compiler/stage3/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
543+ endif
544+
545+-compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/.
546+- $(call removeFiles,$@)
547+- @echo 'Creating $@ ... '
548+- @echo '{-# LANGUAGE CPP #-}' >> $@
549+- @echo 'module Config where' >> $@
550+- @echo >> $@
551+- @echo 'import GhcPrelude' >> $@
552+- @echo >> $@
553+- @echo '#include "ghc_boot_platform.h"' >> $@
554+- @echo >> $@
555+- @echo 'data IntegerLibrary = IntegerGMP' >> $@
556+- @echo ' | IntegerSimple' >> $@
557+- @echo ' deriving Eq' >> $@
558+- @echo >> $@
559+- @echo 'cBuildPlatformString :: String' >> $@
560+- @echo 'cBuildPlatformString = BuildPlatform_NAME' >> $@
561+- @echo 'cHostPlatformString :: String' >> $@
562+- @echo 'cHostPlatformString = HostPlatform_NAME' >> $@
563+- @echo 'cTargetPlatformString :: String' >> $@
564+- @echo 'cTargetPlatformString = TargetPlatform_NAME' >> $@
565+- @echo >> $@
566+- @echo 'cProjectName :: String' >> $@
567+- @echo 'cProjectName = "$(ProjectName)"' >> $@
568+- @echo 'cProjectGitCommitId :: String' >> $@
569+- @echo 'cProjectGitCommitId = "$(ProjectGitCommitId)"' >> $@
570+- @echo 'cProjectVersion :: String' >> $@
571+- @echo 'cProjectVersion = "$(ProjectVersion)"' >> $@
572+- @echo 'cProjectVersionInt :: String' >> $@
573+- @echo 'cProjectVersionInt = "$(ProjectVersionInt)"' >> $@
574+- @echo 'cProjectPatchLevel :: String' >> $@
575+- @echo 'cProjectPatchLevel = "$(ProjectPatchLevel)"' >> $@
576+- @echo 'cProjectPatchLevel1 :: String' >> $@
577+- @echo 'cProjectPatchLevel1 = "$(ProjectPatchLevel1)"' >> $@
578+- @echo 'cProjectPatchLevel2 :: String' >> $@
579+- @echo 'cProjectPatchLevel2 = "$(ProjectPatchLevel2)"' >> $@
580+- @echo 'cBooterVersion :: String' >> $@
581+- @echo 'cBooterVersion = "$(GhcVersion)"' >> $@
582+- @echo 'cStage :: String' >> $@
583+- @echo 'cStage = show (STAGE :: Int)' >> $@
584+- @echo 'cIntegerLibrary :: String' >> $@
585+- @echo 'cIntegerLibrary = "$(INTEGER_LIBRARY)"' >> $@
586+- @echo 'cIntegerLibraryType :: IntegerLibrary' >> $@
587+-ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
588+- @echo 'cIntegerLibraryType = IntegerGMP' >> $@
589+-else ifeq "$(INTEGER_LIBRARY)" "integer-simple"
590+- @echo 'cIntegerLibraryType = IntegerSimple' >> $@
591+-else ifneq "$(CLEANING)" "YES"
592+-$(error Unknown integer library)
593+-endif
594+- @echo 'cSupportsSplitObjs :: String' >> $@
595+- @echo 'cSupportsSplitObjs = "$(SupportsSplitObjs)"' >> $@
596+- @echo 'cGhcWithInterpreter :: String' >> $@
597+- @echo 'cGhcWithInterpreter = "$(GhcWithInterpreter)"' >> $@
598+- @echo 'cGhcWithNativeCodeGen :: String' >> $@
599+- @echo 'cGhcWithNativeCodeGen = "$(GhcWithNativeCodeGen)"' >> $@
600+- @echo 'cGhcWithSMP :: String' >> $@
601+- @echo 'cGhcWithSMP = "$(GhcWithSMP)"' >> $@
602+- @echo 'cGhcRTSWays :: String' >> $@
603+- @echo 'cGhcRTSWays = "$(GhcRTSWays)"' >> $@
604+- @echo 'cGhcRtsWithLibdw :: Bool' >> $@
605+-ifeq "$(GhcRtsWithLibdw)" "YES"
606+- @echo 'cGhcRtsWithLibdw = True' >> $@
607+-else
608+- @echo 'cGhcRtsWithLibdw = False' >> $@
609+-endif
610+- @echo 'cGhcEnableTablesNextToCode :: String' >> $@
611+- @echo 'cGhcEnableTablesNextToCode = "$(GhcEnableTablesNextToCode)"' >> $@
612+- @echo 'cLeadingUnderscore :: String' >> $@
613+- @echo 'cLeadingUnderscore = "$(LeadingUnderscore)"' >> $@
614+- @echo 'cGHC_UNLIT_PGM :: String' >> $@
615+- @echo 'cGHC_UNLIT_PGM = "$(utils/unlit_dist_PROG)"' >> $@
616+- @echo 'cGHC_SPLIT_PGM :: String' >> $@
617+- @echo 'cGHC_SPLIT_PGM = "$(driver/split_dist_PROG)"' >> $@
618+- @echo 'cLibFFI :: Bool' >> $@
619+-ifeq "$(UseLibFFIForAdjustors)" "YES"
620+- @echo 'cLibFFI = True' >> $@
621+-else
622+- @echo 'cLibFFI = False' >> $@
623+-endif
624+-# Note that GhcThreaded just reflects the Makefile variable setting.
625+-# In particular, the stage1 compiler is never actually compiled with
626+-# -threaded, but it will nevertheless have cGhcThreaded = True.
627+-# The "+RTS --info" output will show what RTS GHC is really using.
628+- @echo 'cGhcThreaded :: Bool' >> $@
629+-ifeq "$(GhcThreaded)" "YES"
630+- @echo 'cGhcThreaded = True' >> $@
631+-else
632+- @echo 'cGhcThreaded = False' >> $@
633+-endif
634+- @echo 'cGhcDebugged :: Bool' >> $@
635+-ifeq "$(GhcDebugged)" "YES"
636+- @echo 'cGhcDebugged = True' >> $@
637+-else
638+- @echo 'cGhcDebugged = False' >> $@
639+-endif
640+- @echo done.
641+-
642+-# -----------------------------------------------------------------------------
643+-# Create platform includes
644+-
645+-# Here we generate a little header file containing CPP symbols that GHC
646+-# uses to determine which platform it is building on/for. The platforms
647+-# can differ between stage1 and stage2 if we're cross-compiling, so we
648+-# need one of these header files per stage.
649+-
650+-PLATFORM_H = ghc_boot_platform.h
651+-
652+-compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
653+- $(call removeFiles,$@)
654+- @echo "Creating $@..."
655+- @echo "#ifndef __PLATFORM_H__" >> $@
656+- @echo "#define __PLATFORM_H__" >> $@
657+- @echo >> $@
658+- @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
659+- @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
660+- @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
661+- @echo >> $@
662+- @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
663+- @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
664+- @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
665+- @echo >> $@
666+- @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
667+- @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
668+- @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
669+- @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
670+- @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
671+- @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
672+- @echo "#define LLVM_TARGET \"$(LLVMTarget_CPP)\"" >> $@
673+- @echo >> $@
674+- @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
675+- @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
676+- @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
677+- @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
678+- @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
679+- @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
680+- @echo >> $@
681+- @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
682+- @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
683+- @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
684+- @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
685+- @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
686+- @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
687+- @echo >> $@
688+- @echo "#endif /* __PLATFORM_H__ */" >> $@
689+- @echo "Done."
690+-
691+-# For stage2 and above, the BUILD platform is the HOST of stage1, and
692+-# the HOST platform is the TARGET of stage1. The TARGET remains the same
693+-# (stage1 is the cross-compiler, not stage2).
694+-compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
695+- $(call removeFiles,$@)
696+- @echo "Creating $@..."
697+- @echo "#ifndef __PLATFORM_H__" >> $@
698+- @echo "#define __PLATFORM_H__" >> $@
699+- @echo >> $@
700+- @echo "#define BuildPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
701+- @echo "#define HostPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
702+- @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
703+- @echo >> $@
704+- @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
705+- @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
706+- @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
707+- @echo >> $@
708+- @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
709+- @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
710+- @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
711+- @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
712+- @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
713+- @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
714+- @echo "#define LLVM_TARGET \"$(LLVMTarget_CPP)\"" >> $@
715+- @echo >> $@
716+- @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
717+- @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
718+- @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
719+- @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
720+- @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
721+- @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
722+- @echo >> $@
723+- @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
724+- @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
725+- @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
726+- @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
727+- @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
728+- @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
729+- @echo >> $@
730+- @echo "#endif /* __PLATFORM_H__ */" >> $@
731+- @echo "Done."
732+-
733+-compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
734+- "$(CP)" $< $@
735+-
736+-# ----------------------------------------------------------------------------
737+-# Generate supporting stuff for prelude/PrimOp.hs
738+-# from prelude/primops.txt
739+-
740+-PRIMOP_BITS_NAMES = primop-data-decl.hs-incl \
741+- primop-tag.hs-incl \
742+- primop-list.hs-incl \
743+- primop-has-side-effects.hs-incl \
744+- primop-out-of-line.hs-incl \
745+- primop-commutable.hs-incl \
746+- primop-code-size.hs-incl \
747+- primop-can-fail.hs-incl \
748+- primop-strictness.hs-incl \
749+- primop-fixity.hs-incl \
750+- primop-primop-info.hs-incl \
751+- primop-vector-uniques.hs-incl \
752+- primop-vector-tys.hs-incl \
753+- primop-vector-tys-exports.hs-incl \
754+- primop-vector-tycons.hs-incl
755+-
756+-PRIMOP_BITS_STAGE1 = $(addprefix compiler/stage1/build/,$(PRIMOP_BITS_NAMES))
757+-PRIMOP_BITS_STAGE2 = $(addprefix compiler/stage2/build/,$(PRIMOP_BITS_NAMES))
758+-PRIMOP_BITS_STAGE3 = $(addprefix compiler/stage3/build/,$(PRIMOP_BITS_NAMES))
759+-
760+-compiler_CPP_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
761+-compiler_CPP_OPTS += ${GhcCppOpts}
762+-
763+-# We add these paths to the Haskell compiler's #include search path list since
764+-# we must avoid #including files by paths relative to the source file as Hadrian
765+-# moves the build artifacts out of the source tree. See #8040.
766+-compiler_HC_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
767+-
768+-define preprocessCompilerFiles
769+-# $0 = stage
770+-compiler/stage$1/build/primops.txt: compiler/prelude/primops.txt.pp compiler/stage$1/$$(PLATFORM_H)
771+- $$(HS_CPP) -P $$(compiler_CPP_OPTS) -Icompiler/stage$1 -x c $$< | grep -v '^#pragma GCC' > $$@
772+-
773+-compiler/stage$1/build/primop-data-decl.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
774+- "$$(genprimopcode_INPLACE)" --data-decl < $$< > $$@
775+-compiler/stage$1/build/primop-tag.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
776+- "$$(genprimopcode_INPLACE)" --primop-tag < $$< > $$@
777+-compiler/stage$1/build/primop-list.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
778+- "$$(genprimopcode_INPLACE)" --primop-list < $$< > $$@
779+-compiler/stage$1/build/primop-has-side-effects.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
780+- "$$(genprimopcode_INPLACE)" --has-side-effects < $$< > $$@
781+-compiler/stage$1/build/primop-out-of-line.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
782+- "$$(genprimopcode_INPLACE)" --out-of-line < $$< > $$@
783+-compiler/stage$1/build/primop-commutable.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
784+- "$$(genprimopcode_INPLACE)" --commutable < $$< > $$@
785+-compiler/stage$1/build/primop-code-size.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
786+- "$$(genprimopcode_INPLACE)" --code-size < $$< > $$@
787+-compiler/stage$1/build/primop-can-fail.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
788+- "$$(genprimopcode_INPLACE)" --can-fail < $$< > $$@
789+-compiler/stage$1/build/primop-strictness.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
790+- "$$(genprimopcode_INPLACE)" --strictness < $$< > $$@
791+-compiler/stage$1/build/primop-fixity.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
792+- "$$(genprimopcode_INPLACE)" --fixity < $$< > $$@
793+-compiler/stage$1/build/primop-primop-info.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
794+- "$$(genprimopcode_INPLACE)" --primop-primop-info < $$< > $$@
795+-compiler/stage$1/build/primop-vector-uniques.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
796+- "$$(genprimopcode_INPLACE)" --primop-vector-uniques < $$< > $$@
797+-compiler/stage$1/build/primop-vector-tys.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
798+- "$$(genprimopcode_INPLACE)" --primop-vector-tys < $$< > $$@
799+-compiler/stage$1/build/primop-vector-tys-exports.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
800+- "$$(genprimopcode_INPLACE)" --primop-vector-tys-exports < $$< > $$@
801+-compiler/stage$1/build/primop-vector-tycons.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
802+- "$$(genprimopcode_INPLACE)" --primop-vector-tycons < $$< > $$@
803+-
804+-# Usages aren't used any more; but the generator
805+-# can still generate them if we want them back
806+-compiler/stage$1/build/primop-usage.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
807+- "$$(genprimopcode_INPLACE)" --usage < $$< > $$@
808+-
809+-endef
810+-
811+-$(eval $(call preprocessCompilerFiles,1))
812+-$(eval $(call preprocessCompilerFiles,2))
813+-$(eval $(call preprocessCompilerFiles,3))
814+-
815+ # -----------------------------------------------------------------------------
816+ # Configuration
817+
818+@@ -369,19 +97,6 @@ ifeq "$(WITH_TERMINFO)" "NO"
819+ compiler_stage2_CONFIGURE_OPTS += --flags=-terminfo
820+ endif
821+
822+-# Careful optimisation of the parser: we don't want to throw everything
823+-# at it, because that takes too long and doesn't buy much, but we do want
824+-# to inline certain key external functions, so we instruct GHC not to
825+-# throw away inlinings as it would normally do in -O0 mode.
826+-# Since GHC version 7.8, we need -fcmm-sink to be
827+-# passed to the compiler. This is required on x86 to avoid the
828+-# register allocator running out of stack slots when compiling this
829+-# module with -fPIC -dynamic.
830+-# See #8182 for all the details
831+-compiler/stage1/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
832+-compiler/stage2/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
833+-compiler/stage3/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
834+-
835+ ifeq "$(GhcProfiled)" "YES"
836+ # If we're profiling GHC then we want SCCs. However, adding -auto-all
837+ # everywhere tends to give a hard-to-read profile, and adds lots of
838+@@ -407,9 +122,6 @@ endif
839+
840+ compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
841+
842+-compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1
843+-compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2
844+-compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3
845+ compiler_stage2_HADDOCK_OPTS += --optghc=-DSTAGE=2
846+
847+ compiler/stage1/package-data.mk : compiler/ghc.mk
848+@@ -487,10 +199,6 @@ ifneq "$(BINDIST)" "YES"
849+ compiler_stage2_TAGS_HC_OPTS = -package ghc
850+ $(eval $(call tags-package,compiler,stage2))
851+
852+-$(compiler_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
853+-$(compiler_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
854+-$(compiler_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
855+-
856+ COMPILER_INCLUDES_DEPS += $(includes_H_CONFIG)
857+ COMPILER_INCLUDES_DEPS += $(includes_H_PLATFORM)
858+ COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS)
859+@@ -499,9 +207,13 @@ COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
860+ COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_EXPORTS)
861+ COMPILER_INCLUDES_DEPS += $(includes_DERIVEDCONSTANTS)
862+
863+-$(compiler_stage1_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE1)
864+-$(compiler_stage2_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE2)
865+-$(compiler_stage3_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE3)
866++$(compiler_stage1_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE1) libraries/ghc-prim/dist-boot/ghc_boot_platform.h
867++$(compiler_stage2_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE2) libraries/ghc-prim/dist-install/ghc_boot_platform.h
868++$(compiler_stage3_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE3) libraries/ghc-prim/dist-install/ghc_boot_platform.h
869++
870++compiler_stage1_HC_OPTS += -Ilibraries/ghc-prim/dist-boot -Irts/build
871++compiler_stage2_HC_OPTS += -Ilibraries/ghc-prim/dist-install -Irts/build
872++compiler_stage3_HC_OPTS += -Ilibraries/ghc-prim/dist-install -Irts/build
873+
874+ $(foreach way,$(compiler_stage1_WAYS),\
875+ compiler/stage1/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE1)
876+@@ -511,10 +223,6 @@ $(foreach way,$(compiler_stage3_WAYS),\
877+ compiler/stage3/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE3)
878+
879+
880+-# GHC itself doesn't know about the above dependencies, so we have to
881+-# switch off the recompilation checker for that module:
882+-compiler/prelude/PrimOp_HC_OPTS += -fforce-recomp
883+-
884+ ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
885+ compiler/utils/Util_HC_OPTS += -DDYNAMIC_GHC_PROGRAMS
886+ endif
887+diff --git a/compiler/ghci/ByteCodeInstr.hs b/compiler/ghci/ByteCodeInstr.hs
888+index 07dcd22..cc44033 100644
889+--- a/compiler/ghci/ByteCodeInstr.hs
890++++ b/compiler/ghci/ByteCodeInstr.hs
891+@@ -10,7 +10,7 @@ module ByteCodeInstr (
892+ ) where
893+
894+ #include "HsVersions.h"
895+-#include "../includes/MachDeps.h"
896++#include "MachDeps.h"
897+
898+ import GhcPrelude
899+
900+diff --git a/compiler/ghci/RtClosureInspect.hs b/compiler/ghci/RtClosureInspect.hs
901+index b85322d..a18b50a 100644
902+--- a/compiler/ghci/RtClosureInspect.hs
903++++ b/compiler/ghci/RtClosureInspect.hs
904+@@ -162,7 +162,7 @@ data Closure = Closure { tipe :: ClosureType
905+ instance Outputable ClosureType where
906+ ppr = text . show
907+
908+-#include "../includes/rts/storage/ClosureTypes.h"
909++#include "rts/storage/ClosureTypes.h"
910+
911+ aP_CODE, pAP_CODE :: Int
912+ aP_CODE = AP
913+diff --git a/compiler/main/Config.hs b/compiler/main/Config.hs
914+new file mode 100644
915+index 0000000..f944f7a
916+--- /dev/null
917++++ b/compiler/main/Config.hs
918+@@ -0,0 +1,7 @@
919++{-# LANGUAGE CPP #-}
920++module Config where
921++
922++import GhcPrelude
923++
924++#include "ghc_boot_platform.h"
925++#include "config.hs-incl"
926+\ No newline at end of file
927+diff --git a/compiler/nativeGen/PPC/CodeGen.hs b/compiler/nativeGen/PPC/CodeGen.hs
928+index e2c568c..b0aca64 100644
929+--- a/compiler/nativeGen/PPC/CodeGen.hs
930++++ b/compiler/nativeGen/PPC/CodeGen.hs
931+@@ -22,7 +22,7 @@ where
932+
933+ #include "HsVersions.h"
934+ #include "nativeGen/NCG.h"
935+-#include "../includes/MachDeps.h"
936++#include "MachDeps.h"
937+
938+ -- NCG stuff:
939+ import GhcPrelude
940+diff --git a/compiler/nativeGen/SPARC/CodeGen.hs b/compiler/nativeGen/SPARC/CodeGen.hs
941+index 6dfd589..9d089ef 100644
942+--- a/compiler/nativeGen/SPARC/CodeGen.hs
943++++ b/compiler/nativeGen/SPARC/CodeGen.hs
944+@@ -19,7 +19,7 @@ where
945+
946+ #include "HsVersions.h"
947+ #include "nativeGen/NCG.h"
948+-#include "../includes/MachDeps.h"
949++#include "MachDeps.h"
950+
951+ -- NCG stuff:
952+ import GhcPrelude
953+diff --git a/compiler/nativeGen/X86/CodeGen.hs b/compiler/nativeGen/X86/CodeGen.hs
954+index eb6af1f..d8af5de 100644
955+--- a/compiler/nativeGen/X86/CodeGen.hs
956++++ b/compiler/nativeGen/X86/CodeGen.hs
957+@@ -27,7 +27,7 @@ where
958+
959+ #include "HsVersions.h"
960+ #include "nativeGen/NCG.h"
961+-#include "../includes/MachDeps.h"
962++#include "MachDeps.h"
963+
964+ -- NCG stuff:
965+ import GhcPrelude
966+diff --git a/compiler/parser/Parser.hs b/compiler/parser/Parser.hs
967+index c09ee5f..aab3a3a 100644
968+--- a/compiler/parser/Parser.hs
969++++ b/compiler/parser/Parser.hs
970+@@ -3,6 +3,17 @@
971+ #if __GLASGOW_HASKELL__ >= 710
972+ {-# OPTIONS_GHC -XPartialTypeSignatures #-}
973+ #endif
974++-- Careful optimisation of the parser: we don't want to throw everything
975++-- at it, because that takes too long and doesn't buy much, but we do want
976++-- to inline certain key external functions, so we instruct GHC not to
977++-- throw away inlinings as it would normally do in -O0 mode.
978++-- Since GHC version 7.8, we need -fcmm-sink to be
979++-- passed to the compiler. This is required on x86 to avoid the
980++-- register allocator running out of stack slots when compiling this
981++-- module with -fPIC -dynamic.
982++-- See #8182 for all the details
983++{-# OPTIONS_GHC -O0 -fno-ignore-interface-pragmas -fcmm-sink #-}
984++
985+ -- | This module provides the generated Happy parser for Haskell. It exports
986+ -- a number of parsers which may be used in any library that uses the GHC API.
987+ -- A common usage pattern is to initialize the parser state with a given string
988+@@ -12084,40 +12095,8 @@ sst = setSourceText
989+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
990+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
991+ {-# LINE 1 "<built-in>" #-}
992+-{-# LINE 1 "<command-line>" #-}
993+-{-# LINE 11 "<command-line>" #-}
994+-# 1 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 1 3 4
995+-
996+-# 17 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 3 4
997+-
998+-
999+-
1000+-
1001+-
1002+-
1003+-
1004+-
1005+-
1006+-
1007+-
1008+-
1009+-
1010+-
1011+-
1012+-
1013+-
1014+-
1015+-
1016+-
1017+-
1018+-
1019+-
1020+-
1021+-
1022+-
1023+-
1024+-
1025+-
1026++{-# LINE 18 "<built-in>" #-}
1027++{-# LINE 1 "/usr/local/Cellar/ghc/8.4.4/lib/ghc-8.4.4/include/ghcversion.h" #-}
1028+
1029+
1030+
1031+@@ -12134,9 +12113,9 @@ sst = setSourceText
1032+
1033+
1034+
1035++{-# LINE 19 "<built-in>" #-}
1036++{-# LINE 1 "/var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc91389_0/ghc_2.h" #-}
1037+
1038+-{-# LINE 11 "<command-line>" #-}
1039+-{-# LINE 1 "/nix/store/n5i1zdpmk2b1s3z96649xh8f9kr3g96s-ghc-8.4.3/lib/ghc-8.4.3/include/ghcversion.h" #-}
1040+
1041+
1042+
1043+@@ -12152,8 +12131,6 @@ sst = setSourceText
1044+
1045+
1046+
1047+-{-# LINE 11 "<command-line>" #-}
1048+-{-# LINE 1 "/build/ghc1653_0/ghc_2.h" #-}
1049+
1050+
1051+
1052+@@ -12319,22 +12296,7 @@ sst = setSourceText
1053+
1054+
1055+
1056+-
1057+-
1058+-
1059+-
1060+-
1061+-
1062+-
1063+-
1064+-
1065+-
1066+-
1067+-
1068+-
1069+-
1070+-
1071+-{-# LINE 11 "<command-line>" #-}
1072++{-# LINE 20 "<built-in>" #-}
1073+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
1074+ -- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp
1075+
1076+@@ -12360,6 +12322,7 @@ sst = setSourceText
1077+ #define GTE(n,m) (n Happy_GHC_Exts.>=# m)
1078+ #define EQ(n,m) (n Happy_GHC_Exts.==# m)
1079+ #endif
1080++
1081+ {-# LINE 43 "templates/GenericTemplate.hs" #-}
1082+
1083+ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
1084+@@ -12370,11 +12333,20 @@ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
1085+
1086+
1087+
1088++
1089+ {-# LINE 65 "templates/GenericTemplate.hs" #-}
1090+
1091++
1092+ {-# LINE 75 "templates/GenericTemplate.hs" #-}
1093+
1094+-{-# LINE 84 "templates/GenericTemplate.hs" #-}
1095++
1096++
1097++
1098++
1099++
1100++
1101++
1102++
1103+
1104+ infixr 9 `HappyStk`
1105+ data HappyStk a = HappyStk a (HappyStk a)
1106+@@ -12402,7 +12374,7 @@ happyAccept j tk st sts (HappyStk ans _) =
1107+
1108+ happyDoAction i tk st
1109+ = {- nothing -}
1110+-
1111++
1112+
1113+ case action of
1114+ 0# -> {- nothing -}
1115+@@ -12410,11 +12382,11 @@ happyDoAction i tk st
1116+ -1# -> {- nothing -}
1117+ happyAccept i tk st
1118+ n | LT(n,(0# :: Happy_GHC_Exts.Int#)) -> {- nothing -}
1119+-
1120++
1121+ (happyReduceArr Happy_Data_Array.! rule) i tk st
1122+ where rule = (Happy_GHC_Exts.I# ((Happy_GHC_Exts.negateInt# ((n Happy_GHC_Exts.+# (1# :: Happy_GHC_Exts.Int#))))))
1123+ n -> {- nothing -}
1124+-
1125++
1126+
1127+ happyShift new_state i tk st
1128+ where new_state = (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#))
1129+@@ -12460,6 +12432,7 @@ data HappyAddr = HappyA# Happy_GHC_Exts.Addr#
1130+ -----------------------------------------------------------------------------
1131+ -- HappyState data type (not arrays)
1132+
1133++
1134+ {-# LINE 180 "templates/GenericTemplate.hs" #-}
1135+
1136+ -----------------------------------------------------------------------------
1137+@@ -12625,3 +12598,4 @@ happyDontSeq a b = b
1138+ {-# NOINLINE happyFail #-}
1139+
1140+ -- end of Happy Template.
1141++
1142+diff --git a/compiler/parser/Parser.y.source b/compiler/parser/Parser.y.source
1143+index dd60b06..c987537 100644
1144+--- a/compiler/parser/Parser.y.source
1145++++ b/compiler/parser/Parser.y.source
1146+@@ -8,6 +8,17 @@
1147+ -- ---------------------------------------------------------------------------
1148+
1149+ {
1150++-- Careful optimisation of the parser: we don't want to throw everything
1151++-- at it, because that takes too long and doesn't buy much, but we do want
1152++-- to inline certain key external functions, so we instruct GHC not to
1153++-- throw away inlinings as it would normally do in -O0 mode.
1154++-- Since GHC version 7.8, we need -fcmm-sink to be
1155++-- passed to the compiler. This is required on x86 to avoid the
1156++-- register allocator running out of stack slots when compiling this
1157++-- module with -fPIC -dynamic.
1158++-- See #8182 for all the details
1159++{-# OPTIONS_GHC -O0 -fno-ignore-interface-pragmas -fcmm-sink #-}
1160++
1161+ -- | This module provides the generated Happy parser for Haskell. It exports
1162+ -- a number of parsers which may be used in any library that uses the GHC API.
1163+ -- A common usage pattern is to initialize the parser state with a given string
1164+diff --git a/compiler/prelude/PrelRules.hs b/compiler/prelude/PrelRules.hs
1165+index 7bc6133..0e560f3 100644
1166+--- a/compiler/prelude/PrelRules.hs
1167++++ b/compiler/prelude/PrelRules.hs
1168+@@ -23,7 +23,7 @@ module PrelRules
1169+ where
1170+
1171+ #include "HsVersions.h"
1172+-#include "../includes/MachDeps.h"
1173++#include "MachDeps.h"
1174+
1175+ import GhcPrelude
1176+
1177+diff --git a/compiler/prelude/PrimOp.hs b/compiler/prelude/PrimOp.hs
1178+index 4eb94e9..32d4fc5 100644
1179+--- a/compiler/prelude/PrimOp.hs
1180++++ b/compiler/prelude/PrimOp.hs
1181+@@ -8,6 +8,11 @@
1182+
1183+ -- The default is a bit too low for the quite large primOpInfo definition
1184+ {-# OPTIONS_GHC -fmax-pmcheck-iterations=10000000 #-}
1185++-- GHC itself doesn't know about the pimop bits, so we have to
1186++-- switch off the recompilation checker for that module:
1187++{-# OPTIONS_GHC -fforce-recomp #-}
1188++
1189++
1190+
1191+ module PrimOp (
1192+ PrimOp(..), PrimOpVecCat(..), allThePrimOps,
1193+diff --git a/compiler/prelude/primops.txt.pp b/compiler/prelude/primops.txt.pp
1194+deleted file mode 100644
1195+index 924ac41..0000000
1196+--- a/compiler/prelude/primops.txt.pp
1197++++ /dev/null
1198+@@ -1,3295 +0,0 @@
1199+------------------------------------------------------------------------
1200+---
1201+--- (c) 2010 The University of Glasgow
1202+---
1203+--- Primitive Operations and Types
1204+---
1205+--- For more information on PrimOps, see
1206+--- http://ghc.haskell.org/trac/ghc/wiki/Commentary/PrimOps
1207+---
1208+------------------------------------------------------------------------
1209+-
1210+--- This file is processed by the utility program genprimopcode to produce
1211+--- a number of include files within the compiler and optionally to produce
1212+--- human-readable documentation.
1213+---
1214+--- It should first be preprocessed.
1215+---
1216+--- Information on how PrimOps are implemented and the steps necessary to
1217+--- add a new one can be found in the Commentary:
1218+---
1219+--- http://ghc.haskell.org/trac/ghc/wiki/Commentary/PrimOps
1220+-
1221+--- This file is divided into named sections, each containing or more
1222+--- primop entries. Section headers have the format:
1223+---
1224+--- section "section-name" {description}
1225+---
1226+--- This information is used solely when producing documentation; it is
1227+--- otherwise ignored. The description is optional.
1228+---
1229+--- The format of each primop entry is as follows:
1230+---
1231+--- primop internal-name "name-in-program-text" type category {description} attributes
1232+-
1233+--- The default attribute values which apply if you don't specify
1234+--- other ones. Attribute values can be True, False, or arbitrary
1235+--- text between curly brackets. This is a kludge to enable
1236+--- processors of this file to easily get hold of simple info
1237+--- (eg, out_of_line), whilst avoiding parsing complex expressions
1238+--- needed for strictness info.
1239+---
1240+--- type refers to the general category of the primop. Valid settings include,
1241+---
1242+--- * Compare: A comparison operation of the shape a -> a -> Int#
1243+--- * Monadic: A unary operation of shape a -> a
1244+--- * Dyadic: A binary operation of shape a -> a -> a
1245+--- * GenPrimOp: Any other sort of primop
1246+---
1247+-
1248+--- The vector attribute is rather special. It takes a list of 3-tuples, each of
1249+--- which is of the form <ELEM_TYPE,SCALAR_TYPE,LENGTH>. ELEM_TYPE is the type of
1250+--- the elements in the vector; LENGTH is the length of the vector; and
1251+--- SCALAR_TYPE is the scalar type used to inject to/project from vector
1252+--- element. Note that ELEM_TYPE and SCALAR_TYPE are not the same; for example,
1253+--- to broadcast a scalar value to a vector whose elements are of type Int8, we
1254+--- use an Int#.
1255+-
1256+--- When a primtype or primop has a vector attribute, it is instantiated at each
1257+--- 3-tuple in the list of 3-tuples. That is, the vector attribute allows us to
1258+--- define a family of types or primops. Vector support also adds three new
1259+--- keywords: VECTOR, SCALAR, and VECTUPLE. These keywords are expanded to types
1260+--- derived from the 3-tuple. For the 3-tuple <Int64,INT64,2>, VECTOR expands to
1261+--- Int64X2#, SCALAR expands to INT64, and VECTUPLE expands to (# INT64, INT64
1262+--- #).
1263+-
1264+-defaults
1265+- has_side_effects = False
1266+- out_of_line = False -- See Note Note [PrimOp can_fail and has_side_effects] in PrimOp
1267+- can_fail = False -- See Note Note [PrimOp can_fail and has_side_effects] in PrimOp
1268+- commutable = False
1269+- code_size = { primOpCodeSizeDefault }
1270+- strictness = { \ arity -> mkClosedStrictSig (replicate arity topDmd) topRes }
1271+- fixity = Nothing
1272+- llvm_only = False
1273+- vector = []
1274+-
1275+--- Currently, documentation is produced using latex, so contents of
1276+--- description fields should be legal latex. Descriptions can contain
1277+--- matched pairs of embedded curly brackets.
1278+-
1279+-#include "MachDeps.h"
1280+-
1281+--- We need platform defines (tests for mingw32 below).
1282+-#include "ghc_boot_platform.h"
1283+-
1284+-section "The word size story."
1285+- {Haskell98 specifies that signed integers (type {\tt Int})
1286+- must contain at least 30 bits. GHC always implements {\tt
1287+- Int} using the primitive type {\tt Int\#}, whose size equals
1288+- the {\tt MachDeps.h} constant {\tt WORD\_SIZE\_IN\_BITS}.
1289+- This is normally set based on the {\tt config.h} parameter
1290+- {\tt SIZEOF\_HSWORD}, i.e., 32 bits on 32-bit machines, 64
1291+- bits on 64-bit machines. However, it can also be explicitly
1292+- set to a smaller number, e.g., 31 bits, to allow the
1293+- possibility of using tag bits. Currently GHC itself has only
1294+- 32-bit and 64-bit variants, but 30 or 31-bit code can be
1295+- exported as an external core file for use in other back ends.
1296+-
1297+- GHC also implements a primitive unsigned integer type {\tt
1298+- Word\#} which always has the same number of bits as {\tt
1299+- Int\#}.
1300+-
1301+- In addition, GHC supports families of explicit-sized integers
1302+- and words at 8, 16, 32, and 64 bits, with the usual
1303+- arithmetic operations, comparisons, and a range of
1304+- conversions. The 8-bit and 16-bit sizes are always
1305+- represented as {\tt Int\#} and {\tt Word\#}, and the
1306+- operations implemented in terms of the the primops on these
1307+- types, with suitable range restrictions on the results (using
1308+- the {\tt narrow$n$Int\#} and {\tt narrow$n$Word\#} families
1309+- of primops. The 32-bit sizes are represented using {\tt
1310+- Int\#} and {\tt Word\#} when {\tt WORD\_SIZE\_IN\_BITS}
1311+- $\geq$ 32; otherwise, these are represented using distinct
1312+- primitive types {\tt Int32\#} and {\tt Word32\#}. These (when
1313+- needed) have a complete set of corresponding operations;
1314+- however, nearly all of these are implemented as external C
1315+- functions rather than as primops. Exactly the same story
1316+- applies to the 64-bit sizes. All of these details are hidden
1317+- under the {\tt PrelInt} and {\tt PrelWord} modules, which use
1318+- {\tt \#if}-defs to invoke the appropriate types and
1319+- operators.
1320+-
1321+- Word size also matters for the families of primops for
1322+- indexing/reading/writing fixed-size quantities at offsets
1323+- from an array base, address, or foreign pointer. Here, a
1324+- slightly different approach is taken. The names of these
1325+- primops are fixed, but their {\it types} vary according to
1326+- the value of {\tt WORD\_SIZE\_IN\_BITS}. For example, if word
1327+- size is at least 32 bits then an operator like
1328+- \texttt{indexInt32Array\#} has type {\tt ByteArray\# -> Int\#
1329+- -> Int\#}; otherwise it has type {\tt ByteArray\# -> Int\# ->
1330+- Int32\#}. This approach confines the necessary {\tt
1331+- \#if}-defs to this file; no conditional compilation is needed
1332+- in the files that expose these primops.
1333+-
1334+- Finally, there are strongly deprecated primops for coercing
1335+- between {\tt Addr\#}, the primitive type of machine
1336+- addresses, and {\tt Int\#}. These are pretty bogus anyway,
1337+- but will work on existing 32-bit and 64-bit GHC targets; they
1338+- are completely bogus when tag bits are used in {\tt Int\#},
1339+- so are not available in this case. }
1340+-
1341+--- Define synonyms for indexing ops.
1342+-
1343+-#if WORD_SIZE_IN_BITS < 32
1344+-#define INT32 Int32#
1345+-#define WORD32 Word32#
1346+-#else
1347+-#define INT32 Int#
1348+-#define WORD32 Word#
1349+-#endif
1350+-
1351+-#if WORD_SIZE_IN_BITS < 64
1352+-#define INT64 Int64#
1353+-#define WORD64 Word64#
1354+-#else
1355+-#define INT64 Int#
1356+-#define WORD64 Word#
1357+-#endif
1358+-
1359+-------------------------------------------------------------------------
1360+-section "Char#"
1361+- {Operations on 31-bit characters.}
1362+-------------------------------------------------------------------------
1363+-
1364+-primtype Char#
1365+-
1366+-primop CharGtOp "gtChar#" Compare Char# -> Char# -> Int#
1367+-primop CharGeOp "geChar#" Compare Char# -> Char# -> Int#
1368+-
1369+-primop CharEqOp "eqChar#" Compare
1370+- Char# -> Char# -> Int#
1371+- with commutable = True
1372+-
1373+-primop CharNeOp "neChar#" Compare
1374+- Char# -> Char# -> Int#
1375+- with commutable = True
1376+-
1377+-primop CharLtOp "ltChar#" Compare Char# -> Char# -> Int#
1378+-primop CharLeOp "leChar#" Compare Char# -> Char# -> Int#
1379+-
1380+-primop OrdOp "ord#" GenPrimOp Char# -> Int#
1381+- with code_size = 0
1382+-
1383+-------------------------------------------------------------------------
1384+-section "Int#"
1385+- {Operations on native-size integers (30+ bits).}
1386+-------------------------------------------------------------------------
1387+-
1388+-primtype Int#
1389+-
1390+-primop IntAddOp "+#" Dyadic
1391+- Int# -> Int# -> Int#
1392+- with commutable = True
1393+- fixity = infixl 6
1394+-
1395+-primop IntSubOp "-#" Dyadic Int# -> Int# -> Int#
1396+- with fixity = infixl 6
1397+-
1398+-primop IntMulOp "*#"
1399+- Dyadic Int# -> Int# -> Int#
1400+- {Low word of signed integer multiply.}
1401+- with commutable = True
1402+- fixity = infixl 7
1403+-
1404+-primop IntMulMayOfloOp "mulIntMayOflo#"
1405+- Dyadic Int# -> Int# -> Int#
1406+- {Return non-zero if there is any possibility that the upper word of a
1407+- signed integer multiply might contain useful information. Return
1408+- zero only if you are completely sure that no overflow can occur.
1409+- On a 32-bit platform, the recommended implementation is to do a
1410+- 32 x 32 -> 64 signed multiply, and subtract result[63:32] from
1411+- (result[31] >>signed 31). If this is zero, meaning that the
1412+- upper word is merely a sign extension of the lower one, no
1413+- overflow can occur.
1414+-
1415+- On a 64-bit platform it is not always possible to
1416+- acquire the top 64 bits of the result. Therefore, a recommended
1417+- implementation is to take the absolute value of both operands, and
1418+- return 0 iff bits[63:31] of them are zero, since that means that their
1419+- magnitudes fit within 31 bits, so the magnitude of the product must fit
1420+- into 62 bits.
1421+-
1422+- If in doubt, return non-zero, but do make an effort to create the
1423+- correct answer for small args, since otherwise the performance of
1424+- \texttt{(*) :: Integer -> Integer -> Integer} will be poor.
1425+- }
1426+- with commutable = True
1427+-
1428+-primop IntQuotOp "quotInt#" Dyadic
1429+- Int# -> Int# -> Int#
1430+- {Rounds towards zero. The behavior is undefined if the second argument is
1431+- zero.
1432+- }
1433+- with can_fail = True
1434+-
1435+-primop IntRemOp "remInt#" Dyadic
1436+- Int# -> Int# -> Int#
1437+- {Satisfies \texttt{(quotInt\# x y) *\# y +\# (remInt\# x y) == x}. The
1438+- behavior is undefined if the second argument is zero.
1439+- }
1440+- with can_fail = True
1441+-
1442+-primop IntQuotRemOp "quotRemInt#" GenPrimOp
1443+- Int# -> Int# -> (# Int#, Int# #)
1444+- {Rounds towards zero.}
1445+- with can_fail = True
1446+-
1447+-primop AndIOp "andI#" Dyadic Int# -> Int# -> Int#
1448+- with commutable = True
1449+-
1450+-primop OrIOp "orI#" Dyadic Int# -> Int# -> Int#
1451+- with commutable = True
1452+-
1453+-primop XorIOp "xorI#" Dyadic Int# -> Int# -> Int#
1454+- with commutable = True
1455+-
1456+-primop NotIOp "notI#" Monadic Int# -> Int#
1457+-
1458+-primop IntNegOp "negateInt#" Monadic Int# -> Int#
1459+-primop IntAddCOp "addIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
1460+- {Add signed integers reporting overflow.
1461+- First member of result is the sum truncated to an {\tt Int#};
1462+- second member is zero if the true sum fits in an {\tt Int#},
1463+- nonzero if overflow occurred (the sum is either too large
1464+- or too small to fit in an {\tt Int#}).}
1465+- with code_size = 2
1466+-
1467+-primop IntSubCOp "subIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
1468+- {Subtract signed integers reporting overflow.
1469+- First member of result is the difference truncated to an {\tt Int#};
1470+- second member is zero if the true difference fits in an {\tt Int#},
1471+- nonzero if overflow occurred (the difference is either too large
1472+- or too small to fit in an {\tt Int#}).}
1473+- with code_size = 2
1474+-
1475+-primop IntGtOp ">#" Compare Int# -> Int# -> Int#
1476+- with fixity = infix 4
1477+-
1478+-primop IntGeOp ">=#" Compare Int# -> Int# -> Int#
1479+- with fixity = infix 4
1480+-
1481+-primop IntEqOp "==#" Compare
1482+- Int# -> Int# -> Int#
1483+- with commutable = True
1484+- fixity = infix 4
1485+-
1486+-primop IntNeOp "/=#" Compare
1487+- Int# -> Int# -> Int#
1488+- with commutable = True
1489+- fixity = infix 4
1490+-
1491+-primop IntLtOp "<#" Compare Int# -> Int# -> Int#
1492+- with fixity = infix 4
1493+-
1494+-primop IntLeOp "<=#" Compare Int# -> Int# -> Int#
1495+- with fixity = infix 4
1496+-
1497+-primop ChrOp "chr#" GenPrimOp Int# -> Char#
1498+- with code_size = 0
1499+-
1500+-primop Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
1501+- with code_size = 0
1502+-
1503+-primop Int2FloatOp "int2Float#" GenPrimOp Int# -> Float#
1504+-primop Int2DoubleOp "int2Double#" GenPrimOp Int# -> Double#
1505+-
1506+-primop Word2FloatOp "word2Float#" GenPrimOp Word# -> Float#
1507+-primop Word2DoubleOp "word2Double#" GenPrimOp Word# -> Double#
1508+-
1509+-primop ISllOp "uncheckedIShiftL#" GenPrimOp Int# -> Int# -> Int#
1510+- {Shift left. Result undefined if shift amount is not
1511+- in the range 0 to word size - 1 inclusive.}
1512+-primop ISraOp "uncheckedIShiftRA#" GenPrimOp Int# -> Int# -> Int#
1513+- {Shift right arithmetic. Result undefined if shift amount is not
1514+- in the range 0 to word size - 1 inclusive.}
1515+-primop ISrlOp "uncheckedIShiftRL#" GenPrimOp Int# -> Int# -> Int#
1516+- {Shift right logical. Result undefined if shift amount is not
1517+- in the range 0 to word size - 1 inclusive.}
1518+-
1519+-------------------------------------------------------------------------
1520+-section "Word#"
1521+- {Operations on native-sized unsigned words (30+ bits).}
1522+-------------------------------------------------------------------------
1523+-
1524+-primtype Word#
1525+-
1526+-primop WordAddOp "plusWord#" Dyadic Word# -> Word# -> Word#
1527+- with commutable = True
1528+-
1529+-primop WordSubCOp "subWordC#" GenPrimOp Word# -> Word# -> (# Word#, Int# #)
1530+- {Subtract unsigned integers reporting overflow.
1531+- The first element of the pair is the result. The second element is
1532+- the carry flag, which is nonzero on overflow.}
1533+-
1534+--- Returns (# high, low #) (or equivalently, (# carry, low #))
1535+-primop WordAdd2Op "plusWord2#" GenPrimOp
1536+- Word# -> Word# -> (# Word#, Word# #)
1537+- with commutable = True
1538+-
1539+-primop WordSubOp "minusWord#" Dyadic Word# -> Word# -> Word#
1540+-
1541+-primop WordMulOp "timesWord#" Dyadic Word# -> Word# -> Word#
1542+- with commutable = True
1543+-
1544+--- Returns (# high, low #)
1545+-primop WordMul2Op "timesWord2#" GenPrimOp
1546+- Word# -> Word# -> (# Word#, Word# #)
1547+- with commutable = True
1548+-
1549+-primop WordQuotOp "quotWord#" Dyadic Word# -> Word# -> Word#
1550+- with can_fail = True
1551+-
1552+-primop WordRemOp "remWord#" Dyadic Word# -> Word# -> Word#
1553+- with can_fail = True
1554+-
1555+-primop WordQuotRemOp "quotRemWord#" GenPrimOp
1556+- Word# -> Word# -> (# Word#, Word# #)
1557+- with can_fail = True
1558+-
1559+--- Takes high word of dividend, then low word of dividend, then divisor.
1560+--- Requires that high word is not divisible by divisor.
1561+-primop WordQuotRem2Op "quotRemWord2#" GenPrimOp
1562+- Word# -> Word# -> Word# -> (# Word#, Word# #)
1563+- with can_fail = True
1564+-
1565+-primop AndOp "and#" Dyadic Word# -> Word# -> Word#
1566+- with commutable = True
1567+-
1568+-primop OrOp "or#" Dyadic Word# -> Word# -> Word#
1569+- with commutable = True
1570+-
1571+-primop XorOp "xor#" Dyadic Word# -> Word# -> Word#
1572+- with commutable = True
1573+-
1574+-primop NotOp "not#" Monadic Word# -> Word#
1575+-
1576+-primop SllOp "uncheckedShiftL#" GenPrimOp Word# -> Int# -> Word#
1577+- {Shift left logical. Result undefined if shift amount is not
1578+- in the range 0 to word size - 1 inclusive.}
1579+-primop SrlOp "uncheckedShiftRL#" GenPrimOp Word# -> Int# -> Word#
1580+- {Shift right logical. Result undefined if shift amount is not
1581+- in the range 0 to word size - 1 inclusive.}
1582+-
1583+-primop Word2IntOp "word2Int#" GenPrimOp Word# -> Int#
1584+- with code_size = 0
1585+-
1586+-primop WordGtOp "gtWord#" Compare Word# -> Word# -> Int#
1587+-primop WordGeOp "geWord#" Compare Word# -> Word# -> Int#
1588+-primop WordEqOp "eqWord#" Compare Word# -> Word# -> Int#
1589+-primop WordNeOp "neWord#" Compare Word# -> Word# -> Int#
1590+-primop WordLtOp "ltWord#" Compare Word# -> Word# -> Int#
1591+-primop WordLeOp "leWord#" Compare Word# -> Word# -> Int#
1592+-
1593+-primop PopCnt8Op "popCnt8#" Monadic Word# -> Word#
1594+- {Count the number of set bits in the lower 8 bits of a word.}
1595+-primop PopCnt16Op "popCnt16#" Monadic Word# -> Word#
1596+- {Count the number of set bits in the lower 16 bits of a word.}
1597+-primop PopCnt32Op "popCnt32#" Monadic Word# -> Word#
1598+- {Count the number of set bits in the lower 32 bits of a word.}
1599+-primop PopCnt64Op "popCnt64#" GenPrimOp WORD64 -> Word#
1600+- {Count the number of set bits in a 64-bit word.}
1601+-primop PopCntOp "popCnt#" Monadic Word# -> Word#
1602+- {Count the number of set bits in a word.}
1603+-
1604+-primop Pdep8Op "pdep8#" Dyadic Word# -> Word# -> Word#
1605+- {Deposit bits to lower 8 bits of a word at locations specified by a mask.}
1606+-primop Pdep16Op "pdep16#" Dyadic Word# -> Word# -> Word#
1607+- {Deposit bits to lower 16 bits of a word at locations specified by a mask.}
1608+-primop Pdep32Op "pdep32#" Dyadic Word# -> Word# -> Word#
1609+- {Deposit bits to lower 32 bits of a word at locations specified by a mask.}
1610+-primop Pdep64Op "pdep64#" GenPrimOp WORD64 -> WORD64 -> WORD64
1611+- {Deposit bits to a word at locations specified by a mask.}
1612+-primop PdepOp "pdep#" Dyadic Word# -> Word# -> Word#
1613+- {Deposit bits to a word at locations specified by a mask.}
1614+-
1615+-primop Pext8Op "pext8#" Dyadic Word# -> Word# -> Word#
1616+- {Extract bits from lower 8 bits of a word at locations specified by a mask.}
1617+-primop Pext16Op "pext16#" Dyadic Word# -> Word# -> Word#
1618+- {Extract bits from lower 16 bits of a word at locations specified by a mask.}
1619+-primop Pext32Op "pext32#" Dyadic Word# -> Word# -> Word#
1620+- {Extract bits from lower 32 bits of a word at locations specified by a mask.}
1621+-primop Pext64Op "pext64#" GenPrimOp WORD64 -> WORD64 -> WORD64
1622+- {Extract bits from a word at locations specified by a mask.}
1623+-primop PextOp "pext#" Dyadic Word# -> Word# -> Word#
1624+- {Extract bits from a word at locations specified by a mask.}
1625+-
1626+-primop Clz8Op "clz8#" Monadic Word# -> Word#
1627+- {Count leading zeros in the lower 8 bits of a word.}
1628+-primop Clz16Op "clz16#" Monadic Word# -> Word#
1629+- {Count leading zeros in the lower 16 bits of a word.}
1630+-primop Clz32Op "clz32#" Monadic Word# -> Word#
1631+- {Count leading zeros in the lower 32 bits of a word.}
1632+-primop Clz64Op "clz64#" GenPrimOp WORD64 -> Word#
1633+- {Count leading zeros in a 64-bit word.}
1634+-primop ClzOp "clz#" Monadic Word# -> Word#
1635+- {Count leading zeros in a word.}
1636+-
1637+-primop Ctz8Op "ctz8#" Monadic Word# -> Word#
1638+- {Count trailing zeros in the lower 8 bits of a word.}
1639+-primop Ctz16Op "ctz16#" Monadic Word# -> Word#
1640+- {Count trailing zeros in the lower 16 bits of a word.}
1641+-primop Ctz32Op "ctz32#" Monadic Word# -> Word#
1642+- {Count trailing zeros in the lower 32 bits of a word.}
1643+-primop Ctz64Op "ctz64#" GenPrimOp WORD64 -> Word#
1644+- {Count trailing zeros in a 64-bit word.}
1645+-primop CtzOp "ctz#" Monadic Word# -> Word#
1646+- {Count trailing zeros in a word.}
1647+-
1648+-primop BSwap16Op "byteSwap16#" Monadic Word# -> Word#
1649+- {Swap bytes in the lower 16 bits of a word. The higher bytes are undefined. }
1650+-primop BSwap32Op "byteSwap32#" Monadic Word# -> Word#
1651+- {Swap bytes in the lower 32 bits of a word. The higher bytes are undefined. }
1652+-primop BSwap64Op "byteSwap64#" Monadic WORD64 -> WORD64
1653+- {Swap bytes in a 64 bits of a word.}
1654+-primop BSwapOp "byteSwap#" Monadic Word# -> Word#
1655+- {Swap bytes in a word.}
1656+-
1657+-------------------------------------------------------------------------
1658+-section "Narrowings"
1659+- {Explicit narrowing of native-sized ints or words.}
1660+-------------------------------------------------------------------------
1661+-
1662+-primop Narrow8IntOp "narrow8Int#" Monadic Int# -> Int#
1663+-primop Narrow16IntOp "narrow16Int#" Monadic Int# -> Int#
1664+-primop Narrow32IntOp "narrow32Int#" Monadic Int# -> Int#
1665+-primop Narrow8WordOp "narrow8Word#" Monadic Word# -> Word#
1666+-primop Narrow16WordOp "narrow16Word#" Monadic Word# -> Word#
1667+-primop Narrow32WordOp "narrow32Word#" Monadic Word# -> Word#
1668+-
1669+-
1670+-#if WORD_SIZE_IN_BITS < 32
1671+-------------------------------------------------------------------------
1672+-section "Int32#"
1673+- {Operations on 32-bit integers ({\tt Int32\#}). This type is only used
1674+- if plain {\tt Int\#} has less than 32 bits. In any case, the operations
1675+- are not primops; they are implemented (if needed) as ccalls instead.}
1676+-------------------------------------------------------------------------
1677+-
1678+-primtype Int32#
1679+-
1680+-------------------------------------------------------------------------
1681+-section "Word32#"
1682+- {Operations on 32-bit unsigned words. This type is only used
1683+- if plain {\tt Word\#} has less than 32 bits. In any case, the operations
1684+- are not primops; they are implemented (if needed) as ccalls instead.}
1685+-------------------------------------------------------------------------
1686+-
1687+-primtype Word32#
1688+-
1689+-#endif
1690+-
1691+-
1692+-#if WORD_SIZE_IN_BITS < 64
1693+-------------------------------------------------------------------------
1694+-section "Int64#"
1695+- {Operations on 64-bit unsigned words. This type is only used
1696+- if plain {\tt Int\#} has less than 64 bits. In any case, the operations
1697+- are not primops; they are implemented (if needed) as ccalls instead.}
1698+-------------------------------------------------------------------------
1699+-
1700+-primtype Int64#
1701+-
1702+-------------------------------------------------------------------------
1703+-section "Word64#"
1704+- {Operations on 64-bit unsigned words. This type is only used
1705+- if plain {\tt Word\#} has less than 64 bits. In any case, the operations
1706+- are not primops; they are implemented (if needed) as ccalls instead.}
1707+-------------------------------------------------------------------------
1708+-
1709+-primtype Word64#
1710+-
1711+-#endif
1712+-
1713+-------------------------------------------------------------------------
1714+-section "Double#"
1715+- {Operations on double-precision (64 bit) floating-point numbers.}
1716+-------------------------------------------------------------------------
1717+-
1718+-primtype Double#
1719+-
1720+-primop DoubleGtOp ">##" Compare Double# -> Double# -> Int#
1721+- with fixity = infix 4
1722+-
1723+-primop DoubleGeOp ">=##" Compare Double# -> Double# -> Int#
1724+- with fixity = infix 4
1725+-
1726+-primop DoubleEqOp "==##" Compare
1727+- Double# -> Double# -> Int#
1728+- with commutable = True
1729+- fixity = infix 4
1730+-
1731+-primop DoubleNeOp "/=##" Compare
1732+- Double# -> Double# -> Int#
1733+- with commutable = True
1734+- fixity = infix 4
1735+-
1736+-primop DoubleLtOp "<##" Compare Double# -> Double# -> Int#
1737+- with fixity = infix 4
1738+-
1739+-primop DoubleLeOp "<=##" Compare Double# -> Double# -> Int#
1740+- with fixity = infix 4
1741+-
1742+-primop DoubleAddOp "+##" Dyadic
1743+- Double# -> Double# -> Double#
1744+- with commutable = True
1745+- fixity = infixl 6
1746+-
1747+-primop DoubleSubOp "-##" Dyadic Double# -> Double# -> Double#
1748+- with fixity = infixl 6
1749+-
1750+-primop DoubleMulOp "*##" Dyadic
1751+- Double# -> Double# -> Double#
1752+- with commutable = True
1753+- fixity = infixl 7
1754+-
1755+-primop DoubleDivOp "/##" Dyadic
1756+- Double# -> Double# -> Double#
1757+- with can_fail = True
1758+- fixity = infixl 7
1759+-
1760+-primop DoubleNegOp "negateDouble#" Monadic Double# -> Double#
1761+-
1762+-primop DoubleFabsOp "fabsDouble#" Monadic Double# -> Double#
1763+-
1764+-primop Double2IntOp "double2Int#" GenPrimOp Double# -> Int#
1765+- {Truncates a {\tt Double#} value to the nearest {\tt Int#}.
1766+- Results are undefined if the truncation if truncation yields
1767+- a value outside the range of {\tt Int#}.}
1768+-
1769+-primop Double2FloatOp "double2Float#" GenPrimOp Double# -> Float#
1770+-
1771+-primop DoubleExpOp "expDouble#" Monadic
1772+- Double# -> Double#
1773+- with
1774+- code_size = { primOpCodeSizeForeignCall }
1775+-
1776+-primop DoubleLogOp "logDouble#" Monadic
1777+- Double# -> Double#
1778+- with
1779+- code_size = { primOpCodeSizeForeignCall }
1780+- can_fail = True
1781+-
1782+-primop DoubleSqrtOp "sqrtDouble#" Monadic
1783+- Double# -> Double#
1784+- with
1785+- code_size = { primOpCodeSizeForeignCall }
1786+-
1787+-primop DoubleSinOp "sinDouble#" Monadic
1788+- Double# -> Double#
1789+- with
1790+- code_size = { primOpCodeSizeForeignCall }
1791+-
1792+-primop DoubleCosOp "cosDouble#" Monadic
1793+- Double# -> Double#
1794+- with
1795+- code_size = { primOpCodeSizeForeignCall }
1796+-
1797+-primop DoubleTanOp "tanDouble#" Monadic
1798+- Double# -> Double#
1799+- with
1800+- code_size = { primOpCodeSizeForeignCall }
1801+-
1802+-primop DoubleAsinOp "asinDouble#" Monadic
1803+- Double# -> Double#
1804+- with
1805+- code_size = { primOpCodeSizeForeignCall }
1806+- can_fail = True
1807+-
1808+-primop DoubleAcosOp "acosDouble#" Monadic
1809+- Double# -> Double#
1810+- with
1811+- code_size = { primOpCodeSizeForeignCall }
1812+- can_fail = True
1813+-
1814+-primop DoubleAtanOp "atanDouble#" Monadic
1815+- Double# -> Double#
1816+- with
1817+- code_size = { primOpCodeSizeForeignCall }
1818+-
1819+-primop DoubleSinhOp "sinhDouble#" Monadic
1820+- Double# -> Double#
1821+- with
1822+- code_size = { primOpCodeSizeForeignCall }
1823+-
1824+-primop DoubleCoshOp "coshDouble#" Monadic
1825+- Double# -> Double#
1826+- with
1827+- code_size = { primOpCodeSizeForeignCall }
1828+-
1829+-primop DoubleTanhOp "tanhDouble#" Monadic
1830+- Double# -> Double#
1831+- with
1832+- code_size = { primOpCodeSizeForeignCall }
1833+-
1834+-primop DoublePowerOp "**##" Dyadic
1835+- Double# -> Double# -> Double#
1836+- {Exponentiation.}
1837+- with
1838+- code_size = { primOpCodeSizeForeignCall }
1839+-
1840+-primop DoubleDecode_2IntOp "decodeDouble_2Int#" GenPrimOp
1841+- Double# -> (# Int#, Word#, Word#, Int# #)
1842+- {Convert to integer.
1843+- First component of the result is -1 or 1, indicating the sign of the
1844+- mantissa. The next two are the high and low 32 bits of the mantissa
1845+- respectively, and the last is the exponent.}
1846+- with out_of_line = True
1847+-
1848+-primop DoubleDecode_Int64Op "decodeDouble_Int64#" GenPrimOp
1849+- Double# -> (# INT64, Int# #)
1850+- {Decode {\tt Double\#} into mantissa and base-2 exponent.}
1851+- with out_of_line = True
1852+-
1853+-------------------------------------------------------------------------
1854+-section "Float#"
1855+- {Operations on single-precision (32-bit) floating-point numbers.}
1856+-------------------------------------------------------------------------
1857+-
1858+-primtype Float#
1859+-
1860+-primop FloatGtOp "gtFloat#" Compare Float# -> Float# -> Int#
1861+-primop FloatGeOp "geFloat#" Compare Float# -> Float# -> Int#
1862+-
1863+-primop FloatEqOp "eqFloat#" Compare
1864+- Float# -> Float# -> Int#
1865+- with commutable = True
1866+-
1867+-primop FloatNeOp "neFloat#" Compare
1868+- Float# -> Float# -> Int#
1869+- with commutable = True
1870+-
1871+-primop FloatLtOp "ltFloat#" Compare Float# -> Float# -> Int#
1872+-primop FloatLeOp "leFloat#" Compare Float# -> Float# -> Int#
1873+-
1874+-primop FloatAddOp "plusFloat#" Dyadic
1875+- Float# -> Float# -> Float#
1876+- with commutable = True
1877+-
1878+-primop FloatSubOp "minusFloat#" Dyadic Float# -> Float# -> Float#
1879+-
1880+-primop FloatMulOp "timesFloat#" Dyadic
1881+- Float# -> Float# -> Float#
1882+- with commutable = True
1883+-
1884+-primop FloatDivOp "divideFloat#" Dyadic
1885+- Float# -> Float# -> Float#
1886+- with can_fail = True
1887+-
1888+-primop FloatNegOp "negateFloat#" Monadic Float# -> Float#
1889+-
1890+-primop FloatFabsOp "fabsFloat#" Monadic Float# -> Float#
1891+-
1892+-primop Float2IntOp "float2Int#" GenPrimOp Float# -> Int#
1893+- {Truncates a {\tt Float#} value to the nearest {\tt Int#}.
1894+- Results are undefined if the truncation if truncation yields
1895+- a value outside the range of {\tt Int#}.}
1896+-
1897+-primop FloatExpOp "expFloat#" Monadic
1898+- Float# -> Float#
1899+- with
1900+- code_size = { primOpCodeSizeForeignCall }
1901+-
1902+-primop FloatLogOp "logFloat#" Monadic
1903+- Float# -> Float#
1904+- with
1905+- code_size = { primOpCodeSizeForeignCall }
1906+- can_fail = True
1907+-
1908+-primop FloatSqrtOp "sqrtFloat#" Monadic
1909+- Float# -> Float#
1910+- with
1911+- code_size = { primOpCodeSizeForeignCall }
1912+-
1913+-primop FloatSinOp "sinFloat#" Monadic
1914+- Float# -> Float#
1915+- with
1916+- code_size = { primOpCodeSizeForeignCall }
1917+-
1918+-primop FloatCosOp "cosFloat#" Monadic
1919+- Float# -> Float#
1920+- with
1921+- code_size = { primOpCodeSizeForeignCall }
1922+-
1923+-primop FloatTanOp "tanFloat#" Monadic
1924+- Float# -> Float#
1925+- with
1926+- code_size = { primOpCodeSizeForeignCall }
1927+-
1928+-primop FloatAsinOp "asinFloat#" Monadic
1929+- Float# -> Float#
1930+- with
1931+- code_size = { primOpCodeSizeForeignCall }
1932+- can_fail = True
1933+-
1934+-primop FloatAcosOp "acosFloat#" Monadic
1935+- Float# -> Float#
1936+- with
1937+- code_size = { primOpCodeSizeForeignCall }
1938+- can_fail = True
1939+-
1940+-primop FloatAtanOp "atanFloat#" Monadic
1941+- Float# -> Float#
1942+- with
1943+- code_size = { primOpCodeSizeForeignCall }
1944+-
1945+-primop FloatSinhOp "sinhFloat#" Monadic
1946+- Float# -> Float#
1947+- with
1948+- code_size = { primOpCodeSizeForeignCall }
1949+-
1950+-primop FloatCoshOp "coshFloat#" Monadic
1951+- Float# -> Float#
1952+- with
1953+- code_size = { primOpCodeSizeForeignCall }
1954+-
1955+-primop FloatTanhOp "tanhFloat#" Monadic
1956+- Float# -> Float#
1957+- with
1958+- code_size = { primOpCodeSizeForeignCall }
1959+-
1960+-primop FloatPowerOp "powerFloat#" Dyadic
1961+- Float# -> Float# -> Float#
1962+- with
1963+- code_size = { primOpCodeSizeForeignCall }
1964+-
1965+-primop Float2DoubleOp "float2Double#" GenPrimOp Float# -> Double#
1966+-
1967+-primop FloatDecode_IntOp "decodeFloat_Int#" GenPrimOp
1968+- Float# -> (# Int#, Int# #)
1969+- {Convert to integers.
1970+- First {\tt Int\#} in result is the mantissa; second is the exponent.}
1971+- with out_of_line = True
1972+-
1973+-------------------------------------------------------------------------
1974+-section "Arrays"
1975+- {Operations on {\tt Array\#}.}
1976+-------------------------------------------------------------------------
1977+-
1978+-primtype Array# a
1979+-
1980+-primtype MutableArray# s a
1981+-
1982+-primop NewArrayOp "newArray#" GenPrimOp
1983+- Int# -> a -> State# s -> (# State# s, MutableArray# s a #)
1984+- {Create a new mutable array with the specified number of elements,
1985+- in the specified state thread,
1986+- with each element containing the specified initial value.}
1987+- with
1988+- out_of_line = True
1989+- has_side_effects = True
1990+-
1991+-primop SameMutableArrayOp "sameMutableArray#" GenPrimOp
1992+- MutableArray# s a -> MutableArray# s a -> Int#
1993+-
1994+-primop ReadArrayOp "readArray#" GenPrimOp
1995+- MutableArray# s a -> Int# -> State# s -> (# State# s, a #)
1996+- {Read from specified index of mutable array. Result is not yet evaluated.}
1997+- with
1998+- has_side_effects = True
1999+- can_fail = True
2000+-
2001+-primop WriteArrayOp "writeArray#" GenPrimOp
2002+- MutableArray# s a -> Int# -> a -> State# s -> State# s
2003+- {Write to specified index of mutable array.}
2004+- with
2005+- has_side_effects = True
2006+- can_fail = True
2007+- code_size = 2 -- card update too
2008+-
2009+-primop SizeofArrayOp "sizeofArray#" GenPrimOp
2010+- Array# a -> Int#
2011+- {Return the number of elements in the array.}
2012+-
2013+-primop SizeofMutableArrayOp "sizeofMutableArray#" GenPrimOp
2014+- MutableArray# s a -> Int#
2015+- {Return the number of elements in the array.}
2016+-
2017+-primop IndexArrayOp "indexArray#" GenPrimOp
2018+- Array# a -> Int# -> (# a #)
2019+- {Read from specified index of immutable array. Result is packaged into
2020+- an unboxed singleton; the result itself is not yet evaluated.}
2021+- with
2022+- can_fail = True
2023+-
2024+-primop UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
2025+- MutableArray# s a -> State# s -> (# State# s, Array# a #)
2026+- {Make a mutable array immutable, without copying.}
2027+- with
2028+- has_side_effects = True
2029+-
2030+-primop UnsafeThawArrayOp "unsafeThawArray#" GenPrimOp
2031+- Array# a -> State# s -> (# State# s, MutableArray# s a #)
2032+- {Make an immutable array mutable, without copying.}
2033+- with
2034+- out_of_line = True
2035+- has_side_effects = True
2036+-
2037+-primop CopyArrayOp "copyArray#" GenPrimOp
2038+- Array# a -> Int# -> MutableArray# s a -> Int# -> Int# -> State# s -> State# s
2039+- {Given a source array, an offset into the source array, a
2040+- destination array, an offset into the destination array, and a
2041+- number of elements to copy, copy the elements from the source array
2042+- to the destination array. Both arrays must fully contain the
2043+- specified ranges, but this is not checked. The two arrays must not
2044+- be the same array in different states, but this is not checked
2045+- either.}
2046+- with
2047+- out_of_line = True
2048+- has_side_effects = True
2049+- can_fail = True
2050+-
2051+-primop CopyMutableArrayOp "copyMutableArray#" GenPrimOp
2052+- MutableArray# s a -> Int# -> MutableArray# s a -> Int# -> Int# -> State# s -> State# s
2053+- {Given a source array, an offset into the source array, a
2054+- destination array, an offset into the destination array, and a
2055+- number of elements to copy, copy the elements from the source array
2056+- to the destination array. Both arrays must fully contain the
2057+- specified ranges, but this is not checked. In the case where
2058+- the source and destination are the same array the source and
2059+- destination regions may overlap.}
2060+- with
2061+- out_of_line = True
2062+- has_side_effects = True
2063+- can_fail = True
2064+-
2065+-primop CloneArrayOp "cloneArray#" GenPrimOp
2066+- Array# a -> Int# -> Int# -> Array# a
2067+- {Given a source array, an offset into the source array, and a number
2068+- of elements to copy, create a new array with the elements from the
2069+- source array. The provided array must fully contain the specified
2070+- range, but this is not checked.}
2071+- with
2072+- out_of_line = True
2073+- has_side_effects = True
2074+- can_fail = True
2075+-
2076+-primop CloneMutableArrayOp "cloneMutableArray#" GenPrimOp
2077+- MutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, MutableArray# s a #)
2078+- {Given a source array, an offset into the source array, and a number
2079+- of elements to copy, create a new array with the elements from the
2080+- source array. The provided array must fully contain the specified
2081+- range, but this is not checked.}
2082+- with
2083+- out_of_line = True
2084+- has_side_effects = True
2085+- can_fail = True
2086+-
2087+-primop FreezeArrayOp "freezeArray#" GenPrimOp
2088+- MutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, Array# a #)
2089+- {Given a source array, an offset into the source array, and a number
2090+- of elements to copy, create a new array with the elements from the
2091+- source array. The provided array must fully contain the specified
2092+- range, but this is not checked.}
2093+- with
2094+- out_of_line = True
2095+- has_side_effects = True
2096+- can_fail = True
2097+-
2098+-primop ThawArrayOp "thawArray#" GenPrimOp
2099+- Array# a -> Int# -> Int# -> State# s -> (# State# s, MutableArray# s a #)
2100+- {Given a source array, an offset into the source array, and a number
2101+- of elements to copy, create a new array with the elements from the
2102+- source array. The provided array must fully contain the specified
2103+- range, but this is not checked.}
2104+- with
2105+- out_of_line = True
2106+- has_side_effects = True
2107+- can_fail = True
2108+-
2109+-primop CasArrayOp "casArray#" GenPrimOp
2110+- MutableArray# s a -> Int# -> a -> a -> State# s -> (# State# s, Int#, a #)
2111+- {Unsafe, machine-level atomic compare and swap on an element within an Array.}
2112+- with
2113+- out_of_line = True
2114+- has_side_effects = True
2115+-
2116+-
2117+-------------------------------------------------------------------------
2118+-section "Small Arrays"
2119+-
2120+- {Operations on {\tt SmallArray\#}. A {\tt SmallArray\#} works
2121+- just like an {\tt Array\#}, but with different space use and
2122+- performance characteristics (that are often useful with small
2123+- arrays). The {\tt SmallArray\#} and {\tt SmallMutableArray#}
2124+- lack a `card table'. The purpose of a card table is to avoid
2125+- having to scan every element of the array on each GC by
2126+- keeping track of which elements have changed since the last GC
2127+- and only scanning those that have changed. So the consequence
2128+- of there being no card table is that the representation is
2129+- somewhat smaller and the writes are somewhat faster (because
2130+- the card table does not need to be updated). The disadvantage
2131+- of course is that for a {\tt SmallMutableArray#} the whole
2132+- array has to be scanned on each GC. Thus it is best suited for
2133+- use cases where the mutable array is not long lived, e.g.
2134+- where a mutable array is initialised quickly and then frozen
2135+- to become an immutable {\tt SmallArray\#}.
2136+- }
2137+-
2138+-------------------------------------------------------------------------
2139+-
2140+-primtype SmallArray# a
2141+-
2142+-primtype SmallMutableArray# s a
2143+-
2144+-primop NewSmallArrayOp "newSmallArray#" GenPrimOp
2145+- Int# -> a -> State# s -> (# State# s, SmallMutableArray# s a #)
2146+- {Create a new mutable array with the specified number of elements,
2147+- in the specified state thread,
2148+- with each element containing the specified initial value.}
2149+- with
2150+- out_of_line = True
2151+- has_side_effects = True
2152+-
2153+-primop SameSmallMutableArrayOp "sameSmallMutableArray#" GenPrimOp
2154+- SmallMutableArray# s a -> SmallMutableArray# s a -> Int#
2155+-
2156+-primop ReadSmallArrayOp "readSmallArray#" GenPrimOp
2157+- SmallMutableArray# s a -> Int# -> State# s -> (# State# s, a #)
2158+- {Read from specified index of mutable array. Result is not yet evaluated.}
2159+- with
2160+- has_side_effects = True
2161+- can_fail = True
2162+-
2163+-primop WriteSmallArrayOp "writeSmallArray#" GenPrimOp
2164+- SmallMutableArray# s a -> Int# -> a -> State# s -> State# s
2165+- {Write to specified index of mutable array.}
2166+- with
2167+- has_side_effects = True
2168+- can_fail = True
2169+-
2170+-primop SizeofSmallArrayOp "sizeofSmallArray#" GenPrimOp
2171+- SmallArray# a -> Int#
2172+- {Return the number of elements in the array.}
2173+-
2174+-primop SizeofSmallMutableArrayOp "sizeofSmallMutableArray#" GenPrimOp
2175+- SmallMutableArray# s a -> Int#
2176+- {Return the number of elements in the array.}
2177+-
2178+-primop IndexSmallArrayOp "indexSmallArray#" GenPrimOp
2179+- SmallArray# a -> Int# -> (# a #)
2180+- {Read from specified index of immutable array. Result is packaged into
2181+- an unboxed singleton; the result itself is not yet evaluated.}
2182+- with
2183+- can_fail = True
2184+-
2185+-primop UnsafeFreezeSmallArrayOp "unsafeFreezeSmallArray#" GenPrimOp
2186+- SmallMutableArray# s a -> State# s -> (# State# s, SmallArray# a #)
2187+- {Make a mutable array immutable, without copying.}
2188+- with
2189+- has_side_effects = True
2190+-
2191+-primop UnsafeThawSmallArrayOp "unsafeThawSmallArray#" GenPrimOp
2192+- SmallArray# a -> State# s -> (# State# s, SmallMutableArray# s a #)
2193+- {Make an immutable array mutable, without copying.}
2194+- with
2195+- out_of_line = True
2196+- has_side_effects = True
2197+-
2198+--- The code_size is only correct for the case when the copy family of
2199+--- primops aren't inlined. It would be nice to keep track of both.
2200+-
2201+-primop CopySmallArrayOp "copySmallArray#" GenPrimOp
2202+- SmallArray# a -> Int# -> SmallMutableArray# s a -> Int# -> Int# -> State# s -> State# s
2203+- {Given a source array, an offset into the source array, a
2204+- destination array, an offset into the destination array, and a
2205+- number of elements to copy, copy the elements from the source array
2206+- to the destination array. Both arrays must fully contain the
2207+- specified ranges, but this is not checked. The two arrays must not
2208+- be the same array in different states, but this is not checked
2209+- either.}
2210+- with
2211+- out_of_line = True
2212+- has_side_effects = True
2213+- can_fail = True
2214+-
2215+-primop CopySmallMutableArrayOp "copySmallMutableArray#" GenPrimOp
2216+- SmallMutableArray# s a -> Int# -> SmallMutableArray# s a -> Int# -> Int# -> State# s -> State# s
2217+- {Given a source array, an offset into the source array, a
2218+- destination array, an offset into the destination array, and a
2219+- number of elements to copy, copy the elements from the source array
2220+- to the destination array. The source and destination arrays can
2221+- refer to the same array. Both arrays must fully contain the
2222+- specified ranges, but this is not checked.
2223+- The regions are allowed to overlap, although this is only possible when the same
2224+- array is provided as both the source and the destination. }
2225+- with
2226+- out_of_line = True
2227+- has_side_effects = True
2228+- can_fail = True
2229+-
2230+-primop CloneSmallArrayOp "cloneSmallArray#" GenPrimOp
2231+- SmallArray# a -> Int# -> Int# -> SmallArray# a
2232+- {Given a source array, an offset into the source array, and a number
2233+- of elements to copy, create a new array with the elements from the
2234+- source array. The provided array must fully contain the specified
2235+- range, but this is not checked.}
2236+- with
2237+- out_of_line = True
2238+- has_side_effects = True
2239+- can_fail = True
2240+-
2241+-primop CloneSmallMutableArrayOp "cloneSmallMutableArray#" GenPrimOp
2242+- SmallMutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, SmallMutableArray# s a #)
2243+- {Given a source array, an offset into the source array, and a number
2244+- of elements to copy, create a new array with the elements from the
2245+- source array. The provided array must fully contain the specified
2246+- range, but this is not checked.}
2247+- with
2248+- out_of_line = True
2249+- has_side_effects = True
2250+- can_fail = True
2251+-
2252+-primop FreezeSmallArrayOp "freezeSmallArray#" GenPrimOp
2253+- SmallMutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, SmallArray# a #)
2254+- {Given a source array, an offset into the source array, and a number
2255+- of elements to copy, create a new array with the elements from the
2256+- source array. The provided array must fully contain the specified
2257+- range, but this is not checked.}
2258+- with
2259+- out_of_line = True
2260+- has_side_effects = True
2261+- can_fail = True
2262+-
2263+-primop ThawSmallArrayOp "thawSmallArray#" GenPrimOp
2264+- SmallArray# a -> Int# -> Int# -> State# s -> (# State# s, SmallMutableArray# s a #)
2265+- {Given a source array, an offset into the source array, and a number
2266+- of elements to copy, create a new array with the elements from the
2267+- source array. The provided array must fully contain the specified
2268+- range, but this is not checked.}
2269+- with
2270+- out_of_line = True
2271+- has_side_effects = True
2272+- can_fail = True
2273+-
2274+-primop CasSmallArrayOp "casSmallArray#" GenPrimOp
2275+- SmallMutableArray# s a -> Int# -> a -> a -> State# s -> (# State# s, Int#, a #)
2276+- {Unsafe, machine-level atomic compare and swap on an element within an array.}
2277+- with
2278+- out_of_line = True
2279+- has_side_effects = True
2280+-
2281+-------------------------------------------------------------------------
2282+-section "Byte Arrays"
2283+- {Operations on {\tt ByteArray\#}. A {\tt ByteArray\#} is a just a region of
2284+- raw memory in the garbage-collected heap, which is not
2285+- scanned for pointers. It carries its own size (in bytes).
2286+- There are
2287+- three sets of operations for accessing byte array contents:
2288+- index for reading from immutable byte arrays, and read/write
2289+- for mutable byte arrays. Each set contains operations for a
2290+- range of useful primitive data types. Each operation takes
2291+- an offset measured in terms of the size of the primitive type
2292+- being read or written.}
2293+-
2294+-------------------------------------------------------------------------
2295+-
2296+-primtype ByteArray#
2297+-
2298+-primtype MutableByteArray# s
2299+-
2300+-primop NewByteArrayOp_Char "newByteArray#" GenPrimOp
2301+- Int# -> State# s -> (# State# s, MutableByteArray# s #)
2302+- {Create a new mutable byte array of specified size (in bytes), in
2303+- the specified state thread.}
2304+- with out_of_line = True
2305+- has_side_effects = True
2306+-
2307+-primop NewPinnedByteArrayOp_Char "newPinnedByteArray#" GenPrimOp
2308+- Int# -> State# s -> (# State# s, MutableByteArray# s #)
2309+- {Create a mutable byte array that the GC guarantees not to move.}
2310+- with out_of_line = True
2311+- has_side_effects = True
2312+-
2313+-primop NewAlignedPinnedByteArrayOp_Char "newAlignedPinnedByteArray#" GenPrimOp
2314+- Int# -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
2315+- {Create a mutable byte array, aligned by the specified amount, that the GC guarantees not to move.}
2316+- with out_of_line = True
2317+- has_side_effects = True
2318+-
2319+-primop MutableByteArrayIsPinnedOp "isMutableByteArrayPinned#" GenPrimOp
2320+- MutableByteArray# s -> Int#
2321+- {Determine whether a {\tt MutableByteArray\#} is guaranteed not to move
2322+- during GC.}
2323+- with out_of_line = True
2324+-
2325+-primop ByteArrayIsPinnedOp "isByteArrayPinned#" GenPrimOp
2326+- ByteArray# -> Int#
2327+- {Determine whether a {\tt ByteArray\#} is guaranteed not to move during GC.}
2328+- with out_of_line = True
2329+-
2330+-primop ByteArrayContents_Char "byteArrayContents#" GenPrimOp
2331+- ByteArray# -> Addr#
2332+- {Intended for use with pinned arrays; otherwise very unsafe!}
2333+-
2334+-primop SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
2335+- MutableByteArray# s -> MutableByteArray# s -> Int#
2336+-
2337+-primop ShrinkMutableByteArrayOp_Char "shrinkMutableByteArray#" GenPrimOp
2338+- MutableByteArray# s -> Int# -> State# s -> State# s
2339+- {Shrink mutable byte array to new specified size (in bytes), in
2340+- the specified state thread. The new size argument must be less than or
2341+- equal to the current size as reported by {\tt sizeofMutableArray\#}.}
2342+- with out_of_line = True
2343+- has_side_effects = True
2344+-
2345+-primop ResizeMutableByteArrayOp_Char "resizeMutableByteArray#" GenPrimOp
2346+- MutableByteArray# s -> Int# -> State# s -> (# State# s,MutableByteArray# s #)
2347+- {Resize (unpinned) mutable byte array to new specified size (in bytes).
2348+- The returned {\tt MutableByteArray\#} is either the original
2349+- {\tt MutableByteArray\#} resized in-place or, if not possible, a newly
2350+- allocated (unpinned) {\tt MutableByteArray\#} (with the original content
2351+- copied over).
2352+-
2353+- To avoid undefined behaviour, the original {\tt MutableByteArray\#} shall
2354+- not be accessed anymore after a {\tt resizeMutableByteArray\#} has been
2355+- performed. Moreover, no reference to the old one should be kept in order
2356+- to allow garbage collection of the original {\tt MutableByteArray\#} in
2357+- case a new {\tt MutableByteArray\#} had to be allocated.}
2358+- with out_of_line = True
2359+- has_side_effects = True
2360+-
2361+-primop UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
2362+- MutableByteArray# s -> State# s -> (# State# s, ByteArray# #)
2363+- {Make a mutable byte array immutable, without copying.}
2364+- with
2365+- has_side_effects = True
2366+-
2367+-primop SizeofByteArrayOp "sizeofByteArray#" GenPrimOp
2368+- ByteArray# -> Int#
2369+- {Return the size of the array in bytes.}
2370+-
2371+-primop SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
2372+- MutableByteArray# s -> Int#
2373+- {Return the size of the array in bytes. Note that this is deprecated as it is
2374+- unsafe in the presence of concurrent resize operations on the same byte
2375+- array. See {\tt getSizeofMutableByteArray}.}
2376+-
2377+-primop GetSizeofMutableByteArrayOp "getSizeofMutableByteArray#" GenPrimOp
2378+- MutableByteArray# s -> State# s -> (# State# s, Int# #)
2379+- {Return the number of elements in the array.}
2380+-
2381+-primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
2382+- ByteArray# -> Int# -> Char#
2383+- {Read 8-bit character; offset in bytes.}
2384+- with can_fail = True
2385+-
2386+-primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp
2387+- ByteArray# -> Int# -> Char#
2388+- {Read 31-bit character; offset in 4-byte words.}
2389+- with can_fail = True
2390+-
2391+-primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
2392+- ByteArray# -> Int# -> Int#
2393+- with can_fail = True
2394+-
2395+-primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
2396+- ByteArray# -> Int# -> Word#
2397+- with can_fail = True
2398+-
2399+-primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
2400+- ByteArray# -> Int# -> Addr#
2401+- with can_fail = True
2402+-
2403+-primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
2404+- ByteArray# -> Int# -> Float#
2405+- with can_fail = True
2406+-
2407+-primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
2408+- ByteArray# -> Int# -> Double#
2409+- with can_fail = True
2410+-
2411+-primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
2412+- ByteArray# -> Int# -> StablePtr# a
2413+- with can_fail = True
2414+-
2415+-primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
2416+- ByteArray# -> Int# -> Int#
2417+- {Read 8-bit integer; offset in bytes.}
2418+- with can_fail = True
2419+-
2420+-primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp
2421+- ByteArray# -> Int# -> Int#
2422+- {Read 16-bit integer; offset in 16-bit words.}
2423+- with can_fail = True
2424+-
2425+-primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp
2426+- ByteArray# -> Int# -> INT32
2427+- {Read 32-bit integer; offset in 32-bit words.}
2428+- with can_fail = True
2429+-
2430+-primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
2431+- ByteArray# -> Int# -> INT64
2432+- {Read 64-bit integer; offset in 64-bit words.}
2433+- with can_fail = True
2434+-
2435+-primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
2436+- ByteArray# -> Int# -> Word#
2437+- {Read 8-bit word; offset in bytes.}
2438+- with can_fail = True
2439+-
2440+-primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp
2441+- ByteArray# -> Int# -> Word#
2442+- {Read 16-bit word; offset in 16-bit words.}
2443+- with can_fail = True
2444+-
2445+-primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp
2446+- ByteArray# -> Int# -> WORD32
2447+- {Read 32-bit word; offset in 32-bit words.}
2448+- with can_fail = True
2449+-
2450+-primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
2451+- ByteArray# -> Int# -> WORD64
2452+- {Read 64-bit word; offset in 64-bit words.}
2453+- with can_fail = True
2454+-
2455+-primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp
2456+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)
2457+- {Read 8-bit character; offset in bytes.}
2458+- with has_side_effects = True
2459+- can_fail = True
2460+-
2461+-primop ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp
2462+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)
2463+- {Read 31-bit character; offset in 4-byte words.}
2464+- with has_side_effects = True
2465+- can_fail = True
2466+-
2467+-primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp
2468+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
2469+- {Read integer; offset in words.}
2470+- with has_side_effects = True
2471+- can_fail = True
2472+-
2473+-primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp
2474+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
2475+- {Read word; offset in words.}
2476+- with has_side_effects = True
2477+- can_fail = True
2478+-
2479+-primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
2480+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #)
2481+- with has_side_effects = True
2482+- can_fail = True
2483+-
2484+-primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
2485+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)
2486+- with has_side_effects = True
2487+- can_fail = True
2488+-
2489+-primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
2490+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)
2491+- with has_side_effects = True
2492+- can_fail = True
2493+-
2494+-primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
2495+- MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
2496+- with has_side_effects = True
2497+- can_fail = True
2498+-
2499+-primop ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
2500+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
2501+- with has_side_effects = True
2502+- can_fail = True
2503+-
2504+-primop ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp
2505+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
2506+- with has_side_effects = True
2507+- can_fail = True
2508+-
2509+-primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp
2510+- MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #)
2511+- with has_side_effects = True
2512+- can_fail = True
2513+-
2514+-primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
2515+- MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #)
2516+- with has_side_effects = True
2517+- can_fail = True
2518+-
2519+-primop ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
2520+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
2521+- with has_side_effects = True
2522+- can_fail = True
2523+-
2524+-primop ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp
2525+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
2526+- with has_side_effects = True
2527+- can_fail = True
2528+-
2529+-primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp
2530+- MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #)
2531+- with has_side_effects = True
2532+- can_fail = True
2533+-
2534+-primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
2535+- MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #)
2536+- with has_side_effects = True
2537+- can_fail = True
2538+-
2539+-primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
2540+- MutableByteArray# s -> Int# -> Char# -> State# s -> State# s
2541+- {Write 8-bit character; offset in bytes.}
2542+- with has_side_effects = True
2543+- can_fail = True
2544+-
2545+-primop WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp
2546+- MutableByteArray# s -> Int# -> Char# -> State# s -> State# s
2547+- {Write 31-bit character; offset in 4-byte words.}
2548+- with has_side_effects = True
2549+- can_fail = True
2550+-
2551+-primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
2552+- MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2553+- with has_side_effects = True
2554+- can_fail = True
2555+-
2556+-primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
2557+- MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
2558+- with has_side_effects = True
2559+- can_fail = True
2560+-
2561+-primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
2562+- MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s
2563+- with has_side_effects = True
2564+- can_fail = True
2565+-
2566+-primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
2567+- MutableByteArray# s -> Int# -> Float# -> State# s -> State# s
2568+- with has_side_effects = True
2569+- can_fail = True
2570+-
2571+-primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
2572+- MutableByteArray# s -> Int# -> Double# -> State# s -> State# s
2573+- with has_side_effects = True
2574+- can_fail = True
2575+-
2576+-primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
2577+- MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s
2578+- with has_side_effects = True
2579+- can_fail = True
2580+-
2581+-primop WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
2582+- MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2583+- with has_side_effects = True
2584+- can_fail = True
2585+-
2586+-primop WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp
2587+- MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2588+- with has_side_effects = True
2589+- can_fail = True
2590+-
2591+-primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp
2592+- MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s
2593+- with has_side_effects = True
2594+- can_fail = True
2595+-
2596+-primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
2597+- MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s
2598+- with can_fail = True
2599+- has_side_effects = True
2600+-
2601+-primop WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
2602+- MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
2603+- with has_side_effects = True
2604+- can_fail = True
2605+-
2606+-primop WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp
2607+- MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
2608+- with has_side_effects = True
2609+- can_fail = True
2610+-
2611+-primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp
2612+- MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s
2613+- with has_side_effects = True
2614+- can_fail = True
2615+-
2616+-primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
2617+- MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s
2618+- with has_side_effects = True
2619+- can_fail = True
2620+-
2621+-primop CompareByteArraysOp "compareByteArrays#" GenPrimOp
2622+- ByteArray# -> Int# -> ByteArray# -> Int# -> Int# -> Int#
2623+- {{\tt compareByteArrays# src1 src1_ofs src2 src2_ofs n} compares
2624+- {\tt n} bytes starting at offset {\tt src1_ofs} in the first
2625+- {\tt ByteArray#} {\tt src1} to the range of {\tt n} bytes
2626+- (i.e. same length) starting at offset {\tt src2_ofs} of the second
2627+- {\tt ByteArray#} {\tt src2}. Both arrays must fully contain the
2628+- specified ranges, but this is not checked. Returns an {\tt Int#}
2629+- less than, equal to, or greater than zero if the range is found,
2630+- respectively, to be byte-wise lexicographically less than, to
2631+- match, or be greater than the second range.}
2632+- with
2633+- can_fail = True
2634+-
2635+-primop CopyByteArrayOp "copyByteArray#" GenPrimOp
2636+- ByteArray# -> Int# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2637+- {{\tt copyByteArray# src src_ofs dst dst_ofs n} copies the range
2638+- starting at offset {\tt src_ofs} of length {\tt n} from the
2639+- {\tt ByteArray#} {\tt src} to the {\tt MutableByteArray#} {\tt dst}
2640+- starting at offset {\tt dst_ofs}. Both arrays must fully contain
2641+- the specified ranges, but this is not checked. The two arrays must
2642+- not be the same array in different states, but this is not checked
2643+- either.}
2644+- with
2645+- has_side_effects = True
2646+- code_size = { primOpCodeSizeForeignCall + 4}
2647+- can_fail = True
2648+-
2649+-primop CopyMutableByteArrayOp "copyMutableByteArray#" GenPrimOp
2650+- MutableByteArray# s -> Int# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2651+- {Copy a range of the first MutableByteArray# to the specified region in the second MutableByteArray#.
2652+- Both arrays must fully contain the specified ranges, but this is not checked. The regions are
2653+- allowed to overlap, although this is only possible when the same array is provided
2654+- as both the source and the destination.}
2655+- with
2656+- has_side_effects = True
2657+- code_size = { primOpCodeSizeForeignCall + 4 }
2658+- can_fail = True
2659+-
2660+-primop CopyByteArrayToAddrOp "copyByteArrayToAddr#" GenPrimOp
2661+- ByteArray# -> Int# -> Addr# -> Int# -> State# s -> State# s
2662+- {Copy a range of the ByteArray# to the memory range starting at the Addr#.
2663+- The ByteArray# and the memory region at Addr# must fully contain the
2664+- specified ranges, but this is not checked. The Addr# must not point into the
2665+- ByteArray# (e.g. if the ByteArray# were pinned), but this is not checked
2666+- either.}
2667+- with
2668+- has_side_effects = True
2669+- code_size = { primOpCodeSizeForeignCall + 4}
2670+- can_fail = True
2671+-
2672+-primop CopyMutableByteArrayToAddrOp "copyMutableByteArrayToAddr#" GenPrimOp
2673+- MutableByteArray# s -> Int# -> Addr# -> Int# -> State# s -> State# s
2674+- {Copy a range of the MutableByteArray# to the memory range starting at the
2675+- Addr#. The MutableByteArray# and the memory region at Addr# must fully
2676+- contain the specified ranges, but this is not checked. The Addr# must not
2677+- point into the MutableByteArray# (e.g. if the MutableByteArray# were
2678+- pinned), but this is not checked either.}
2679+- with
2680+- has_side_effects = True
2681+- code_size = { primOpCodeSizeForeignCall + 4}
2682+- can_fail = True
2683+-
2684+-primop CopyAddrToByteArrayOp "copyAddrToByteArray#" GenPrimOp
2685+- Addr# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2686+- {Copy a memory range starting at the Addr# to the specified range in the
2687+- MutableByteArray#. The memory region at Addr# and the ByteArray# must fully
2688+- contain the specified ranges, but this is not checked. The Addr# must not
2689+- point into the MutableByteArray# (e.g. if the MutableByteArray# were pinned),
2690+- but this is not checked either.}
2691+- with
2692+- has_side_effects = True
2693+- code_size = { primOpCodeSizeForeignCall + 4}
2694+- can_fail = True
2695+-
2696+-primop SetByteArrayOp "setByteArray#" GenPrimOp
2697+- MutableByteArray# s -> Int# -> Int# -> Int# -> State# s -> State# s
2698+- {{\tt setByteArray# ba off len c} sets the byte range {\tt [off, off+len]} of
2699+- the {\tt MutableByteArray#} to the byte {\tt c}.}
2700+- with
2701+- has_side_effects = True
2702+- code_size = { primOpCodeSizeForeignCall + 4 }
2703+- can_fail = True
2704+-
2705+--- Atomic operations
2706+-
2707+-primop AtomicReadByteArrayOp_Int "atomicReadIntArray#" GenPrimOp
2708+- MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
2709+- {Given an array and an offset in Int units, read an element. The
2710+- index is assumed to be in bounds. Implies a full memory barrier.}
2711+- with has_side_effects = True
2712+- can_fail = True
2713+-
2714+-primop AtomicWriteByteArrayOp_Int "atomicWriteIntArray#" GenPrimOp
2715+- MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
2716+- {Given an array and an offset in Int units, write an element. The
2717+- index is assumed to be in bounds. Implies a full memory barrier.}
2718+- with has_side_effects = True
2719+- can_fail = True
2720+-
2721+-primop CasByteArrayOp_Int "casIntArray#" GenPrimOp
2722+- MutableByteArray# s -> Int# -> Int# -> Int# -> State# s -> (# State# s, Int# #)
2723+- {Given an array, an offset in Int units, the expected old value, and
2724+- the new value, perform an atomic compare and swap i.e. write the new
2725+- value if the current value matches the provided old value. Returns
2726+- the value of the element before the operation. Implies a full memory
2727+- barrier.}
2728+- with has_side_effects = True
2729+- can_fail = True
2730+-
2731+-primop FetchAddByteArrayOp_Int "fetchAddIntArray#" GenPrimOp
2732+- MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
2733+- {Given an array, and offset in Int units, and a value to add,
2734+- atomically add the value to the element. Returns the value of the
2735+- element before the operation. Implies a full memory barrier.}
2736+- with has_side_effects = True
2737+- can_fail = True
2738+-
2739+-primop FetchSubByteArrayOp_Int "fetchSubIntArray#" GenPrimOp
2740+- MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
2741+- {Given an array, and offset in Int units, and a value to subtract,
2742+- atomically substract the value to the element. Returns the value of
2743+- the element before the operation. Implies a full memory barrier.}
2744+- with has_side_effects = True
2745+- can_fail = True
2746+-
2747+-primop FetchAndByteArrayOp_Int "fetchAndIntArray#" GenPrimOp
2748+- MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
2749+- {Given an array, and offset in Int units, and a value to AND,
2750+- atomically AND the value to the element. Returns the value of the
2751+- element before the operation. Implies a full memory barrier.}
2752+- with has_side_effects = True
2753+- can_fail = True
2754+-
2755+-primop FetchNandByteArrayOp_Int "fetchNandIntArray#" GenPrimOp
2756+- MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
2757+- {Given an array, and offset in Int units, and a value to NAND,
2758+- atomically NAND the value to the element. Returns the value of the
2759+- element before the operation. Implies a full memory barrier.}
2760+- with has_side_effects = True
2761+- can_fail = True
2762+-
2763+-primop FetchOrByteArrayOp_Int "fetchOrIntArray#" GenPrimOp
2764+- MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
2765+- {Given an array, and offset in Int units, and a value to OR,
2766+- atomically OR the value to the element. Returns the value of the
2767+- element before the operation. Implies a full memory barrier.}
2768+- with has_side_effects = True
2769+- can_fail = True
2770+-
2771+-primop FetchXorByteArrayOp_Int "fetchXorIntArray#" GenPrimOp
2772+- MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
2773+- {Given an array, and offset in Int units, and a value to XOR,
2774+- atomically XOR the value to the element. Returns the value of the
2775+- element before the operation. Implies a full memory barrier.}
2776+- with has_side_effects = True
2777+- can_fail = True
2778+-
2779+-
2780+-------------------------------------------------------------------------
2781+-section "Arrays of arrays"
2782+- {Operations on {\tt ArrayArray\#}. An {\tt ArrayArray\#} contains references to {\em unpointed}
2783+- arrays, such as {\tt ByteArray\#s}. Hence, it is not parameterised by the element types,
2784+- just like a {\tt ByteArray\#}, but it needs to be scanned during GC, just like an {\tt Array#}.
2785+- We represent an {\tt ArrayArray\#} exactly as a {\tt Array\#}, but provide element-type-specific
2786+- indexing, reading, and writing.}
2787+-------------------------------------------------------------------------
2788+-
2789+-primtype ArrayArray#
2790+-
2791+-primtype MutableArrayArray# s
2792+-
2793+-primop NewArrayArrayOp "newArrayArray#" GenPrimOp
2794+- Int# -> State# s -> (# State# s, MutableArrayArray# s #)
2795+- {Create a new mutable array of arrays with the specified number of elements,
2796+- in the specified state thread, with each element recursively referring to the
2797+- newly created array.}
2798+- with
2799+- out_of_line = True
2800+- has_side_effects = True
2801+-
2802+-primop SameMutableArrayArrayOp "sameMutableArrayArray#" GenPrimOp
2803+- MutableArrayArray# s -> MutableArrayArray# s -> Int#
2804+-
2805+-primop UnsafeFreezeArrayArrayOp "unsafeFreezeArrayArray#" GenPrimOp
2806+- MutableArrayArray# s -> State# s -> (# State# s, ArrayArray# #)
2807+- {Make a mutable array of arrays immutable, without copying.}
2808+- with
2809+- has_side_effects = True
2810+-
2811+-primop SizeofArrayArrayOp "sizeofArrayArray#" GenPrimOp
2812+- ArrayArray# -> Int#
2813+- {Return the number of elements in the array.}
2814+-
2815+-primop SizeofMutableArrayArrayOp "sizeofMutableArrayArray#" GenPrimOp
2816+- MutableArrayArray# s -> Int#
2817+- {Return the number of elements in the array.}
2818+-
2819+-primop IndexArrayArrayOp_ByteArray "indexByteArrayArray#" GenPrimOp
2820+- ArrayArray# -> Int# -> ByteArray#
2821+- with can_fail = True
2822+-
2823+-primop IndexArrayArrayOp_ArrayArray "indexArrayArrayArray#" GenPrimOp
2824+- ArrayArray# -> Int# -> ArrayArray#
2825+- with can_fail = True
2826+-
2827+-primop ReadArrayArrayOp_ByteArray "readByteArrayArray#" GenPrimOp
2828+- MutableArrayArray# s -> Int# -> State# s -> (# State# s, ByteArray# #)
2829+- with has_side_effects = True
2830+- can_fail = True
2831+-
2832+-primop ReadArrayArrayOp_MutableByteArray "readMutableByteArrayArray#" GenPrimOp
2833+- MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
2834+- with has_side_effects = True
2835+- can_fail = True
2836+-
2837+-primop ReadArrayArrayOp_ArrayArray "readArrayArrayArray#" GenPrimOp
2838+- MutableArrayArray# s -> Int# -> State# s -> (# State# s, ArrayArray# #)
2839+- with has_side_effects = True
2840+- can_fail = True
2841+-
2842+-primop ReadArrayArrayOp_MutableArrayArray "readMutableArrayArrayArray#" GenPrimOp
2843+- MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableArrayArray# s #)
2844+- with has_side_effects = True
2845+- can_fail = True
2846+-
2847+-primop WriteArrayArrayOp_ByteArray "writeByteArrayArray#" GenPrimOp
2848+- MutableArrayArray# s -> Int# -> ByteArray# -> State# s -> State# s
2849+- with has_side_effects = True
2850+- can_fail = True
2851+-
2852+-primop WriteArrayArrayOp_MutableByteArray "writeMutableByteArrayArray#" GenPrimOp
2853+- MutableArrayArray# s -> Int# -> MutableByteArray# s -> State# s -> State# s
2854+- with has_side_effects = True
2855+- can_fail = True
2856+-
2857+-primop WriteArrayArrayOp_ArrayArray "writeArrayArrayArray#" GenPrimOp
2858+- MutableArrayArray# s -> Int# -> ArrayArray# -> State# s -> State# s
2859+- with has_side_effects = True
2860+- can_fail = True
2861+-
2862+-primop WriteArrayArrayOp_MutableArrayArray "writeMutableArrayArrayArray#" GenPrimOp
2863+- MutableArrayArray# s -> Int# -> MutableArrayArray# s -> State# s -> State# s
2864+- with has_side_effects = True
2865+- can_fail = True
2866+-
2867+-primop CopyArrayArrayOp "copyArrayArray#" GenPrimOp
2868+- ArrayArray# -> Int# -> MutableArrayArray# s -> Int# -> Int# -> State# s -> State# s
2869+- {Copy a range of the ArrayArray# to the specified region in the MutableArrayArray#.
2870+- Both arrays must fully contain the specified ranges, but this is not checked.
2871+- The two arrays must not be the same array in different states, but this is not checked either.}
2872+- with
2873+- out_of_line = True
2874+- has_side_effects = True
2875+- can_fail = True
2876+-
2877+-primop CopyMutableArrayArrayOp "copyMutableArrayArray#" GenPrimOp
2878+- MutableArrayArray# s -> Int# -> MutableArrayArray# s -> Int# -> Int# -> State# s -> State# s
2879+- {Copy a range of the first MutableArrayArray# to the specified region in the second
2880+- MutableArrayArray#.
2881+- Both arrays must fully contain the specified ranges, but this is not checked.
2882+- The regions are allowed to overlap, although this is only possible when the same
2883+- array is provided as both the source and the destination.
2884+- }
2885+- with
2886+- out_of_line = True
2887+- has_side_effects = True
2888+- can_fail = True
2889+-
2890+-------------------------------------------------------------------------
2891+-section "Addr#"
2892+-------------------------------------------------------------------------
2893+-
2894+-primtype Addr#
2895+- { An arbitrary machine address assumed to point outside
2896+- the garbage-collected heap. }
2897+-
2898+-pseudoop "nullAddr#" Addr#
2899+- { The null address. }
2900+-
2901+-primop AddrAddOp "plusAddr#" GenPrimOp Addr# -> Int# -> Addr#
2902+-primop AddrSubOp "minusAddr#" GenPrimOp Addr# -> Addr# -> Int#
2903+- {Result is meaningless if two {\tt Addr\#}s are so far apart that their
2904+- difference doesn't fit in an {\tt Int\#}.}
2905+-primop AddrRemOp "remAddr#" GenPrimOp Addr# -> Int# -> Int#
2906+- {Return the remainder when the {\tt Addr\#} arg, treated like an {\tt Int\#},
2907+- is divided by the {\tt Int\#} arg.}
2908+-#if (WORD_SIZE_IN_BITS == 32 || WORD_SIZE_IN_BITS == 64)
2909+-primop Addr2IntOp "addr2Int#" GenPrimOp Addr# -> Int#
2910+- {Coerce directly from address to int. Strongly deprecated.}
2911+- with code_size = 0
2912+-primop Int2AddrOp "int2Addr#" GenPrimOp Int# -> Addr#
2913+- {Coerce directly from int to address. Strongly deprecated.}
2914+- with code_size = 0
2915+-#endif
2916+-
2917+-primop AddrGtOp "gtAddr#" Compare Addr# -> Addr# -> Int#
2918+-primop AddrGeOp "geAddr#" Compare Addr# -> Addr# -> Int#
2919+-primop AddrEqOp "eqAddr#" Compare Addr# -> Addr# -> Int#
2920+-primop AddrNeOp "neAddr#" Compare Addr# -> Addr# -> Int#
2921+-primop AddrLtOp "ltAddr#" Compare Addr# -> Addr# -> Int#
2922+-primop AddrLeOp "leAddr#" Compare Addr# -> Addr# -> Int#
2923+-
2924+-primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
2925+- Addr# -> Int# -> Char#
2926+- {Reads 8-bit character; offset in bytes.}
2927+- with can_fail = True
2928+-
2929+-primop IndexOffAddrOp_WideChar "indexWideCharOffAddr#" GenPrimOp
2930+- Addr# -> Int# -> Char#
2931+- {Reads 31-bit character; offset in 4-byte words.}
2932+- with can_fail = True
2933+-
2934+-primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
2935+- Addr# -> Int# -> Int#
2936+- with can_fail = True
2937+-
2938+-primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
2939+- Addr# -> Int# -> Word#
2940+- with can_fail = True
2941+-
2942+-primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
2943+- Addr# -> Int# -> Addr#
2944+- with can_fail = True
2945+-
2946+-primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
2947+- Addr# -> Int# -> Float#
2948+- with can_fail = True
2949+-
2950+-primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
2951+- Addr# -> Int# -> Double#
2952+- with can_fail = True
2953+-
2954+-primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
2955+- Addr# -> Int# -> StablePtr# a
2956+- with can_fail = True
2957+-
2958+-primop IndexOffAddrOp_Int8 "indexInt8OffAddr#" GenPrimOp
2959+- Addr# -> Int# -> Int#
2960+- with can_fail = True
2961+-
2962+-primop IndexOffAddrOp_Int16 "indexInt16OffAddr#" GenPrimOp
2963+- Addr# -> Int# -> Int#
2964+- with can_fail = True
2965+-
2966+-primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp
2967+- Addr# -> Int# -> INT32
2968+- with can_fail = True
2969+-
2970+-primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
2971+- Addr# -> Int# -> INT64
2972+- with can_fail = True
2973+-
2974+-primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp
2975+- Addr# -> Int# -> Word#
2976+- with can_fail = True
2977+-
2978+-primop IndexOffAddrOp_Word16 "indexWord16OffAddr#" GenPrimOp
2979+- Addr# -> Int# -> Word#
2980+- with can_fail = True
2981+-
2982+-primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp
2983+- Addr# -> Int# -> WORD32
2984+- with can_fail = True
2985+-
2986+-primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
2987+- Addr# -> Int# -> WORD64
2988+- with can_fail = True
2989+-
2990+-primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
2991+- Addr# -> Int# -> State# s -> (# State# s, Char# #)
2992+- {Reads 8-bit character; offset in bytes.}
2993+- with has_side_effects = True
2994+- can_fail = True
2995+-
2996+-primop ReadOffAddrOp_WideChar "readWideCharOffAddr#" GenPrimOp
2997+- Addr# -> Int# -> State# s -> (# State# s, Char# #)
2998+- {Reads 31-bit character; offset in 4-byte words.}
2999+- with has_side_effects = True
3000+- can_fail = True
3001+-
3002+-primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
3003+- Addr# -> Int# -> State# s -> (# State# s, Int# #)
3004+- with has_side_effects = True
3005+- can_fail = True
3006+-
3007+-primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
3008+- Addr# -> Int# -> State# s -> (# State# s, Word# #)
3009+- with has_side_effects = True
3010+- can_fail = True
3011+-
3012+-primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
3013+- Addr# -> Int# -> State# s -> (# State# s, Addr# #)
3014+- with has_side_effects = True
3015+- can_fail = True
3016+-
3017+-primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
3018+- Addr# -> Int# -> State# s -> (# State# s, Float# #)
3019+- with has_side_effects = True
3020+- can_fail = True
3021+-
3022+-primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
3023+- Addr# -> Int# -> State# s -> (# State# s, Double# #)
3024+- with has_side_effects = True
3025+- can_fail = True
3026+-
3027+-primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
3028+- Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
3029+- with has_side_effects = True
3030+- can_fail = True
3031+-
3032+-primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
3033+- Addr# -> Int# -> State# s -> (# State# s, Int# #)
3034+- with has_side_effects = True
3035+- can_fail = True
3036+-
3037+-primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp
3038+- Addr# -> Int# -> State# s -> (# State# s, Int# #)
3039+- with has_side_effects = True
3040+- can_fail = True
3041+-
3042+-primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
3043+- Addr# -> Int# -> State# s -> (# State# s, INT32 #)
3044+- with has_side_effects = True
3045+- can_fail = True
3046+-
3047+-primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
3048+- Addr# -> Int# -> State# s -> (# State# s, INT64 #)
3049+- with has_side_effects = True
3050+- can_fail = True
3051+-
3052+-primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
3053+- Addr# -> Int# -> State# s -> (# State# s, Word# #)
3054+- with has_side_effects = True
3055+- can_fail = True
3056+-
3057+-primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp
3058+- Addr# -> Int# -> State# s -> (# State# s, Word# #)
3059+- with has_side_effects = True
3060+- can_fail = True
3061+-
3062+-primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
3063+- Addr# -> Int# -> State# s -> (# State# s, WORD32 #)
3064+- with has_side_effects = True
3065+- can_fail = True
3066+-
3067+-primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
3068+- Addr# -> Int# -> State# s -> (# State# s, WORD64 #)
3069+- with has_side_effects = True
3070+- can_fail = True
3071+-
3072+-primop WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
3073+- Addr# -> Int# -> Char# -> State# s -> State# s
3074+- with has_side_effects = True
3075+- can_fail = True
3076+-
3077+-primop WriteOffAddrOp_WideChar "writeWideCharOffAddr#" GenPrimOp
3078+- Addr# -> Int# -> Char# -> State# s -> State# s
3079+- with has_side_effects = True
3080+- can_fail = True
3081+-
3082+-primop WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
3083+- Addr# -> Int# -> Int# -> State# s -> State# s
3084+- with has_side_effects = True
3085+- can_fail = True
3086+-
3087+-primop WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
3088+- Addr# -> Int# -> Word# -> State# s -> State# s
3089+- with has_side_effects = True
3090+- can_fail = True
3091+-
3092+-primop WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
3093+- Addr# -> Int# -> Addr# -> State# s -> State# s
3094+- with has_side_effects = True
3095+- can_fail = True
3096+-
3097+-primop WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
3098+- Addr# -> Int# -> Float# -> State# s -> State# s
3099+- with has_side_effects = True
3100+- can_fail = True
3101+-
3102+-primop WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
3103+- Addr# -> Int# -> Double# -> State# s -> State# s
3104+- with has_side_effects = True
3105+- can_fail = True
3106+-
3107+-primop WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
3108+- Addr# -> Int# -> StablePtr# a -> State# s -> State# s
3109+- with has_side_effects = True
3110+- can_fail = True
3111+-
3112+-primop WriteOffAddrOp_Int8 "writeInt8OffAddr#" GenPrimOp
3113+- Addr# -> Int# -> Int# -> State# s -> State# s
3114+- with has_side_effects = True
3115+- can_fail = True
3116+-
3117+-primop WriteOffAddrOp_Int16 "writeInt16OffAddr#" GenPrimOp
3118+- Addr# -> Int# -> Int# -> State# s -> State# s
3119+- with has_side_effects = True
3120+- can_fail = True
3121+-
3122+-primop WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp
3123+- Addr# -> Int# -> INT32 -> State# s -> State# s
3124+- with has_side_effects = True
3125+- can_fail = True
3126+-
3127+-primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
3128+- Addr# -> Int# -> INT64 -> State# s -> State# s
3129+- with has_side_effects = True
3130+- can_fail = True
3131+-
3132+-primop WriteOffAddrOp_Word8 "writeWord8OffAddr#" GenPrimOp
3133+- Addr# -> Int# -> Word# -> State# s -> State# s
3134+- with has_side_effects = True
3135+- can_fail = True
3136+-
3137+-primop WriteOffAddrOp_Word16 "writeWord16OffAddr#" GenPrimOp
3138+- Addr# -> Int# -> Word# -> State# s -> State# s
3139+- with has_side_effects = True
3140+- can_fail = True
3141+-
3142+-primop WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp
3143+- Addr# -> Int# -> WORD32 -> State# s -> State# s
3144+- with has_side_effects = True
3145+- can_fail = True
3146+-
3147+-primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
3148+- Addr# -> Int# -> WORD64 -> State# s -> State# s
3149+- with has_side_effects = True
3150+- can_fail = True
3151+-
3152+-------------------------------------------------------------------------
3153+-section "Mutable variables"
3154+- {Operations on MutVar\#s.}
3155+-------------------------------------------------------------------------
3156+-
3157+-primtype MutVar# s a
3158+- {A {\tt MutVar\#} behaves like a single-element mutable array.}
3159+-
3160+-primop NewMutVarOp "newMutVar#" GenPrimOp
3161+- a -> State# s -> (# State# s, MutVar# s a #)
3162+- {Create {\tt MutVar\#} with specified initial value in specified state thread.}
3163+- with
3164+- out_of_line = True
3165+- has_side_effects = True
3166+-
3167+--- Note [Why MutVar# ops can't fail]
3168+--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3169+---
3170+--- We don't label readMutVar# or writeMutVar# as can_fail.
3171+--- This may seem a bit peculiar, because they surely *could*
3172+--- fail spectacularly if passed a pointer to unallocated memory.
3173+--- But MutVar#s are always correct by construction; we never
3174+--- test if a pointer is valid before using it with these operations.
3175+--- So we never have to worry about floating the pointer reference
3176+--- outside a validity test. At the moment, has_side_effects blocks
3177+--- up the relevant optimizations anyway, but we hope to draw finer
3178+--- distinctions soon, which should improve matters for readMutVar#
3179+--- at least.
3180+-
3181+-primop ReadMutVarOp "readMutVar#" GenPrimOp
3182+- MutVar# s a -> State# s -> (# State# s, a #)
3183+- {Read contents of {\tt MutVar\#}. Result is not yet evaluated.}
3184+- with
3185+- -- See Note [Why MutVar# ops can't fail]
3186+- has_side_effects = True
3187+-
3188+-primop WriteMutVarOp "writeMutVar#" GenPrimOp
3189+- MutVar# s a -> a -> State# s -> State# s
3190+- {Write contents of {\tt MutVar\#}.}
3191+- with
3192+- -- See Note [Why MutVar# ops can't fail]
3193+- has_side_effects = True
3194+- code_size = { primOpCodeSizeForeignCall } -- for the write barrier
3195+-
3196+-primop SameMutVarOp "sameMutVar#" GenPrimOp
3197+- MutVar# s a -> MutVar# s a -> Int#
3198+-
3199+--- Note [Why not an unboxed tuple in atomicModifyMutVar#?]
3200+--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3201+---
3202+--- Looking at the type of atomicModifyMutVar#, one might wonder why
3203+--- it doesn't return an unboxed tuple. e.g.,
3204+---
3205+--- MutVar# s a -> (a -> (# a, b #)) -> State# s -> (# State# s, b #)
3206+---
3207+--- The reason is that atomicModifyMutVar# relies on laziness for its atomicity.
3208+--- Given a MutVar# containing x, atomicModifyMutVar# merely replaces the
3209+--- its contents with a thunk of the form (fst (f x)). This can be done using an
3210+--- atomic compare-and-swap as it is merely replacing a pointer.
3211+-
3212+-primop AtomicModifyMutVarOp "atomicModifyMutVar#" GenPrimOp
3213+- MutVar# s a -> (a -> b) -> State# s -> (# State# s, c #)
3214+- { Modify the contents of a {\tt MutVar\#}. Note that this isn't strictly
3215+- speaking the correct type for this function, it should really be
3216+- {\tt MutVar# s a -> (a -> (a,b)) -> State# s -> (# State# s, b #)}, however
3217+- we don't know about pairs here. }
3218+- with
3219+- out_of_line = True
3220+- has_side_effects = True
3221+- can_fail = True
3222+-
3223+-primop CasMutVarOp "casMutVar#" GenPrimOp
3224+- MutVar# s a -> a -> a -> State# s -> (# State# s, Int#, a #)
3225+- with
3226+- out_of_line = True
3227+- has_side_effects = True
3228+-
3229+-------------------------------------------------------------------------
3230+-section "Exceptions"
3231+-------------------------------------------------------------------------
3232+-
3233+--- Note [Strictness for mask/unmask/catch]
3234+--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3235+--- Consider this example, which comes from GHC.IO.Handle.Internals:
3236+--- wantReadableHandle3 f ma b st
3237+--- = case ... of
3238+--- DEFAULT -> case ma of MVar a -> ...
3239+--- 0# -> maskAsynchExceptions# (\st -> case ma of MVar a -> ...)
3240+--- The outer case just decides whether to mask exceptions, but we don't want
3241+--- thereby to hide the strictness in 'ma'! Hence the use of strictApply1Dmd.
3242+---
3243+--- For catch, catchSTM, and catchRetry, we must be extra careful; see
3244+--- Note [Exceptions and strictness] in Demand
3245+-
3246+-primop CatchOp "catch#" GenPrimOp
3247+- (State# RealWorld -> (# State# RealWorld, a #) )
3248+- -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
3249+- -> State# RealWorld
3250+- -> (# State# RealWorld, a #)
3251+- with
3252+- strictness = { \ _arity -> mkClosedStrictSig [ lazyApply1Dmd
3253+- , lazyApply2Dmd
3254+- , topDmd] topRes }
3255+- -- See Note [Strictness for mask/unmask/catch]
3256+- out_of_line = True
3257+- has_side_effects = True
3258+-
3259+-primop RaiseOp "raise#" GenPrimOp
3260+- b -> o
3261+- -- NB: the type variable "o" is "a", but with OpenKind
3262+- with
3263+- strictness = { \ _arity -> mkClosedStrictSig [topDmd] exnRes }
3264+- -- NB: result is ThrowsExn
3265+- out_of_line = True
3266+- has_side_effects = True
3267+- -- raise# certainly throws a Haskell exception and hence has_side_effects
3268+- -- It doesn't actually make much difference because the fact that it
3269+- -- returns bottom independently ensures that we are careful not to discard
3270+- -- it. But still, it's better to say the Right Thing.
3271+-
3272+--- raiseIO# needs to be a primop, because exceptions in the IO monad
3273+--- must be *precise* - we don't want the strictness analyser turning
3274+--- one kind of bottom into another, as it is allowed to do in pure code.
3275+---
3276+--- But we *do* want to know that it returns bottom after
3277+--- being applied to two arguments, so that this function is strict in y
3278+--- f x y | x>0 = raiseIO blah
3279+--- | y>0 = return 1
3280+--- | otherwise = return 2
3281+---
3282+--- TODO Check that the above notes on @f@ are valid. The function successfully
3283+--- produces an IO exception when compiled without optimization. If we analyze
3284+--- it as strict in @y@, won't we change that behavior under optimization?
3285+--- I thought the rule was that it was okay to replace one valid imprecise
3286+--- exception with another, but not to replace a precise exception with
3287+--- an imprecise one (dfeuer, 2017-03-05).
3288+-
3289+-primop RaiseIOOp "raiseIO#" GenPrimOp
3290+- a -> State# RealWorld -> (# State# RealWorld, b #)
3291+- with
3292+- strictness = { \ _arity -> mkClosedStrictSig [topDmd, topDmd] exnRes }
3293+- out_of_line = True
3294+- has_side_effects = True
3295+-
3296+-primop MaskAsyncExceptionsOp "maskAsyncExceptions#" GenPrimOp
3297+- (State# RealWorld -> (# State# RealWorld, a #))
3298+- -> (State# RealWorld -> (# State# RealWorld, a #))
3299+- with
3300+- strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
3301+- -- See Note [Strictness for mask/unmask/catch]
3302+- out_of_line = True
3303+- has_side_effects = True
3304+-
3305+-primop MaskUninterruptibleOp "maskUninterruptible#" GenPrimOp
3306+- (State# RealWorld -> (# State# RealWorld, a #))
3307+- -> (State# RealWorld -> (# State# RealWorld, a #))
3308+- with
3309+- strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
3310+- out_of_line = True
3311+- has_side_effects = True
3312+-
3313+-primop UnmaskAsyncExceptionsOp "unmaskAsyncExceptions#" GenPrimOp
3314+- (State# RealWorld -> (# State# RealWorld, a #))
3315+- -> (State# RealWorld -> (# State# RealWorld, a #))
3316+- with
3317+- strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
3318+- -- See Note [Strictness for mask/unmask/catch]
3319+- out_of_line = True
3320+- has_side_effects = True
3321+-
3322+-primop MaskStatus "getMaskingState#" GenPrimOp
3323+- State# RealWorld -> (# State# RealWorld, Int# #)
3324+- with
3325+- out_of_line = True
3326+- has_side_effects = True
3327+-
3328+-------------------------------------------------------------------------
3329+-section "STM-accessible Mutable Variables"
3330+-------------------------------------------------------------------------
3331+-
3332+-primtype TVar# s a
3333+-
3334+-primop AtomicallyOp "atomically#" GenPrimOp
3335+- (State# RealWorld -> (# State# RealWorld, a #) )
3336+- -> State# RealWorld -> (# State# RealWorld, a #)
3337+- with
3338+- strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
3339+- -- See Note [Strictness for mask/unmask/catch]
3340+- out_of_line = True
3341+- has_side_effects = True
3342+-
3343+--- NB: retry#'s strictness information specifies it to throw an exception
3344+--- This lets the compiler perform some extra simplifications, since retry#
3345+--- will technically never return.
3346+---
3347+--- This allows the simplifier to replace things like:
3348+--- case retry# s1
3349+--- (# s2, a #) -> e
3350+--- with:
3351+--- retry# s1
3352+--- where 'e' would be unreachable anyway. See Trac #8091.
3353+---
3354+--- Note that it *does not* return botRes as the "exception" that is thrown may be
3355+--- "caught" by catchRetry#. This mistake caused #14171.
3356+-primop RetryOp "retry#" GenPrimOp
3357+- State# RealWorld -> (# State# RealWorld, a #)
3358+- with
3359+- strictness = { \ _arity -> mkClosedStrictSig [topDmd] exnRes }
3360+- out_of_line = True
3361+- has_side_effects = True
3362+-
3363+-primop CatchRetryOp "catchRetry#" GenPrimOp
3364+- (State# RealWorld -> (# State# RealWorld, a #) )
3365+- -> (State# RealWorld -> (# State# RealWorld, a #) )
3366+- -> (State# RealWorld -> (# State# RealWorld, a #) )
3367+- with
3368+- strictness = { \ _arity -> mkClosedStrictSig [ catchArgDmd
3369+- , lazyApply1Dmd
3370+- , topDmd ] topRes }
3371+- -- See Note [Strictness for mask/unmask/catch]
3372+- out_of_line = True
3373+- has_side_effects = True
3374+-
3375+-primop CatchSTMOp "catchSTM#" GenPrimOp
3376+- (State# RealWorld -> (# State# RealWorld, a #) )
3377+- -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
3378+- -> (State# RealWorld -> (# State# RealWorld, a #) )
3379+- with
3380+- strictness = { \ _arity -> mkClosedStrictSig [ lazyApply1Dmd
3381+- , lazyApply2Dmd
3382+- , topDmd ] topRes }
3383+- -- See Note [Strictness for mask/unmask/catch]
3384+- out_of_line = True
3385+- has_side_effects = True
3386+-
3387+-primop Check "check#" GenPrimOp
3388+- (State# RealWorld -> (# State# RealWorld, a #) )
3389+- -> (State# RealWorld -> State# RealWorld)
3390+- with
3391+- out_of_line = True
3392+- has_side_effects = True
3393+-
3394+-primop NewTVarOp "newTVar#" GenPrimOp
3395+- a
3396+- -> State# s -> (# State# s, TVar# s a #)
3397+- {Create a new {\tt TVar\#} holding a specified initial value.}
3398+- with
3399+- out_of_line = True
3400+- has_side_effects = True
3401+-
3402+-primop ReadTVarOp "readTVar#" GenPrimOp
3403+- TVar# s a
3404+- -> State# s -> (# State# s, a #)
3405+- {Read contents of {\tt TVar\#}. Result is not yet evaluated.}
3406+- with
3407+- out_of_line = True
3408+- has_side_effects = True
3409+-
3410+-primop ReadTVarIOOp "readTVarIO#" GenPrimOp
3411+- TVar# s a
3412+- -> State# s -> (# State# s, a #)
3413+- {Read contents of {\tt TVar\#} outside an STM transaction}
3414+- with
3415+- out_of_line = True
3416+- has_side_effects = True
3417+-
3418+-primop WriteTVarOp "writeTVar#" GenPrimOp
3419+- TVar# s a
3420+- -> a
3421+- -> State# s -> State# s
3422+- {Write contents of {\tt TVar\#}.}
3423+- with
3424+- out_of_line = True
3425+- has_side_effects = True
3426+-
3427+-primop SameTVarOp "sameTVar#" GenPrimOp
3428+- TVar# s a -> TVar# s a -> Int#
3429+-
3430+-
3431+-------------------------------------------------------------------------
3432+-section "Synchronized Mutable Variables"
3433+- {Operations on {\tt MVar\#}s. }
3434+-------------------------------------------------------------------------
3435+-
3436+-primtype MVar# s a
3437+- { A shared mutable variable ({\it not} the same as a {\tt MutVar\#}!).
3438+- (Note: in a non-concurrent implementation, {\tt (MVar\# a)} can be
3439+- represented by {\tt (MutVar\# (Maybe a))}.) }
3440+-
3441+-primop NewMVarOp "newMVar#" GenPrimOp
3442+- State# s -> (# State# s, MVar# s a #)
3443+- {Create new {\tt MVar\#}; initially empty.}
3444+- with
3445+- out_of_line = True
3446+- has_side_effects = True
3447+-
3448+-primop TakeMVarOp "takeMVar#" GenPrimOp
3449+- MVar# s a -> State# s -> (# State# s, a #)
3450+- {If {\tt MVar\#} is empty, block until it becomes full.
3451+- Then remove and return its contents, and set it empty.}
3452+- with
3453+- out_of_line = True
3454+- has_side_effects = True
3455+-
3456+-primop TryTakeMVarOp "tryTakeMVar#" GenPrimOp
3457+- MVar# s a -> State# s -> (# State# s, Int#, a #)
3458+- {If {\tt MVar\#} is empty, immediately return with integer 0 and value undefined.
3459+- Otherwise, return with integer 1 and contents of {\tt MVar\#}, and set {\tt MVar\#} empty.}
3460+- with
3461+- out_of_line = True
3462+- has_side_effects = True
3463+-
3464+-primop PutMVarOp "putMVar#" GenPrimOp
3465+- MVar# s a -> a -> State# s -> State# s
3466+- {If {\tt MVar\#} is full, block until it becomes empty.
3467+- Then store value arg as its new contents.}
3468+- with
3469+- out_of_line = True
3470+- has_side_effects = True
3471+-
3472+-primop TryPutMVarOp "tryPutMVar#" GenPrimOp
3473+- MVar# s a -> a -> State# s -> (# State# s, Int# #)
3474+- {If {\tt MVar\#} is full, immediately return with integer 0.
3475+- Otherwise, store value arg as {\tt MVar\#}'s new contents, and return with integer 1.}
3476+- with
3477+- out_of_line = True
3478+- has_side_effects = True
3479+-
3480+-primop ReadMVarOp "readMVar#" GenPrimOp
3481+- MVar# s a -> State# s -> (# State# s, a #)
3482+- {If {\tt MVar\#} is empty, block until it becomes full.
3483+- Then read its contents without modifying the MVar, without possibility
3484+- of intervention from other threads.}
3485+- with
3486+- out_of_line = True
3487+- has_side_effects = True
3488+-
3489+-primop TryReadMVarOp "tryReadMVar#" GenPrimOp
3490+- MVar# s a -> State# s -> (# State# s, Int#, a #)
3491+- {If {\tt MVar\#} is empty, immediately return with integer 0 and value undefined.
3492+- Otherwise, return with integer 1 and contents of {\tt MVar\#}.}
3493+- with
3494+- out_of_line = True
3495+- has_side_effects = True
3496+-
3497+-primop SameMVarOp "sameMVar#" GenPrimOp
3498+- MVar# s a -> MVar# s a -> Int#
3499+-
3500+-primop IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
3501+- MVar# s a -> State# s -> (# State# s, Int# #)
3502+- {Return 1 if {\tt MVar\#} is empty; 0 otherwise.}
3503+- with
3504+- out_of_line = True
3505+- has_side_effects = True
3506+-
3507+-------------------------------------------------------------------------
3508+-section "Delay/wait operations"
3509+-------------------------------------------------------------------------
3510+-
3511+-primop DelayOp "delay#" GenPrimOp
3512+- Int# -> State# s -> State# s
3513+- {Sleep specified number of microseconds.}
3514+- with
3515+- has_side_effects = True
3516+- out_of_line = True
3517+-
3518+-primop WaitReadOp "waitRead#" GenPrimOp
3519+- Int# -> State# s -> State# s
3520+- {Block until input is available on specified file descriptor.}
3521+- with
3522+- has_side_effects = True
3523+- out_of_line = True
3524+-
3525+-primop WaitWriteOp "waitWrite#" GenPrimOp
3526+- Int# -> State# s -> State# s
3527+- {Block until output is possible on specified file descriptor.}
3528+- with
3529+- has_side_effects = True
3530+- out_of_line = True
3531+-
3532+-#if defined(mingw32_TARGET_OS)
3533+-primop AsyncReadOp "asyncRead#" GenPrimOp
3534+- Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
3535+- {Asynchronously read bytes from specified file descriptor.}
3536+- with
3537+- has_side_effects = True
3538+- out_of_line = True
3539+-
3540+-primop AsyncWriteOp "asyncWrite#" GenPrimOp
3541+- Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
3542+- {Asynchronously write bytes from specified file descriptor.}
3543+- with
3544+- has_side_effects = True
3545+- out_of_line = True
3546+-
3547+-primop AsyncDoProcOp "asyncDoProc#" GenPrimOp
3548+- Addr# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
3549+- {Asynchronously perform procedure (first arg), passing it 2nd arg.}
3550+- with
3551+- has_side_effects = True
3552+- out_of_line = True
3553+-
3554+-#endif
3555+-
3556+-------------------------------------------------------------------------
3557+-section "Concurrency primitives"
3558+-------------------------------------------------------------------------
3559+-
3560+-primtype State# s
3561+- { {\tt State\#} is the primitive, unlifted type of states. It has
3562+- one type parameter, thus {\tt State\# RealWorld}, or {\tt State\# s},
3563+- where s is a type variable. The only purpose of the type parameter
3564+- is to keep different state threads separate. It is represented by
3565+- nothing at all. }
3566+-
3567+-primtype RealWorld
3568+- { {\tt RealWorld} is deeply magical. It is {\it primitive}, but it is not
3569+- {\it unlifted} (hence {\tt ptrArg}). We never manipulate values of type
3570+- {\tt RealWorld}; it's only used in the type system, to parameterise {\tt State\#}. }
3571+-
3572+-primtype ThreadId#
3573+- {(In a non-concurrent implementation, this can be a singleton
3574+- type, whose (unique) value is returned by {\tt myThreadId\#}. The
3575+- other operations can be omitted.)}
3576+-
3577+-primop ForkOp "fork#" GenPrimOp
3578+- a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
3579+- with
3580+- has_side_effects = True
3581+- out_of_line = True
3582+-
3583+-primop ForkOnOp "forkOn#" GenPrimOp
3584+- Int# -> a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
3585+- with
3586+- has_side_effects = True
3587+- out_of_line = True
3588+-
3589+-primop KillThreadOp "killThread#" GenPrimOp
3590+- ThreadId# -> a -> State# RealWorld -> State# RealWorld
3591+- with
3592+- has_side_effects = True
3593+- out_of_line = True
3594+-
3595+-primop YieldOp "yield#" GenPrimOp
3596+- State# RealWorld -> State# RealWorld
3597+- with
3598+- has_side_effects = True
3599+- out_of_line = True
3600+-
3601+-primop MyThreadIdOp "myThreadId#" GenPrimOp
3602+- State# RealWorld -> (# State# RealWorld, ThreadId# #)
3603+- with
3604+- out_of_line = True
3605+- has_side_effects = True
3606+-
3607+-primop LabelThreadOp "labelThread#" GenPrimOp
3608+- ThreadId# -> Addr# -> State# RealWorld -> State# RealWorld
3609+- with
3610+- has_side_effects = True
3611+- out_of_line = True
3612+-
3613+-primop IsCurrentThreadBoundOp "isCurrentThreadBound#" GenPrimOp
3614+- State# RealWorld -> (# State# RealWorld, Int# #)
3615+- with
3616+- out_of_line = True
3617+- has_side_effects = True
3618+-
3619+-primop NoDuplicateOp "noDuplicate#" GenPrimOp
3620+- State# s -> State# s
3621+- with
3622+- out_of_line = True
3623+- has_side_effects = True
3624+-
3625+-primop ThreadStatusOp "threadStatus#" GenPrimOp
3626+- ThreadId# -> State# RealWorld -> (# State# RealWorld, Int#, Int#, Int# #)
3627+- with
3628+- out_of_line = True
3629+- has_side_effects = True
3630+-
3631+-------------------------------------------------------------------------
3632+-section "Weak pointers"
3633+-------------------------------------------------------------------------
3634+-
3635+-primtype Weak# b
3636+-
3637+--- note that tyvar "o" denotes openAlphaTyVar
3638+-
3639+-primop MkWeakOp "mkWeak#" GenPrimOp
3640+- o -> b -> (State# RealWorld -> (# State# RealWorld, c #))
3641+- -> State# RealWorld -> (# State# RealWorld, Weak# b #)
3642+- { {\tt mkWeak# k v finalizer s} creates a weak reference to value {\tt k},
3643+- with an associated reference to some value {\tt v}. If {\tt k} is still
3644+- alive then {\tt v} can be retrieved using {\tt deRefWeak#}. Note that
3645+- the type of {\tt k} must be represented by a pointer (i.e. of kind {\tt
3646+- TYPE 'LiftedRep} or {\tt TYPE 'UnliftedRep}). }
3647+- with
3648+- has_side_effects = True
3649+- out_of_line = True
3650+-
3651+-primop MkWeakNoFinalizerOp "mkWeakNoFinalizer#" GenPrimOp
3652+- o -> b -> State# RealWorld -> (# State# RealWorld, Weak# b #)
3653+- with
3654+- has_side_effects = True
3655+- out_of_line = True
3656+-
3657+-primop AddCFinalizerToWeakOp "addCFinalizerToWeak#" GenPrimOp
3658+- Addr# -> Addr# -> Int# -> Addr# -> Weak# b
3659+- -> State# RealWorld -> (# State# RealWorld, Int# #)
3660+- { {\tt addCFinalizerToWeak# fptr ptr flag eptr w} attaches a C
3661+- function pointer {\tt fptr} to a weak pointer {\tt w} as a finalizer. If
3662+- {\tt flag} is zero, {\tt fptr} will be called with one argument,
3663+- {\tt ptr}. Otherwise, it will be called with two arguments,
3664+- {\tt eptr} and {\tt ptr}. {\tt addCFinalizerToWeak#} returns
3665+- 1 on success, or 0 if {\tt w} is already dead. }
3666+- with
3667+- has_side_effects = True
3668+- out_of_line = True
3669+-
3670+-primop DeRefWeakOp "deRefWeak#" GenPrimOp
3671+- Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
3672+- with
3673+- has_side_effects = True
3674+- out_of_line = True
3675+-
3676+-primop FinalizeWeakOp "finalizeWeak#" GenPrimOp
3677+- Weak# a -> State# RealWorld -> (# State# RealWorld, Int#,
3678+- (State# RealWorld -> (# State# RealWorld, b #) ) #)
3679+- { Finalize a weak pointer. The return value is an unboxed tuple
3680+- containing the new state of the world and an "unboxed Maybe",
3681+- represented by an {\tt Int#} and a (possibly invalid) finalization
3682+- action. An {\tt Int#} of {\tt 1} indicates that the finalizer is valid. The
3683+- return value {\tt b} from the finalizer should be ignored. }
3684+- with
3685+- has_side_effects = True
3686+- out_of_line = True
3687+-
3688+-primop TouchOp "touch#" GenPrimOp
3689+- o -> State# RealWorld -> State# RealWorld
3690+- with
3691+- code_size = { 0 }
3692+- has_side_effects = True
3693+-
3694+-------------------------------------------------------------------------
3695+-section "Stable pointers and names"
3696+-------------------------------------------------------------------------
3697+-
3698+-primtype StablePtr# a
3699+-
3700+-primtype StableName# a
3701+-
3702+-primop MakeStablePtrOp "makeStablePtr#" GenPrimOp
3703+- a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
3704+- with
3705+- has_side_effects = True
3706+- out_of_line = True
3707+-
3708+-primop DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
3709+- StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
3710+- with
3711+- has_side_effects = True
3712+- out_of_line = True
3713+-
3714+-primop EqStablePtrOp "eqStablePtr#" GenPrimOp
3715+- StablePtr# a -> StablePtr# a -> Int#
3716+- with
3717+- has_side_effects = True
3718+-
3719+-primop MakeStableNameOp "makeStableName#" GenPrimOp
3720+- a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
3721+- with
3722+- has_side_effects = True
3723+- out_of_line = True
3724+-
3725+-primop EqStableNameOp "eqStableName#" GenPrimOp
3726+- StableName# a -> StableName# b -> Int#
3727+-
3728+-primop StableNameToIntOp "stableNameToInt#" GenPrimOp
3729+- StableName# a -> Int#
3730+-
3731+-------------------------------------------------------------------------
3732+-section "Compact normal form"
3733+-------------------------------------------------------------------------
3734+-
3735+-primtype Compact#
3736+-
3737+-primop CompactNewOp "compactNew#" GenPrimOp
3738+- Word# -> State# RealWorld -> (# State# RealWorld, Compact# #)
3739+- { Create a new Compact with the given size (in bytes, not words).
3740+- The size is rounded up to a multiple of the allocator block size,
3741+- and capped to one mega block. }
3742+- with
3743+- has_side_effects = True
3744+- out_of_line = True
3745+-
3746+-primop CompactResizeOp "compactResize#" GenPrimOp
3747+- Compact# -> Word# -> State# RealWorld ->
3748+- State# RealWorld
3749+- { Set the new allocation size of the compact. This value (in bytes)
3750+- determines the size of each block in the compact chain. }
3751+- with
3752+- has_side_effects = True
3753+- out_of_line = True
3754+-
3755+-primop CompactContainsOp "compactContains#" GenPrimOp
3756+- Compact# -> a -> State# RealWorld -> (# State# RealWorld, Int# #)
3757+- { Returns 1# if the object is contained in the compact, 0# otherwise. }
3758+- with
3759+- out_of_line = True
3760+-
3761+-primop CompactContainsAnyOp "compactContainsAny#" GenPrimOp
3762+- a -> State# RealWorld -> (# State# RealWorld, Int# #)
3763+- { Returns 1# if the object is in any compact at all, 0# otherwise. }
3764+- with
3765+- out_of_line = True
3766+-
3767+-primop CompactGetFirstBlockOp "compactGetFirstBlock#" GenPrimOp
3768+- Compact# -> State# RealWorld -> (# State# RealWorld, Addr#, Word# #)
3769+- { Returns the address and the size (in bytes) of the first block of
3770+- a compact. }
3771+- with
3772+- out_of_line = True
3773+-
3774+-primop CompactGetNextBlockOp "compactGetNextBlock#" GenPrimOp
3775+- Compact# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr#, Word# #)
3776+- { Given a compact and the address of one its blocks, returns the
3777+- next block and its size, or #nullAddr if the argument was the
3778+- last block in the compact. }
3779+- with
3780+- out_of_line = True
3781+-
3782+-primop CompactAllocateBlockOp "compactAllocateBlock#" GenPrimOp
3783+- Word# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr# #)
3784+- { Attempt to allocate a compact block with the given size (in
3785+- bytes) at the given address. The first argument is a hint to
3786+- the allocator, allocation might be satisfied at a different
3787+- address (which is returned).
3788+- The resulting block is not known to the GC until
3789+- compactFixupPointers# is called on it, and care must be taken
3790+- so that the address does not escape or memory will be leaked.
3791+- }
3792+- with
3793+- has_side_effects = True
3794+- out_of_line = True
3795+-
3796+-primop CompactFixupPointersOp "compactFixupPointers#" GenPrimOp
3797+- Addr# -> Addr# -> State# RealWorld -> (# State# RealWorld, Compact#, Addr# #)
3798+- { Given the pointer to the first block of a compact, and the
3799+- address of the root object in the old address space, fix up
3800+- the internal pointers inside the compact to account for
3801+- a different position in memory than when it was serialized.
3802+- This method must be called exactly once after importing
3803+- a serialized compact, and returns the new compact and
3804+- the new adjusted root address. }
3805+- with
3806+- has_side_effects = True
3807+- out_of_line = True
3808+-
3809+-primop CompactAdd "compactAdd#" GenPrimOp
3810+- Compact# -> a -> State# RealWorld -> (# State# RealWorld, a #)
3811+- { Recursively add a closure and its transitive closure to a
3812+- {\texttt Compact\#}, evaluating any unevaluated components at the
3813+- same time. Note: {\texttt compactAdd\#} is not thread-safe, so
3814+- only one thread may call {\texttt compactAdd\#} with a particular
3815+- {\texttt Compact#} at any given time. The primop does not
3816+- enforce any mutual exclusion; the caller is expected to
3817+- arrange this. }
3818+- with
3819+- has_side_effects = True
3820+- out_of_line = True
3821+-
3822+-primop CompactAddWithSharing "compactAddWithSharing#" GenPrimOp
3823+- Compact# -> a -> State# RealWorld -> (# State# RealWorld, a #)
3824+- { Like {\texttt compactAdd\#}, but retains sharing and cycles
3825+- during compaction. }
3826+- with
3827+- has_side_effects = True
3828+- out_of_line = True
3829+-
3830+-primop CompactSize "compactSize#" GenPrimOp
3831+- Compact# -> State# RealWorld -> (# State# RealWorld, Word# #)
3832+- { Return the size (in bytes) of the total amount of data in the Compact# }
3833+- with
3834+- has_side_effects = True
3835+- out_of_line = True
3836+-
3837+-------------------------------------------------------------------------
3838+-section "Unsafe pointer equality"
3839+--- (#1 Bad Guy: Alastair Reid :)
3840+-------------------------------------------------------------------------
3841+-
3842+-primop ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
3843+- a -> a -> Int#
3844+- { Returns {\texttt 1\#} if the given pointers are equal and {\texttt 0\#} otherwise. }
3845+- with
3846+- can_fail = True -- See Note [reallyUnsafePtrEquality#]
3847+-
3848+-
3849+--- Note [reallyUnsafePtrEquality#]
3850+--- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3851+---
3852+--- reallyUnsafePtrEquality# can't actually fail, per se, but we mark it can_fail
3853+--- anyway. Until 5a9a1738023a, GHC considered primops okay for speculation only
3854+--- when their arguments were known to be forced. This was unnecessarily
3855+--- conservative, but it prevented reallyUnsafePtrEquality# from floating out of
3856+--- places where its arguments were known to be forced. Unfortunately, GHC could
3857+--- sometimes lose track of whether those arguments were forced, leading to let/app
3858+--- invariant failures (see Trac 13027 and the discussion in Trac 11444). Now that
3859+--- ok_for_speculation skips over lifted arguments, we need to explicitly prevent
3860+--- reallyUnsafePtrEquality# from floating out. The reasons are closely related
3861+--- to those described in Note [dataToTag#], although the consequences are less
3862+--- severe. Imagine if we had
3863+---
3864+--- \x y . case x of x'
3865+--- DEFAULT ->
3866+--- case y of y'
3867+--- DEFAULT ->
3868+--- let eq = reallyUnsafePtrEquality# x' y'
3869+--- in ...
3870+---
3871+--- If the let floats out, we'll get
3872+---
3873+--- \x y . let eq = reallyUnsafePtrEquality# x y
3874+--- in case x of ...
3875+---
3876+--- The trouble is that pointer equality between thunks is very different
3877+--- from pointer equality between the values those thunks reduce to, and the latter
3878+--- is typically much more precise.
3879+-
3880+-------------------------------------------------------------------------
3881+-section "Parallelism"
3882+-------------------------------------------------------------------------
3883+-
3884+-primop ParOp "par#" GenPrimOp
3885+- a -> Int#
3886+- with
3887+- -- Note that Par is lazy to avoid that the sparked thing
3888+- -- gets evaluated strictly, which it should *not* be
3889+- has_side_effects = True
3890+- code_size = { primOpCodeSizeForeignCall }
3891+-
3892+-primop SparkOp "spark#" GenPrimOp
3893+- a -> State# s -> (# State# s, a #)
3894+- with has_side_effects = True
3895+- code_size = { primOpCodeSizeForeignCall }
3896+-
3897+-primop SeqOp "seq#" GenPrimOp
3898+- a -> State# s -> (# State# s, a #)
3899+- -- See Note [seq# magic] in PrelRules
3900+-
3901+-primop GetSparkOp "getSpark#" GenPrimOp
3902+- State# s -> (# State# s, Int#, a #)
3903+- with
3904+- has_side_effects = True
3905+- out_of_line = True
3906+-
3907+-primop NumSparks "numSparks#" GenPrimOp
3908+- State# s -> (# State# s, Int# #)
3909+- { Returns the number of sparks in the local spark pool. }
3910+- with
3911+- has_side_effects = True
3912+- out_of_line = True
3913+-
3914+-------------------------------------------------------------------------
3915+-section "Tag to enum stuff"
3916+- {Convert back and forth between values of enumerated types
3917+- and small integers.}
3918+-------------------------------------------------------------------------
3919+-
3920+-primop DataToTagOp "dataToTag#" GenPrimOp
3921+- a -> Int# -- Zero-indexed; the first constructor has tag zero
3922+- with
3923+- can_fail = True -- See Note [dataToTag#]
3924+- strictness = { \ _arity -> mkClosedStrictSig [evalDmd] topRes }
3925+- -- dataToTag# must have an evaluated argument
3926+-
3927+-primop TagToEnumOp "tagToEnum#" GenPrimOp
3928+- Int# -> a
3929+-
3930+-{- Note [dataToTag#]
3931+-~~~~~~~~~~~~~~~~~~~~
3932+-The dataToTag# primop should always be applied to an evaluated argument.
3933+-The way to ensure this is to invoke it via the 'getTag' wrapper in GHC.Base:
3934+- getTag :: a -> Int#
3935+- getTag !x = dataToTag# x
3936+-
3937+-But now consider
3938+- \z. case x of y -> let v = dataToTag# y in ...
3939+-
3940+-To improve floating, the FloatOut pass (deliberately) does a
3941+-binder-swap on the case, to give
3942+- \z. case x of y -> let v = dataToTag# x in ...
3943+-
3944+-Now FloatOut might float that v-binding outside the \z. But that is
3945+-bad because that might mean x gest evaluated much too early! (CorePrep
3946+-adds an eval to a dataToTag# call, to ensure that the argument really is
3947+-evaluated; see CorePrep Note [dataToTag magic].)
3948+-
3949+-Solution: make DataToTag into a can_fail primop. That will stop it floating
3950+-(see Note [PrimOp can_fail and has_side_effects] in PrimOp). It's a bit of
3951+-a hack but never mind.
3952+--}
3953+-
3954+-------------------------------------------------------------------------
3955+-section "Bytecode operations"
3956+- {Support for manipulating bytecode objects used by the interpreter and
3957+- linker.
3958+-
3959+- Bytecode objects are heap objects which represent top-level bindings and
3960+- contain a list of instructions and data needed by these instructions.}
3961+-------------------------------------------------------------------------
3962+-
3963+-primtype BCO#
3964+- { Primitive bytecode type. }
3965+-
3966+-primop AddrToAnyOp "addrToAny#" GenPrimOp
3967+- Addr# -> (# a #)
3968+- { Convert an {\tt Addr\#} to a followable Any type. }
3969+- with
3970+- code_size = 0
3971+-
3972+-primop AnyToAddrOp "anyToAddr#" GenPrimOp
3973+- a -> State# RealWorld -> (# State# RealWorld, Addr# #)
3974+- { Retrieve the address of any Haskell value. This is
3975+- essentially an {\texttt unsafeCoerce\#}, but if implemented as such
3976+- the core lint pass complains and fails to compile.
3977+- As a primop, it is opaque to core/stg, and only appears
3978+- in cmm (where the copy propagation pass will get rid of it).
3979+- Note that "a" must be a value, not a thunk! It's too late
3980+- for strictness analysis to enforce this, so you're on your
3981+- own to guarantee this. Also note that {\texttt Addr\#} is not a GC
3982+- pointer - up to you to guarantee that it does not become
3983+- a dangling pointer immediately after you get it.}
3984+- with
3985+- code_size = 0
3986+-
3987+-primop MkApUpd0_Op "mkApUpd0#" GenPrimOp
3988+- BCO# -> (# a #)
3989+- { Wrap a BCO in a {\tt AP_UPD} thunk which will be updated with the value of
3990+- the BCO when evaluated. }
3991+- with
3992+- out_of_line = True
3993+-
3994+-primop NewBCOOp "newBCO#" GenPrimOp
3995+- ByteArray# -> ByteArray# -> Array# a -> Int# -> ByteArray# -> State# s -> (# State# s, BCO# #)
3996+- { {\tt newBCO\# instrs lits ptrs arity bitmap} creates a new bytecode object. The
3997+- resulting object encodes a function of the given arity with the instructions
3998+- encoded in {\tt instrs}, and a static reference table usage bitmap given by
3999+- {\tt bitmap}. }
4000+- with
4001+- has_side_effects = True
4002+- out_of_line = True
4003+-
4004+-primop UnpackClosureOp "unpackClosure#" GenPrimOp
4005+- a -> (# Addr#, Array# b, ByteArray# #)
4006+- { {\tt unpackClosure\# closure} copies non-pointers and pointers in the
4007+- payload of the given closure into two new arrays, and returns a pointer to
4008+- the first word of the closure's info table, a pointer array for the
4009+- pointers in the payload, and a non-pointer array for the non-pointers in
4010+- the payload. }
4011+- with
4012+- out_of_line = True
4013+-
4014+-primop GetApStackValOp "getApStackVal#" GenPrimOp
4015+- a -> Int# -> (# Int#, b #)
4016+- with
4017+- out_of_line = True
4018+-
4019+-------------------------------------------------------------------------
4020+-section "Misc"
4021+- {These aren't nearly as wired in as Etc...}
4022+-------------------------------------------------------------------------
4023+-
4024+-primop GetCCSOfOp "getCCSOf#" GenPrimOp
4025+- a -> State# s -> (# State# s, Addr# #)
4026+-
4027+-primop GetCurrentCCSOp "getCurrentCCS#" GenPrimOp
4028+- a -> State# s -> (# State# s, Addr# #)
4029+- { Returns the current {\tt CostCentreStack} (value is {\tt NULL} if
4030+- not profiling). Takes a dummy argument which can be used to
4031+- avoid the call to {\tt getCurrentCCS\#} being floated out by the
4032+- simplifier, which would result in an uninformative stack
4033+- ("CAF"). }
4034+-
4035+-primop ClearCCSOp "clearCCS#" GenPrimOp
4036+- (State# s -> (# State# s, a #)) -> State# s -> (# State# s, a #)
4037+- { Run the supplied IO action with an empty CCS. For example, this
4038+- is used by the interpreter to run an interpreted computation
4039+- without the call stack showing that it was invoked from GHC. }
4040+- with
4041+- out_of_line = True
4042+-
4043+-------------------------------------------------------------------------
4044+-section "Etc"
4045+- {Miscellaneous built-ins}
4046+-------------------------------------------------------------------------
4047+-
4048+-primtype Proxy# a
4049+- { The type constructor {\tt Proxy#} is used to bear witness to some
4050+- type variable. It's used when you want to pass around proxy values
4051+- for doing things like modelling type applications. A {\tt Proxy#}
4052+- is not only unboxed, it also has a polymorphic kind, and has no
4053+- runtime representation, being totally free. }
4054+-
4055+-pseudoop "proxy#"
4056+- Proxy# a
4057+- { Witness for an unboxed {\tt Proxy#} value, which has no runtime
4058+- representation. }
4059+-
4060+-pseudoop "seq"
4061+- a -> b -> b
4062+- { The value of {\tt seq a b} is bottom if {\tt a} is bottom, and
4063+- otherwise equal to {\tt b}. In other words, it evaluates the first
4064+- argument {\tt a} to weak head normal form (WHNF). {\tt seq} is usually
4065+- introduced to improve performance by avoiding unneeded laziness.
4066+-
4067+- A note on evaluation order: the expression {\tt seq a b} does
4068+- {\it not} guarantee that {\tt a} will be evaluated before {\tt b}.
4069+- The only guarantee given by {\tt seq} is that the both {\tt a}
4070+- and {\tt b} will be evaluated before {\tt seq} returns a value.
4071+- In particular, this means that {\tt b} may be evaluated before
4072+- {\tt a}. If you need to guarantee a specific order of evaluation,
4073+- you must use the function {\tt pseq} from the "parallel" package. }
4074+-
4075+-pseudoop "unsafeCoerce#"
4076+- a -> b
4077+- { The function {\tt unsafeCoerce\#} allows you to side-step the typechecker entirely. That
4078+- is, it allows you to coerce any type into any other type. If you use this function,
4079+- you had better get it right, otherwise segmentation faults await. It is generally
4080+- used when you want to write a program that you know is well-typed, but where Haskell's
4081+- type system is not expressive enough to prove that it is well typed.
4082+-
4083+- The following uses of {\tt unsafeCoerce\#} are supposed to work (i.e. not lead to
4084+- spurious compile-time or run-time crashes):
4085+-
4086+- * Casting any lifted type to {\tt Any}
4087+-
4088+- * Casting {\tt Any} back to the real type
4089+-
4090+- * Casting an unboxed type to another unboxed type of the same size.
4091+- (Casting between floating-point and integral types does not work.
4092+- See the {\tt GHC.Float} module for functions to do work.)
4093+-
4094+- * Casting between two types that have the same runtime representation. One case is when
4095+- the two types differ only in "phantom" type parameters, for example
4096+- {\tt Ptr Int} to {\tt Ptr Float}, or {\tt [Int]} to {\tt [Float]} when the list is
4097+- known to be empty. Also, a {\tt newtype} of a type {\tt T} has the same representation
4098+- at runtime as {\tt T}.
4099+-
4100+- Other uses of {\tt unsafeCoerce\#} are undefined. In particular, you should not use
4101+- {\tt unsafeCoerce\#} to cast a T to an algebraic data type D, unless T is also
4102+- an algebraic data type. For example, do not cast {\tt Int->Int} to {\tt Bool}, even if
4103+- you later cast that {\tt Bool} back to {\tt Int->Int} before applying it. The reasons
4104+- have to do with GHC's internal representation details (for the cognoscenti, data values
4105+- can be entered but function closures cannot). If you want a safe type to cast things
4106+- to, use {\tt Any}, which is not an algebraic data type.
4107+-
4108+- }
4109+-
4110+--- NB. It is tempting to think that casting a value to a type that it doesn't have is safe
4111+--- as long as you don't "do anything" with the value in its cast form, such as seq on it. This
4112+--- isn't the case: the compiler can insert seqs itself, and if these happen at the wrong type,
4113+--- Bad Things Might Happen. See bug #1616: in this case we cast a function of type (a,b) -> (a,b)
4114+--- to () -> () and back again. The strictness analyser saw that the function was strict, but
4115+--- the wrapper had type () -> (), and hence the wrapper de-constructed the (), the worker re-constructed
4116+--- a new (), with the result that the code ended up with "case () of (a,b) -> ...".
4117+-
4118+-primop TraceEventOp "traceEvent#" GenPrimOp
4119+- Addr# -> State# s -> State# s
4120+- { Emits an event via the RTS tracing framework. The contents
4121+- of the event is the zero-terminated byte string passed as the first
4122+- argument. The event will be emitted either to the .eventlog file,
4123+- or to stderr, depending on the runtime RTS flags. }
4124+- with
4125+- has_side_effects = True
4126+- out_of_line = True
4127+-
4128+-primop TraceMarkerOp "traceMarker#" GenPrimOp
4129+- Addr# -> State# s -> State# s
4130+- { Emits a marker event via the RTS tracing framework. The contents
4131+- of the event is the zero-terminated byte string passed as the first
4132+- argument. The event will be emitted either to the .eventlog file,
4133+- or to stderr, depending on the runtime RTS flags. }
4134+- with
4135+- has_side_effects = True
4136+- out_of_line = True
4137+-
4138+-------------------------------------------------------------------------
4139+-section "Safe coercions"
4140+-------------------------------------------------------------------------
4141+-
4142+-pseudoop "coerce"
4143+- Coercible a b => a -> b
4144+- { The function {\tt coerce} allows you to safely convert between values of
4145+- types that have the same representation with no run-time overhead. In the
4146+- simplest case you can use it instead of a newtype constructor, to go from
4147+- the newtype's concrete type to the abstract type. But it also works in
4148+- more complicated settings, e.g. converting a list of newtypes to a list of
4149+- concrete types.
4150+- }
4151+-
4152+-------------------------------------------------------------------------
4153+-section "SIMD Vectors"
4154+- {Operations on SIMD vectors.}
4155+-------------------------------------------------------------------------
4156+-
4157+-#define ALL_VECTOR_TYPES \
4158+- [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
4159+- ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
4160+- ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
4161+- ,<Word8,Word#,16>,<Word16,Word#,8>,<Word32,WORD32,4>,<Word64,WORD64,2> \
4162+- ,<Word8,Word#,32>,<Word16,Word#,16>,<Word32,WORD32,8>,<Word64,WORD64,4> \
4163+- ,<Word8,Word#,64>,<Word16,Word#,32>,<Word32,WORD32,16>,<Word64,WORD64,8> \
4164+- ,<Float,Float#,4>,<Double,Double#,2> \
4165+- ,<Float,Float#,8>,<Double,Double#,4> \
4166+- ,<Float,Float#,16>,<Double,Double#,8>]
4167+-
4168+-#define SIGNED_VECTOR_TYPES \
4169+- [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
4170+- ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
4171+- ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
4172+- ,<Float,Float#,4>,<Double,Double#,2> \
4173+- ,<Float,Float#,8>,<Double,Double#,4> \
4174+- ,<Float,Float#,16>,<Double,Double#,8>]
4175+-
4176+-#define FLOAT_VECTOR_TYPES \
4177+- [<Float,Float#,4>,<Double,Double#,2> \
4178+- ,<Float,Float#,8>,<Double,Double#,4> \
4179+- ,<Float,Float#,16>,<Double,Double#,8>]
4180+-
4181+-#define INT_VECTOR_TYPES \
4182+- [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
4183+- ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
4184+- ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
4185+- ,<Word8,Word#,16>,<Word16,Word#,8>,<Word32,WORD32,4>,<Word64,WORD64,2> \
4186+- ,<Word8,Word#,32>,<Word16,Word#,16>,<Word32,WORD32,8>,<Word64,WORD64,4> \
4187+- ,<Word8,Word#,64>,<Word16,Word#,32>,<Word32,WORD32,16>,<Word64,WORD64,8>]
4188+-
4189+-primtype VECTOR
4190+- with llvm_only = True
4191+- vector = ALL_VECTOR_TYPES
4192+-
4193+-primop VecBroadcastOp "broadcast#" GenPrimOp
4194+- SCALAR -> VECTOR
4195+- { Broadcast a scalar to all elements of a vector. }
4196+- with llvm_only = True
4197+- vector = ALL_VECTOR_TYPES
4198+-
4199+-primop VecPackOp "pack#" GenPrimOp
4200+- VECTUPLE -> VECTOR
4201+- { Pack the elements of an unboxed tuple into a vector. }
4202+- with llvm_only = True
4203+- vector = ALL_VECTOR_TYPES
4204+-
4205+-primop VecUnpackOp "unpack#" GenPrimOp
4206+- VECTOR -> VECTUPLE
4207+- { Unpack the elements of a vector into an unboxed tuple. #}
4208+- with llvm_only = True
4209+- vector = ALL_VECTOR_TYPES
4210+-
4211+-primop VecInsertOp "insert#" GenPrimOp
4212+- VECTOR -> SCALAR -> Int# -> VECTOR
4213+- { Insert a scalar at the given position in a vector. }
4214+- with can_fail = True
4215+- llvm_only = True
4216+- vector = ALL_VECTOR_TYPES
4217+-
4218+-primop VecAddOp "plus#" Dyadic
4219+- VECTOR -> VECTOR -> VECTOR
4220+- { Add two vectors element-wise. }
4221+- with commutable = True
4222+- llvm_only = True
4223+- vector = ALL_VECTOR_TYPES
4224+-
4225+-primop VecSubOp "minus#" Dyadic
4226+- VECTOR -> VECTOR -> VECTOR
4227+- { Subtract two vectors element-wise. }
4228+- with llvm_only = True
4229+- vector = ALL_VECTOR_TYPES
4230+-
4231+-primop VecMulOp "times#" Dyadic
4232+- VECTOR -> VECTOR -> VECTOR
4233+- { Multiply two vectors element-wise. }
4234+- with commutable = True
4235+- llvm_only = True
4236+- vector = ALL_VECTOR_TYPES
4237+-
4238+-primop VecDivOp "divide#" Dyadic
4239+- VECTOR -> VECTOR -> VECTOR
4240+- { Divide two vectors element-wise. }
4241+- with can_fail = True
4242+- llvm_only = True
4243+- vector = FLOAT_VECTOR_TYPES
4244+-
4245+-primop VecQuotOp "quot#" Dyadic
4246+- VECTOR -> VECTOR -> VECTOR
4247+- { Rounds towards zero element-wise. }
4248+- with can_fail = True
4249+- llvm_only = True
4250+- vector = INT_VECTOR_TYPES
4251+-
4252+-primop VecRemOp "rem#" Dyadic
4253+- VECTOR -> VECTOR -> VECTOR
4254+- { Satisfies \texttt{(quot\# x y) times\# y plus\# (rem\# x y) == x}. }
4255+- with can_fail = True
4256+- llvm_only = True
4257+- vector = INT_VECTOR_TYPES
4258+-
4259+-primop VecNegOp "negate#" Monadic
4260+- VECTOR -> VECTOR
4261+- { Negate element-wise. }
4262+- with llvm_only = True
4263+- vector = SIGNED_VECTOR_TYPES
4264+-
4265+-primop VecIndexByteArrayOp "indexArray#" GenPrimOp
4266+- ByteArray# -> Int# -> VECTOR
4267+- { Read a vector from specified index of immutable array. }
4268+- with can_fail = True
4269+- llvm_only = True
4270+- vector = ALL_VECTOR_TYPES
4271+-
4272+-primop VecReadByteArrayOp "readArray#" GenPrimOp
4273+- MutableByteArray# s -> Int# -> State# s -> (# State# s, VECTOR #)
4274+- { Read a vector from specified index of mutable array. }
4275+- with has_side_effects = True
4276+- can_fail = True
4277+- llvm_only = True
4278+- vector = ALL_VECTOR_TYPES
4279+-
4280+-primop VecWriteByteArrayOp "writeArray#" GenPrimOp
4281+- MutableByteArray# s -> Int# -> VECTOR -> State# s -> State# s
4282+- { Write a vector to specified index of mutable array. }
4283+- with has_side_effects = True
4284+- can_fail = True
4285+- llvm_only = True
4286+- vector = ALL_VECTOR_TYPES
4287+-
4288+-primop VecIndexOffAddrOp "indexOffAddr#" GenPrimOp
4289+- Addr# -> Int# -> VECTOR
4290+- { Reads vector; offset in bytes. }
4291+- with can_fail = True
4292+- llvm_only = True
4293+- vector = ALL_VECTOR_TYPES
4294+-
4295+-primop VecReadOffAddrOp "readOffAddr#" GenPrimOp
4296+- Addr# -> Int# -> State# s -> (# State# s, VECTOR #)
4297+- { Reads vector; offset in bytes. }
4298+- with has_side_effects = True
4299+- can_fail = True
4300+- llvm_only = True
4301+- vector = ALL_VECTOR_TYPES
4302+-
4303+-primop VecWriteOffAddrOp "writeOffAddr#" GenPrimOp
4304+- Addr# -> Int# -> VECTOR -> State# s -> State# s
4305+- { Write vector; offset in bytes. }
4306+- with has_side_effects = True
4307+- can_fail = True
4308+- llvm_only = True
4309+- vector = ALL_VECTOR_TYPES
4310+-
4311+-
4312+-primop VecIndexScalarByteArrayOp "indexArrayAs#" GenPrimOp
4313+- ByteArray# -> Int# -> VECTOR
4314+- { Read a vector from specified index of immutable array of scalars; offset is in scalar elements. }
4315+- with can_fail = True
4316+- llvm_only = True
4317+- vector = ALL_VECTOR_TYPES
4318+-
4319+-primop VecReadScalarByteArrayOp "readArrayAs#" GenPrimOp
4320+- MutableByteArray# s -> Int# -> State# s -> (# State# s, VECTOR #)
4321+- { Read a vector from specified index of mutable array of scalars; offset is in scalar elements. }
4322+- with has_side_effects = True
4323+- can_fail = True
4324+- llvm_only = True
4325+- vector = ALL_VECTOR_TYPES
4326+-
4327+-primop VecWriteScalarByteArrayOp "writeArrayAs#" GenPrimOp
4328+- MutableByteArray# s -> Int# -> VECTOR -> State# s -> State# s
4329+- { Write a vector to specified index of mutable array of scalars; offset is in scalar elements. }
4330+- with has_side_effects = True
4331+- can_fail = True
4332+- llvm_only = True
4333+- vector = ALL_VECTOR_TYPES
4334+-
4335+-primop VecIndexScalarOffAddrOp "indexOffAddrAs#" GenPrimOp
4336+- Addr# -> Int# -> VECTOR
4337+- { Reads vector; offset in scalar elements. }
4338+- with can_fail = True
4339+- llvm_only = True
4340+- vector = ALL_VECTOR_TYPES
4341+-
4342+-primop VecReadScalarOffAddrOp "readOffAddrAs#" GenPrimOp
4343+- Addr# -> Int# -> State# s -> (# State# s, VECTOR #)
4344+- { Reads vector; offset in scalar elements. }
4345+- with has_side_effects = True
4346+- can_fail = True
4347+- llvm_only = True
4348+- vector = ALL_VECTOR_TYPES
4349+-
4350+-primop VecWriteScalarOffAddrOp "writeOffAddrAs#" GenPrimOp
4351+- Addr# -> Int# -> VECTOR -> State# s -> State# s
4352+- { Write vector; offset in scalar elements. }
4353+- with has_side_effects = True
4354+- can_fail = True
4355+- llvm_only = True
4356+- vector = ALL_VECTOR_TYPES
4357+-
4358+-------------------------------------------------------------------------
4359+-
4360+-section "Prefetch"
4361+- {Prefetch operations: Note how every prefetch operation has a name
4362+- with the pattern prefetch*N#, where N is either 0,1,2, or 3.
4363+-
4364+- This suffix number, N, is the "locality level" of the prefetch, following the
4365+- convention in GCC and other compilers.
4366+- Higher locality numbers correspond to the memory being loaded in more
4367+- levels of the cpu cache, and being retained after initial use. The naming
4368+- convention follows the naming convention of the prefetch intrinsic found
4369+- in the GCC and Clang C compilers.
4370+-
4371+- On the LLVM backend, prefetch*N# uses the LLVM prefetch intrinsic
4372+- with locality level N. The code generated by LLVM is target architecture
4373+- dependent, but should agree with the GHC NCG on x86 systems.
4374+-
4375+- On the Sparc and PPC native backends, prefetch*N is a No-Op.
4376+-
4377+- On the x86 NCG, N=0 will generate prefetchNTA,
4378+- N=1 generates prefetcht2, N=2 generates prefetcht1, and
4379+- N=3 generates prefetcht0.
4380+-
4381+- For streaming workloads, the prefetch*0 operations are recommended.
4382+- For workloads which do many reads or writes to a memory location in a short period of time,
4383+- prefetch*3 operations are recommended.
4384+-
4385+- For further reading about prefetch and associated systems performance optimization,
4386+- the instruction set and optimization manuals by Intel and other CPU vendors are
4387+- excellent starting place.
4388+-
4389+-
4390+- The "Intel 64 and IA-32 Architectures Optimization Reference Manual" is
4391+- especially a helpful read, even if your software is meant for other CPU
4392+- architectures or vendor hardware. The manual can be found at
4393+- http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-optimization-manual.html .
4394+-
4395+- The {\tt prefetch*} family of operations has the order of operations
4396+- determined by passing around the {\tt State#} token.
4397+-
4398+- To get a "pure" version of these operations, use {\tt inlinePerformIO} which is quite safe in this context.
4399+-
4400+- It is important to note that while the prefetch operations will never change the
4401+- answer to a pure computation, They CAN change the memory locations resident
4402+- in a CPU cache and that may change the performance and timing characteristics
4403+- of an application. The prefetch operations are marked has_side_effects=True
4404+- to reflect that these operations have side effects with respect to the runtime
4405+- performance characteristics of the resulting code. Additionally, if the prefetchValue
4406+- operations did not have this attribute, GHC does a float out transformation that
4407+- results in a let/app violation, at least with the current design.
4408+- }
4409+-
4410+-
4411+-
4412+-------------------------------------------------------------------------
4413+-
4414+-
4415+---- the Int# argument for prefetch is the byte offset on the byteArray or Addr#
4416+-
4417+----
4418+-primop PrefetchByteArrayOp3 "prefetchByteArray3#" GenPrimOp
4419+- ByteArray# -> Int# -> State# s -> State# s
4420+- with has_side_effects = True
4421+-
4422+-primop PrefetchMutableByteArrayOp3 "prefetchMutableByteArray3#" GenPrimOp
4423+- MutableByteArray# s -> Int# -> State# s -> State# s
4424+- with has_side_effects = True
4425+-
4426+-primop PrefetchAddrOp3 "prefetchAddr3#" GenPrimOp
4427+- Addr# -> Int# -> State# s -> State# s
4428+- with has_side_effects = True
4429+-
4430+-primop PrefetchValueOp3 "prefetchValue3#" GenPrimOp
4431+- a -> State# s -> State# s
4432+- with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
4433+- has_side_effects = True
4434+-----
4435+-
4436+-primop PrefetchByteArrayOp2 "prefetchByteArray2#" GenPrimOp
4437+- ByteArray# -> Int# -> State# s -> State# s
4438+- with has_side_effects = True
4439+-
4440+-primop PrefetchMutableByteArrayOp2 "prefetchMutableByteArray2#" GenPrimOp
4441+- MutableByteArray# s -> Int# -> State# s -> State# s
4442+- with has_side_effects = True
4443+-
4444+-primop PrefetchAddrOp2 "prefetchAddr2#" GenPrimOp
4445+- Addr# -> Int# -> State# s -> State# s
4446+- with has_side_effects = True
4447+-
4448+-primop PrefetchValueOp2 "prefetchValue2#" GenPrimOp
4449+- a -> State# s -> State# s
4450+- with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
4451+- has_side_effects = True
4452+-----
4453+-
4454+-primop PrefetchByteArrayOp1 "prefetchByteArray1#" GenPrimOp
4455+- ByteArray# -> Int# -> State# s -> State# s
4456+- with has_side_effects = True
4457+-
4458+-primop PrefetchMutableByteArrayOp1 "prefetchMutableByteArray1#" GenPrimOp
4459+- MutableByteArray# s -> Int# -> State# s -> State# s
4460+- with has_side_effects = True
4461+-
4462+-primop PrefetchAddrOp1 "prefetchAddr1#" GenPrimOp
4463+- Addr# -> Int# -> State# s -> State# s
4464+- with has_side_effects = True
4465+-
4466+-primop PrefetchValueOp1 "prefetchValue1#" GenPrimOp
4467+- a -> State# s -> State# s
4468+- with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
4469+- has_side_effects = True
4470+-----
4471+-
4472+-primop PrefetchByteArrayOp0 "prefetchByteArray0#" GenPrimOp
4473+- ByteArray# -> Int# -> State# s -> State# s
4474+- with has_side_effects = True
4475+-
4476+-primop PrefetchMutableByteArrayOp0 "prefetchMutableByteArray0#" GenPrimOp
4477+- MutableByteArray# s -> Int# -> State# s -> State# s
4478+- with has_side_effects = True
4479+-
4480+-primop PrefetchAddrOp0 "prefetchAddr0#" GenPrimOp
4481+- Addr# -> Int# -> State# s -> State# s
4482+- with has_side_effects = True
4483+-
4484+-primop PrefetchValueOp0 "prefetchValue0#" GenPrimOp
4485+- a -> State# s -> State# s
4486+- with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
4487+- has_side_effects = True
4488+-
4489+-------------------------------------------------------------------------
4490+---- ---
4491+-------------------------------------------------------------------------
4492+-
4493+-thats_all_folks
4494+diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs
4495+index c3c8ae3..32fb8f5 100644
4496+--- a/compiler/utils/Binary.hs
4497++++ b/compiler/utils/Binary.hs
4498+@@ -58,7 +58,7 @@ module Binary
4499+ #include "HsVersions.h"
4500+
4501+ -- The *host* architecture version:
4502+-#include "../includes/MachDeps.h"
4503++#include "MachDeps.h"
4504+
4505+ import GhcPrelude
4506+
4507+diff --git a/ghc.mk b/ghc.mk
4508+index 38c165d..7cb7913 100644
4509+--- a/ghc.mk
4510++++ b/ghc.mk
4511+@@ -593,26 +593,6 @@ BOOT_LIBS = $(foreach lib,$(PACKAGES_STAGE0),$(libraries/$(lib)_dist-boot_v_LIB)
4512+ # Only build internal interpreter support for the stage2 ghci lib
4513+ libraries/ghci_dist-install_CONFIGURE_OPTS += --flags=ghci
4514+
4515+-# ----------------------------------------
4516+-# Special magic for the ghc-prim package
4517+-
4518+-# We want the ghc-prim package to include the GHC.Prim module when it
4519+-# is registered, but not when it is built, because GHC.Prim is not a
4520+-# real source module, it is built-in to GHC.
4521+-
4522+-# Strip it out again before building the package:
4523+-define libraries/ghc-prim_PACKAGE_MAGIC
4524+-libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
4525+-endef
4526+-
4527+-PRIMOPS_TXT_STAGE1 = compiler/stage1/build/primops.txt
4528+-
4529+-libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $$(genprimopcode_INPLACE) $(PRIMOPS_TXT_STAGE1) | $$(dir $$@)/.
4530+- "$(genprimopcode_INPLACE)" --make-haskell-wrappers < $(PRIMOPS_TXT_STAGE1) >$@
4531+-
4532+-# Required so that Haddock documents the primops.
4533+-libraries/ghc-prim_dist-install_EXTRA_HADDOCK_SRCS = libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
4534+-
4535+ # ----------------------------------------
4536+ # Special magic for the integer package
4537+
4538+diff --git a/ghc/ghc.mk b/ghc/ghc.mk
4539+index 20fa142..ad4b7c2 100644
4540+--- a/ghc/ghc.mk
4541++++ b/ghc/ghc.mk
4542+@@ -14,10 +14,6 @@ ghc_USES_CABAL = YES
4543+ ghc_PACKAGE = ghc-bin
4544+ ghc_EXECUTABLE = ghc
4545+
4546+-ghc_stage1_CONFIGURE_OPTS += --flags=stage1
4547+-ghc_stage2_CONFIGURE_OPTS += --flags=stage2
4548+-ghc_stage3_CONFIGURE_OPTS += --flags=stage3
4549+-
4550+ ifeq "$(GhcWithInterpreter)" "YES"
4551+ ghc_stage2_CONFIGURE_OPTS += --flags=ghci
4552+ ghc_stage3_CONFIGURE_OPTS += --flags=ghci
4553+@@ -121,9 +117,9 @@ ghc/stage2/build/tmp/$(ghc_stage2_PROG) : $(foreach lib,$(PACKAGES_STAGE1),$(lib
4554+ endif
4555+
4556+ # Modules here import HsVersions.h, so we need ghc_boot_platform.h
4557+-$(ghc_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
4558+-$(ghc_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
4559+-$(ghc_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
4560++$(ghc_stage1_depfile_haskell) : libraries/ghc-prim/dist-boot/$(PLATFORM_H)
4561++$(ghc_stage2_depfile_haskell) : libraries/ghc-prim/dist-install/$(PLATFORM_H)
4562++$(ghc_stage3_depfile_haskell) : libraries/ghc-prim/dist-install/$(PLATFORM_H)
4563+
4564+ all_ghc_stage1 : $(GHC_STAGE1)
4565+ all_ghc_stage2 : $(GHC_STAGE2)
4566+@@ -173,6 +169,12 @@ endif
4567+ INSTALL_LIBS += settings
4568+ INSTALL_LIBS += llvm-targets
4569+
4570++# A rather nasty hack needed because we still have headers in
4571++# ghc-prim and rts.
4572++ghc_stage1_HC_OPTS += -Irts/build -Ilibraries/ghc-prim/dist-boot
4573++ghc_stage2_HC_OPTS += -Irts/build -Ilibraries/ghc-prim/dist-install
4574++ghc_stage3_HC_OPTS += -Irts/build -Ilibraries/ghc-prim/dist-install
4575++
4576+ ifeq "$(Windows_Host)" "NO"
4577+ install: install_ghc_link
4578+ .PHONY: install_ghc_link
4579+diff --git a/includes/ghc.mk b/includes/ghc.mk
4580+index d08ecfb..9358950 100644
4581+--- a/includes/ghc.mk
4582++++ b/includes/ghc.mk
4583+@@ -229,4 +229,6 @@ install_includes :
4584+ $(INSTALL_HEADER) $(INSTALL_OPTS) includes/$d/*.h "$(DESTDIR)$(ghcheaderdir)/$d/" && \
4585+ ) true
4586+ $(INSTALL_HEADER) $(INSTALL_OPTS) $(includes_H_CONFIG) $(includes_H_PLATFORM) $(includes_H_VERSION) $(includes_DERIVEDCONSTANTS) "$(DESTDIR)$(ghcheaderdir)/"
4587++ $(INSTALL_HEADER) rts/build/*.h rts/build/*.hs-incl includes/CodeGen.Platform.hs "$(DESTDIR)$(ghcheaderdir)/"
4588++ $(INSTALL_HEADER) $(includes_GHCCONSTANTS_HASKELL_TYPE) $(includes_GHCCONSTANTS_HASKELL_VALUE) $(includes_GHCCONSTANTS_HASKELL_WRAPPERS) $(includes_GHCCONSTANTS_HASKELL_EXPORTS) "$(DESTDIR)$(ghcheaderdir)/"
4589+
4590+diff --git a/libraries/ghc-prim/ghc-prim.cabal b/libraries/ghc-prim/ghc-prim.cabal
4591+index f395c9f..099ebeb 100644
4592+--- a/libraries/ghc-prim/ghc-prim.cabal
4593++++ b/libraries/ghc-prim/ghc-prim.cabal
4594+@@ -12,6 +12,16 @@ build-type: Custom
4595+ description:
4596+ This package contains the primitive types and operations supplied by GHC.
4597+
4598++Flag boot
4599++ Description: Is this stage 1?
4600++ Default: False
4601++ Manual: True
4602++
4603++Flag install
4604++ Description: Is this stage 2?
4605++ Default: True
4606++ Manual: True
4607++
4608+ extra-source-files: changelog.md
4609+
4610+ source-repository head
4611+@@ -81,3 +91,27 @@ Library
4612+ -- We need to set the unit ID to ghc-prim (without a version number)
4613+ -- as it's magic.
4614+ ghc-options: -this-unit-id ghc-prim
4615++
4616++ if flag(boot)
4617++ include-dirs: dist-boot
4618++ else
4619++ if flag(install)
4620++ include-dirs: dist-install
4621++
4622++ install-includes:
4623++ ghc_boot_platform.h
4624++ primop-data-decl.hs-incl
4625++ primop-tag.hs-incl
4626++ primop-list.hs-incl
4627++ primop-has-side-effects.hs-incl
4628++ primop-out-of-line.hs-incl
4629++ primop-commutable.hs-incl
4630++ primop-code-size.hs-incl
4631++ primop-can-fail.hs-incl
4632++ primop-strictness.hs-incl
4633++ primop-fixity.hs-incl
4634++ primop-primop-info.hs-incl
4635++ primop-vector-uniques.hs-incl
4636++ primop-vector-tys.hs-incl
4637++ primop-vector-tys-exports.hs-incl
4638++ primop-vector-tycons.hs-incl
4639+\ No newline at end of file
4640+diff --git a/libraries/ghc-prim/ghc.mk b/libraries/ghc-prim/ghc.mk
4641+index 03740bf..5b09478 100644
4642+--- a/libraries/ghc-prim/ghc.mk
4643++++ b/libraries/ghc-prim/ghc.mk
4644+@@ -1,5 +1,202 @@
4645+ libraries/ghc-prim_PACKAGE = ghc-prim
4646+ libraries/ghc-prim_dist-install_GROUP = libraries
4647++
4648++libraries/ghc-prim_stage1_CONFIGURE_OPTS += --flags=boot
4649++libraries/ghc-prim_stage2_CONFIGURE_OPTS += --flags=install
4650++libraries/ghc-prim_stage3_CONFIGURE_OPTS += --flags=install
4651++
4652++
4653++# ----------------------------------------
4654++# Special magic for the ghc-prim package
4655++
4656++# We want the ghc-prim package to include the GHC.Prim module when it
4657++# is registered, but not when it is built, because GHC.Prim is not a
4658++# real source module, it is built-in to GHC.
4659++
4660++# Strip it out again before building the package:
4661++define libraries/ghc-prim_PACKAGE_MAGIC
4662++libraries/ghc-prim_dist-install_MODULES := $$(filter-out GHC.Prim,$$(libraries/ghc-prim_dist-install_MODULES))
4663++endef
4664++
4665++PRIMOPS_TXT_STAGE1 = libraries/ghc-prim/dist-boot/primops.txt
4666++
4667++libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $$(genprimopcode_INPLACE) $(PRIMOPS_TXT_STAGE1) | $$(dir $$@)/.
4668++ "$(genprimopcode_INPLACE)" --make-haskell-wrappers < $(PRIMOPS_TXT_STAGE1) >$@
4669++
4670++# Required so that Haddock documents the primops.
4671++libraries/ghc-prim_dist-install_EXTRA_HADDOCK_SRCS = libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
4672++
4673++
4674++# -----------------------------------------------------------------------------
4675++# Create platform includes
4676++
4677++# Here we generate a little header file containing CPP symbols that GHC
4678++# uses to determine which platform it is building on/for. The platforms
4679++# can differ between stage1 and stage2 if we're cross-compiling, so we
4680++# need one of these header files per stage.
4681++
4682++PLATFORM_H = ghc_boot_platform.h
4683++
4684++libraries/ghc-prim/dist-boot/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
4685++ $(call removeFiles,$@)
4686++ @echo "Creating $@..."
4687++ @echo "#ifndef __PLATFORM_H__" >> $@
4688++ @echo "#define __PLATFORM_H__" >> $@
4689++ @echo >> $@
4690++ @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
4691++ @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
4692++ @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
4693++ @echo >> $@
4694++ @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
4695++ @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
4696++ @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
4697++ @echo >> $@
4698++ @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
4699++ @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
4700++ @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
4701++ @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
4702++ @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
4703++ @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
4704++ @echo "#define LLVM_TARGET \"$(LLVMTarget_CPP)\"" >> $@
4705++ @echo >> $@
4706++ @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
4707++ @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
4708++ @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
4709++ @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
4710++ @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
4711++ @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
4712++ @echo >> $@
4713++ @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
4714++ @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
4715++ @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
4716++ @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
4717++ @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
4718++ @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
4719++ @echo >> $@
4720++ @echo "#endif /* __PLATFORM_H__ */" >> $@
4721++ @echo "Done."
4722++
4723++# For stage2 and above, the BUILD platform is the HOST of stage1, and
4724++# the HOST platform is the TARGET of stage1. The TARGET remains the same
4725++# (stage1 is the cross-compiler, not stage2).
4726++libraries/ghc-prim/dist-install/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
4727++ $(call removeFiles,$@)
4728++ @echo "Creating $@..."
4729++ @echo "#ifndef __PLATFORM_H__" >> $@
4730++ @echo "#define __PLATFORM_H__" >> $@
4731++ @echo >> $@
4732++ @echo "#define BuildPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
4733++ @echo "#define HostPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
4734++ @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
4735++ @echo >> $@
4736++ @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
4737++ @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
4738++ @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
4739++ @echo >> $@
4740++ @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
4741++ @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
4742++ @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
4743++ @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
4744++ @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
4745++ @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
4746++ @echo "#define LLVM_TARGET \"$(LLVMTarget_CPP)\"" >> $@
4747++ @echo >> $@
4748++ @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
4749++ @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
4750++ @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
4751++ @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
4752++ @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
4753++ @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
4754++ @echo >> $@
4755++ @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
4756++ @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
4757++ @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
4758++ @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
4759++ @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
4760++ @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
4761++ @echo >> $@
4762++ @echo "#endif /* __PLATFORM_H__ */" >> $@
4763++ @echo "Done."
4764++
4765++# ----------------------------------------------------------------------------
4766++# Generate supporting stuff for prelude/PrimOp.hs
4767++# from prelude/primops.txt
4768++
4769++PRIMOP_BITS_NAMES = primop-data-decl.hs-incl \
4770++ primop-tag.hs-incl \
4771++ primop-list.hs-incl \
4772++ primop-has-side-effects.hs-incl \
4773++ primop-out-of-line.hs-incl \
4774++ primop-commutable.hs-incl \
4775++ primop-code-size.hs-incl \
4776++ primop-can-fail.hs-incl \
4777++ primop-strictness.hs-incl \
4778++ primop-fixity.hs-incl \
4779++ primop-primop-info.hs-incl \
4780++ primop-vector-uniques.hs-incl \
4781++ primop-vector-tys.hs-incl \
4782++ primop-vector-tys-exports.hs-incl \
4783++ primop-vector-tycons.hs-incl
4784++
4785++PRIMOP_BITS_STAGE1 = $(addprefix libraries/ghc-prim/dist-boot/,$(PRIMOP_BITS_NAMES))
4786++PRIMOP_BITS_STAGE2 = $(addprefix libraries/ghc-prim/dist-install/,$(PRIMOP_BITS_NAMES))
4787++PRIMOP_BITS_STAGE3 = $(addprefix libraries/ghc-prim/dist-install/,$(PRIMOP_BITS_NAMES))
4788++
4789++compiler_CPP_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
4790++compiler_CPP_OPTS += ${GhcCppOpts}
4791++
4792++# We add these paths to the Haskell compiler's #include search path list since
4793++# we must avoid #including files by paths relative to the source file as Hadrian
4794++# moves the build artifacts out of the source tree. See #8040.
4795++compiler_HC_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
4796++
4797++define preprocessCompilerFiles
4798++# $0 = stage
4799++libraries/ghc-prim/$1/primops.txt: libraries/ghc-prim/primops.txt.pp libraries/ghc-prim/$1/$$(PLATFORM_H)
4800++ $$(HS_CPP) -P $$(compiler_CPP_OPTS) -Ilibraries/ghc-prim/$1 -x c $$< | grep -v '^#pragma GCC' > $$@
4801++
4802++libraries/ghc-prim/$1/primop-data-decl.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4803++ "$$(genprimopcode_INPLACE)" --data-decl < $$< > $$@
4804++libraries/ghc-prim/$1/primop-tag.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4805++ "$$(genprimopcode_INPLACE)" --primop-tag < $$< > $$@
4806++libraries/ghc-prim/$1/primop-list.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4807++ "$$(genprimopcode_INPLACE)" --primop-list < $$< > $$@
4808++libraries/ghc-prim/$1/primop-has-side-effects.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4809++ "$$(genprimopcode_INPLACE)" --has-side-effects < $$< > $$@
4810++libraries/ghc-prim/$1/primop-out-of-line.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4811++ "$$(genprimopcode_INPLACE)" --out-of-line < $$< > $$@
4812++libraries/ghc-prim/$1/primop-commutable.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4813++ "$$(genprimopcode_INPLACE)" --commutable < $$< > $$@
4814++libraries/ghc-prim/$1/primop-code-size.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4815++ "$$(genprimopcode_INPLACE)" --code-size < $$< > $$@
4816++libraries/ghc-prim/$1/primop-can-fail.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4817++ "$$(genprimopcode_INPLACE)" --can-fail < $$< > $$@
4818++libraries/ghc-prim/$1/primop-strictness.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4819++ "$$(genprimopcode_INPLACE)" --strictness < $$< > $$@
4820++libraries/ghc-prim/$1/primop-fixity.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4821++ "$$(genprimopcode_INPLACE)" --fixity < $$< > $$@
4822++libraries/ghc-prim/$1/primop-primop-info.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4823++ "$$(genprimopcode_INPLACE)" --primop-primop-info < $$< > $$@
4824++libraries/ghc-prim/$1/primop-vector-uniques.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4825++ "$$(genprimopcode_INPLACE)" --primop-vector-uniques < $$< > $$@
4826++libraries/ghc-prim/$1/primop-vector-tys.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4827++ "$$(genprimopcode_INPLACE)" --primop-vector-tys < $$< > $$@
4828++libraries/ghc-prim/$1/primop-vector-tys-exports.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4829++ "$$(genprimopcode_INPLACE)" --primop-vector-tys-exports < $$< > $$@
4830++libraries/ghc-prim/$1/primop-vector-tycons.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4831++ "$$(genprimopcode_INPLACE)" --primop-vector-tycons < $$< > $$@
4832++
4833++# Usages aren't used any more; but the generator
4834++# can still generate them if we want them back
4835++libraries/ghc-prim/$1/primop-usage.hs-incl: libraries/ghc-prim/$1/primops.txt $$$$(genprimopcode_INPLACE)
4836++ "$$(genprimopcode_INPLACE)" --usage < $$< > $$@
4837++
4838++endef
4839++
4840++$(eval $(call preprocessCompilerFiles,dist-boot))
4841++$(eval $(call preprocessCompilerFiles,dist-install))
4842++
4843++
4844+ $(if $(filter ghc-prim,$(PACKAGES_STAGE0)),$(eval $(call build-package,libraries/ghc-prim,dist-boot,0)))
4845+ $(if $(filter ghc-prim,$(PACKAGES_STAGE1)),$(eval $(call build-package,libraries/ghc-prim,dist-install,1)))
4846+ $(if $(filter ghc-prim,$(PACKAGES_STAGE2)),$(eval $(call build-package,libraries/ghc-prim,dist-install,2)))
4847+diff --git a/libraries/ghc-prim/primops.txt.pp b/libraries/ghc-prim/primops.txt.pp
4848+new file mode 100644
4849+index 0000000..924ac41
4850+--- /dev/null
4851++++ b/libraries/ghc-prim/primops.txt.pp
4852+@@ -0,0 +1,3295 @@
4853++-----------------------------------------------------------------------
4854++--
4855++-- (c) 2010 The University of Glasgow
4856++--
4857++-- Primitive Operations and Types
4858++--
4859++-- For more information on PrimOps, see
4860++-- http://ghc.haskell.org/trac/ghc/wiki/Commentary/PrimOps
4861++--
4862++-----------------------------------------------------------------------
4863++
4864++-- This file is processed by the utility program genprimopcode to produce
4865++-- a number of include files within the compiler and optionally to produce
4866++-- human-readable documentation.
4867++--
4868++-- It should first be preprocessed.
4869++--
4870++-- Information on how PrimOps are implemented and the steps necessary to
4871++-- add a new one can be found in the Commentary:
4872++--
4873++-- http://ghc.haskell.org/trac/ghc/wiki/Commentary/PrimOps
4874++
4875++-- This file is divided into named sections, each containing or more
4876++-- primop entries. Section headers have the format:
4877++--
4878++-- section "section-name" {description}
4879++--
4880++-- This information is used solely when producing documentation; it is
4881++-- otherwise ignored. The description is optional.
4882++--
4883++-- The format of each primop entry is as follows:
4884++--
4885++-- primop internal-name "name-in-program-text" type category {description} attributes
4886++
4887++-- The default attribute values which apply if you don't specify
4888++-- other ones. Attribute values can be True, False, or arbitrary
4889++-- text between curly brackets. This is a kludge to enable
4890++-- processors of this file to easily get hold of simple info
4891++-- (eg, out_of_line), whilst avoiding parsing complex expressions
4892++-- needed for strictness info.
4893++--
4894++-- type refers to the general category of the primop. Valid settings include,
4895++--
4896++-- * Compare: A comparison operation of the shape a -> a -> Int#
4897++-- * Monadic: A unary operation of shape a -> a
4898++-- * Dyadic: A binary operation of shape a -> a -> a
4899++-- * GenPrimOp: Any other sort of primop
4900++--
4901++
4902++-- The vector attribute is rather special. It takes a list of 3-tuples, each of
4903++-- which is of the form <ELEM_TYPE,SCALAR_TYPE,LENGTH>. ELEM_TYPE is the type of
4904++-- the elements in the vector; LENGTH is the length of the vector; and
4905++-- SCALAR_TYPE is the scalar type used to inject to/project from vector
4906++-- element. Note that ELEM_TYPE and SCALAR_TYPE are not the same; for example,
4907++-- to broadcast a scalar value to a vector whose elements are of type Int8, we
4908++-- use an Int#.
4909++
4910++-- When a primtype or primop has a vector attribute, it is instantiated at each
4911++-- 3-tuple in the list of 3-tuples. That is, the vector attribute allows us to
4912++-- define a family of types or primops. Vector support also adds three new
4913++-- keywords: VECTOR, SCALAR, and VECTUPLE. These keywords are expanded to types
4914++-- derived from the 3-tuple. For the 3-tuple <Int64,INT64,2>, VECTOR expands to
4915++-- Int64X2#, SCALAR expands to INT64, and VECTUPLE expands to (# INT64, INT64
4916++-- #).
4917++
4918++defaults
4919++ has_side_effects = False
4920++ out_of_line = False -- See Note Note [PrimOp can_fail and has_side_effects] in PrimOp
4921++ can_fail = False -- See Note Note [PrimOp can_fail and has_side_effects] in PrimOp
4922++ commutable = False
4923++ code_size = { primOpCodeSizeDefault }
4924++ strictness = { \ arity -> mkClosedStrictSig (replicate arity topDmd) topRes }
4925++ fixity = Nothing
4926++ llvm_only = False
4927++ vector = []
4928++
4929++-- Currently, documentation is produced using latex, so contents of
4930++-- description fields should be legal latex. Descriptions can contain
4931++-- matched pairs of embedded curly brackets.
4932++
4933++#include "MachDeps.h"
4934++
4935++-- We need platform defines (tests for mingw32 below).
4936++#include "ghc_boot_platform.h"
4937++
4938++section "The word size story."
4939++ {Haskell98 specifies that signed integers (type {\tt Int})
4940++ must contain at least 30 bits. GHC always implements {\tt
4941++ Int} using the primitive type {\tt Int\#}, whose size equals
4942++ the {\tt MachDeps.h} constant {\tt WORD\_SIZE\_IN\_BITS}.
4943++ This is normally set based on the {\tt config.h} parameter
4944++ {\tt SIZEOF\_HSWORD}, i.e., 32 bits on 32-bit machines, 64
4945++ bits on 64-bit machines. However, it can also be explicitly
4946++ set to a smaller number, e.g., 31 bits, to allow the
4947++ possibility of using tag bits. Currently GHC itself has only
4948++ 32-bit and 64-bit variants, but 30 or 31-bit code can be
4949++ exported as an external core file for use in other back ends.
4950++
4951++ GHC also implements a primitive unsigned integer type {\tt
4952++ Word\#} which always has the same number of bits as {\tt
4953++ Int\#}.
4954++
4955++ In addition, GHC supports families of explicit-sized integers
4956++ and words at 8, 16, 32, and 64 bits, with the usual
4957++ arithmetic operations, comparisons, and a range of
4958++ conversions. The 8-bit and 16-bit sizes are always
4959++ represented as {\tt Int\#} and {\tt Word\#}, and the
4960++ operations implemented in terms of the the primops on these
4961++ types, with suitable range restrictions on the results (using
4962++ the {\tt narrow$n$Int\#} and {\tt narrow$n$Word\#} families
4963++ of primops. The 32-bit sizes are represented using {\tt
4964++ Int\#} and {\tt Word\#} when {\tt WORD\_SIZE\_IN\_BITS}
4965++ $\geq$ 32; otherwise, these are represented using distinct
4966++ primitive types {\tt Int32\#} and {\tt Word32\#}. These (when
4967++ needed) have a complete set of corresponding operations;
4968++ however, nearly all of these are implemented as external C
4969++ functions rather than as primops. Exactly the same story
4970++ applies to the 64-bit sizes. All of these details are hidden
4971++ under the {\tt PrelInt} and {\tt PrelWord} modules, which use
4972++ {\tt \#if}-defs to invoke the appropriate types and
4973++ operators.
4974++
4975++ Word size also matters for the families of primops for
4976++ indexing/reading/writing fixed-size quantities at offsets
4977++ from an array base, address, or foreign pointer. Here, a
4978++ slightly different approach is taken. The names of these
4979++ primops are fixed, but their {\it types} vary according to
4980++ the value of {\tt WORD\_SIZE\_IN\_BITS}. For example, if word
4981++ size is at least 32 bits then an operator like
4982++ \texttt{indexInt32Array\#} has type {\tt ByteArray\# -> Int\#
4983++ -> Int\#}; otherwise it has type {\tt ByteArray\# -> Int\# ->
4984++ Int32\#}. This approach confines the necessary {\tt
4985++ \#if}-defs to this file; no conditional compilation is needed
4986++ in the files that expose these primops.
4987++
4988++ Finally, there are strongly deprecated primops for coercing
4989++ between {\tt Addr\#}, the primitive type of machine
4990++ addresses, and {\tt Int\#}. These are pretty bogus anyway,
4991++ but will work on existing 32-bit and 64-bit GHC targets; they
4992++ are completely bogus when tag bits are used in {\tt Int\#},
4993++ so are not available in this case. }
4994++
4995++-- Define synonyms for indexing ops.
4996++
4997++#if WORD_SIZE_IN_BITS < 32
4998++#define INT32 Int32#
4999++#define WORD32 Word32#
5000++#else
5001++#define INT32 Int#
5002++#define WORD32 Word#
5003++#endif
5004++
5005++#if WORD_SIZE_IN_BITS < 64
5006++#define INT64 Int64#
5007++#define WORD64 Word64#
5008++#else
5009++#define INT64 Int#
5010++#define WORD64 Word#
5011++#endif
5012++
5013++------------------------------------------------------------------------
5014++section "Char#"
5015++ {Operations on 31-bit characters.}
5016++------------------------------------------------------------------------
5017++
5018++primtype Char#
5019++
5020++primop CharGtOp "gtChar#" Compare Char# -> Char# -> Int#
5021++primop CharGeOp "geChar#" Compare Char# -> Char# -> Int#
5022++
5023++primop CharEqOp "eqChar#" Compare
5024++ Char# -> Char# -> Int#
5025++ with commutable = True
5026++
5027++primop CharNeOp "neChar#" Compare
5028++ Char# -> Char# -> Int#
5029++ with commutable = True
5030++
5031++primop CharLtOp "ltChar#" Compare Char# -> Char# -> Int#
5032++primop CharLeOp "leChar#" Compare Char# -> Char# -> Int#
5033++
5034++primop OrdOp "ord#" GenPrimOp Char# -> Int#
5035++ with code_size = 0
5036++
5037++------------------------------------------------------------------------
5038++section "Int#"
5039++ {Operations on native-size integers (30+ bits).}
5040++------------------------------------------------------------------------
5041++
5042++primtype Int#
5043++
5044++primop IntAddOp "+#" Dyadic
5045++ Int# -> Int# -> Int#
5046++ with commutable = True
5047++ fixity = infixl 6
5048++
5049++primop IntSubOp "-#" Dyadic Int# -> Int# -> Int#
5050++ with fixity = infixl 6
5051++
5052++primop IntMulOp "*#"
5053++ Dyadic Int# -> Int# -> Int#
5054++ {Low word of signed integer multiply.}
5055++ with commutable = True
5056++ fixity = infixl 7
5057++
5058++primop IntMulMayOfloOp "mulIntMayOflo#"
5059++ Dyadic Int# -> Int# -> Int#
5060++ {Return non-zero if there is any possibility that the upper word of a
5061++ signed integer multiply might contain useful information. Return
5062++ zero only if you are completely sure that no overflow can occur.
5063++ On a 32-bit platform, the recommended implementation is to do a
5064++ 32 x 32 -> 64 signed multiply, and subtract result[63:32] from
5065++ (result[31] >>signed 31). If this is zero, meaning that the
5066++ upper word is merely a sign extension of the lower one, no
5067++ overflow can occur.
5068++
5069++ On a 64-bit platform it is not always possible to
5070++ acquire the top 64 bits of the result. Therefore, a recommended
5071++ implementation is to take the absolute value of both operands, and
5072++ return 0 iff bits[63:31] of them are zero, since that means that their
5073++ magnitudes fit within 31 bits, so the magnitude of the product must fit
5074++ into 62 bits.
5075++
5076++ If in doubt, return non-zero, but do make an effort to create the
5077++ correct answer for small args, since otherwise the performance of
5078++ \texttt{(*) :: Integer -> Integer -> Integer} will be poor.
5079++ }
5080++ with commutable = True
5081++
5082++primop IntQuotOp "quotInt#" Dyadic
5083++ Int# -> Int# -> Int#
5084++ {Rounds towards zero. The behavior is undefined if the second argument is
5085++ zero.
5086++ }
5087++ with can_fail = True
5088++
5089++primop IntRemOp "remInt#" Dyadic
5090++ Int# -> Int# -> Int#
5091++ {Satisfies \texttt{(quotInt\# x y) *\# y +\# (remInt\# x y) == x}. The
5092++ behavior is undefined if the second argument is zero.
5093++ }
5094++ with can_fail = True
5095++
5096++primop IntQuotRemOp "quotRemInt#" GenPrimOp
5097++ Int# -> Int# -> (# Int#, Int# #)
5098++ {Rounds towards zero.}
5099++ with can_fail = True
5100++
5101++primop AndIOp "andI#" Dyadic Int# -> Int# -> Int#
5102++ with commutable = True
5103++
5104++primop OrIOp "orI#" Dyadic Int# -> Int# -> Int#
5105++ with commutable = True
5106++
5107++primop XorIOp "xorI#" Dyadic Int# -> Int# -> Int#
5108++ with commutable = True
5109++
5110++primop NotIOp "notI#" Monadic Int# -> Int#
5111++
5112++primop IntNegOp "negateInt#" Monadic Int# -> Int#
5113++primop IntAddCOp "addIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
5114++ {Add signed integers reporting overflow.
5115++ First member of result is the sum truncated to an {\tt Int#};
5116++ second member is zero if the true sum fits in an {\tt Int#},
5117++ nonzero if overflow occurred (the sum is either too large
5118++ or too small to fit in an {\tt Int#}).}
5119++ with code_size = 2
5120++
5121++primop IntSubCOp "subIntC#" GenPrimOp Int# -> Int# -> (# Int#, Int# #)
5122++ {Subtract signed integers reporting overflow.
5123++ First member of result is the difference truncated to an {\tt Int#};
5124++ second member is zero if the true difference fits in an {\tt Int#},
5125++ nonzero if overflow occurred (the difference is either too large
5126++ or too small to fit in an {\tt Int#}).}
5127++ with code_size = 2
5128++
5129++primop IntGtOp ">#" Compare Int# -> Int# -> Int#
5130++ with fixity = infix 4
5131++
5132++primop IntGeOp ">=#" Compare Int# -> Int# -> Int#
5133++ with fixity = infix 4
5134++
5135++primop IntEqOp "==#" Compare
5136++ Int# -> Int# -> Int#
5137++ with commutable = True
5138++ fixity = infix 4
5139++
5140++primop IntNeOp "/=#" Compare
5141++ Int# -> Int# -> Int#
5142++ with commutable = True
5143++ fixity = infix 4
5144++
5145++primop IntLtOp "<#" Compare Int# -> Int# -> Int#
5146++ with fixity = infix 4
5147++
5148++primop IntLeOp "<=#" Compare Int# -> Int# -> Int#
5149++ with fixity = infix 4
5150++
5151++primop ChrOp "chr#" GenPrimOp Int# -> Char#
5152++ with code_size = 0
5153++
5154++primop Int2WordOp "int2Word#" GenPrimOp Int# -> Word#
5155++ with code_size = 0
5156++
5157++primop Int2FloatOp "int2Float#" GenPrimOp Int# -> Float#
5158++primop Int2DoubleOp "int2Double#" GenPrimOp Int# -> Double#
5159++
5160++primop Word2FloatOp "word2Float#" GenPrimOp Word# -> Float#
5161++primop Word2DoubleOp "word2Double#" GenPrimOp Word# -> Double#
5162++
5163++primop ISllOp "uncheckedIShiftL#" GenPrimOp Int# -> Int# -> Int#
5164++ {Shift left. Result undefined if shift amount is not
5165++ in the range 0 to word size - 1 inclusive.}
5166++primop ISraOp "uncheckedIShiftRA#" GenPrimOp Int# -> Int# -> Int#
5167++ {Shift right arithmetic. Result undefined if shift amount is not
5168++ in the range 0 to word size - 1 inclusive.}
5169++primop ISrlOp "uncheckedIShiftRL#" GenPrimOp Int# -> Int# -> Int#
5170++ {Shift right logical. Result undefined if shift amount is not
5171++ in the range 0 to word size - 1 inclusive.}
5172++
5173++------------------------------------------------------------------------
5174++section "Word#"
5175++ {Operations on native-sized unsigned words (30+ bits).}
5176++------------------------------------------------------------------------
5177++
5178++primtype Word#
5179++
5180++primop WordAddOp "plusWord#" Dyadic Word# -> Word# -> Word#
5181++ with commutable = True
5182++
5183++primop WordSubCOp "subWordC#" GenPrimOp Word# -> Word# -> (# Word#, Int# #)
5184++ {Subtract unsigned integers reporting overflow.
5185++ The first element of the pair is the result. The second element is
5186++ the carry flag, which is nonzero on overflow.}
5187++
5188++-- Returns (# high, low #) (or equivalently, (# carry, low #))
5189++primop WordAdd2Op "plusWord2#" GenPrimOp
5190++ Word# -> Word# -> (# Word#, Word# #)
5191++ with commutable = True
5192++
5193++primop WordSubOp "minusWord#" Dyadic Word# -> Word# -> Word#
5194++
5195++primop WordMulOp "timesWord#" Dyadic Word# -> Word# -> Word#
5196++ with commutable = True
5197++
5198++-- Returns (# high, low #)
5199++primop WordMul2Op "timesWord2#" GenPrimOp
5200++ Word# -> Word# -> (# Word#, Word# #)
5201++ with commutable = True
5202++
5203++primop WordQuotOp "quotWord#" Dyadic Word# -> Word# -> Word#
5204++ with can_fail = True
5205++
5206++primop WordRemOp "remWord#" Dyadic Word# -> Word# -> Word#
5207++ with can_fail = True
5208++
5209++primop WordQuotRemOp "quotRemWord#" GenPrimOp
5210++ Word# -> Word# -> (# Word#, Word# #)
5211++ with can_fail = True
5212++
5213++-- Takes high word of dividend, then low word of dividend, then divisor.
5214++-- Requires that high word is not divisible by divisor.
5215++primop WordQuotRem2Op "quotRemWord2#" GenPrimOp
5216++ Word# -> Word# -> Word# -> (# Word#, Word# #)
5217++ with can_fail = True
5218++
5219++primop AndOp "and#" Dyadic Word# -> Word# -> Word#
5220++ with commutable = True
5221++
5222++primop OrOp "or#" Dyadic Word# -> Word# -> Word#
5223++ with commutable = True
5224++
5225++primop XorOp "xor#" Dyadic Word# -> Word# -> Word#
5226++ with commutable = True
5227++
5228++primop NotOp "not#" Monadic Word# -> Word#
5229++
5230++primop SllOp "uncheckedShiftL#" GenPrimOp Word# -> Int# -> Word#
5231++ {Shift left logical. Result undefined if shift amount is not
5232++ in the range 0 to word size - 1 inclusive.}
5233++primop SrlOp "uncheckedShiftRL#" GenPrimOp Word# -> Int# -> Word#
5234++ {Shift right logical. Result undefined if shift amount is not
5235++ in the range 0 to word size - 1 inclusive.}
5236++
5237++primop Word2IntOp "word2Int#" GenPrimOp Word# -> Int#
5238++ with code_size = 0
5239++
5240++primop WordGtOp "gtWord#" Compare Word# -> Word# -> Int#
5241++primop WordGeOp "geWord#" Compare Word# -> Word# -> Int#
5242++primop WordEqOp "eqWord#" Compare Word# -> Word# -> Int#
5243++primop WordNeOp "neWord#" Compare Word# -> Word# -> Int#
5244++primop WordLtOp "ltWord#" Compare Word# -> Word# -> Int#
5245++primop WordLeOp "leWord#" Compare Word# -> Word# -> Int#
5246++
5247++primop PopCnt8Op "popCnt8#" Monadic Word# -> Word#
5248++ {Count the number of set bits in the lower 8 bits of a word.}
5249++primop PopCnt16Op "popCnt16#" Monadic Word# -> Word#
5250++ {Count the number of set bits in the lower 16 bits of a word.}
5251++primop PopCnt32Op "popCnt32#" Monadic Word# -> Word#
5252++ {Count the number of set bits in the lower 32 bits of a word.}
5253++primop PopCnt64Op "popCnt64#" GenPrimOp WORD64 -> Word#
5254++ {Count the number of set bits in a 64-bit word.}
5255++primop PopCntOp "popCnt#" Monadic Word# -> Word#
5256++ {Count the number of set bits in a word.}
5257++
5258++primop Pdep8Op "pdep8#" Dyadic Word# -> Word# -> Word#
5259++ {Deposit bits to lower 8 bits of a word at locations specified by a mask.}
5260++primop Pdep16Op "pdep16#" Dyadic Word# -> Word# -> Word#
5261++ {Deposit bits to lower 16 bits of a word at locations specified by a mask.}
5262++primop Pdep32Op "pdep32#" Dyadic Word# -> Word# -> Word#
5263++ {Deposit bits to lower 32 bits of a word at locations specified by a mask.}
5264++primop Pdep64Op "pdep64#" GenPrimOp WORD64 -> WORD64 -> WORD64
5265++ {Deposit bits to a word at locations specified by a mask.}
5266++primop PdepOp "pdep#" Dyadic Word# -> Word# -> Word#
5267++ {Deposit bits to a word at locations specified by a mask.}
5268++
5269++primop Pext8Op "pext8#" Dyadic Word# -> Word# -> Word#
5270++ {Extract bits from lower 8 bits of a word at locations specified by a mask.}
5271++primop Pext16Op "pext16#" Dyadic Word# -> Word# -> Word#
5272++ {Extract bits from lower 16 bits of a word at locations specified by a mask.}
5273++primop Pext32Op "pext32#" Dyadic Word# -> Word# -> Word#
5274++ {Extract bits from lower 32 bits of a word at locations specified by a mask.}
5275++primop Pext64Op "pext64#" GenPrimOp WORD64 -> WORD64 -> WORD64
5276++ {Extract bits from a word at locations specified by a mask.}
5277++primop PextOp "pext#" Dyadic Word# -> Word# -> Word#
5278++ {Extract bits from a word at locations specified by a mask.}
5279++
5280++primop Clz8Op "clz8#" Monadic Word# -> Word#
5281++ {Count leading zeros in the lower 8 bits of a word.}
5282++primop Clz16Op "clz16#" Monadic Word# -> Word#
5283++ {Count leading zeros in the lower 16 bits of a word.}
5284++primop Clz32Op "clz32#" Monadic Word# -> Word#
5285++ {Count leading zeros in the lower 32 bits of a word.}
5286++primop Clz64Op "clz64#" GenPrimOp WORD64 -> Word#
5287++ {Count leading zeros in a 64-bit word.}
5288++primop ClzOp "clz#" Monadic Word# -> Word#
5289++ {Count leading zeros in a word.}
5290++
5291++primop Ctz8Op "ctz8#" Monadic Word# -> Word#
5292++ {Count trailing zeros in the lower 8 bits of a word.}
5293++primop Ctz16Op "ctz16#" Monadic Word# -> Word#
5294++ {Count trailing zeros in the lower 16 bits of a word.}
5295++primop Ctz32Op "ctz32#" Monadic Word# -> Word#
5296++ {Count trailing zeros in the lower 32 bits of a word.}
5297++primop Ctz64Op "ctz64#" GenPrimOp WORD64 -> Word#
5298++ {Count trailing zeros in a 64-bit word.}
5299++primop CtzOp "ctz#" Monadic Word# -> Word#
5300++ {Count trailing zeros in a word.}
5301++
5302++primop BSwap16Op "byteSwap16#" Monadic Word# -> Word#
5303++ {Swap bytes in the lower 16 bits of a word. The higher bytes are undefined. }
5304++primop BSwap32Op "byteSwap32#" Monadic Word# -> Word#
5305++ {Swap bytes in the lower 32 bits of a word. The higher bytes are undefined. }
5306++primop BSwap64Op "byteSwap64#" Monadic WORD64 -> WORD64
5307++ {Swap bytes in a 64 bits of a word.}
5308++primop BSwapOp "byteSwap#" Monadic Word# -> Word#
5309++ {Swap bytes in a word.}
5310++
5311++------------------------------------------------------------------------
5312++section "Narrowings"
5313++ {Explicit narrowing of native-sized ints or words.}
5314++------------------------------------------------------------------------
5315++
5316++primop Narrow8IntOp "narrow8Int#" Monadic Int# -> Int#
5317++primop Narrow16IntOp "narrow16Int#" Monadic Int# -> Int#
5318++primop Narrow32IntOp "narrow32Int#" Monadic Int# -> Int#
5319++primop Narrow8WordOp "narrow8Word#" Monadic Word# -> Word#
5320++primop Narrow16WordOp "narrow16Word#" Monadic Word# -> Word#
5321++primop Narrow32WordOp "narrow32Word#" Monadic Word# -> Word#
5322++
5323++
5324++#if WORD_SIZE_IN_BITS < 32
5325++------------------------------------------------------------------------
5326++section "Int32#"
5327++ {Operations on 32-bit integers ({\tt Int32\#}). This type is only used
5328++ if plain {\tt Int\#} has less than 32 bits. In any case, the operations
5329++ are not primops; they are implemented (if needed) as ccalls instead.}
5330++------------------------------------------------------------------------
5331++
5332++primtype Int32#
5333++
5334++------------------------------------------------------------------------
5335++section "Word32#"
5336++ {Operations on 32-bit unsigned words. This type is only used
5337++ if plain {\tt Word\#} has less than 32 bits. In any case, the operations
5338++ are not primops; they are implemented (if needed) as ccalls instead.}
5339++------------------------------------------------------------------------
5340++
5341++primtype Word32#
5342++
5343++#endif
5344++
5345++
5346++#if WORD_SIZE_IN_BITS < 64
5347++------------------------------------------------------------------------
5348++section "Int64#"
5349++ {Operations on 64-bit unsigned words. This type is only used
5350++ if plain {\tt Int\#} has less than 64 bits. In any case, the operations
5351++ are not primops; they are implemented (if needed) as ccalls instead.}
5352++------------------------------------------------------------------------
5353++
5354++primtype Int64#
5355++
5356++------------------------------------------------------------------------
5357++section "Word64#"
5358++ {Operations on 64-bit unsigned words. This type is only used
5359++ if plain {\tt Word\#} has less than 64 bits. In any case, the operations
5360++ are not primops; they are implemented (if needed) as ccalls instead.}
5361++------------------------------------------------------------------------
5362++
5363++primtype Word64#
5364++
5365++#endif
5366++
5367++------------------------------------------------------------------------
5368++section "Double#"
5369++ {Operations on double-precision (64 bit) floating-point numbers.}
5370++------------------------------------------------------------------------
5371++
5372++primtype Double#
5373++
5374++primop DoubleGtOp ">##" Compare Double# -> Double# -> Int#
5375++ with fixity = infix 4
5376++
5377++primop DoubleGeOp ">=##" Compare Double# -> Double# -> Int#
5378++ with fixity = infix 4
5379++
5380++primop DoubleEqOp "==##" Compare
5381++ Double# -> Double# -> Int#
5382++ with commutable = True
5383++ fixity = infix 4
5384++
5385++primop DoubleNeOp "/=##" Compare
5386++ Double# -> Double# -> Int#
5387++ with commutable = True
5388++ fixity = infix 4
5389++
5390++primop DoubleLtOp "<##" Compare Double# -> Double# -> Int#
5391++ with fixity = infix 4
5392++
5393++primop DoubleLeOp "<=##" Compare Double# -> Double# -> Int#
5394++ with fixity = infix 4
5395++
5396++primop DoubleAddOp "+##" Dyadic
5397++ Double# -> Double# -> Double#
5398++ with commutable = True
5399++ fixity = infixl 6
5400++
5401++primop DoubleSubOp "-##" Dyadic Double# -> Double# -> Double#
5402++ with fixity = infixl 6
5403++
5404++primop DoubleMulOp "*##" Dyadic
5405++ Double# -> Double# -> Double#
5406++ with commutable = True
5407++ fixity = infixl 7
5408++
5409++primop DoubleDivOp "/##" Dyadic
5410++ Double# -> Double# -> Double#
5411++ with can_fail = True
5412++ fixity = infixl 7
5413++
5414++primop DoubleNegOp "negateDouble#" Monadic Double# -> Double#
5415++
5416++primop DoubleFabsOp "fabsDouble#" Monadic Double# -> Double#
5417++
5418++primop Double2IntOp "double2Int#" GenPrimOp Double# -> Int#
5419++ {Truncates a {\tt Double#} value to the nearest {\tt Int#}.
5420++ Results are undefined if the truncation if truncation yields
5421++ a value outside the range of {\tt Int#}.}
5422++
5423++primop Double2FloatOp "double2Float#" GenPrimOp Double# -> Float#
5424++
5425++primop DoubleExpOp "expDouble#" Monadic
5426++ Double# -> Double#
5427++ with
5428++ code_size = { primOpCodeSizeForeignCall }
5429++
5430++primop DoubleLogOp "logDouble#" Monadic
5431++ Double# -> Double#
5432++ with
5433++ code_size = { primOpCodeSizeForeignCall }
5434++ can_fail = True
5435++
5436++primop DoubleSqrtOp "sqrtDouble#" Monadic
5437++ Double# -> Double#
5438++ with
5439++ code_size = { primOpCodeSizeForeignCall }
5440++
5441++primop DoubleSinOp "sinDouble#" Monadic
5442++ Double# -> Double#
5443++ with
5444++ code_size = { primOpCodeSizeForeignCall }
5445++
5446++primop DoubleCosOp "cosDouble#" Monadic
5447++ Double# -> Double#
5448++ with
5449++ code_size = { primOpCodeSizeForeignCall }
5450++
5451++primop DoubleTanOp "tanDouble#" Monadic
5452++ Double# -> Double#
5453++ with
5454++ code_size = { primOpCodeSizeForeignCall }
5455++
5456++primop DoubleAsinOp "asinDouble#" Monadic
5457++ Double# -> Double#
5458++ with
5459++ code_size = { primOpCodeSizeForeignCall }
5460++ can_fail = True
5461++
5462++primop DoubleAcosOp "acosDouble#" Monadic
5463++ Double# -> Double#
5464++ with
5465++ code_size = { primOpCodeSizeForeignCall }
5466++ can_fail = True
5467++
5468++primop DoubleAtanOp "atanDouble#" Monadic
5469++ Double# -> Double#
5470++ with
5471++ code_size = { primOpCodeSizeForeignCall }
5472++
5473++primop DoubleSinhOp "sinhDouble#" Monadic
5474++ Double# -> Double#
5475++ with
5476++ code_size = { primOpCodeSizeForeignCall }
5477++
5478++primop DoubleCoshOp "coshDouble#" Monadic
5479++ Double# -> Double#
5480++ with
5481++ code_size = { primOpCodeSizeForeignCall }
5482++
5483++primop DoubleTanhOp "tanhDouble#" Monadic
5484++ Double# -> Double#
5485++ with
5486++ code_size = { primOpCodeSizeForeignCall }
5487++
5488++primop DoublePowerOp "**##" Dyadic
5489++ Double# -> Double# -> Double#
5490++ {Exponentiation.}
5491++ with
5492++ code_size = { primOpCodeSizeForeignCall }
5493++
5494++primop DoubleDecode_2IntOp "decodeDouble_2Int#" GenPrimOp
5495++ Double# -> (# Int#, Word#, Word#, Int# #)
5496++ {Convert to integer.
5497++ First component of the result is -1 or 1, indicating the sign of the
5498++ mantissa. The next two are the high and low 32 bits of the mantissa
5499++ respectively, and the last is the exponent.}
5500++ with out_of_line = True
5501++
5502++primop DoubleDecode_Int64Op "decodeDouble_Int64#" GenPrimOp
5503++ Double# -> (# INT64, Int# #)
5504++ {Decode {\tt Double\#} into mantissa and base-2 exponent.}
5505++ with out_of_line = True
5506++
5507++------------------------------------------------------------------------
5508++section "Float#"
5509++ {Operations on single-precision (32-bit) floating-point numbers.}
5510++------------------------------------------------------------------------
5511++
5512++primtype Float#
5513++
5514++primop FloatGtOp "gtFloat#" Compare Float# -> Float# -> Int#
5515++primop FloatGeOp "geFloat#" Compare Float# -> Float# -> Int#
5516++
5517++primop FloatEqOp "eqFloat#" Compare
5518++ Float# -> Float# -> Int#
5519++ with commutable = True
5520++
5521++primop FloatNeOp "neFloat#" Compare
5522++ Float# -> Float# -> Int#
5523++ with commutable = True
5524++
5525++primop FloatLtOp "ltFloat#" Compare Float# -> Float# -> Int#
5526++primop FloatLeOp "leFloat#" Compare Float# -> Float# -> Int#
5527++
5528++primop FloatAddOp "plusFloat#" Dyadic
5529++ Float# -> Float# -> Float#
5530++ with commutable = True
5531++
5532++primop FloatSubOp "minusFloat#" Dyadic Float# -> Float# -> Float#
5533++
5534++primop FloatMulOp "timesFloat#" Dyadic
5535++ Float# -> Float# -> Float#
5536++ with commutable = True
5537++
5538++primop FloatDivOp "divideFloat#" Dyadic
5539++ Float# -> Float# -> Float#
5540++ with can_fail = True
5541++
5542++primop FloatNegOp "negateFloat#" Monadic Float# -> Float#
5543++
5544++primop FloatFabsOp "fabsFloat#" Monadic Float# -> Float#
5545++
5546++primop Float2IntOp "float2Int#" GenPrimOp Float# -> Int#
5547++ {Truncates a {\tt Float#} value to the nearest {\tt Int#}.
5548++ Results are undefined if the truncation if truncation yields
5549++ a value outside the range of {\tt Int#}.}
5550++
5551++primop FloatExpOp "expFloat#" Monadic
5552++ Float# -> Float#
5553++ with
5554++ code_size = { primOpCodeSizeForeignCall }
5555++
5556++primop FloatLogOp "logFloat#" Monadic
5557++ Float# -> Float#
5558++ with
5559++ code_size = { primOpCodeSizeForeignCall }
5560++ can_fail = True
5561++
5562++primop FloatSqrtOp "sqrtFloat#" Monadic
5563++ Float# -> Float#
5564++ with
5565++ code_size = { primOpCodeSizeForeignCall }
5566++
5567++primop FloatSinOp "sinFloat#" Monadic
5568++ Float# -> Float#
5569++ with
5570++ code_size = { primOpCodeSizeForeignCall }
5571++
5572++primop FloatCosOp "cosFloat#" Monadic
5573++ Float# -> Float#
5574++ with
5575++ code_size = { primOpCodeSizeForeignCall }
5576++
5577++primop FloatTanOp "tanFloat#" Monadic
5578++ Float# -> Float#
5579++ with
5580++ code_size = { primOpCodeSizeForeignCall }
5581++
5582++primop FloatAsinOp "asinFloat#" Monadic
5583++ Float# -> Float#
5584++ with
5585++ code_size = { primOpCodeSizeForeignCall }
5586++ can_fail = True
5587++
5588++primop FloatAcosOp "acosFloat#" Monadic
5589++ Float# -> Float#
5590++ with
5591++ code_size = { primOpCodeSizeForeignCall }
5592++ can_fail = True
5593++
5594++primop FloatAtanOp "atanFloat#" Monadic
5595++ Float# -> Float#
5596++ with
5597++ code_size = { primOpCodeSizeForeignCall }
5598++
5599++primop FloatSinhOp "sinhFloat#" Monadic
5600++ Float# -> Float#
5601++ with
5602++ code_size = { primOpCodeSizeForeignCall }
5603++
5604++primop FloatCoshOp "coshFloat#" Monadic
5605++ Float# -> Float#
5606++ with
5607++ code_size = { primOpCodeSizeForeignCall }
5608++
5609++primop FloatTanhOp "tanhFloat#" Monadic
5610++ Float# -> Float#
5611++ with
5612++ code_size = { primOpCodeSizeForeignCall }
5613++
5614++primop FloatPowerOp "powerFloat#" Dyadic
5615++ Float# -> Float# -> Float#
5616++ with
5617++ code_size = { primOpCodeSizeForeignCall }
5618++
5619++primop Float2DoubleOp "float2Double#" GenPrimOp Float# -> Double#
5620++
5621++primop FloatDecode_IntOp "decodeFloat_Int#" GenPrimOp
5622++ Float# -> (# Int#, Int# #)
5623++ {Convert to integers.
5624++ First {\tt Int\#} in result is the mantissa; second is the exponent.}
5625++ with out_of_line = True
5626++
5627++------------------------------------------------------------------------
5628++section "Arrays"
5629++ {Operations on {\tt Array\#}.}
5630++------------------------------------------------------------------------
5631++
5632++primtype Array# a
5633++
5634++primtype MutableArray# s a
5635++
5636++primop NewArrayOp "newArray#" GenPrimOp
5637++ Int# -> a -> State# s -> (# State# s, MutableArray# s a #)
5638++ {Create a new mutable array with the specified number of elements,
5639++ in the specified state thread,
5640++ with each element containing the specified initial value.}
5641++ with
5642++ out_of_line = True
5643++ has_side_effects = True
5644++
5645++primop SameMutableArrayOp "sameMutableArray#" GenPrimOp
5646++ MutableArray# s a -> MutableArray# s a -> Int#
5647++
5648++primop ReadArrayOp "readArray#" GenPrimOp
5649++ MutableArray# s a -> Int# -> State# s -> (# State# s, a #)
5650++ {Read from specified index of mutable array. Result is not yet evaluated.}
5651++ with
5652++ has_side_effects = True
5653++ can_fail = True
5654++
5655++primop WriteArrayOp "writeArray#" GenPrimOp
5656++ MutableArray# s a -> Int# -> a -> State# s -> State# s
5657++ {Write to specified index of mutable array.}
5658++ with
5659++ has_side_effects = True
5660++ can_fail = True
5661++ code_size = 2 -- card update too
5662++
5663++primop SizeofArrayOp "sizeofArray#" GenPrimOp
5664++ Array# a -> Int#
5665++ {Return the number of elements in the array.}
5666++
5667++primop SizeofMutableArrayOp "sizeofMutableArray#" GenPrimOp
5668++ MutableArray# s a -> Int#
5669++ {Return the number of elements in the array.}
5670++
5671++primop IndexArrayOp "indexArray#" GenPrimOp
5672++ Array# a -> Int# -> (# a #)
5673++ {Read from specified index of immutable array. Result is packaged into
5674++ an unboxed singleton; the result itself is not yet evaluated.}
5675++ with
5676++ can_fail = True
5677++
5678++primop UnsafeFreezeArrayOp "unsafeFreezeArray#" GenPrimOp
5679++ MutableArray# s a -> State# s -> (# State# s, Array# a #)
5680++ {Make a mutable array immutable, without copying.}
5681++ with
5682++ has_side_effects = True
5683++
5684++primop UnsafeThawArrayOp "unsafeThawArray#" GenPrimOp
5685++ Array# a -> State# s -> (# State# s, MutableArray# s a #)
5686++ {Make an immutable array mutable, without copying.}
5687++ with
5688++ out_of_line = True
5689++ has_side_effects = True
5690++
5691++primop CopyArrayOp "copyArray#" GenPrimOp
5692++ Array# a -> Int# -> MutableArray# s a -> Int# -> Int# -> State# s -> State# s
5693++ {Given a source array, an offset into the source array, a
5694++ destination array, an offset into the destination array, and a
5695++ number of elements to copy, copy the elements from the source array
5696++ to the destination array. Both arrays must fully contain the
5697++ specified ranges, but this is not checked. The two arrays must not
5698++ be the same array in different states, but this is not checked
5699++ either.}
5700++ with
5701++ out_of_line = True
5702++ has_side_effects = True
5703++ can_fail = True
5704++
5705++primop CopyMutableArrayOp "copyMutableArray#" GenPrimOp
5706++ MutableArray# s a -> Int# -> MutableArray# s a -> Int# -> Int# -> State# s -> State# s
5707++ {Given a source array, an offset into the source array, a
5708++ destination array, an offset into the destination array, and a
5709++ number of elements to copy, copy the elements from the source array
5710++ to the destination array. Both arrays must fully contain the
5711++ specified ranges, but this is not checked. In the case where
5712++ the source and destination are the same array the source and
5713++ destination regions may overlap.}
5714++ with
5715++ out_of_line = True
5716++ has_side_effects = True
5717++ can_fail = True
5718++
5719++primop CloneArrayOp "cloneArray#" GenPrimOp
5720++ Array# a -> Int# -> Int# -> Array# a
5721++ {Given a source array, an offset into the source array, and a number
5722++ of elements to copy, create a new array with the elements from the
5723++ source array. The provided array must fully contain the specified
5724++ range, but this is not checked.}
5725++ with
5726++ out_of_line = True
5727++ has_side_effects = True
5728++ can_fail = True
5729++
5730++primop CloneMutableArrayOp "cloneMutableArray#" GenPrimOp
5731++ MutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, MutableArray# s a #)
5732++ {Given a source array, an offset into the source array, and a number
5733++ of elements to copy, create a new array with the elements from the
5734++ source array. The provided array must fully contain the specified
5735++ range, but this is not checked.}
5736++ with
5737++ out_of_line = True
5738++ has_side_effects = True
5739++ can_fail = True
5740++
5741++primop FreezeArrayOp "freezeArray#" GenPrimOp
5742++ MutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, Array# a #)
5743++ {Given a source array, an offset into the source array, and a number
5744++ of elements to copy, create a new array with the elements from the
5745++ source array. The provided array must fully contain the specified
5746++ range, but this is not checked.}
5747++ with
5748++ out_of_line = True
5749++ has_side_effects = True
5750++ can_fail = True
5751++
5752++primop ThawArrayOp "thawArray#" GenPrimOp
5753++ Array# a -> Int# -> Int# -> State# s -> (# State# s, MutableArray# s a #)
5754++ {Given a source array, an offset into the source array, and a number
5755++ of elements to copy, create a new array with the elements from the
5756++ source array. The provided array must fully contain the specified
5757++ range, but this is not checked.}
5758++ with
5759++ out_of_line = True
5760++ has_side_effects = True
5761++ can_fail = True
5762++
5763++primop CasArrayOp "casArray#" GenPrimOp
5764++ MutableArray# s a -> Int# -> a -> a -> State# s -> (# State# s, Int#, a #)
5765++ {Unsafe, machine-level atomic compare and swap on an element within an Array.}
5766++ with
5767++ out_of_line = True
5768++ has_side_effects = True
5769++
5770++
5771++------------------------------------------------------------------------
5772++section "Small Arrays"
5773++
5774++ {Operations on {\tt SmallArray\#}. A {\tt SmallArray\#} works
5775++ just like an {\tt Array\#}, but with different space use and
5776++ performance characteristics (that are often useful with small
5777++ arrays). The {\tt SmallArray\#} and {\tt SmallMutableArray#}
5778++ lack a `card table'. The purpose of a card table is to avoid
5779++ having to scan every element of the array on each GC by
5780++ keeping track of which elements have changed since the last GC
5781++ and only scanning those that have changed. So the consequence
5782++ of there being no card table is that the representation is
5783++ somewhat smaller and the writes are somewhat faster (because
5784++ the card table does not need to be updated). The disadvantage
5785++ of course is that for a {\tt SmallMutableArray#} the whole
5786++ array has to be scanned on each GC. Thus it is best suited for
5787++ use cases where the mutable array is not long lived, e.g.
5788++ where a mutable array is initialised quickly and then frozen
5789++ to become an immutable {\tt SmallArray\#}.
5790++ }
5791++
5792++------------------------------------------------------------------------
5793++
5794++primtype SmallArray# a
5795++
5796++primtype SmallMutableArray# s a
5797++
5798++primop NewSmallArrayOp "newSmallArray#" GenPrimOp
5799++ Int# -> a -> State# s -> (# State# s, SmallMutableArray# s a #)
5800++ {Create a new mutable array with the specified number of elements,
5801++ in the specified state thread,
5802++ with each element containing the specified initial value.}
5803++ with
5804++ out_of_line = True
5805++ has_side_effects = True
5806++
5807++primop SameSmallMutableArrayOp "sameSmallMutableArray#" GenPrimOp
5808++ SmallMutableArray# s a -> SmallMutableArray# s a -> Int#
5809++
5810++primop ReadSmallArrayOp "readSmallArray#" GenPrimOp
5811++ SmallMutableArray# s a -> Int# -> State# s -> (# State# s, a #)
5812++ {Read from specified index of mutable array. Result is not yet evaluated.}
5813++ with
5814++ has_side_effects = True
5815++ can_fail = True
5816++
5817++primop WriteSmallArrayOp "writeSmallArray#" GenPrimOp
5818++ SmallMutableArray# s a -> Int# -> a -> State# s -> State# s
5819++ {Write to specified index of mutable array.}
5820++ with
5821++ has_side_effects = True
5822++ can_fail = True
5823++
5824++primop SizeofSmallArrayOp "sizeofSmallArray#" GenPrimOp
5825++ SmallArray# a -> Int#
5826++ {Return the number of elements in the array.}
5827++
5828++primop SizeofSmallMutableArrayOp "sizeofSmallMutableArray#" GenPrimOp
5829++ SmallMutableArray# s a -> Int#
5830++ {Return the number of elements in the array.}
5831++
5832++primop IndexSmallArrayOp "indexSmallArray#" GenPrimOp
5833++ SmallArray# a -> Int# -> (# a #)
5834++ {Read from specified index of immutable array. Result is packaged into
5835++ an unboxed singleton; the result itself is not yet evaluated.}
5836++ with
5837++ can_fail = True
5838++
5839++primop UnsafeFreezeSmallArrayOp "unsafeFreezeSmallArray#" GenPrimOp
5840++ SmallMutableArray# s a -> State# s -> (# State# s, SmallArray# a #)
5841++ {Make a mutable array immutable, without copying.}
5842++ with
5843++ has_side_effects = True
5844++
5845++primop UnsafeThawSmallArrayOp "unsafeThawSmallArray#" GenPrimOp
5846++ SmallArray# a -> State# s -> (# State# s, SmallMutableArray# s a #)
5847++ {Make an immutable array mutable, without copying.}
5848++ with
5849++ out_of_line = True
5850++ has_side_effects = True
5851++
5852++-- The code_size is only correct for the case when the copy family of
5853++-- primops aren't inlined. It would be nice to keep track of both.
5854++
5855++primop CopySmallArrayOp "copySmallArray#" GenPrimOp
5856++ SmallArray# a -> Int# -> SmallMutableArray# s a -> Int# -> Int# -> State# s -> State# s
5857++ {Given a source array, an offset into the source array, a
5858++ destination array, an offset into the destination array, and a
5859++ number of elements to copy, copy the elements from the source array
5860++ to the destination array. Both arrays must fully contain the
5861++ specified ranges, but this is not checked. The two arrays must not
5862++ be the same array in different states, but this is not checked
5863++ either.}
5864++ with
5865++ out_of_line = True
5866++ has_side_effects = True
5867++ can_fail = True
5868++
5869++primop CopySmallMutableArrayOp "copySmallMutableArray#" GenPrimOp
5870++ SmallMutableArray# s a -> Int# -> SmallMutableArray# s a -> Int# -> Int# -> State# s -> State# s
5871++ {Given a source array, an offset into the source array, a
5872++ destination array, an offset into the destination array, and a
5873++ number of elements to copy, copy the elements from the source array
5874++ to the destination array. The source and destination arrays can
5875++ refer to the same array. Both arrays must fully contain the
5876++ specified ranges, but this is not checked.
5877++ The regions are allowed to overlap, although this is only possible when the same
5878++ array is provided as both the source and the destination. }
5879++ with
5880++ out_of_line = True
5881++ has_side_effects = True
5882++ can_fail = True
5883++
5884++primop CloneSmallArrayOp "cloneSmallArray#" GenPrimOp
5885++ SmallArray# a -> Int# -> Int# -> SmallArray# a
5886++ {Given a source array, an offset into the source array, and a number
5887++ of elements to copy, create a new array with the elements from the
5888++ source array. The provided array must fully contain the specified
5889++ range, but this is not checked.}
5890++ with
5891++ out_of_line = True
5892++ has_side_effects = True
5893++ can_fail = True
5894++
5895++primop CloneSmallMutableArrayOp "cloneSmallMutableArray#" GenPrimOp
5896++ SmallMutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, SmallMutableArray# s a #)
5897++ {Given a source array, an offset into the source array, and a number
5898++ of elements to copy, create a new array with the elements from the
5899++ source array. The provided array must fully contain the specified
5900++ range, but this is not checked.}
5901++ with
5902++ out_of_line = True
5903++ has_side_effects = True
5904++ can_fail = True
5905++
5906++primop FreezeSmallArrayOp "freezeSmallArray#" GenPrimOp
5907++ SmallMutableArray# s a -> Int# -> Int# -> State# s -> (# State# s, SmallArray# a #)
5908++ {Given a source array, an offset into the source array, and a number
5909++ of elements to copy, create a new array with the elements from the
5910++ source array. The provided array must fully contain the specified
5911++ range, but this is not checked.}
5912++ with
5913++ out_of_line = True
5914++ has_side_effects = True
5915++ can_fail = True
5916++
5917++primop ThawSmallArrayOp "thawSmallArray#" GenPrimOp
5918++ SmallArray# a -> Int# -> Int# -> State# s -> (# State# s, SmallMutableArray# s a #)
5919++ {Given a source array, an offset into the source array, and a number
5920++ of elements to copy, create a new array with the elements from the
5921++ source array. The provided array must fully contain the specified
5922++ range, but this is not checked.}
5923++ with
5924++ out_of_line = True
5925++ has_side_effects = True
5926++ can_fail = True
5927++
5928++primop CasSmallArrayOp "casSmallArray#" GenPrimOp
5929++ SmallMutableArray# s a -> Int# -> a -> a -> State# s -> (# State# s, Int#, a #)
5930++ {Unsafe, machine-level atomic compare and swap on an element within an array.}
5931++ with
5932++ out_of_line = True
5933++ has_side_effects = True
5934++
5935++------------------------------------------------------------------------
5936++section "Byte Arrays"
5937++ {Operations on {\tt ByteArray\#}. A {\tt ByteArray\#} is a just a region of
5938++ raw memory in the garbage-collected heap, which is not
5939++ scanned for pointers. It carries its own size (in bytes).
5940++ There are
5941++ three sets of operations for accessing byte array contents:
5942++ index for reading from immutable byte arrays, and read/write
5943++ for mutable byte arrays. Each set contains operations for a
5944++ range of useful primitive data types. Each operation takes
5945++ an offset measured in terms of the size of the primitive type
5946++ being read or written.}
5947++
5948++------------------------------------------------------------------------
5949++
5950++primtype ByteArray#
5951++
5952++primtype MutableByteArray# s
5953++
5954++primop NewByteArrayOp_Char "newByteArray#" GenPrimOp
5955++ Int# -> State# s -> (# State# s, MutableByteArray# s #)
5956++ {Create a new mutable byte array of specified size (in bytes), in
5957++ the specified state thread.}
5958++ with out_of_line = True
5959++ has_side_effects = True
5960++
5961++primop NewPinnedByteArrayOp_Char "newPinnedByteArray#" GenPrimOp
5962++ Int# -> State# s -> (# State# s, MutableByteArray# s #)
5963++ {Create a mutable byte array that the GC guarantees not to move.}
5964++ with out_of_line = True
5965++ has_side_effects = True
5966++
5967++primop NewAlignedPinnedByteArrayOp_Char "newAlignedPinnedByteArray#" GenPrimOp
5968++ Int# -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
5969++ {Create a mutable byte array, aligned by the specified amount, that the GC guarantees not to move.}
5970++ with out_of_line = True
5971++ has_side_effects = True
5972++
5973++primop MutableByteArrayIsPinnedOp "isMutableByteArrayPinned#" GenPrimOp
5974++ MutableByteArray# s -> Int#
5975++ {Determine whether a {\tt MutableByteArray\#} is guaranteed not to move
5976++ during GC.}
5977++ with out_of_line = True
5978++
5979++primop ByteArrayIsPinnedOp "isByteArrayPinned#" GenPrimOp
5980++ ByteArray# -> Int#
5981++ {Determine whether a {\tt ByteArray\#} is guaranteed not to move during GC.}
5982++ with out_of_line = True
5983++
5984++primop ByteArrayContents_Char "byteArrayContents#" GenPrimOp
5985++ ByteArray# -> Addr#
5986++ {Intended for use with pinned arrays; otherwise very unsafe!}
5987++
5988++primop SameMutableByteArrayOp "sameMutableByteArray#" GenPrimOp
5989++ MutableByteArray# s -> MutableByteArray# s -> Int#
5990++
5991++primop ShrinkMutableByteArrayOp_Char "shrinkMutableByteArray#" GenPrimOp
5992++ MutableByteArray# s -> Int# -> State# s -> State# s
5993++ {Shrink mutable byte array to new specified size (in bytes), in
5994++ the specified state thread. The new size argument must be less than or
5995++ equal to the current size as reported by {\tt sizeofMutableArray\#}.}
5996++ with out_of_line = True
5997++ has_side_effects = True
5998++
5999++primop ResizeMutableByteArrayOp_Char "resizeMutableByteArray#" GenPrimOp
6000++ MutableByteArray# s -> Int# -> State# s -> (# State# s,MutableByteArray# s #)
6001++ {Resize (unpinned) mutable byte array to new specified size (in bytes).
6002++ The returned {\tt MutableByteArray\#} is either the original
6003++ {\tt MutableByteArray\#} resized in-place or, if not possible, a newly
6004++ allocated (unpinned) {\tt MutableByteArray\#} (with the original content
6005++ copied over).
6006++
6007++ To avoid undefined behaviour, the original {\tt MutableByteArray\#} shall
6008++ not be accessed anymore after a {\tt resizeMutableByteArray\#} has been
6009++ performed. Moreover, no reference to the old one should be kept in order
6010++ to allow garbage collection of the original {\tt MutableByteArray\#} in
6011++ case a new {\tt MutableByteArray\#} had to be allocated.}
6012++ with out_of_line = True
6013++ has_side_effects = True
6014++
6015++primop UnsafeFreezeByteArrayOp "unsafeFreezeByteArray#" GenPrimOp
6016++ MutableByteArray# s -> State# s -> (# State# s, ByteArray# #)
6017++ {Make a mutable byte array immutable, without copying.}
6018++ with
6019++ has_side_effects = True
6020++
6021++primop SizeofByteArrayOp "sizeofByteArray#" GenPrimOp
6022++ ByteArray# -> Int#
6023++ {Return the size of the array in bytes.}
6024++
6025++primop SizeofMutableByteArrayOp "sizeofMutableByteArray#" GenPrimOp
6026++ MutableByteArray# s -> Int#
6027++ {Return the size of the array in bytes. Note that this is deprecated as it is
6028++ unsafe in the presence of concurrent resize operations on the same byte
6029++ array. See {\tt getSizeofMutableByteArray}.}
6030++
6031++primop GetSizeofMutableByteArrayOp "getSizeofMutableByteArray#" GenPrimOp
6032++ MutableByteArray# s -> State# s -> (# State# s, Int# #)
6033++ {Return the number of elements in the array.}
6034++
6035++primop IndexByteArrayOp_Char "indexCharArray#" GenPrimOp
6036++ ByteArray# -> Int# -> Char#
6037++ {Read 8-bit character; offset in bytes.}
6038++ with can_fail = True
6039++
6040++primop IndexByteArrayOp_WideChar "indexWideCharArray#" GenPrimOp
6041++ ByteArray# -> Int# -> Char#
6042++ {Read 31-bit character; offset in 4-byte words.}
6043++ with can_fail = True
6044++
6045++primop IndexByteArrayOp_Int "indexIntArray#" GenPrimOp
6046++ ByteArray# -> Int# -> Int#
6047++ with can_fail = True
6048++
6049++primop IndexByteArrayOp_Word "indexWordArray#" GenPrimOp
6050++ ByteArray# -> Int# -> Word#
6051++ with can_fail = True
6052++
6053++primop IndexByteArrayOp_Addr "indexAddrArray#" GenPrimOp
6054++ ByteArray# -> Int# -> Addr#
6055++ with can_fail = True
6056++
6057++primop IndexByteArrayOp_Float "indexFloatArray#" GenPrimOp
6058++ ByteArray# -> Int# -> Float#
6059++ with can_fail = True
6060++
6061++primop IndexByteArrayOp_Double "indexDoubleArray#" GenPrimOp
6062++ ByteArray# -> Int# -> Double#
6063++ with can_fail = True
6064++
6065++primop IndexByteArrayOp_StablePtr "indexStablePtrArray#" GenPrimOp
6066++ ByteArray# -> Int# -> StablePtr# a
6067++ with can_fail = True
6068++
6069++primop IndexByteArrayOp_Int8 "indexInt8Array#" GenPrimOp
6070++ ByteArray# -> Int# -> Int#
6071++ {Read 8-bit integer; offset in bytes.}
6072++ with can_fail = True
6073++
6074++primop IndexByteArrayOp_Int16 "indexInt16Array#" GenPrimOp
6075++ ByteArray# -> Int# -> Int#
6076++ {Read 16-bit integer; offset in 16-bit words.}
6077++ with can_fail = True
6078++
6079++primop IndexByteArrayOp_Int32 "indexInt32Array#" GenPrimOp
6080++ ByteArray# -> Int# -> INT32
6081++ {Read 32-bit integer; offset in 32-bit words.}
6082++ with can_fail = True
6083++
6084++primop IndexByteArrayOp_Int64 "indexInt64Array#" GenPrimOp
6085++ ByteArray# -> Int# -> INT64
6086++ {Read 64-bit integer; offset in 64-bit words.}
6087++ with can_fail = True
6088++
6089++primop IndexByteArrayOp_Word8 "indexWord8Array#" GenPrimOp
6090++ ByteArray# -> Int# -> Word#
6091++ {Read 8-bit word; offset in bytes.}
6092++ with can_fail = True
6093++
6094++primop IndexByteArrayOp_Word16 "indexWord16Array#" GenPrimOp
6095++ ByteArray# -> Int# -> Word#
6096++ {Read 16-bit word; offset in 16-bit words.}
6097++ with can_fail = True
6098++
6099++primop IndexByteArrayOp_Word32 "indexWord32Array#" GenPrimOp
6100++ ByteArray# -> Int# -> WORD32
6101++ {Read 32-bit word; offset in 32-bit words.}
6102++ with can_fail = True
6103++
6104++primop IndexByteArrayOp_Word64 "indexWord64Array#" GenPrimOp
6105++ ByteArray# -> Int# -> WORD64
6106++ {Read 64-bit word; offset in 64-bit words.}
6107++ with can_fail = True
6108++
6109++primop ReadByteArrayOp_Char "readCharArray#" GenPrimOp
6110++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)
6111++ {Read 8-bit character; offset in bytes.}
6112++ with has_side_effects = True
6113++ can_fail = True
6114++
6115++primop ReadByteArrayOp_WideChar "readWideCharArray#" GenPrimOp
6116++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Char# #)
6117++ {Read 31-bit character; offset in 4-byte words.}
6118++ with has_side_effects = True
6119++ can_fail = True
6120++
6121++primop ReadByteArrayOp_Int "readIntArray#" GenPrimOp
6122++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
6123++ {Read integer; offset in words.}
6124++ with has_side_effects = True
6125++ can_fail = True
6126++
6127++primop ReadByteArrayOp_Word "readWordArray#" GenPrimOp
6128++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
6129++ {Read word; offset in words.}
6130++ with has_side_effects = True
6131++ can_fail = True
6132++
6133++primop ReadByteArrayOp_Addr "readAddrArray#" GenPrimOp
6134++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Addr# #)
6135++ with has_side_effects = True
6136++ can_fail = True
6137++
6138++primop ReadByteArrayOp_Float "readFloatArray#" GenPrimOp
6139++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Float# #)
6140++ with has_side_effects = True
6141++ can_fail = True
6142++
6143++primop ReadByteArrayOp_Double "readDoubleArray#" GenPrimOp
6144++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Double# #)
6145++ with has_side_effects = True
6146++ can_fail = True
6147++
6148++primop ReadByteArrayOp_StablePtr "readStablePtrArray#" GenPrimOp
6149++ MutableByteArray# s -> Int# -> State# s -> (# State# s, StablePtr# a #)
6150++ with has_side_effects = True
6151++ can_fail = True
6152++
6153++primop ReadByteArrayOp_Int8 "readInt8Array#" GenPrimOp
6154++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
6155++ with has_side_effects = True
6156++ can_fail = True
6157++
6158++primop ReadByteArrayOp_Int16 "readInt16Array#" GenPrimOp
6159++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
6160++ with has_side_effects = True
6161++ can_fail = True
6162++
6163++primop ReadByteArrayOp_Int32 "readInt32Array#" GenPrimOp
6164++ MutableByteArray# s -> Int# -> State# s -> (# State# s, INT32 #)
6165++ with has_side_effects = True
6166++ can_fail = True
6167++
6168++primop ReadByteArrayOp_Int64 "readInt64Array#" GenPrimOp
6169++ MutableByteArray# s -> Int# -> State# s -> (# State# s, INT64 #)
6170++ with has_side_effects = True
6171++ can_fail = True
6172++
6173++primop ReadByteArrayOp_Word8 "readWord8Array#" GenPrimOp
6174++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
6175++ with has_side_effects = True
6176++ can_fail = True
6177++
6178++primop ReadByteArrayOp_Word16 "readWord16Array#" GenPrimOp
6179++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Word# #)
6180++ with has_side_effects = True
6181++ can_fail = True
6182++
6183++primop ReadByteArrayOp_Word32 "readWord32Array#" GenPrimOp
6184++ MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD32 #)
6185++ with has_side_effects = True
6186++ can_fail = True
6187++
6188++primop ReadByteArrayOp_Word64 "readWord64Array#" GenPrimOp
6189++ MutableByteArray# s -> Int# -> State# s -> (# State# s, WORD64 #)
6190++ with has_side_effects = True
6191++ can_fail = True
6192++
6193++primop WriteByteArrayOp_Char "writeCharArray#" GenPrimOp
6194++ MutableByteArray# s -> Int# -> Char# -> State# s -> State# s
6195++ {Write 8-bit character; offset in bytes.}
6196++ with has_side_effects = True
6197++ can_fail = True
6198++
6199++primop WriteByteArrayOp_WideChar "writeWideCharArray#" GenPrimOp
6200++ MutableByteArray# s -> Int# -> Char# -> State# s -> State# s
6201++ {Write 31-bit character; offset in 4-byte words.}
6202++ with has_side_effects = True
6203++ can_fail = True
6204++
6205++primop WriteByteArrayOp_Int "writeIntArray#" GenPrimOp
6206++ MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6207++ with has_side_effects = True
6208++ can_fail = True
6209++
6210++primop WriteByteArrayOp_Word "writeWordArray#" GenPrimOp
6211++ MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
6212++ with has_side_effects = True
6213++ can_fail = True
6214++
6215++primop WriteByteArrayOp_Addr "writeAddrArray#" GenPrimOp
6216++ MutableByteArray# s -> Int# -> Addr# -> State# s -> State# s
6217++ with has_side_effects = True
6218++ can_fail = True
6219++
6220++primop WriteByteArrayOp_Float "writeFloatArray#" GenPrimOp
6221++ MutableByteArray# s -> Int# -> Float# -> State# s -> State# s
6222++ with has_side_effects = True
6223++ can_fail = True
6224++
6225++primop WriteByteArrayOp_Double "writeDoubleArray#" GenPrimOp
6226++ MutableByteArray# s -> Int# -> Double# -> State# s -> State# s
6227++ with has_side_effects = True
6228++ can_fail = True
6229++
6230++primop WriteByteArrayOp_StablePtr "writeStablePtrArray#" GenPrimOp
6231++ MutableByteArray# s -> Int# -> StablePtr# a -> State# s -> State# s
6232++ with has_side_effects = True
6233++ can_fail = True
6234++
6235++primop WriteByteArrayOp_Int8 "writeInt8Array#" GenPrimOp
6236++ MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6237++ with has_side_effects = True
6238++ can_fail = True
6239++
6240++primop WriteByteArrayOp_Int16 "writeInt16Array#" GenPrimOp
6241++ MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6242++ with has_side_effects = True
6243++ can_fail = True
6244++
6245++primop WriteByteArrayOp_Int32 "writeInt32Array#" GenPrimOp
6246++ MutableByteArray# s -> Int# -> INT32 -> State# s -> State# s
6247++ with has_side_effects = True
6248++ can_fail = True
6249++
6250++primop WriteByteArrayOp_Int64 "writeInt64Array#" GenPrimOp
6251++ MutableByteArray# s -> Int# -> INT64 -> State# s -> State# s
6252++ with can_fail = True
6253++ has_side_effects = True
6254++
6255++primop WriteByteArrayOp_Word8 "writeWord8Array#" GenPrimOp
6256++ MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
6257++ with has_side_effects = True
6258++ can_fail = True
6259++
6260++primop WriteByteArrayOp_Word16 "writeWord16Array#" GenPrimOp
6261++ MutableByteArray# s -> Int# -> Word# -> State# s -> State# s
6262++ with has_side_effects = True
6263++ can_fail = True
6264++
6265++primop WriteByteArrayOp_Word32 "writeWord32Array#" GenPrimOp
6266++ MutableByteArray# s -> Int# -> WORD32 -> State# s -> State# s
6267++ with has_side_effects = True
6268++ can_fail = True
6269++
6270++primop WriteByteArrayOp_Word64 "writeWord64Array#" GenPrimOp
6271++ MutableByteArray# s -> Int# -> WORD64 -> State# s -> State# s
6272++ with has_side_effects = True
6273++ can_fail = True
6274++
6275++primop CompareByteArraysOp "compareByteArrays#" GenPrimOp
6276++ ByteArray# -> Int# -> ByteArray# -> Int# -> Int# -> Int#
6277++ {{\tt compareByteArrays# src1 src1_ofs src2 src2_ofs n} compares
6278++ {\tt n} bytes starting at offset {\tt src1_ofs} in the first
6279++ {\tt ByteArray#} {\tt src1} to the range of {\tt n} bytes
6280++ (i.e. same length) starting at offset {\tt src2_ofs} of the second
6281++ {\tt ByteArray#} {\tt src2}. Both arrays must fully contain the
6282++ specified ranges, but this is not checked. Returns an {\tt Int#}
6283++ less than, equal to, or greater than zero if the range is found,
6284++ respectively, to be byte-wise lexicographically less than, to
6285++ match, or be greater than the second range.}
6286++ with
6287++ can_fail = True
6288++
6289++primop CopyByteArrayOp "copyByteArray#" GenPrimOp
6290++ ByteArray# -> Int# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6291++ {{\tt copyByteArray# src src_ofs dst dst_ofs n} copies the range
6292++ starting at offset {\tt src_ofs} of length {\tt n} from the
6293++ {\tt ByteArray#} {\tt src} to the {\tt MutableByteArray#} {\tt dst}
6294++ starting at offset {\tt dst_ofs}. Both arrays must fully contain
6295++ the specified ranges, but this is not checked. The two arrays must
6296++ not be the same array in different states, but this is not checked
6297++ either.}
6298++ with
6299++ has_side_effects = True
6300++ code_size = { primOpCodeSizeForeignCall + 4}
6301++ can_fail = True
6302++
6303++primop CopyMutableByteArrayOp "copyMutableByteArray#" GenPrimOp
6304++ MutableByteArray# s -> Int# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6305++ {Copy a range of the first MutableByteArray# to the specified region in the second MutableByteArray#.
6306++ Both arrays must fully contain the specified ranges, but this is not checked. The regions are
6307++ allowed to overlap, although this is only possible when the same array is provided
6308++ as both the source and the destination.}
6309++ with
6310++ has_side_effects = True
6311++ code_size = { primOpCodeSizeForeignCall + 4 }
6312++ can_fail = True
6313++
6314++primop CopyByteArrayToAddrOp "copyByteArrayToAddr#" GenPrimOp
6315++ ByteArray# -> Int# -> Addr# -> Int# -> State# s -> State# s
6316++ {Copy a range of the ByteArray# to the memory range starting at the Addr#.
6317++ The ByteArray# and the memory region at Addr# must fully contain the
6318++ specified ranges, but this is not checked. The Addr# must not point into the
6319++ ByteArray# (e.g. if the ByteArray# were pinned), but this is not checked
6320++ either.}
6321++ with
6322++ has_side_effects = True
6323++ code_size = { primOpCodeSizeForeignCall + 4}
6324++ can_fail = True
6325++
6326++primop CopyMutableByteArrayToAddrOp "copyMutableByteArrayToAddr#" GenPrimOp
6327++ MutableByteArray# s -> Int# -> Addr# -> Int# -> State# s -> State# s
6328++ {Copy a range of the MutableByteArray# to the memory range starting at the
6329++ Addr#. The MutableByteArray# and the memory region at Addr# must fully
6330++ contain the specified ranges, but this is not checked. The Addr# must not
6331++ point into the MutableByteArray# (e.g. if the MutableByteArray# were
6332++ pinned), but this is not checked either.}
6333++ with
6334++ has_side_effects = True
6335++ code_size = { primOpCodeSizeForeignCall + 4}
6336++ can_fail = True
6337++
6338++primop CopyAddrToByteArrayOp "copyAddrToByteArray#" GenPrimOp
6339++ Addr# -> MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6340++ {Copy a memory range starting at the Addr# to the specified range in the
6341++ MutableByteArray#. The memory region at Addr# and the ByteArray# must fully
6342++ contain the specified ranges, but this is not checked. The Addr# must not
6343++ point into the MutableByteArray# (e.g. if the MutableByteArray# were pinned),
6344++ but this is not checked either.}
6345++ with
6346++ has_side_effects = True
6347++ code_size = { primOpCodeSizeForeignCall + 4}
6348++ can_fail = True
6349++
6350++primop SetByteArrayOp "setByteArray#" GenPrimOp
6351++ MutableByteArray# s -> Int# -> Int# -> Int# -> State# s -> State# s
6352++ {{\tt setByteArray# ba off len c} sets the byte range {\tt [off, off+len]} of
6353++ the {\tt MutableByteArray#} to the byte {\tt c}.}
6354++ with
6355++ has_side_effects = True
6356++ code_size = { primOpCodeSizeForeignCall + 4 }
6357++ can_fail = True
6358++
6359++-- Atomic operations
6360++
6361++primop AtomicReadByteArrayOp_Int "atomicReadIntArray#" GenPrimOp
6362++ MutableByteArray# s -> Int# -> State# s -> (# State# s, Int# #)
6363++ {Given an array and an offset in Int units, read an element. The
6364++ index is assumed to be in bounds. Implies a full memory barrier.}
6365++ with has_side_effects = True
6366++ can_fail = True
6367++
6368++primop AtomicWriteByteArrayOp_Int "atomicWriteIntArray#" GenPrimOp
6369++ MutableByteArray# s -> Int# -> Int# -> State# s -> State# s
6370++ {Given an array and an offset in Int units, write an element. The
6371++ index is assumed to be in bounds. Implies a full memory barrier.}
6372++ with has_side_effects = True
6373++ can_fail = True
6374++
6375++primop CasByteArrayOp_Int "casIntArray#" GenPrimOp
6376++ MutableByteArray# s -> Int# -> Int# -> Int# -> State# s -> (# State# s, Int# #)
6377++ {Given an array, an offset in Int units, the expected old value, and
6378++ the new value, perform an atomic compare and swap i.e. write the new
6379++ value if the current value matches the provided old value. Returns
6380++ the value of the element before the operation. Implies a full memory
6381++ barrier.}
6382++ with has_side_effects = True
6383++ can_fail = True
6384++
6385++primop FetchAddByteArrayOp_Int "fetchAddIntArray#" GenPrimOp
6386++ MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
6387++ {Given an array, and offset in Int units, and a value to add,
6388++ atomically add the value to the element. Returns the value of the
6389++ element before the operation. Implies a full memory barrier.}
6390++ with has_side_effects = True
6391++ can_fail = True
6392++
6393++primop FetchSubByteArrayOp_Int "fetchSubIntArray#" GenPrimOp
6394++ MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
6395++ {Given an array, and offset in Int units, and a value to subtract,
6396++ atomically substract the value to the element. Returns the value of
6397++ the element before the operation. Implies a full memory barrier.}
6398++ with has_side_effects = True
6399++ can_fail = True
6400++
6401++primop FetchAndByteArrayOp_Int "fetchAndIntArray#" GenPrimOp
6402++ MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
6403++ {Given an array, and offset in Int units, and a value to AND,
6404++ atomically AND the value to the element. Returns the value of the
6405++ element before the operation. Implies a full memory barrier.}
6406++ with has_side_effects = True
6407++ can_fail = True
6408++
6409++primop FetchNandByteArrayOp_Int "fetchNandIntArray#" GenPrimOp
6410++ MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
6411++ {Given an array, and offset in Int units, and a value to NAND,
6412++ atomically NAND the value to the element. Returns the value of the
6413++ element before the operation. Implies a full memory barrier.}
6414++ with has_side_effects = True
6415++ can_fail = True
6416++
6417++primop FetchOrByteArrayOp_Int "fetchOrIntArray#" GenPrimOp
6418++ MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
6419++ {Given an array, and offset in Int units, and a value to OR,
6420++ atomically OR the value to the element. Returns the value of the
6421++ element before the operation. Implies a full memory barrier.}
6422++ with has_side_effects = True
6423++ can_fail = True
6424++
6425++primop FetchXorByteArrayOp_Int "fetchXorIntArray#" GenPrimOp
6426++ MutableByteArray# s -> Int# -> Int# -> State# s -> (# State# s, Int# #)
6427++ {Given an array, and offset in Int units, and a value to XOR,
6428++ atomically XOR the value to the element. Returns the value of the
6429++ element before the operation. Implies a full memory barrier.}
6430++ with has_side_effects = True
6431++ can_fail = True
6432++
6433++
6434++------------------------------------------------------------------------
6435++section "Arrays of arrays"
6436++ {Operations on {\tt ArrayArray\#}. An {\tt ArrayArray\#} contains references to {\em unpointed}
6437++ arrays, such as {\tt ByteArray\#s}. Hence, it is not parameterised by the element types,
6438++ just like a {\tt ByteArray\#}, but it needs to be scanned during GC, just like an {\tt Array#}.
6439++ We represent an {\tt ArrayArray\#} exactly as a {\tt Array\#}, but provide element-type-specific
6440++ indexing, reading, and writing.}
6441++------------------------------------------------------------------------
6442++
6443++primtype ArrayArray#
6444++
6445++primtype MutableArrayArray# s
6446++
6447++primop NewArrayArrayOp "newArrayArray#" GenPrimOp
6448++ Int# -> State# s -> (# State# s, MutableArrayArray# s #)
6449++ {Create a new mutable array of arrays with the specified number of elements,
6450++ in the specified state thread, with each element recursively referring to the
6451++ newly created array.}
6452++ with
6453++ out_of_line = True
6454++ has_side_effects = True
6455++
6456++primop SameMutableArrayArrayOp "sameMutableArrayArray#" GenPrimOp
6457++ MutableArrayArray# s -> MutableArrayArray# s -> Int#
6458++
6459++primop UnsafeFreezeArrayArrayOp "unsafeFreezeArrayArray#" GenPrimOp
6460++ MutableArrayArray# s -> State# s -> (# State# s, ArrayArray# #)
6461++ {Make a mutable array of arrays immutable, without copying.}
6462++ with
6463++ has_side_effects = True
6464++
6465++primop SizeofArrayArrayOp "sizeofArrayArray#" GenPrimOp
6466++ ArrayArray# -> Int#
6467++ {Return the number of elements in the array.}
6468++
6469++primop SizeofMutableArrayArrayOp "sizeofMutableArrayArray#" GenPrimOp
6470++ MutableArrayArray# s -> Int#
6471++ {Return the number of elements in the array.}
6472++
6473++primop IndexArrayArrayOp_ByteArray "indexByteArrayArray#" GenPrimOp
6474++ ArrayArray# -> Int# -> ByteArray#
6475++ with can_fail = True
6476++
6477++primop IndexArrayArrayOp_ArrayArray "indexArrayArrayArray#" GenPrimOp
6478++ ArrayArray# -> Int# -> ArrayArray#
6479++ with can_fail = True
6480++
6481++primop ReadArrayArrayOp_ByteArray "readByteArrayArray#" GenPrimOp
6482++ MutableArrayArray# s -> Int# -> State# s -> (# State# s, ByteArray# #)
6483++ with has_side_effects = True
6484++ can_fail = True
6485++
6486++primop ReadArrayArrayOp_MutableByteArray "readMutableByteArrayArray#" GenPrimOp
6487++ MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableByteArray# s #)
6488++ with has_side_effects = True
6489++ can_fail = True
6490++
6491++primop ReadArrayArrayOp_ArrayArray "readArrayArrayArray#" GenPrimOp
6492++ MutableArrayArray# s -> Int# -> State# s -> (# State# s, ArrayArray# #)
6493++ with has_side_effects = True
6494++ can_fail = True
6495++
6496++primop ReadArrayArrayOp_MutableArrayArray "readMutableArrayArrayArray#" GenPrimOp
6497++ MutableArrayArray# s -> Int# -> State# s -> (# State# s, MutableArrayArray# s #)
6498++ with has_side_effects = True
6499++ can_fail = True
6500++
6501++primop WriteArrayArrayOp_ByteArray "writeByteArrayArray#" GenPrimOp
6502++ MutableArrayArray# s -> Int# -> ByteArray# -> State# s -> State# s
6503++ with has_side_effects = True
6504++ can_fail = True
6505++
6506++primop WriteArrayArrayOp_MutableByteArray "writeMutableByteArrayArray#" GenPrimOp
6507++ MutableArrayArray# s -> Int# -> MutableByteArray# s -> State# s -> State# s
6508++ with has_side_effects = True
6509++ can_fail = True
6510++
6511++primop WriteArrayArrayOp_ArrayArray "writeArrayArrayArray#" GenPrimOp
6512++ MutableArrayArray# s -> Int# -> ArrayArray# -> State# s -> State# s
6513++ with has_side_effects = True
6514++ can_fail = True
6515++
6516++primop WriteArrayArrayOp_MutableArrayArray "writeMutableArrayArrayArray#" GenPrimOp
6517++ MutableArrayArray# s -> Int# -> MutableArrayArray# s -> State# s -> State# s
6518++ with has_side_effects = True
6519++ can_fail = True
6520++
6521++primop CopyArrayArrayOp "copyArrayArray#" GenPrimOp
6522++ ArrayArray# -> Int# -> MutableArrayArray# s -> Int# -> Int# -> State# s -> State# s
6523++ {Copy a range of the ArrayArray# to the specified region in the MutableArrayArray#.
6524++ Both arrays must fully contain the specified ranges, but this is not checked.
6525++ The two arrays must not be the same array in different states, but this is not checked either.}
6526++ with
6527++ out_of_line = True
6528++ has_side_effects = True
6529++ can_fail = True
6530++
6531++primop CopyMutableArrayArrayOp "copyMutableArrayArray#" GenPrimOp
6532++ MutableArrayArray# s -> Int# -> MutableArrayArray# s -> Int# -> Int# -> State# s -> State# s
6533++ {Copy a range of the first MutableArrayArray# to the specified region in the second
6534++ MutableArrayArray#.
6535++ Both arrays must fully contain the specified ranges, but this is not checked.
6536++ The regions are allowed to overlap, although this is only possible when the same
6537++ array is provided as both the source and the destination.
6538++ }
6539++ with
6540++ out_of_line = True
6541++ has_side_effects = True
6542++ can_fail = True
6543++
6544++------------------------------------------------------------------------
6545++section "Addr#"
6546++------------------------------------------------------------------------
6547++
6548++primtype Addr#
6549++ { An arbitrary machine address assumed to point outside
6550++ the garbage-collected heap. }
6551++
6552++pseudoop "nullAddr#" Addr#
6553++ { The null address. }
6554++
6555++primop AddrAddOp "plusAddr#" GenPrimOp Addr# -> Int# -> Addr#
6556++primop AddrSubOp "minusAddr#" GenPrimOp Addr# -> Addr# -> Int#
6557++ {Result is meaningless if two {\tt Addr\#}s are so far apart that their
6558++ difference doesn't fit in an {\tt Int\#}.}
6559++primop AddrRemOp "remAddr#" GenPrimOp Addr# -> Int# -> Int#
6560++ {Return the remainder when the {\tt Addr\#} arg, treated like an {\tt Int\#},
6561++ is divided by the {\tt Int\#} arg.}
6562++#if (WORD_SIZE_IN_BITS == 32 || WORD_SIZE_IN_BITS == 64)
6563++primop Addr2IntOp "addr2Int#" GenPrimOp Addr# -> Int#
6564++ {Coerce directly from address to int. Strongly deprecated.}
6565++ with code_size = 0
6566++primop Int2AddrOp "int2Addr#" GenPrimOp Int# -> Addr#
6567++ {Coerce directly from int to address. Strongly deprecated.}
6568++ with code_size = 0
6569++#endif
6570++
6571++primop AddrGtOp "gtAddr#" Compare Addr# -> Addr# -> Int#
6572++primop AddrGeOp "geAddr#" Compare Addr# -> Addr# -> Int#
6573++primop AddrEqOp "eqAddr#" Compare Addr# -> Addr# -> Int#
6574++primop AddrNeOp "neAddr#" Compare Addr# -> Addr# -> Int#
6575++primop AddrLtOp "ltAddr#" Compare Addr# -> Addr# -> Int#
6576++primop AddrLeOp "leAddr#" Compare Addr# -> Addr# -> Int#
6577++
6578++primop IndexOffAddrOp_Char "indexCharOffAddr#" GenPrimOp
6579++ Addr# -> Int# -> Char#
6580++ {Reads 8-bit character; offset in bytes.}
6581++ with can_fail = True
6582++
6583++primop IndexOffAddrOp_WideChar "indexWideCharOffAddr#" GenPrimOp
6584++ Addr# -> Int# -> Char#
6585++ {Reads 31-bit character; offset in 4-byte words.}
6586++ with can_fail = True
6587++
6588++primop IndexOffAddrOp_Int "indexIntOffAddr#" GenPrimOp
6589++ Addr# -> Int# -> Int#
6590++ with can_fail = True
6591++
6592++primop IndexOffAddrOp_Word "indexWordOffAddr#" GenPrimOp
6593++ Addr# -> Int# -> Word#
6594++ with can_fail = True
6595++
6596++primop IndexOffAddrOp_Addr "indexAddrOffAddr#" GenPrimOp
6597++ Addr# -> Int# -> Addr#
6598++ with can_fail = True
6599++
6600++primop IndexOffAddrOp_Float "indexFloatOffAddr#" GenPrimOp
6601++ Addr# -> Int# -> Float#
6602++ with can_fail = True
6603++
6604++primop IndexOffAddrOp_Double "indexDoubleOffAddr#" GenPrimOp
6605++ Addr# -> Int# -> Double#
6606++ with can_fail = True
6607++
6608++primop IndexOffAddrOp_StablePtr "indexStablePtrOffAddr#" GenPrimOp
6609++ Addr# -> Int# -> StablePtr# a
6610++ with can_fail = True
6611++
6612++primop IndexOffAddrOp_Int8 "indexInt8OffAddr#" GenPrimOp
6613++ Addr# -> Int# -> Int#
6614++ with can_fail = True
6615++
6616++primop IndexOffAddrOp_Int16 "indexInt16OffAddr#" GenPrimOp
6617++ Addr# -> Int# -> Int#
6618++ with can_fail = True
6619++
6620++primop IndexOffAddrOp_Int32 "indexInt32OffAddr#" GenPrimOp
6621++ Addr# -> Int# -> INT32
6622++ with can_fail = True
6623++
6624++primop IndexOffAddrOp_Int64 "indexInt64OffAddr#" GenPrimOp
6625++ Addr# -> Int# -> INT64
6626++ with can_fail = True
6627++
6628++primop IndexOffAddrOp_Word8 "indexWord8OffAddr#" GenPrimOp
6629++ Addr# -> Int# -> Word#
6630++ with can_fail = True
6631++
6632++primop IndexOffAddrOp_Word16 "indexWord16OffAddr#" GenPrimOp
6633++ Addr# -> Int# -> Word#
6634++ with can_fail = True
6635++
6636++primop IndexOffAddrOp_Word32 "indexWord32OffAddr#" GenPrimOp
6637++ Addr# -> Int# -> WORD32
6638++ with can_fail = True
6639++
6640++primop IndexOffAddrOp_Word64 "indexWord64OffAddr#" GenPrimOp
6641++ Addr# -> Int# -> WORD64
6642++ with can_fail = True
6643++
6644++primop ReadOffAddrOp_Char "readCharOffAddr#" GenPrimOp
6645++ Addr# -> Int# -> State# s -> (# State# s, Char# #)
6646++ {Reads 8-bit character; offset in bytes.}
6647++ with has_side_effects = True
6648++ can_fail = True
6649++
6650++primop ReadOffAddrOp_WideChar "readWideCharOffAddr#" GenPrimOp
6651++ Addr# -> Int# -> State# s -> (# State# s, Char# #)
6652++ {Reads 31-bit character; offset in 4-byte words.}
6653++ with has_side_effects = True
6654++ can_fail = True
6655++
6656++primop ReadOffAddrOp_Int "readIntOffAddr#" GenPrimOp
6657++ Addr# -> Int# -> State# s -> (# State# s, Int# #)
6658++ with has_side_effects = True
6659++ can_fail = True
6660++
6661++primop ReadOffAddrOp_Word "readWordOffAddr#" GenPrimOp
6662++ Addr# -> Int# -> State# s -> (# State# s, Word# #)
6663++ with has_side_effects = True
6664++ can_fail = True
6665++
6666++primop ReadOffAddrOp_Addr "readAddrOffAddr#" GenPrimOp
6667++ Addr# -> Int# -> State# s -> (# State# s, Addr# #)
6668++ with has_side_effects = True
6669++ can_fail = True
6670++
6671++primop ReadOffAddrOp_Float "readFloatOffAddr#" GenPrimOp
6672++ Addr# -> Int# -> State# s -> (# State# s, Float# #)
6673++ with has_side_effects = True
6674++ can_fail = True
6675++
6676++primop ReadOffAddrOp_Double "readDoubleOffAddr#" GenPrimOp
6677++ Addr# -> Int# -> State# s -> (# State# s, Double# #)
6678++ with has_side_effects = True
6679++ can_fail = True
6680++
6681++primop ReadOffAddrOp_StablePtr "readStablePtrOffAddr#" GenPrimOp
6682++ Addr# -> Int# -> State# s -> (# State# s, StablePtr# a #)
6683++ with has_side_effects = True
6684++ can_fail = True
6685++
6686++primop ReadOffAddrOp_Int8 "readInt8OffAddr#" GenPrimOp
6687++ Addr# -> Int# -> State# s -> (# State# s, Int# #)
6688++ with has_side_effects = True
6689++ can_fail = True
6690++
6691++primop ReadOffAddrOp_Int16 "readInt16OffAddr#" GenPrimOp
6692++ Addr# -> Int# -> State# s -> (# State# s, Int# #)
6693++ with has_side_effects = True
6694++ can_fail = True
6695++
6696++primop ReadOffAddrOp_Int32 "readInt32OffAddr#" GenPrimOp
6697++ Addr# -> Int# -> State# s -> (# State# s, INT32 #)
6698++ with has_side_effects = True
6699++ can_fail = True
6700++
6701++primop ReadOffAddrOp_Int64 "readInt64OffAddr#" GenPrimOp
6702++ Addr# -> Int# -> State# s -> (# State# s, INT64 #)
6703++ with has_side_effects = True
6704++ can_fail = True
6705++
6706++primop ReadOffAddrOp_Word8 "readWord8OffAddr#" GenPrimOp
6707++ Addr# -> Int# -> State# s -> (# State# s, Word# #)
6708++ with has_side_effects = True
6709++ can_fail = True
6710++
6711++primop ReadOffAddrOp_Word16 "readWord16OffAddr#" GenPrimOp
6712++ Addr# -> Int# -> State# s -> (# State# s, Word# #)
6713++ with has_side_effects = True
6714++ can_fail = True
6715++
6716++primop ReadOffAddrOp_Word32 "readWord32OffAddr#" GenPrimOp
6717++ Addr# -> Int# -> State# s -> (# State# s, WORD32 #)
6718++ with has_side_effects = True
6719++ can_fail = True
6720++
6721++primop ReadOffAddrOp_Word64 "readWord64OffAddr#" GenPrimOp
6722++ Addr# -> Int# -> State# s -> (# State# s, WORD64 #)
6723++ with has_side_effects = True
6724++ can_fail = True
6725++
6726++primop WriteOffAddrOp_Char "writeCharOffAddr#" GenPrimOp
6727++ Addr# -> Int# -> Char# -> State# s -> State# s
6728++ with has_side_effects = True
6729++ can_fail = True
6730++
6731++primop WriteOffAddrOp_WideChar "writeWideCharOffAddr#" GenPrimOp
6732++ Addr# -> Int# -> Char# -> State# s -> State# s
6733++ with has_side_effects = True
6734++ can_fail = True
6735++
6736++primop WriteOffAddrOp_Int "writeIntOffAddr#" GenPrimOp
6737++ Addr# -> Int# -> Int# -> State# s -> State# s
6738++ with has_side_effects = True
6739++ can_fail = True
6740++
6741++primop WriteOffAddrOp_Word "writeWordOffAddr#" GenPrimOp
6742++ Addr# -> Int# -> Word# -> State# s -> State# s
6743++ with has_side_effects = True
6744++ can_fail = True
6745++
6746++primop WriteOffAddrOp_Addr "writeAddrOffAddr#" GenPrimOp
6747++ Addr# -> Int# -> Addr# -> State# s -> State# s
6748++ with has_side_effects = True
6749++ can_fail = True
6750++
6751++primop WriteOffAddrOp_Float "writeFloatOffAddr#" GenPrimOp
6752++ Addr# -> Int# -> Float# -> State# s -> State# s
6753++ with has_side_effects = True
6754++ can_fail = True
6755++
6756++primop WriteOffAddrOp_Double "writeDoubleOffAddr#" GenPrimOp
6757++ Addr# -> Int# -> Double# -> State# s -> State# s
6758++ with has_side_effects = True
6759++ can_fail = True
6760++
6761++primop WriteOffAddrOp_StablePtr "writeStablePtrOffAddr#" GenPrimOp
6762++ Addr# -> Int# -> StablePtr# a -> State# s -> State# s
6763++ with has_side_effects = True
6764++ can_fail = True
6765++
6766++primop WriteOffAddrOp_Int8 "writeInt8OffAddr#" GenPrimOp
6767++ Addr# -> Int# -> Int# -> State# s -> State# s
6768++ with has_side_effects = True
6769++ can_fail = True
6770++
6771++primop WriteOffAddrOp_Int16 "writeInt16OffAddr#" GenPrimOp
6772++ Addr# -> Int# -> Int# -> State# s -> State# s
6773++ with has_side_effects = True
6774++ can_fail = True
6775++
6776++primop WriteOffAddrOp_Int32 "writeInt32OffAddr#" GenPrimOp
6777++ Addr# -> Int# -> INT32 -> State# s -> State# s
6778++ with has_side_effects = True
6779++ can_fail = True
6780++
6781++primop WriteOffAddrOp_Int64 "writeInt64OffAddr#" GenPrimOp
6782++ Addr# -> Int# -> INT64 -> State# s -> State# s
6783++ with has_side_effects = True
6784++ can_fail = True
6785++
6786++primop WriteOffAddrOp_Word8 "writeWord8OffAddr#" GenPrimOp
6787++ Addr# -> Int# -> Word# -> State# s -> State# s
6788++ with has_side_effects = True
6789++ can_fail = True
6790++
6791++primop WriteOffAddrOp_Word16 "writeWord16OffAddr#" GenPrimOp
6792++ Addr# -> Int# -> Word# -> State# s -> State# s
6793++ with has_side_effects = True
6794++ can_fail = True
6795++
6796++primop WriteOffAddrOp_Word32 "writeWord32OffAddr#" GenPrimOp
6797++ Addr# -> Int# -> WORD32 -> State# s -> State# s
6798++ with has_side_effects = True
6799++ can_fail = True
6800++
6801++primop WriteOffAddrOp_Word64 "writeWord64OffAddr#" GenPrimOp
6802++ Addr# -> Int# -> WORD64 -> State# s -> State# s
6803++ with has_side_effects = True
6804++ can_fail = True
6805++
6806++------------------------------------------------------------------------
6807++section "Mutable variables"
6808++ {Operations on MutVar\#s.}
6809++------------------------------------------------------------------------
6810++
6811++primtype MutVar# s a
6812++ {A {\tt MutVar\#} behaves like a single-element mutable array.}
6813++
6814++primop NewMutVarOp "newMutVar#" GenPrimOp
6815++ a -> State# s -> (# State# s, MutVar# s a #)
6816++ {Create {\tt MutVar\#} with specified initial value in specified state thread.}
6817++ with
6818++ out_of_line = True
6819++ has_side_effects = True
6820++
6821++-- Note [Why MutVar# ops can't fail]
6822++-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6823++--
6824++-- We don't label readMutVar# or writeMutVar# as can_fail.
6825++-- This may seem a bit peculiar, because they surely *could*
6826++-- fail spectacularly if passed a pointer to unallocated memory.
6827++-- But MutVar#s are always correct by construction; we never
6828++-- test if a pointer is valid before using it with these operations.
6829++-- So we never have to worry about floating the pointer reference
6830++-- outside a validity test. At the moment, has_side_effects blocks
6831++-- up the relevant optimizations anyway, but we hope to draw finer
6832++-- distinctions soon, which should improve matters for readMutVar#
6833++-- at least.
6834++
6835++primop ReadMutVarOp "readMutVar#" GenPrimOp
6836++ MutVar# s a -> State# s -> (# State# s, a #)
6837++ {Read contents of {\tt MutVar\#}. Result is not yet evaluated.}
6838++ with
6839++ -- See Note [Why MutVar# ops can't fail]
6840++ has_side_effects = True
6841++
6842++primop WriteMutVarOp "writeMutVar#" GenPrimOp
6843++ MutVar# s a -> a -> State# s -> State# s
6844++ {Write contents of {\tt MutVar\#}.}
6845++ with
6846++ -- See Note [Why MutVar# ops can't fail]
6847++ has_side_effects = True
6848++ code_size = { primOpCodeSizeForeignCall } -- for the write barrier
6849++
6850++primop SameMutVarOp "sameMutVar#" GenPrimOp
6851++ MutVar# s a -> MutVar# s a -> Int#
6852++
6853++-- Note [Why not an unboxed tuple in atomicModifyMutVar#?]
6854++-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6855++--
6856++-- Looking at the type of atomicModifyMutVar#, one might wonder why
6857++-- it doesn't return an unboxed tuple. e.g.,
6858++--
6859++-- MutVar# s a -> (a -> (# a, b #)) -> State# s -> (# State# s, b #)
6860++--
6861++-- The reason is that atomicModifyMutVar# relies on laziness for its atomicity.
6862++-- Given a MutVar# containing x, atomicModifyMutVar# merely replaces the
6863++-- its contents with a thunk of the form (fst (f x)). This can be done using an
6864++-- atomic compare-and-swap as it is merely replacing a pointer.
6865++
6866++primop AtomicModifyMutVarOp "atomicModifyMutVar#" GenPrimOp
6867++ MutVar# s a -> (a -> b) -> State# s -> (# State# s, c #)
6868++ { Modify the contents of a {\tt MutVar\#}. Note that this isn't strictly
6869++ speaking the correct type for this function, it should really be
6870++ {\tt MutVar# s a -> (a -> (a,b)) -> State# s -> (# State# s, b #)}, however
6871++ we don't know about pairs here. }
6872++ with
6873++ out_of_line = True
6874++ has_side_effects = True
6875++ can_fail = True
6876++
6877++primop CasMutVarOp "casMutVar#" GenPrimOp
6878++ MutVar# s a -> a -> a -> State# s -> (# State# s, Int#, a #)
6879++ with
6880++ out_of_line = True
6881++ has_side_effects = True
6882++
6883++------------------------------------------------------------------------
6884++section "Exceptions"
6885++------------------------------------------------------------------------
6886++
6887++-- Note [Strictness for mask/unmask/catch]
6888++-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
6889++-- Consider this example, which comes from GHC.IO.Handle.Internals:
6890++-- wantReadableHandle3 f ma b st
6891++-- = case ... of
6892++-- DEFAULT -> case ma of MVar a -> ...
6893++-- 0# -> maskAsynchExceptions# (\st -> case ma of MVar a -> ...)
6894++-- The outer case just decides whether to mask exceptions, but we don't want
6895++-- thereby to hide the strictness in 'ma'! Hence the use of strictApply1Dmd.
6896++--
6897++-- For catch, catchSTM, and catchRetry, we must be extra careful; see
6898++-- Note [Exceptions and strictness] in Demand
6899++
6900++primop CatchOp "catch#" GenPrimOp
6901++ (State# RealWorld -> (# State# RealWorld, a #) )
6902++ -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
6903++ -> State# RealWorld
6904++ -> (# State# RealWorld, a #)
6905++ with
6906++ strictness = { \ _arity -> mkClosedStrictSig [ lazyApply1Dmd
6907++ , lazyApply2Dmd
6908++ , topDmd] topRes }
6909++ -- See Note [Strictness for mask/unmask/catch]
6910++ out_of_line = True
6911++ has_side_effects = True
6912++
6913++primop RaiseOp "raise#" GenPrimOp
6914++ b -> o
6915++ -- NB: the type variable "o" is "a", but with OpenKind
6916++ with
6917++ strictness = { \ _arity -> mkClosedStrictSig [topDmd] exnRes }
6918++ -- NB: result is ThrowsExn
6919++ out_of_line = True
6920++ has_side_effects = True
6921++ -- raise# certainly throws a Haskell exception and hence has_side_effects
6922++ -- It doesn't actually make much difference because the fact that it
6923++ -- returns bottom independently ensures that we are careful not to discard
6924++ -- it. But still, it's better to say the Right Thing.
6925++
6926++-- raiseIO# needs to be a primop, because exceptions in the IO monad
6927++-- must be *precise* - we don't want the strictness analyser turning
6928++-- one kind of bottom into another, as it is allowed to do in pure code.
6929++--
6930++-- But we *do* want to know that it returns bottom after
6931++-- being applied to two arguments, so that this function is strict in y
6932++-- f x y | x>0 = raiseIO blah
6933++-- | y>0 = return 1
6934++-- | otherwise = return 2
6935++--
6936++-- TODO Check that the above notes on @f@ are valid. The function successfully
6937++-- produces an IO exception when compiled without optimization. If we analyze
6938++-- it as strict in @y@, won't we change that behavior under optimization?
6939++-- I thought the rule was that it was okay to replace one valid imprecise
6940++-- exception with another, but not to replace a precise exception with
6941++-- an imprecise one (dfeuer, 2017-03-05).
6942++
6943++primop RaiseIOOp "raiseIO#" GenPrimOp
6944++ a -> State# RealWorld -> (# State# RealWorld, b #)
6945++ with
6946++ strictness = { \ _arity -> mkClosedStrictSig [topDmd, topDmd] exnRes }
6947++ out_of_line = True
6948++ has_side_effects = True
6949++
6950++primop MaskAsyncExceptionsOp "maskAsyncExceptions#" GenPrimOp
6951++ (State# RealWorld -> (# State# RealWorld, a #))
6952++ -> (State# RealWorld -> (# State# RealWorld, a #))
6953++ with
6954++ strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
6955++ -- See Note [Strictness for mask/unmask/catch]
6956++ out_of_line = True
6957++ has_side_effects = True
6958++
6959++primop MaskUninterruptibleOp "maskUninterruptible#" GenPrimOp
6960++ (State# RealWorld -> (# State# RealWorld, a #))
6961++ -> (State# RealWorld -> (# State# RealWorld, a #))
6962++ with
6963++ strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
6964++ out_of_line = True
6965++ has_side_effects = True
6966++
6967++primop UnmaskAsyncExceptionsOp "unmaskAsyncExceptions#" GenPrimOp
6968++ (State# RealWorld -> (# State# RealWorld, a #))
6969++ -> (State# RealWorld -> (# State# RealWorld, a #))
6970++ with
6971++ strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
6972++ -- See Note [Strictness for mask/unmask/catch]
6973++ out_of_line = True
6974++ has_side_effects = True
6975++
6976++primop MaskStatus "getMaskingState#" GenPrimOp
6977++ State# RealWorld -> (# State# RealWorld, Int# #)
6978++ with
6979++ out_of_line = True
6980++ has_side_effects = True
6981++
6982++------------------------------------------------------------------------
6983++section "STM-accessible Mutable Variables"
6984++------------------------------------------------------------------------
6985++
6986++primtype TVar# s a
6987++
6988++primop AtomicallyOp "atomically#" GenPrimOp
6989++ (State# RealWorld -> (# State# RealWorld, a #) )
6990++ -> State# RealWorld -> (# State# RealWorld, a #)
6991++ with
6992++ strictness = { \ _arity -> mkClosedStrictSig [strictApply1Dmd,topDmd] topRes }
6993++ -- See Note [Strictness for mask/unmask/catch]
6994++ out_of_line = True
6995++ has_side_effects = True
6996++
6997++-- NB: retry#'s strictness information specifies it to throw an exception
6998++-- This lets the compiler perform some extra simplifications, since retry#
6999++-- will technically never return.
7000++--
7001++-- This allows the simplifier to replace things like:
7002++-- case retry# s1
7003++-- (# s2, a #) -> e
7004++-- with:
7005++-- retry# s1
7006++-- where 'e' would be unreachable anyway. See Trac #8091.
7007++--
7008++-- Note that it *does not* return botRes as the "exception" that is thrown may be
7009++-- "caught" by catchRetry#. This mistake caused #14171.
7010++primop RetryOp "retry#" GenPrimOp
7011++ State# RealWorld -> (# State# RealWorld, a #)
7012++ with
7013++ strictness = { \ _arity -> mkClosedStrictSig [topDmd] exnRes }
7014++ out_of_line = True
7015++ has_side_effects = True
7016++
7017++primop CatchRetryOp "catchRetry#" GenPrimOp
7018++ (State# RealWorld -> (# State# RealWorld, a #) )
7019++ -> (State# RealWorld -> (# State# RealWorld, a #) )
7020++ -> (State# RealWorld -> (# State# RealWorld, a #) )
7021++ with
7022++ strictness = { \ _arity -> mkClosedStrictSig [ catchArgDmd
7023++ , lazyApply1Dmd
7024++ , topDmd ] topRes }
7025++ -- See Note [Strictness for mask/unmask/catch]
7026++ out_of_line = True
7027++ has_side_effects = True
7028++
7029++primop CatchSTMOp "catchSTM#" GenPrimOp
7030++ (State# RealWorld -> (# State# RealWorld, a #) )
7031++ -> (b -> State# RealWorld -> (# State# RealWorld, a #) )
7032++ -> (State# RealWorld -> (# State# RealWorld, a #) )
7033++ with
7034++ strictness = { \ _arity -> mkClosedStrictSig [ lazyApply1Dmd
7035++ , lazyApply2Dmd
7036++ , topDmd ] topRes }
7037++ -- See Note [Strictness for mask/unmask/catch]
7038++ out_of_line = True
7039++ has_side_effects = True
7040++
7041++primop Check "check#" GenPrimOp
7042++ (State# RealWorld -> (# State# RealWorld, a #) )
7043++ -> (State# RealWorld -> State# RealWorld)
7044++ with
7045++ out_of_line = True
7046++ has_side_effects = True
7047++
7048++primop NewTVarOp "newTVar#" GenPrimOp
7049++ a
7050++ -> State# s -> (# State# s, TVar# s a #)
7051++ {Create a new {\tt TVar\#} holding a specified initial value.}
7052++ with
7053++ out_of_line = True
7054++ has_side_effects = True
7055++
7056++primop ReadTVarOp "readTVar#" GenPrimOp
7057++ TVar# s a
7058++ -> State# s -> (# State# s, a #)
7059++ {Read contents of {\tt TVar\#}. Result is not yet evaluated.}
7060++ with
7061++ out_of_line = True
7062++ has_side_effects = True
7063++
7064++primop ReadTVarIOOp "readTVarIO#" GenPrimOp
7065++ TVar# s a
7066++ -> State# s -> (# State# s, a #)
7067++ {Read contents of {\tt TVar\#} outside an STM transaction}
7068++ with
7069++ out_of_line = True
7070++ has_side_effects = True
7071++
7072++primop WriteTVarOp "writeTVar#" GenPrimOp
7073++ TVar# s a
7074++ -> a
7075++ -> State# s -> State# s
7076++ {Write contents of {\tt TVar\#}.}
7077++ with
7078++ out_of_line = True
7079++ has_side_effects = True
7080++
7081++primop SameTVarOp "sameTVar#" GenPrimOp
7082++ TVar# s a -> TVar# s a -> Int#
7083++
7084++
7085++------------------------------------------------------------------------
7086++section "Synchronized Mutable Variables"
7087++ {Operations on {\tt MVar\#}s. }
7088++------------------------------------------------------------------------
7089++
7090++primtype MVar# s a
7091++ { A shared mutable variable ({\it not} the same as a {\tt MutVar\#}!).
7092++ (Note: in a non-concurrent implementation, {\tt (MVar\# a)} can be
7093++ represented by {\tt (MutVar\# (Maybe a))}.) }
7094++
7095++primop NewMVarOp "newMVar#" GenPrimOp
7096++ State# s -> (# State# s, MVar# s a #)
7097++ {Create new {\tt MVar\#}; initially empty.}
7098++ with
7099++ out_of_line = True
7100++ has_side_effects = True
7101++
7102++primop TakeMVarOp "takeMVar#" GenPrimOp
7103++ MVar# s a -> State# s -> (# State# s, a #)
7104++ {If {\tt MVar\#} is empty, block until it becomes full.
7105++ Then remove and return its contents, and set it empty.}
7106++ with
7107++ out_of_line = True
7108++ has_side_effects = True
7109++
7110++primop TryTakeMVarOp "tryTakeMVar#" GenPrimOp
7111++ MVar# s a -> State# s -> (# State# s, Int#, a #)
7112++ {If {\tt MVar\#} is empty, immediately return with integer 0 and value undefined.
7113++ Otherwise, return with integer 1 and contents of {\tt MVar\#}, and set {\tt MVar\#} empty.}
7114++ with
7115++ out_of_line = True
7116++ has_side_effects = True
7117++
7118++primop PutMVarOp "putMVar#" GenPrimOp
7119++ MVar# s a -> a -> State# s -> State# s
7120++ {If {\tt MVar\#} is full, block until it becomes empty.
7121++ Then store value arg as its new contents.}
7122++ with
7123++ out_of_line = True
7124++ has_side_effects = True
7125++
7126++primop TryPutMVarOp "tryPutMVar#" GenPrimOp
7127++ MVar# s a -> a -> State# s -> (# State# s, Int# #)
7128++ {If {\tt MVar\#} is full, immediately return with integer 0.
7129++ Otherwise, store value arg as {\tt MVar\#}'s new contents, and return with integer 1.}
7130++ with
7131++ out_of_line = True
7132++ has_side_effects = True
7133++
7134++primop ReadMVarOp "readMVar#" GenPrimOp
7135++ MVar# s a -> State# s -> (# State# s, a #)
7136++ {If {\tt MVar\#} is empty, block until it becomes full.
7137++ Then read its contents without modifying the MVar, without possibility
7138++ of intervention from other threads.}
7139++ with
7140++ out_of_line = True
7141++ has_side_effects = True
7142++
7143++primop TryReadMVarOp "tryReadMVar#" GenPrimOp
7144++ MVar# s a -> State# s -> (# State# s, Int#, a #)
7145++ {If {\tt MVar\#} is empty, immediately return with integer 0 and value undefined.
7146++ Otherwise, return with integer 1 and contents of {\tt MVar\#}.}
7147++ with
7148++ out_of_line = True
7149++ has_side_effects = True
7150++
7151++primop SameMVarOp "sameMVar#" GenPrimOp
7152++ MVar# s a -> MVar# s a -> Int#
7153++
7154++primop IsEmptyMVarOp "isEmptyMVar#" GenPrimOp
7155++ MVar# s a -> State# s -> (# State# s, Int# #)
7156++ {Return 1 if {\tt MVar\#} is empty; 0 otherwise.}
7157++ with
7158++ out_of_line = True
7159++ has_side_effects = True
7160++
7161++------------------------------------------------------------------------
7162++section "Delay/wait operations"
7163++------------------------------------------------------------------------
7164++
7165++primop DelayOp "delay#" GenPrimOp
7166++ Int# -> State# s -> State# s
7167++ {Sleep specified number of microseconds.}
7168++ with
7169++ has_side_effects = True
7170++ out_of_line = True
7171++
7172++primop WaitReadOp "waitRead#" GenPrimOp
7173++ Int# -> State# s -> State# s
7174++ {Block until input is available on specified file descriptor.}
7175++ with
7176++ has_side_effects = True
7177++ out_of_line = True
7178++
7179++primop WaitWriteOp "waitWrite#" GenPrimOp
7180++ Int# -> State# s -> State# s
7181++ {Block until output is possible on specified file descriptor.}
7182++ with
7183++ has_side_effects = True
7184++ out_of_line = True
7185++
7186++#if defined(mingw32_TARGET_OS)
7187++primop AsyncReadOp "asyncRead#" GenPrimOp
7188++ Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
7189++ {Asynchronously read bytes from specified file descriptor.}
7190++ with
7191++ has_side_effects = True
7192++ out_of_line = True
7193++
7194++primop AsyncWriteOp "asyncWrite#" GenPrimOp
7195++ Int# -> Int# -> Int# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
7196++ {Asynchronously write bytes from specified file descriptor.}
7197++ with
7198++ has_side_effects = True
7199++ out_of_line = True
7200++
7201++primop AsyncDoProcOp "asyncDoProc#" GenPrimOp
7202++ Addr# -> Addr# -> State# RealWorld-> (# State# RealWorld, Int#, Int# #)
7203++ {Asynchronously perform procedure (first arg), passing it 2nd arg.}
7204++ with
7205++ has_side_effects = True
7206++ out_of_line = True
7207++
7208++#endif
7209++
7210++------------------------------------------------------------------------
7211++section "Concurrency primitives"
7212++------------------------------------------------------------------------
7213++
7214++primtype State# s
7215++ { {\tt State\#} is the primitive, unlifted type of states. It has
7216++ one type parameter, thus {\tt State\# RealWorld}, or {\tt State\# s},
7217++ where s is a type variable. The only purpose of the type parameter
7218++ is to keep different state threads separate. It is represented by
7219++ nothing at all. }
7220++
7221++primtype RealWorld
7222++ { {\tt RealWorld} is deeply magical. It is {\it primitive}, but it is not
7223++ {\it unlifted} (hence {\tt ptrArg}). We never manipulate values of type
7224++ {\tt RealWorld}; it's only used in the type system, to parameterise {\tt State\#}. }
7225++
7226++primtype ThreadId#
7227++ {(In a non-concurrent implementation, this can be a singleton
7228++ type, whose (unique) value is returned by {\tt myThreadId\#}. The
7229++ other operations can be omitted.)}
7230++
7231++primop ForkOp "fork#" GenPrimOp
7232++ a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
7233++ with
7234++ has_side_effects = True
7235++ out_of_line = True
7236++
7237++primop ForkOnOp "forkOn#" GenPrimOp
7238++ Int# -> a -> State# RealWorld -> (# State# RealWorld, ThreadId# #)
7239++ with
7240++ has_side_effects = True
7241++ out_of_line = True
7242++
7243++primop KillThreadOp "killThread#" GenPrimOp
7244++ ThreadId# -> a -> State# RealWorld -> State# RealWorld
7245++ with
7246++ has_side_effects = True
7247++ out_of_line = True
7248++
7249++primop YieldOp "yield#" GenPrimOp
7250++ State# RealWorld -> State# RealWorld
7251++ with
7252++ has_side_effects = True
7253++ out_of_line = True
7254++
7255++primop MyThreadIdOp "myThreadId#" GenPrimOp
7256++ State# RealWorld -> (# State# RealWorld, ThreadId# #)
7257++ with
7258++ out_of_line = True
7259++ has_side_effects = True
7260++
7261++primop LabelThreadOp "labelThread#" GenPrimOp
7262++ ThreadId# -> Addr# -> State# RealWorld -> State# RealWorld
7263++ with
7264++ has_side_effects = True
7265++ out_of_line = True
7266++
7267++primop IsCurrentThreadBoundOp "isCurrentThreadBound#" GenPrimOp
7268++ State# RealWorld -> (# State# RealWorld, Int# #)
7269++ with
7270++ out_of_line = True
7271++ has_side_effects = True
7272++
7273++primop NoDuplicateOp "noDuplicate#" GenPrimOp
7274++ State# s -> State# s
7275++ with
7276++ out_of_line = True
7277++ has_side_effects = True
7278++
7279++primop ThreadStatusOp "threadStatus#" GenPrimOp
7280++ ThreadId# -> State# RealWorld -> (# State# RealWorld, Int#, Int#, Int# #)
7281++ with
7282++ out_of_line = True
7283++ has_side_effects = True
7284++
7285++------------------------------------------------------------------------
7286++section "Weak pointers"
7287++------------------------------------------------------------------------
7288++
7289++primtype Weak# b
7290++
7291++-- note that tyvar "o" denotes openAlphaTyVar
7292++
7293++primop MkWeakOp "mkWeak#" GenPrimOp
7294++ o -> b -> (State# RealWorld -> (# State# RealWorld, c #))
7295++ -> State# RealWorld -> (# State# RealWorld, Weak# b #)
7296++ { {\tt mkWeak# k v finalizer s} creates a weak reference to value {\tt k},
7297++ with an associated reference to some value {\tt v}. If {\tt k} is still
7298++ alive then {\tt v} can be retrieved using {\tt deRefWeak#}. Note that
7299++ the type of {\tt k} must be represented by a pointer (i.e. of kind {\tt
7300++ TYPE 'LiftedRep} or {\tt TYPE 'UnliftedRep}). }
7301++ with
7302++ has_side_effects = True
7303++ out_of_line = True
7304++
7305++primop MkWeakNoFinalizerOp "mkWeakNoFinalizer#" GenPrimOp
7306++ o -> b -> State# RealWorld -> (# State# RealWorld, Weak# b #)
7307++ with
7308++ has_side_effects = True
7309++ out_of_line = True
7310++
7311++primop AddCFinalizerToWeakOp "addCFinalizerToWeak#" GenPrimOp
7312++ Addr# -> Addr# -> Int# -> Addr# -> Weak# b
7313++ -> State# RealWorld -> (# State# RealWorld, Int# #)
7314++ { {\tt addCFinalizerToWeak# fptr ptr flag eptr w} attaches a C
7315++ function pointer {\tt fptr} to a weak pointer {\tt w} as a finalizer. If
7316++ {\tt flag} is zero, {\tt fptr} will be called with one argument,
7317++ {\tt ptr}. Otherwise, it will be called with two arguments,
7318++ {\tt eptr} and {\tt ptr}. {\tt addCFinalizerToWeak#} returns
7319++ 1 on success, or 0 if {\tt w} is already dead. }
7320++ with
7321++ has_side_effects = True
7322++ out_of_line = True
7323++
7324++primop DeRefWeakOp "deRefWeak#" GenPrimOp
7325++ Weak# a -> State# RealWorld -> (# State# RealWorld, Int#, a #)
7326++ with
7327++ has_side_effects = True
7328++ out_of_line = True
7329++
7330++primop FinalizeWeakOp "finalizeWeak#" GenPrimOp
7331++ Weak# a -> State# RealWorld -> (# State# RealWorld, Int#,
7332++ (State# RealWorld -> (# State# RealWorld, b #) ) #)
7333++ { Finalize a weak pointer. The return value is an unboxed tuple
7334++ containing the new state of the world and an "unboxed Maybe",
7335++ represented by an {\tt Int#} and a (possibly invalid) finalization
7336++ action. An {\tt Int#} of {\tt 1} indicates that the finalizer is valid. The
7337++ return value {\tt b} from the finalizer should be ignored. }
7338++ with
7339++ has_side_effects = True
7340++ out_of_line = True
7341++
7342++primop TouchOp "touch#" GenPrimOp
7343++ o -> State# RealWorld -> State# RealWorld
7344++ with
7345++ code_size = { 0 }
7346++ has_side_effects = True
7347++
7348++------------------------------------------------------------------------
7349++section "Stable pointers and names"
7350++------------------------------------------------------------------------
7351++
7352++primtype StablePtr# a
7353++
7354++primtype StableName# a
7355++
7356++primop MakeStablePtrOp "makeStablePtr#" GenPrimOp
7357++ a -> State# RealWorld -> (# State# RealWorld, StablePtr# a #)
7358++ with
7359++ has_side_effects = True
7360++ out_of_line = True
7361++
7362++primop DeRefStablePtrOp "deRefStablePtr#" GenPrimOp
7363++ StablePtr# a -> State# RealWorld -> (# State# RealWorld, a #)
7364++ with
7365++ has_side_effects = True
7366++ out_of_line = True
7367++
7368++primop EqStablePtrOp "eqStablePtr#" GenPrimOp
7369++ StablePtr# a -> StablePtr# a -> Int#
7370++ with
7371++ has_side_effects = True
7372++
7373++primop MakeStableNameOp "makeStableName#" GenPrimOp
7374++ a -> State# RealWorld -> (# State# RealWorld, StableName# a #)
7375++ with
7376++ has_side_effects = True
7377++ out_of_line = True
7378++
7379++primop EqStableNameOp "eqStableName#" GenPrimOp
7380++ StableName# a -> StableName# b -> Int#
7381++
7382++primop StableNameToIntOp "stableNameToInt#" GenPrimOp
7383++ StableName# a -> Int#
7384++
7385++------------------------------------------------------------------------
7386++section "Compact normal form"
7387++------------------------------------------------------------------------
7388++
7389++primtype Compact#
7390++
7391++primop CompactNewOp "compactNew#" GenPrimOp
7392++ Word# -> State# RealWorld -> (# State# RealWorld, Compact# #)
7393++ { Create a new Compact with the given size (in bytes, not words).
7394++ The size is rounded up to a multiple of the allocator block size,
7395++ and capped to one mega block. }
7396++ with
7397++ has_side_effects = True
7398++ out_of_line = True
7399++
7400++primop CompactResizeOp "compactResize#" GenPrimOp
7401++ Compact# -> Word# -> State# RealWorld ->
7402++ State# RealWorld
7403++ { Set the new allocation size of the compact. This value (in bytes)
7404++ determines the size of each block in the compact chain. }
7405++ with
7406++ has_side_effects = True
7407++ out_of_line = True
7408++
7409++primop CompactContainsOp "compactContains#" GenPrimOp
7410++ Compact# -> a -> State# RealWorld -> (# State# RealWorld, Int# #)
7411++ { Returns 1# if the object is contained in the compact, 0# otherwise. }
7412++ with
7413++ out_of_line = True
7414++
7415++primop CompactContainsAnyOp "compactContainsAny#" GenPrimOp
7416++ a -> State# RealWorld -> (# State# RealWorld, Int# #)
7417++ { Returns 1# if the object is in any compact at all, 0# otherwise. }
7418++ with
7419++ out_of_line = True
7420++
7421++primop CompactGetFirstBlockOp "compactGetFirstBlock#" GenPrimOp
7422++ Compact# -> State# RealWorld -> (# State# RealWorld, Addr#, Word# #)
7423++ { Returns the address and the size (in bytes) of the first block of
7424++ a compact. }
7425++ with
7426++ out_of_line = True
7427++
7428++primop CompactGetNextBlockOp "compactGetNextBlock#" GenPrimOp
7429++ Compact# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr#, Word# #)
7430++ { Given a compact and the address of one its blocks, returns the
7431++ next block and its size, or #nullAddr if the argument was the
7432++ last block in the compact. }
7433++ with
7434++ out_of_line = True
7435++
7436++primop CompactAllocateBlockOp "compactAllocateBlock#" GenPrimOp
7437++ Word# -> Addr# -> State# RealWorld -> (# State# RealWorld, Addr# #)
7438++ { Attempt to allocate a compact block with the given size (in
7439++ bytes) at the given address. The first argument is a hint to
7440++ the allocator, allocation might be satisfied at a different
7441++ address (which is returned).
7442++ The resulting block is not known to the GC until
7443++ compactFixupPointers# is called on it, and care must be taken
7444++ so that the address does not escape or memory will be leaked.
7445++ }
7446++ with
7447++ has_side_effects = True
7448++ out_of_line = True
7449++
7450++primop CompactFixupPointersOp "compactFixupPointers#" GenPrimOp
7451++ Addr# -> Addr# -> State# RealWorld -> (# State# RealWorld, Compact#, Addr# #)
7452++ { Given the pointer to the first block of a compact, and the
7453++ address of the root object in the old address space, fix up
7454++ the internal pointers inside the compact to account for
7455++ a different position in memory than when it was serialized.
7456++ This method must be called exactly once after importing
7457++ a serialized compact, and returns the new compact and
7458++ the new adjusted root address. }
7459++ with
7460++ has_side_effects = True
7461++ out_of_line = True
7462++
7463++primop CompactAdd "compactAdd#" GenPrimOp
7464++ Compact# -> a -> State# RealWorld -> (# State# RealWorld, a #)
7465++ { Recursively add a closure and its transitive closure to a
7466++ {\texttt Compact\#}, evaluating any unevaluated components at the
7467++ same time. Note: {\texttt compactAdd\#} is not thread-safe, so
7468++ only one thread may call {\texttt compactAdd\#} with a particular
7469++ {\texttt Compact#} at any given time. The primop does not
7470++ enforce any mutual exclusion; the caller is expected to
7471++ arrange this. }
7472++ with
7473++ has_side_effects = True
7474++ out_of_line = True
7475++
7476++primop CompactAddWithSharing "compactAddWithSharing#" GenPrimOp
7477++ Compact# -> a -> State# RealWorld -> (# State# RealWorld, a #)
7478++ { Like {\texttt compactAdd\#}, but retains sharing and cycles
7479++ during compaction. }
7480++ with
7481++ has_side_effects = True
7482++ out_of_line = True
7483++
7484++primop CompactSize "compactSize#" GenPrimOp
7485++ Compact# -> State# RealWorld -> (# State# RealWorld, Word# #)
7486++ { Return the size (in bytes) of the total amount of data in the Compact# }
7487++ with
7488++ has_side_effects = True
7489++ out_of_line = True
7490++
7491++------------------------------------------------------------------------
7492++section "Unsafe pointer equality"
7493++-- (#1 Bad Guy: Alastair Reid :)
7494++------------------------------------------------------------------------
7495++
7496++primop ReallyUnsafePtrEqualityOp "reallyUnsafePtrEquality#" GenPrimOp
7497++ a -> a -> Int#
7498++ { Returns {\texttt 1\#} if the given pointers are equal and {\texttt 0\#} otherwise. }
7499++ with
7500++ can_fail = True -- See Note [reallyUnsafePtrEquality#]
7501++
7502++
7503++-- Note [reallyUnsafePtrEquality#]
7504++-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7505++--
7506++-- reallyUnsafePtrEquality# can't actually fail, per se, but we mark it can_fail
7507++-- anyway. Until 5a9a1738023a, GHC considered primops okay for speculation only
7508++-- when their arguments were known to be forced. This was unnecessarily
7509++-- conservative, but it prevented reallyUnsafePtrEquality# from floating out of
7510++-- places where its arguments were known to be forced. Unfortunately, GHC could
7511++-- sometimes lose track of whether those arguments were forced, leading to let/app
7512++-- invariant failures (see Trac 13027 and the discussion in Trac 11444). Now that
7513++-- ok_for_speculation skips over lifted arguments, we need to explicitly prevent
7514++-- reallyUnsafePtrEquality# from floating out. The reasons are closely related
7515++-- to those described in Note [dataToTag#], although the consequences are less
7516++-- severe. Imagine if we had
7517++--
7518++-- \x y . case x of x'
7519++-- DEFAULT ->
7520++-- case y of y'
7521++-- DEFAULT ->
7522++-- let eq = reallyUnsafePtrEquality# x' y'
7523++-- in ...
7524++--
7525++-- If the let floats out, we'll get
7526++--
7527++-- \x y . let eq = reallyUnsafePtrEquality# x y
7528++-- in case x of ...
7529++--
7530++-- The trouble is that pointer equality between thunks is very different
7531++-- from pointer equality between the values those thunks reduce to, and the latter
7532++-- is typically much more precise.
7533++
7534++------------------------------------------------------------------------
7535++section "Parallelism"
7536++------------------------------------------------------------------------
7537++
7538++primop ParOp "par#" GenPrimOp
7539++ a -> Int#
7540++ with
7541++ -- Note that Par is lazy to avoid that the sparked thing
7542++ -- gets evaluated strictly, which it should *not* be
7543++ has_side_effects = True
7544++ code_size = { primOpCodeSizeForeignCall }
7545++
7546++primop SparkOp "spark#" GenPrimOp
7547++ a -> State# s -> (# State# s, a #)
7548++ with has_side_effects = True
7549++ code_size = { primOpCodeSizeForeignCall }
7550++
7551++primop SeqOp "seq#" GenPrimOp
7552++ a -> State# s -> (# State# s, a #)
7553++ -- See Note [seq# magic] in PrelRules
7554++
7555++primop GetSparkOp "getSpark#" GenPrimOp
7556++ State# s -> (# State# s, Int#, a #)
7557++ with
7558++ has_side_effects = True
7559++ out_of_line = True
7560++
7561++primop NumSparks "numSparks#" GenPrimOp
7562++ State# s -> (# State# s, Int# #)
7563++ { Returns the number of sparks in the local spark pool. }
7564++ with
7565++ has_side_effects = True
7566++ out_of_line = True
7567++
7568++------------------------------------------------------------------------
7569++section "Tag to enum stuff"
7570++ {Convert back and forth between values of enumerated types
7571++ and small integers.}
7572++------------------------------------------------------------------------
7573++
7574++primop DataToTagOp "dataToTag#" GenPrimOp
7575++ a -> Int# -- Zero-indexed; the first constructor has tag zero
7576++ with
7577++ can_fail = True -- See Note [dataToTag#]
7578++ strictness = { \ _arity -> mkClosedStrictSig [evalDmd] topRes }
7579++ -- dataToTag# must have an evaluated argument
7580++
7581++primop TagToEnumOp "tagToEnum#" GenPrimOp
7582++ Int# -> a
7583++
7584++{- Note [dataToTag#]
7585++~~~~~~~~~~~~~~~~~~~~
7586++The dataToTag# primop should always be applied to an evaluated argument.
7587++The way to ensure this is to invoke it via the 'getTag' wrapper in GHC.Base:
7588++ getTag :: a -> Int#
7589++ getTag !x = dataToTag# x
7590++
7591++But now consider
7592++ \z. case x of y -> let v = dataToTag# y in ...
7593++
7594++To improve floating, the FloatOut pass (deliberately) does a
7595++binder-swap on the case, to give
7596++ \z. case x of y -> let v = dataToTag# x in ...
7597++
7598++Now FloatOut might float that v-binding outside the \z. But that is
7599++bad because that might mean x gest evaluated much too early! (CorePrep
7600++adds an eval to a dataToTag# call, to ensure that the argument really is
7601++evaluated; see CorePrep Note [dataToTag magic].)
7602++
7603++Solution: make DataToTag into a can_fail primop. That will stop it floating
7604++(see Note [PrimOp can_fail and has_side_effects] in PrimOp). It's a bit of
7605++a hack but never mind.
7606++-}
7607++
7608++------------------------------------------------------------------------
7609++section "Bytecode operations"
7610++ {Support for manipulating bytecode objects used by the interpreter and
7611++ linker.
7612++
7613++ Bytecode objects are heap objects which represent top-level bindings and
7614++ contain a list of instructions and data needed by these instructions.}
7615++------------------------------------------------------------------------
7616++
7617++primtype BCO#
7618++ { Primitive bytecode type. }
7619++
7620++primop AddrToAnyOp "addrToAny#" GenPrimOp
7621++ Addr# -> (# a #)
7622++ { Convert an {\tt Addr\#} to a followable Any type. }
7623++ with
7624++ code_size = 0
7625++
7626++primop AnyToAddrOp "anyToAddr#" GenPrimOp
7627++ a -> State# RealWorld -> (# State# RealWorld, Addr# #)
7628++ { Retrieve the address of any Haskell value. This is
7629++ essentially an {\texttt unsafeCoerce\#}, but if implemented as such
7630++ the core lint pass complains and fails to compile.
7631++ As a primop, it is opaque to core/stg, and only appears
7632++ in cmm (where the copy propagation pass will get rid of it).
7633++ Note that "a" must be a value, not a thunk! It's too late
7634++ for strictness analysis to enforce this, so you're on your
7635++ own to guarantee this. Also note that {\texttt Addr\#} is not a GC
7636++ pointer - up to you to guarantee that it does not become
7637++ a dangling pointer immediately after you get it.}
7638++ with
7639++ code_size = 0
7640++
7641++primop MkApUpd0_Op "mkApUpd0#" GenPrimOp
7642++ BCO# -> (# a #)
7643++ { Wrap a BCO in a {\tt AP_UPD} thunk which will be updated with the value of
7644++ the BCO when evaluated. }
7645++ with
7646++ out_of_line = True
7647++
7648++primop NewBCOOp "newBCO#" GenPrimOp
7649++ ByteArray# -> ByteArray# -> Array# a -> Int# -> ByteArray# -> State# s -> (# State# s, BCO# #)
7650++ { {\tt newBCO\# instrs lits ptrs arity bitmap} creates a new bytecode object. The
7651++ resulting object encodes a function of the given arity with the instructions
7652++ encoded in {\tt instrs}, and a static reference table usage bitmap given by
7653++ {\tt bitmap}. }
7654++ with
7655++ has_side_effects = True
7656++ out_of_line = True
7657++
7658++primop UnpackClosureOp "unpackClosure#" GenPrimOp
7659++ a -> (# Addr#, Array# b, ByteArray# #)
7660++ { {\tt unpackClosure\# closure} copies non-pointers and pointers in the
7661++ payload of the given closure into two new arrays, and returns a pointer to
7662++ the first word of the closure's info table, a pointer array for the
7663++ pointers in the payload, and a non-pointer array for the non-pointers in
7664++ the payload. }
7665++ with
7666++ out_of_line = True
7667++
7668++primop GetApStackValOp "getApStackVal#" GenPrimOp
7669++ a -> Int# -> (# Int#, b #)
7670++ with
7671++ out_of_line = True
7672++
7673++------------------------------------------------------------------------
7674++section "Misc"
7675++ {These aren't nearly as wired in as Etc...}
7676++------------------------------------------------------------------------
7677++
7678++primop GetCCSOfOp "getCCSOf#" GenPrimOp
7679++ a -> State# s -> (# State# s, Addr# #)
7680++
7681++primop GetCurrentCCSOp "getCurrentCCS#" GenPrimOp
7682++ a -> State# s -> (# State# s, Addr# #)
7683++ { Returns the current {\tt CostCentreStack} (value is {\tt NULL} if
7684++ not profiling). Takes a dummy argument which can be used to
7685++ avoid the call to {\tt getCurrentCCS\#} being floated out by the
7686++ simplifier, which would result in an uninformative stack
7687++ ("CAF"). }
7688++
7689++primop ClearCCSOp "clearCCS#" GenPrimOp
7690++ (State# s -> (# State# s, a #)) -> State# s -> (# State# s, a #)
7691++ { Run the supplied IO action with an empty CCS. For example, this
7692++ is used by the interpreter to run an interpreted computation
7693++ without the call stack showing that it was invoked from GHC. }
7694++ with
7695++ out_of_line = True
7696++
7697++------------------------------------------------------------------------
7698++section "Etc"
7699++ {Miscellaneous built-ins}
7700++------------------------------------------------------------------------
7701++
7702++primtype Proxy# a
7703++ { The type constructor {\tt Proxy#} is used to bear witness to some
7704++ type variable. It's used when you want to pass around proxy values
7705++ for doing things like modelling type applications. A {\tt Proxy#}
7706++ is not only unboxed, it also has a polymorphic kind, and has no
7707++ runtime representation, being totally free. }
7708++
7709++pseudoop "proxy#"
7710++ Proxy# a
7711++ { Witness for an unboxed {\tt Proxy#} value, which has no runtime
7712++ representation. }
7713++
7714++pseudoop "seq"
7715++ a -> b -> b
7716++ { The value of {\tt seq a b} is bottom if {\tt a} is bottom, and
7717++ otherwise equal to {\tt b}. In other words, it evaluates the first
7718++ argument {\tt a} to weak head normal form (WHNF). {\tt seq} is usually
7719++ introduced to improve performance by avoiding unneeded laziness.
7720++
7721++ A note on evaluation order: the expression {\tt seq a b} does
7722++ {\it not} guarantee that {\tt a} will be evaluated before {\tt b}.
7723++ The only guarantee given by {\tt seq} is that the both {\tt a}
7724++ and {\tt b} will be evaluated before {\tt seq} returns a value.
7725++ In particular, this means that {\tt b} may be evaluated before
7726++ {\tt a}. If you need to guarantee a specific order of evaluation,
7727++ you must use the function {\tt pseq} from the "parallel" package. }
7728++
7729++pseudoop "unsafeCoerce#"
7730++ a -> b
7731++ { The function {\tt unsafeCoerce\#} allows you to side-step the typechecker entirely. That
7732++ is, it allows you to coerce any type into any other type. If you use this function,
7733++ you had better get it right, otherwise segmentation faults await. It is generally
7734++ used when you want to write a program that you know is well-typed, but where Haskell's
7735++ type system is not expressive enough to prove that it is well typed.
7736++
7737++ The following uses of {\tt unsafeCoerce\#} are supposed to work (i.e. not lead to
7738++ spurious compile-time or run-time crashes):
7739++
7740++ * Casting any lifted type to {\tt Any}
7741++
7742++ * Casting {\tt Any} back to the real type
7743++
7744++ * Casting an unboxed type to another unboxed type of the same size.
7745++ (Casting between floating-point and integral types does not work.
7746++ See the {\tt GHC.Float} module for functions to do work.)
7747++
7748++ * Casting between two types that have the same runtime representation. One case is when
7749++ the two types differ only in "phantom" type parameters, for example
7750++ {\tt Ptr Int} to {\tt Ptr Float}, or {\tt [Int]} to {\tt [Float]} when the list is
7751++ known to be empty. Also, a {\tt newtype} of a type {\tt T} has the same representation
7752++ at runtime as {\tt T}.
7753++
7754++ Other uses of {\tt unsafeCoerce\#} are undefined. In particular, you should not use
7755++ {\tt unsafeCoerce\#} to cast a T to an algebraic data type D, unless T is also
7756++ an algebraic data type. For example, do not cast {\tt Int->Int} to {\tt Bool}, even if
7757++ you later cast that {\tt Bool} back to {\tt Int->Int} before applying it. The reasons
7758++ have to do with GHC's internal representation details (for the cognoscenti, data values
7759++ can be entered but function closures cannot). If you want a safe type to cast things
7760++ to, use {\tt Any}, which is not an algebraic data type.
7761++
7762++ }
7763++
7764++-- NB. It is tempting to think that casting a value to a type that it doesn't have is safe
7765++-- as long as you don't "do anything" with the value in its cast form, such as seq on it. This
7766++-- isn't the case: the compiler can insert seqs itself, and if these happen at the wrong type,
7767++-- Bad Things Might Happen. See bug #1616: in this case we cast a function of type (a,b) -> (a,b)
7768++-- to () -> () and back again. The strictness analyser saw that the function was strict, but
7769++-- the wrapper had type () -> (), and hence the wrapper de-constructed the (), the worker re-constructed
7770++-- a new (), with the result that the code ended up with "case () of (a,b) -> ...".
7771++
7772++primop TraceEventOp "traceEvent#" GenPrimOp
7773++ Addr# -> State# s -> State# s
7774++ { Emits an event via the RTS tracing framework. The contents
7775++ of the event is the zero-terminated byte string passed as the first
7776++ argument. The event will be emitted either to the .eventlog file,
7777++ or to stderr, depending on the runtime RTS flags. }
7778++ with
7779++ has_side_effects = True
7780++ out_of_line = True
7781++
7782++primop TraceMarkerOp "traceMarker#" GenPrimOp
7783++ Addr# -> State# s -> State# s
7784++ { Emits a marker event via the RTS tracing framework. The contents
7785++ of the event is the zero-terminated byte string passed as the first
7786++ argument. The event will be emitted either to the .eventlog file,
7787++ or to stderr, depending on the runtime RTS flags. }
7788++ with
7789++ has_side_effects = True
7790++ out_of_line = True
7791++
7792++------------------------------------------------------------------------
7793++section "Safe coercions"
7794++------------------------------------------------------------------------
7795++
7796++pseudoop "coerce"
7797++ Coercible a b => a -> b
7798++ { The function {\tt coerce} allows you to safely convert between values of
7799++ types that have the same representation with no run-time overhead. In the
7800++ simplest case you can use it instead of a newtype constructor, to go from
7801++ the newtype's concrete type to the abstract type. But it also works in
7802++ more complicated settings, e.g. converting a list of newtypes to a list of
7803++ concrete types.
7804++ }
7805++
7806++------------------------------------------------------------------------
7807++section "SIMD Vectors"
7808++ {Operations on SIMD vectors.}
7809++------------------------------------------------------------------------
7810++
7811++#define ALL_VECTOR_TYPES \
7812++ [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
7813++ ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
7814++ ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
7815++ ,<Word8,Word#,16>,<Word16,Word#,8>,<Word32,WORD32,4>,<Word64,WORD64,2> \
7816++ ,<Word8,Word#,32>,<Word16,Word#,16>,<Word32,WORD32,8>,<Word64,WORD64,4> \
7817++ ,<Word8,Word#,64>,<Word16,Word#,32>,<Word32,WORD32,16>,<Word64,WORD64,8> \
7818++ ,<Float,Float#,4>,<Double,Double#,2> \
7819++ ,<Float,Float#,8>,<Double,Double#,4> \
7820++ ,<Float,Float#,16>,<Double,Double#,8>]
7821++
7822++#define SIGNED_VECTOR_TYPES \
7823++ [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
7824++ ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
7825++ ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
7826++ ,<Float,Float#,4>,<Double,Double#,2> \
7827++ ,<Float,Float#,8>,<Double,Double#,4> \
7828++ ,<Float,Float#,16>,<Double,Double#,8>]
7829++
7830++#define FLOAT_VECTOR_TYPES \
7831++ [<Float,Float#,4>,<Double,Double#,2> \
7832++ ,<Float,Float#,8>,<Double,Double#,4> \
7833++ ,<Float,Float#,16>,<Double,Double#,8>]
7834++
7835++#define INT_VECTOR_TYPES \
7836++ [<Int8,Int#,16>,<Int16,Int#,8>,<Int32,INT32,4>,<Int64,INT64,2> \
7837++ ,<Int8,Int#,32>,<Int16,Int#,16>,<Int32,INT32,8>,<Int64,INT64,4> \
7838++ ,<Int8,Int#,64>,<Int16,Int#,32>,<Int32,INT32,16>,<Int64,INT64,8> \
7839++ ,<Word8,Word#,16>,<Word16,Word#,8>,<Word32,WORD32,4>,<Word64,WORD64,2> \
7840++ ,<Word8,Word#,32>,<Word16,Word#,16>,<Word32,WORD32,8>,<Word64,WORD64,4> \
7841++ ,<Word8,Word#,64>,<Word16,Word#,32>,<Word32,WORD32,16>,<Word64,WORD64,8>]
7842++
7843++primtype VECTOR
7844++ with llvm_only = True
7845++ vector = ALL_VECTOR_TYPES
7846++
7847++primop VecBroadcastOp "broadcast#" GenPrimOp
7848++ SCALAR -> VECTOR
7849++ { Broadcast a scalar to all elements of a vector. }
7850++ with llvm_only = True
7851++ vector = ALL_VECTOR_TYPES
7852++
7853++primop VecPackOp "pack#" GenPrimOp
7854++ VECTUPLE -> VECTOR
7855++ { Pack the elements of an unboxed tuple into a vector. }
7856++ with llvm_only = True
7857++ vector = ALL_VECTOR_TYPES
7858++
7859++primop VecUnpackOp "unpack#" GenPrimOp
7860++ VECTOR -> VECTUPLE
7861++ { Unpack the elements of a vector into an unboxed tuple. #}
7862++ with llvm_only = True
7863++ vector = ALL_VECTOR_TYPES
7864++
7865++primop VecInsertOp "insert#" GenPrimOp
7866++ VECTOR -> SCALAR -> Int# -> VECTOR
7867++ { Insert a scalar at the given position in a vector. }
7868++ with can_fail = True
7869++ llvm_only = True
7870++ vector = ALL_VECTOR_TYPES
7871++
7872++primop VecAddOp "plus#" Dyadic
7873++ VECTOR -> VECTOR -> VECTOR
7874++ { Add two vectors element-wise. }
7875++ with commutable = True
7876++ llvm_only = True
7877++ vector = ALL_VECTOR_TYPES
7878++
7879++primop VecSubOp "minus#" Dyadic
7880++ VECTOR -> VECTOR -> VECTOR
7881++ { Subtract two vectors element-wise. }
7882++ with llvm_only = True
7883++ vector = ALL_VECTOR_TYPES
7884++
7885++primop VecMulOp "times#" Dyadic
7886++ VECTOR -> VECTOR -> VECTOR
7887++ { Multiply two vectors element-wise. }
7888++ with commutable = True
7889++ llvm_only = True
7890++ vector = ALL_VECTOR_TYPES
7891++
7892++primop VecDivOp "divide#" Dyadic
7893++ VECTOR -> VECTOR -> VECTOR
7894++ { Divide two vectors element-wise. }
7895++ with can_fail = True
7896++ llvm_only = True
7897++ vector = FLOAT_VECTOR_TYPES
7898++
7899++primop VecQuotOp "quot#" Dyadic
7900++ VECTOR -> VECTOR -> VECTOR
7901++ { Rounds towards zero element-wise. }
7902++ with can_fail = True
7903++ llvm_only = True
7904++ vector = INT_VECTOR_TYPES
7905++
7906++primop VecRemOp "rem#" Dyadic
7907++ VECTOR -> VECTOR -> VECTOR
7908++ { Satisfies \texttt{(quot\# x y) times\# y plus\# (rem\# x y) == x}. }
7909++ with can_fail = True
7910++ llvm_only = True
7911++ vector = INT_VECTOR_TYPES
7912++
7913++primop VecNegOp "negate#" Monadic
7914++ VECTOR -> VECTOR
7915++ { Negate element-wise. }
7916++ with llvm_only = True
7917++ vector = SIGNED_VECTOR_TYPES
7918++
7919++primop VecIndexByteArrayOp "indexArray#" GenPrimOp
7920++ ByteArray# -> Int# -> VECTOR
7921++ { Read a vector from specified index of immutable array. }
7922++ with can_fail = True
7923++ llvm_only = True
7924++ vector = ALL_VECTOR_TYPES
7925++
7926++primop VecReadByteArrayOp "readArray#" GenPrimOp
7927++ MutableByteArray# s -> Int# -> State# s -> (# State# s, VECTOR #)
7928++ { Read a vector from specified index of mutable array. }
7929++ with has_side_effects = True
7930++ can_fail = True
7931++ llvm_only = True
7932++ vector = ALL_VECTOR_TYPES
7933++
7934++primop VecWriteByteArrayOp "writeArray#" GenPrimOp
7935++ MutableByteArray# s -> Int# -> VECTOR -> State# s -> State# s
7936++ { Write a vector to specified index of mutable array. }
7937++ with has_side_effects = True
7938++ can_fail = True
7939++ llvm_only = True
7940++ vector = ALL_VECTOR_TYPES
7941++
7942++primop VecIndexOffAddrOp "indexOffAddr#" GenPrimOp
7943++ Addr# -> Int# -> VECTOR
7944++ { Reads vector; offset in bytes. }
7945++ with can_fail = True
7946++ llvm_only = True
7947++ vector = ALL_VECTOR_TYPES
7948++
7949++primop VecReadOffAddrOp "readOffAddr#" GenPrimOp
7950++ Addr# -> Int# -> State# s -> (# State# s, VECTOR #)
7951++ { Reads vector; offset in bytes. }
7952++ with has_side_effects = True
7953++ can_fail = True
7954++ llvm_only = True
7955++ vector = ALL_VECTOR_TYPES
7956++
7957++primop VecWriteOffAddrOp "writeOffAddr#" GenPrimOp
7958++ Addr# -> Int# -> VECTOR -> State# s -> State# s
7959++ { Write vector; offset in bytes. }
7960++ with has_side_effects = True
7961++ can_fail = True
7962++ llvm_only = True
7963++ vector = ALL_VECTOR_TYPES
7964++
7965++
7966++primop VecIndexScalarByteArrayOp "indexArrayAs#" GenPrimOp
7967++ ByteArray# -> Int# -> VECTOR
7968++ { Read a vector from specified index of immutable array of scalars; offset is in scalar elements. }
7969++ with can_fail = True
7970++ llvm_only = True
7971++ vector = ALL_VECTOR_TYPES
7972++
7973++primop VecReadScalarByteArrayOp "readArrayAs#" GenPrimOp
7974++ MutableByteArray# s -> Int# -> State# s -> (# State# s, VECTOR #)
7975++ { Read a vector from specified index of mutable array of scalars; offset is in scalar elements. }
7976++ with has_side_effects = True
7977++ can_fail = True
7978++ llvm_only = True
7979++ vector = ALL_VECTOR_TYPES
7980++
7981++primop VecWriteScalarByteArrayOp "writeArrayAs#" GenPrimOp
7982++ MutableByteArray# s -> Int# -> VECTOR -> State# s -> State# s
7983++ { Write a vector to specified index of mutable array of scalars; offset is in scalar elements. }
7984++ with has_side_effects = True
7985++ can_fail = True
7986++ llvm_only = True
7987++ vector = ALL_VECTOR_TYPES
7988++
7989++primop VecIndexScalarOffAddrOp "indexOffAddrAs#" GenPrimOp
7990++ Addr# -> Int# -> VECTOR
7991++ { Reads vector; offset in scalar elements. }
7992++ with can_fail = True
7993++ llvm_only = True
7994++ vector = ALL_VECTOR_TYPES
7995++
7996++primop VecReadScalarOffAddrOp "readOffAddrAs#" GenPrimOp
7997++ Addr# -> Int# -> State# s -> (# State# s, VECTOR #)
7998++ { Reads vector; offset in scalar elements. }
7999++ with has_side_effects = True
8000++ can_fail = True
8001++ llvm_only = True
8002++ vector = ALL_VECTOR_TYPES
8003++
8004++primop VecWriteScalarOffAddrOp "writeOffAddrAs#" GenPrimOp
8005++ Addr# -> Int# -> VECTOR -> State# s -> State# s
8006++ { Write vector; offset in scalar elements. }
8007++ with has_side_effects = True
8008++ can_fail = True
8009++ llvm_only = True
8010++ vector = ALL_VECTOR_TYPES
8011++
8012++------------------------------------------------------------------------
8013++
8014++section "Prefetch"
8015++ {Prefetch operations: Note how every prefetch operation has a name
8016++ with the pattern prefetch*N#, where N is either 0,1,2, or 3.
8017++
8018++ This suffix number, N, is the "locality level" of the prefetch, following the
8019++ convention in GCC and other compilers.
8020++ Higher locality numbers correspond to the memory being loaded in more
8021++ levels of the cpu cache, and being retained after initial use. The naming
8022++ convention follows the naming convention of the prefetch intrinsic found
8023++ in the GCC and Clang C compilers.
8024++
8025++ On the LLVM backend, prefetch*N# uses the LLVM prefetch intrinsic
8026++ with locality level N. The code generated by LLVM is target architecture
8027++ dependent, but should agree with the GHC NCG on x86 systems.
8028++
8029++ On the Sparc and PPC native backends, prefetch*N is a No-Op.
8030++
8031++ On the x86 NCG, N=0 will generate prefetchNTA,
8032++ N=1 generates prefetcht2, N=2 generates prefetcht1, and
8033++ N=3 generates prefetcht0.
8034++
8035++ For streaming workloads, the prefetch*0 operations are recommended.
8036++ For workloads which do many reads or writes to a memory location in a short period of time,
8037++ prefetch*3 operations are recommended.
8038++
8039++ For further reading about prefetch and associated systems performance optimization,
8040++ the instruction set and optimization manuals by Intel and other CPU vendors are
8041++ excellent starting place.
8042++
8043++
8044++ The "Intel 64 and IA-32 Architectures Optimization Reference Manual" is
8045++ especially a helpful read, even if your software is meant for other CPU
8046++ architectures or vendor hardware. The manual can be found at
8047++ http://www.intel.com/content/www/us/en/architecture-and-technology/64-ia-32-architectures-optimization-manual.html .
8048++
8049++ The {\tt prefetch*} family of operations has the order of operations
8050++ determined by passing around the {\tt State#} token.
8051++
8052++ To get a "pure" version of these operations, use {\tt inlinePerformIO} which is quite safe in this context.
8053++
8054++ It is important to note that while the prefetch operations will never change the
8055++ answer to a pure computation, They CAN change the memory locations resident
8056++ in a CPU cache and that may change the performance and timing characteristics
8057++ of an application. The prefetch operations are marked has_side_effects=True
8058++ to reflect that these operations have side effects with respect to the runtime
8059++ performance characteristics of the resulting code. Additionally, if the prefetchValue
8060++ operations did not have this attribute, GHC does a float out transformation that
8061++ results in a let/app violation, at least with the current design.
8062++ }
8063++
8064++
8065++
8066++------------------------------------------------------------------------
8067++
8068++
8069++--- the Int# argument for prefetch is the byte offset on the byteArray or Addr#
8070++
8071++---
8072++primop PrefetchByteArrayOp3 "prefetchByteArray3#" GenPrimOp
8073++ ByteArray# -> Int# -> State# s -> State# s
8074++ with has_side_effects = True
8075++
8076++primop PrefetchMutableByteArrayOp3 "prefetchMutableByteArray3#" GenPrimOp
8077++ MutableByteArray# s -> Int# -> State# s -> State# s
8078++ with has_side_effects = True
8079++
8080++primop PrefetchAddrOp3 "prefetchAddr3#" GenPrimOp
8081++ Addr# -> Int# -> State# s -> State# s
8082++ with has_side_effects = True
8083++
8084++primop PrefetchValueOp3 "prefetchValue3#" GenPrimOp
8085++ a -> State# s -> State# s
8086++ with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
8087++ has_side_effects = True
8088++----
8089++
8090++primop PrefetchByteArrayOp2 "prefetchByteArray2#" GenPrimOp
8091++ ByteArray# -> Int# -> State# s -> State# s
8092++ with has_side_effects = True
8093++
8094++primop PrefetchMutableByteArrayOp2 "prefetchMutableByteArray2#" GenPrimOp
8095++ MutableByteArray# s -> Int# -> State# s -> State# s
8096++ with has_side_effects = True
8097++
8098++primop PrefetchAddrOp2 "prefetchAddr2#" GenPrimOp
8099++ Addr# -> Int# -> State# s -> State# s
8100++ with has_side_effects = True
8101++
8102++primop PrefetchValueOp2 "prefetchValue2#" GenPrimOp
8103++ a -> State# s -> State# s
8104++ with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
8105++ has_side_effects = True
8106++----
8107++
8108++primop PrefetchByteArrayOp1 "prefetchByteArray1#" GenPrimOp
8109++ ByteArray# -> Int# -> State# s -> State# s
8110++ with has_side_effects = True
8111++
8112++primop PrefetchMutableByteArrayOp1 "prefetchMutableByteArray1#" GenPrimOp
8113++ MutableByteArray# s -> Int# -> State# s -> State# s
8114++ with has_side_effects = True
8115++
8116++primop PrefetchAddrOp1 "prefetchAddr1#" GenPrimOp
8117++ Addr# -> Int# -> State# s -> State# s
8118++ with has_side_effects = True
8119++
8120++primop PrefetchValueOp1 "prefetchValue1#" GenPrimOp
8121++ a -> State# s -> State# s
8122++ with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
8123++ has_side_effects = True
8124++----
8125++
8126++primop PrefetchByteArrayOp0 "prefetchByteArray0#" GenPrimOp
8127++ ByteArray# -> Int# -> State# s -> State# s
8128++ with has_side_effects = True
8129++
8130++primop PrefetchMutableByteArrayOp0 "prefetchMutableByteArray0#" GenPrimOp
8131++ MutableByteArray# s -> Int# -> State# s -> State# s
8132++ with has_side_effects = True
8133++
8134++primop PrefetchAddrOp0 "prefetchAddr0#" GenPrimOp
8135++ Addr# -> Int# -> State# s -> State# s
8136++ with has_side_effects = True
8137++
8138++primop PrefetchValueOp0 "prefetchValue0#" GenPrimOp
8139++ a -> State# s -> State# s
8140++ with strictness = { \ _arity -> mkClosedStrictSig [botDmd, topDmd] topRes }
8141++ has_side_effects = True
8142++
8143++------------------------------------------------------------------------
8144++--- ---
8145++------------------------------------------------------------------------
8146++
8147++thats_all_folks
8148+diff --git a/rts/build/HsVersions.h b/rts/build/HsVersions.h
8149+new file mode 100644
8150+index 0000000..a4ec3e4
8151+--- /dev/null
8152++++ b/rts/build/HsVersions.h
8153+@@ -0,0 +1,65 @@
8154++#pragma once
8155++
8156++#if 0
8157++
8158++IMPORTANT! If you put extra tabs/spaces in these macro definitions,
8159++you will screw up the layout where they are used in case expressions!
8160++
8161++(This is cpp-dependent, of course)
8162++
8163++#endif
8164++
8165++/* Useful in the headers that we share with the RTS */
8166++#define COMPILING_GHC 1
8167++
8168++/* Pull in all the platform defines for this build (foo_TARGET_ARCH etc.) */
8169++#include "ghc_boot_platform.h"
8170++
8171++/* Pull in the autoconf defines (HAVE_FOO), but don't include
8172++ * ghcconfig.h, because that will include ghcplatform.h which has the
8173++ * wrong platform settings for the compiler (it has the platform
8174++ * settings for the target plat instead). */
8175++#include "ghcautoconf.h"
8176++
8177++#define GLOBAL_VAR(name,value,ty) \
8178++{-# NOINLINE name #-}; \
8179++name :: IORef (ty); \
8180++name = Util.global (value);
8181++
8182++#define GLOBAL_VAR_M(name,value,ty) \
8183++{-# NOINLINE name #-}; \
8184++name :: IORef (ty); \
8185++name = Util.globalM (value);
8186++
8187++
8188++#define SHARED_GLOBAL_VAR(name,accessor,saccessor,value,ty) \
8189++{-# NOINLINE name #-}; \
8190++name :: IORef (ty); \
8191++name = Util.sharedGlobal (value) (accessor); \
8192++foreign import ccall unsafe saccessor \
8193++ accessor :: Ptr (IORef a) -> IO (Ptr (IORef a));
8194++
8195++#define SHARED_GLOBAL_VAR_M(name,accessor,saccessor,value,ty) \
8196++{-# NOINLINE name #-}; \
8197++name :: IORef (ty); \
8198++name = Util.sharedGlobalM (value) (accessor); \
8199++foreign import ccall unsafe saccessor \
8200++ accessor :: Ptr (IORef a) -> IO (Ptr (IORef a));
8201++
8202++
8203++#define ASSERT(e) if debugIsOn && not (e) then (assertPanic __FILE__ __LINE__) else
8204++#define ASSERT2(e,msg) if debugIsOn && not (e) then (assertPprPanic __FILE__ __LINE__ (msg)) else
8205++#define WARN( e, msg ) (warnPprTrace (e) __FILE__ __LINE__ (msg)) $
8206++
8207++-- Examples: Assuming flagSet :: String -> m Bool
8208++--
8209++-- do { c <- getChar; MASSERT( isUpper c ); ... }
8210++-- do { c <- getChar; MASSERT2( isUpper c, text "Bad" ); ... }
8211++-- do { str <- getStr; ASSERTM( flagSet str ); .. }
8212++-- do { str <- getStr; ASSERTM2( flagSet str, text "Bad" ); .. }
8213++-- do { str <- getStr; WARNM2( flagSet str, text "Flag is set" ); .. }
8214++#define MASSERT(e) ASSERT(e) return ()
8215++#define MASSERT2(e,msg) ASSERT2(e,msg) return ()
8216++#define ASSERTM(e) do { bool <- e; MASSERT(bool) }
8217++#define ASSERTM2(e,msg) do { bool <- e; MASSERT2(bool,msg) }
8218++#define WARNM2(e,msg) do { bool <- e; WARN(bool, msg) return () }
8219+diff --git a/rts/ghc.mk b/rts/ghc.mk
8220+index 761cc43..457d394 100644
8221+--- a/rts/ghc.mk
8222++++ b/rts/ghc.mk
8223+@@ -34,6 +34,95 @@ rts_dist_WAYS = $(rts_WAYS)
8224+ ALL_RTS_LIBS = $(foreach way,$(rts_WAYS),rts/dist/build/libHSrts$($(way)_libsuf))
8225+ $(eval $(call all-target,rts,$(ALL_RTS_LIBS)))
8226+
8227++
8228++rts/build/config.hs-incl : mk/config.mk mk/project.mk | $$(dir $$@)/.
8229++ $(call removeFiles,$@)
8230++ @echo 'Creating $@ ... '
8231++ @echo 'data IntegerLibrary = IntegerGMP' >> $@
8232++ @echo ' | IntegerSimple' >> $@
8233++ @echo ' deriving Eq' >> $@
8234++ @echo >> $@
8235++ @echo 'cBuildPlatformString :: String' >> $@
8236++ @echo 'cBuildPlatformString = BuildPlatform_NAME' >> $@
8237++ @echo 'cHostPlatformString :: String' >> $@
8238++ @echo 'cHostPlatformString = HostPlatform_NAME' >> $@
8239++ @echo 'cTargetPlatformString :: String' >> $@
8240++ @echo 'cTargetPlatformString = TargetPlatform_NAME' >> $@
8241++ @echo >> $@
8242++ @echo 'cProjectName :: String' >> $@
8243++ @echo 'cProjectName = "$(ProjectName)"' >> $@
8244++ @echo 'cProjectGitCommitId :: String' >> $@
8245++ @echo 'cProjectGitCommitId = "$(ProjectGitCommitId)"' >> $@
8246++ @echo 'cProjectVersion :: String' >> $@
8247++ @echo 'cProjectVersion = "$(ProjectVersion)"' >> $@
8248++ @echo 'cProjectVersionInt :: String' >> $@
8249++ @echo 'cProjectVersionInt = "$(ProjectVersionInt)"' >> $@
8250++ @echo 'cProjectPatchLevel :: String' >> $@
8251++ @echo 'cProjectPatchLevel = "$(ProjectPatchLevel)"' >> $@
8252++ @echo 'cProjectPatchLevel1 :: String' >> $@
8253++ @echo 'cProjectPatchLevel1 = "$(ProjectPatchLevel1)"' >> $@
8254++ @echo 'cProjectPatchLevel2 :: String' >> $@
8255++ @echo 'cProjectPatchLevel2 = "$(ProjectPatchLevel2)"' >> $@
8256++ @echo 'cBooterVersion :: String' >> $@
8257++ @echo 'cBooterVersion = "$(GhcVersion)"' >> $@
8258++ @echo 'cStage :: String' >> $@
8259++ @echo 'cStage = show (STAGE :: Int)' >> $@
8260++ @echo 'cIntegerLibraryType :: IntegerLibrary' >> $@
8261++ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
8262++ @echo 'cIntegerLibraryType = IntegerGMP' >> $@
8263++else ifeq "$(INTEGER_LIBRARY)" "integer-simple"
8264++ @echo 'cIntegerLibraryType = IntegerSimple' >> $@
8265++else ifneq "$(CLEANING)" "YES"
8266++$(error Unknown integer library)
8267++endif
8268++ @echo 'cSupportsSplitObjs :: String' >> $@
8269++ @echo 'cSupportsSplitObjs = "$(SupportsSplitObjs)"' >> $@
8270++ @echo 'cGhcWithInterpreter :: String' >> $@
8271++ @echo 'cGhcWithInterpreter = "$(GhcWithInterpreter)"' >> $@
8272++ @echo 'cGhcWithNativeCodeGen :: String' >> $@
8273++ @echo 'cGhcWithNativeCodeGen = "$(GhcWithNativeCodeGen)"' >> $@
8274++ @echo 'cGhcWithSMP :: String' >> $@
8275++ @echo 'cGhcWithSMP = "$(GhcWithSMP)"' >> $@
8276++ @echo 'cGhcRTSWays :: String' >> $@
8277++ @echo 'cGhcRTSWays = "$(GhcRTSWays)"' >> $@
8278++ @echo 'cGhcRtsWithLibdw :: Bool' >> $@
8279++ifeq "$(GhcRtsWithLibdw)" "YES"
8280++ @echo 'cGhcRtsWithLibdw = True' >> $@
8281++else
8282++ @echo 'cGhcRtsWithLibdw = False' >> $@
8283++endif
8284++ @echo 'cGhcEnableTablesNextToCode :: String' >> $@
8285++ @echo 'cGhcEnableTablesNextToCode = "$(GhcEnableTablesNextToCode)"' >> $@
8286++ @echo 'cLeadingUnderscore :: String' >> $@
8287++ @echo 'cLeadingUnderscore = "$(LeadingUnderscore)"' >> $@
8288++ @echo 'cGHC_UNLIT_PGM :: String' >> $@
8289++ @echo 'cGHC_UNLIT_PGM = "$(utils/unlit_dist_PROG)"' >> $@
8290++ @echo 'cGHC_SPLIT_PGM :: String' >> $@
8291++ @echo 'cGHC_SPLIT_PGM = "$(driver/split_dist_PROG)"' >> $@
8292++ @echo 'cLibFFI :: Bool' >> $@
8293++ifeq "$(UseLibFFIForAdjustors)" "YES"
8294++ @echo 'cLibFFI = True' >> $@
8295++else
8296++ @echo 'cLibFFI = False' >> $@
8297++endif
8298++# Note that GhcThreaded just reflects the Makefile variable setting.
8299++# In particular, the stage1 compiler is never actually compiled with
8300++# -threaded, but it will nevertheless have cGhcThreaded = True.
8301++# The "+RTS --info" output will show what RTS GHC is really using.
8302++ @echo 'cGhcThreaded :: Bool' >> $@
8303++ifeq "$(GhcThreaded)" "YES"
8304++ @echo 'cGhcThreaded = True' >> $@
8305++else
8306++ @echo 'cGhcThreaded = False' >> $@
8307++endif
8308++ @echo 'cGhcDebugged :: Bool' >> $@
8309++ifeq "$(GhcDebugged)" "YES"
8310++ @echo 'cGhcDebugged = True' >> $@
8311++else
8312++ @echo 'cGhcDebugged = False' >> $@
8313++endif
8314++ @echo done.
8315++
8316+ # -----------------------------------------------------------------------------
8317+ # Defining the sources
8318+
8319+diff --git a/rts/rts.cabal b/rts/rts.cabal
8320+index f8f1e2e..52c3a4f 100644
8321+--- a/rts/rts.cabal
8322++++ b/rts/rts.cabal
8323+@@ -7,7 +7,7 @@ build-type: Simple
8324+ flag libm
8325+ default: True
8326+ flag librt
8327+- default: True
8328++ default: False
8329+ flag libdl
8330+ default: True
8331+ flag ffi
8332+@@ -23,7 +23,7 @@ flag libdw
8333+ flag 64bit
8334+ default: False
8335+ flag leading-underscore
8336+- default: False
8337++ default: True
8338+
8339+ library
8340+ -- rts is a wired in package and
8341+@@ -80,6 +80,11 @@ library
8342+ ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h
8343+ -- ^ from ../includes
8344+ DerivedConstants.h ffi.h ffitarget.h
8345++ GHCConstantsHaskellType.hs GHCConstantsHaskellWrappers.hs
8346++ CodeGen.Platform.hs
8347++ platformConstants
8348++ config.hs-incl
8349++ HsVersions.h
8350+ -- ^ generated
8351+ rts/Adjustor.h
8352+ rts/BlockSignals.h
8353+diff --git a/rts/rts.cabal.in b/rts/rts.cabal.in
8354+index 664a8f1..717a5a1 100644
8355+--- a/rts/rts.cabal.in
8356++++ b/rts/rts.cabal.in
8357+@@ -80,6 +80,11 @@ library
8358+ ghcautoconf.h ghcconfig.h ghcplatform.h ghcversion.h
8359+ -- ^ from ../includes
8360+ DerivedConstants.h ffi.h ffitarget.h
8361++ GHCConstantsHaskellType.hs GHCConstantsHaskellWrappers.hs
8362++ CodeGen.Platform.hs
8363++ platformConstants
8364++ config.hs-incl
8365++ HsVersions.h
8366+ -- ^ generated
8367+ rts/Adjustor.h
8368+ rts/BlockSignals.h
8369+diff --git a/utils/genapply/Main.hs b/utils/genapply/Main.hs
8370+index b30c9f8..150c8c8 100644
8371+--- a/utils/genapply/Main.hs
8372++++ b/utils/genapply/Main.hs
8373+@@ -17,7 +17,7 @@ module Main(main) where
8374+ #include "../../includes/rts/Constants.h"
8375+
8376+ -- Needed for TAG_BITS
8377+-#include "../../includes/MachDeps.h"
8378++#include "MachDeps.h"
8379+
8380+ #if MIN_VERSION_base(4,11,0)
8381+ import Prelude hiding ((<>))
8382+diff --git a/utils/genprimopcode/Parser.hs b/utils/genprimopcode/Parser.hs
8383+index a4d2800..e9cbeaf 100644
8384+--- a/utils/genprimopcode/Parser.hs
8385++++ b/utils/genprimopcode/Parser.hs
8386+@@ -940,11 +940,9 @@ parse = run_parser parsex
8387+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
8388+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
8389+ {-# LINE 1 "<built-in>" #-}
8390+-{-# LINE 1 "<command-line>" #-}
8391+-{-# LINE 11 "<command-line>" #-}
8392+-# 1 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 1 3 4
8393++{-# LINE 18 "<built-in>" #-}
8394++{-# LINE 1 "/usr/local/Cellar/ghc/8.4.4/lib/ghc-8.4.4/include/ghcversion.h" #-}
8395+
8396+-# 17 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 3 4
8397+
8398+
8399+
8400+@@ -960,6 +958,8 @@ parse = run_parser parsex
8401+
8402+
8403+
8404++{-# LINE 19 "<built-in>" #-}
8405++{-# LINE 1 "/var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc91389_0/ghc_2.h" #-}
8406+
8407+
8408+
8409+@@ -991,8 +991,6 @@ parse = run_parser parsex
8410+
8411+
8412+
8413+-{-# LINE 11 "<command-line>" #-}
8414+-{-# LINE 1 "/nix/store/n5i1zdpmk2b1s3z96649xh8f9kr3g96s-ghc-8.4.3/lib/ghc-8.4.3/include/ghcversion.h" #-}
8415+
8416+
8417+
8418+@@ -1008,8 +1006,6 @@ parse = run_parser parsex
8419+
8420+
8421+
8422+-{-# LINE 11 "<command-line>" #-}
8423+-{-# LINE 1 "/build/ghc1653_0/ghc_2.h" #-}
8424+
8425+
8426+
8427+@@ -1145,52 +1141,7 @@ parse = run_parser parsex
8428+
8429+
8430+
8431+-
8432+-
8433+-
8434+-
8435+-
8436+-
8437+-
8438+-
8439+-
8440+-
8441+-
8442+-
8443+-
8444+-
8445+-
8446+-
8447+-
8448+-
8449+-
8450+-
8451+-
8452+-
8453+-
8454+-
8455+-
8456+-
8457+-
8458+-
8459+-
8460+-
8461+-
8462+-
8463+-
8464+-
8465+-
8466+-
8467+-
8468+-
8469+-
8470+-
8471+-
8472+-
8473+-
8474+-
8475+-
8476+-{-# LINE 11 "<command-line>" #-}
8477++{-# LINE 20 "<built-in>" #-}
8478+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
8479+ -- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp
8480+
8481+@@ -1216,6 +1167,7 @@ parse = run_parser parsex
8482+ #define GTE(n,m) (n Happy_GHC_Exts.>=# m)
8483+ #define EQ(n,m) (n Happy_GHC_Exts.==# m)
8484+ #endif
8485++
8486+ {-# LINE 43 "templates/GenericTemplate.hs" #-}
8487+
8488+ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
8489+@@ -1226,11 +1178,20 @@ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
8490+
8491+
8492+
8493++
8494+ {-# LINE 65 "templates/GenericTemplate.hs" #-}
8495+
8496++
8497+ {-# LINE 75 "templates/GenericTemplate.hs" #-}
8498+
8499+-{-# LINE 84 "templates/GenericTemplate.hs" #-}
8500++
8501++
8502++
8503++
8504++
8505++
8506++
8507++
8508+
8509+ infixr 9 `HappyStk`
8510+ data HappyStk a = HappyStk a (HappyStk a)
8511+@@ -1258,7 +1219,7 @@ happyAccept j tk st sts (HappyStk ans _) =
8512+
8513+ happyDoAction i tk st
8514+ = {- nothing -}
8515+-
8516++
8517+
8518+ case action of
8519+ 0# -> {- nothing -}
8520+@@ -1266,11 +1227,11 @@ happyDoAction i tk st
8521+ -1# -> {- nothing -}
8522+ happyAccept i tk st
8523+ n | LT(n,(0# :: Happy_GHC_Exts.Int#)) -> {- nothing -}
8524+-
8525++
8526+ (happyReduceArr Happy_Data_Array.! rule) i tk st
8527+ where rule = (Happy_GHC_Exts.I# ((Happy_GHC_Exts.negateInt# ((n Happy_GHC_Exts.+# (1# :: Happy_GHC_Exts.Int#))))))
8528+ n -> {- nothing -}
8529+-
8530++
8531+
8532+ happyShift new_state i tk st
8533+ where new_state = (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#))
8534+@@ -1316,6 +1277,7 @@ data HappyAddr = HappyA# Happy_GHC_Exts.Addr#
8535+ -----------------------------------------------------------------------------
8536+ -- HappyState data type (not arrays)
8537+
8538++
8539+ {-# LINE 180 "templates/GenericTemplate.hs" #-}
8540+
8541+ -----------------------------------------------------------------------------
8542+@@ -1481,3 +1443,4 @@ happyDontSeq a b = b
8543+ {-# NOINLINE happyFail #-}
8544+
8545+ -- end of Happy Template.
8546++
8547+diff --git a/utils/hpc/HpcParser.hs b/utils/hpc/HpcParser.hs
8548+index 4160e75..58dc1b0 100644
8549+--- a/utils/hpc/HpcParser.hs
8550++++ b/utils/hpc/HpcParser.hs
8551+@@ -409,11 +409,9 @@ happyError e = error $ show (take 10 e)
8552+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
8553+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
8554+ {-# LINE 1 "<built-in>" #-}
8555+-{-# LINE 1 "<command-line>" #-}
8556+-{-# LINE 11 "<command-line>" #-}
8557+-# 1 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 1 3 4
8558++{-# LINE 18 "<built-in>" #-}
8559++{-# LINE 1 "/usr/local/Cellar/ghc/8.4.4/lib/ghc-8.4.4/include/ghcversion.h" #-}
8560+
8561+-# 17 "/nix/store/akak0rxhbi4n87z3nx78ipv76frvj841-glibc-2.27-dev/include/stdc-predef.h" 3 4
8562+
8563+
8564+
8565+@@ -429,6 +427,8 @@ happyError e = error $ show (take 10 e)
8566+
8567+
8568+
8569++{-# LINE 19 "<built-in>" #-}
8570++{-# LINE 1 "/var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc91389_0/ghc_2.h" #-}
8571+
8572+
8573+
8574+@@ -460,8 +460,6 @@ happyError e = error $ show (take 10 e)
8575+
8576+
8577+
8578+-{-# LINE 11 "<command-line>" #-}
8579+-{-# LINE 1 "/nix/store/n5i1zdpmk2b1s3z96649xh8f9kr3g96s-ghc-8.4.3/lib/ghc-8.4.3/include/ghcversion.h" #-}
8580+
8581+
8582+
8583+@@ -477,8 +475,6 @@ happyError e = error $ show (take 10 e)
8584+
8585+
8586+
8587+-{-# LINE 11 "<command-line>" #-}
8588+-{-# LINE 1 "/build/ghc1653_0/ghc_2.h" #-}
8589+
8590+
8591+
8592+@@ -614,52 +610,7 @@ happyError e = error $ show (take 10 e)
8593+
8594+
8595+
8596+-
8597+-
8598+-
8599+-
8600+-
8601+-
8602+-
8603+-
8604+-
8605+-
8606+-
8607+-
8608+-
8609+-
8610+-
8611+-
8612+-
8613+-
8614+-
8615+-
8616+-
8617+-
8618+-
8619+-
8620+-
8621+-
8622+-
8623+-
8624+-
8625+-
8626+-
8627+-
8628+-
8629+-
8630+-
8631+-
8632+-
8633+-
8634+-
8635+-
8636+-
8637+-
8638+-
8639+-
8640+-
8641+-{-# LINE 11 "<command-line>" #-}
8642++{-# LINE 20 "<built-in>" #-}
8643+ {-# LINE 1 "templates/GenericTemplate.hs" #-}
8644+ -- Id: GenericTemplate.hs,v 1.26 2005/01/14 14:47:22 simonmar Exp
8645+
8646+@@ -685,6 +636,7 @@ happyError e = error $ show (take 10 e)
8647+ #define GTE(n,m) (n Happy_GHC_Exts.>=# m)
8648+ #define EQ(n,m) (n Happy_GHC_Exts.==# m)
8649+ #endif
8650++
8651+ {-# LINE 43 "templates/GenericTemplate.hs" #-}
8652+
8653+ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
8654+@@ -695,11 +647,20 @@ data Happy_IntList = HappyCons Happy_GHC_Exts.Int# Happy_IntList
8655+
8656+
8657+
8658++
8659+ {-# LINE 65 "templates/GenericTemplate.hs" #-}
8660+
8661++
8662+ {-# LINE 75 "templates/GenericTemplate.hs" #-}
8663+
8664+-{-# LINE 84 "templates/GenericTemplate.hs" #-}
8665++
8666++
8667++
8668++
8669++
8670++
8671++
8672++
8673+
8674+ infixr 9 `HappyStk`
8675+ data HappyStk a = HappyStk a (HappyStk a)
8676+@@ -727,7 +688,7 @@ happyAccept j tk st sts (HappyStk ans _) =
8677+
8678+ happyDoAction i tk st
8679+ = {- nothing -}
8680+-
8681++
8682+
8683+ case action of
8684+ 0# -> {- nothing -}
8685+@@ -735,11 +696,11 @@ happyDoAction i tk st
8686+ -1# -> {- nothing -}
8687+ happyAccept i tk st
8688+ n | LT(n,(0# :: Happy_GHC_Exts.Int#)) -> {- nothing -}
8689+-
8690++
8691+ (happyReduceArr Happy_Data_Array.! rule) i tk st
8692+ where rule = (Happy_GHC_Exts.I# ((Happy_GHC_Exts.negateInt# ((n Happy_GHC_Exts.+# (1# :: Happy_GHC_Exts.Int#))))))
8693+ n -> {- nothing -}
8694+-
8695++
8696+
8697+ happyShift new_state i tk st
8698+ where new_state = (n Happy_GHC_Exts.-# (1# :: Happy_GHC_Exts.Int#))
8699+@@ -785,6 +746,7 @@ data HappyAddr = HappyA# Happy_GHC_Exts.Addr#
8700+ -----------------------------------------------------------------------------
8701+ -- HappyState data type (not arrays)
8702+
8703++
8704+ {-# LINE 180 "templates/GenericTemplate.hs" #-}
8705+
8706+ -----------------------------------------------------------------------------
8707+@@ -950,3 +912,4 @@ happyDontSeq a b = b
8708+ {-# NOINLINE happyFail #-}
8709+
8710+ -- end of Happy Template.
8711++
overlays/patches/ghc/ghc-8.6-Cabal-fix-datadir.patchnew file+21
@@ -0,0 +1,21 @@
1+Submodule libraries/Cabal contains modified content
2+diff --git a/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs b/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs
3+index 678ccbca3..ffa712e8a 100644
4+--- a/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs
5++++ b/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs
6+@@ -192,10 +192,14 @@ generate pkg_descr lbi clbi =
7+ bindir = flat_bindir,
8+ libdir = flat_libdir,
9+ dynlibdir = flat_dynlibdir,
10+- datadir = flat_datadir,
11+ libexecdir = flat_libexecdir,
12+ sysconfdir = flat_sysconfdir
13+ } = absoluteComponentInstallDirs pkg_descr lbi cid NoCopyDest
14++
15++ InstallDirs {
16++ datadir = flat_datadir
17++ } = absoluteInstallDirs pkg_descr lbi NoCopyDest
18++
19+ InstallDirs {
20+ bindir = flat_bindirrel,
21+ libdir = flat_libdirrel,
overlays/patches/ghc/ghc-8.6.1-iserv-changes.patchnew file+811
@@ -0,0 +1,811 @@
1+diff --git a/configure.ac b/configure.ac
2+index 5fd3441563..7eb8f90f25 100644
3+--- a/configure.ac
4++++ b/configure.ac
5+@@ -1334,7 +1334,7 @@ checkMake380() {
6+ checkMake380 make
7+ checkMake380 gmake
8+
9+-AC_CONFIG_FILES([mk/config.mk mk/install.mk mk/project.mk rts/rts.cabal compiler/ghc.cabal ghc/ghc-bin.cabal utils/runghc/runghc.cabal utils/gen-dll/gen-dll.cabal libraries/ghc-boot/ghc-boot.cabal libraries/ghc-boot-th/ghc-boot-th.cabal libraries/ghci/ghci.cabal libraries/ghc-heap/ghc-heap.cabal settings docs/users_guide/ghc_config.py docs/index.html libraries/prologue.txt distrib/configure.ac])
10++AC_CONFIG_FILES([mk/config.mk mk/install.mk mk/project.mk rts/rts.cabal compiler/ghc.cabal ghc/ghc-bin.cabal utils/iserv/iserv.cabal utils/iserv-proxy/iserv-proxy.cabal utils/remote-iserv/remote-iserv.cabal utils/runghc/runghc.cabal utils/gen-dll/gen-dll.cabal libraries/ghc-boot/ghc-boot.cabal libraries/ghc-boot-th/ghc-boot-th.cabal libraries/ghci/ghci.cabal libraries/ghc-heap/ghc-heap.cabal libraries/libiserv/libiserv.cabal settings docs/users_guide/ghc_config.py docs/index.html libraries/prologue.txt distrib/configure.ac])
11+ AC_OUTPUT
12+ [
13+ if test "$print_make_warning" = "true"; then
14+diff --git a/libraries/libiserv/libiserv.cabal b/libraries/libiserv/libiserv.cabal
15+deleted file mode 100644
16+index fc0a022120..0000000000
17+--- a/libraries/libiserv/libiserv.cabal
18++++ /dev/null
19+@@ -1,39 +0,0 @@
20+-Name: libiserv
21+-Version: 8.6.1
22+-Copyright: XXX
23+-License: BSD3
24+-License-File: LICENSE
25+-Author: XXX
26+-Maintainer: XXX
27+-Synopsis: Provides shared functionality between iserv and iserv-proxy
28+-Description:
29+-Category: Development
30+-build-type: Simple
31+-cabal-version: >=1.10
32+-
33+-Flag network
34+- Description: Build libiserv with over-the-network support
35+- Default: False
36+-
37+-Library
38+- Default-Language: Haskell2010
39+- Hs-Source-Dirs: src
40+- Exposed-Modules: Lib
41+- , GHCi.Utils
42+- Build-Depends: base >= 4 && < 5,
43+- binary >= 0.7 && < 0.11,
44+- bytestring >= 0.10 && < 0.11,
45+- containers >= 0.5 && < 0.7,
46+- deepseq >= 1.4 && < 1.5,
47+- ghci == 8.6.*
48+- if flag(network)
49+- Exposed-Modules: Remote.Message
50+- , Remote.Slave
51+- Build-Depends: network >= 2.6 && < 2.7,
52+- directory >= 1.3 && < 1.4,
53+- filepath >= 1.4 && < 1.5
54+-
55+- if os(windows)
56+- Cpp-Options: -DWINDOWS
57+- else
58+- Build-Depends: unix >= 2.7 && < 2.9
59+diff --git a/libraries/libiserv/libiserv.cabal.in b/libraries/libiserv/libiserv.cabal.in
60+new file mode 100644
61+index 0000000000..31eaaeb838
62+--- /dev/null
63++++ b/libraries/libiserv/libiserv.cabal.in
64+@@ -0,0 +1,43 @@
65++-- WARNING: libiserv.cabal is automatically generated from libiserv.cabal.in by
66++-- ../../configure. Make sure you are editing libiserv.cabal.in, not
67++-- libiserv.cabal.
68++
69++Name: libiserv
70++Version: @ProjectVersionMunged@
71++Copyright: XXX
72++License: BSD3
73++License-File: LICENSE
74++Author: XXX
75++Maintainer: XXX
76++Synopsis: Provides shared functionality between iserv and iserv-proxy
77++Description:
78++Category: Development
79++build-type: Simple
80++cabal-version: >=1.10
81++
82++Flag network
83++ Description: Build libiserv with over-the-network support
84++ Default: False
85++
86++Library
87++ Default-Language: Haskell2010
88++ Hs-Source-Dirs: src
89++ Exposed-Modules: Lib
90++ , GHCi.Utils
91++ Build-Depends: base >= 4 && < 5,
92++ binary >= 0.7 && < 0.11,
93++ bytestring >= 0.10 && < 0.11,
94++ containers >= 0.5 && < 0.7,
95++ deepseq >= 1.4 && < 1.5,
96++ ghci == @ProjectVersionMunged@
97++ if flag(network)
98++ Exposed-Modules: Remote.Message
99++ , Remote.Slave
100++ Build-Depends: network >= 2.6 && < 2.7,
101++ directory >= 1.3 && < 1.4,
102++ filepath >= 1.4 && < 1.5
103++
104++ if os(windows)
105++ Cpp-Options: -DWINDOWS
106++ else
107++ Build-Depends: unix >= 2.7 && < 2.9
108+diff --git a/utils/iserv-proxy/Makefile b/utils/iserv-proxy/Makefile
109+index f160978c19..dec92996f7 100644
110+--- a/utils/iserv-proxy/Makefile
111++++ b/utils/iserv-proxy/Makefile
112+@@ -10,6 +10,6 @@
113+ #
114+ # -----------------------------------------------------------------------------
115+
116+-dir = iserv
117+-TOP = ..
118++dir = iserv-proxy
119++TOP = ../..
120+ include $(TOP)/mk/sub-makefile.mk
121+diff --git a/utils/iserv-proxy/iserv-proxy.cabal b/utils/iserv-proxy/iserv-proxy.cabal
122+deleted file mode 100644
123+index 5d276b244d..0000000000
124+--- a/utils/iserv-proxy/iserv-proxy.cabal
125++++ /dev/null
126+@@ -1,78 +0,0 @@
127+-Name: iserv-proxy
128+-Version: 8.6
129+-Copyright: XXX
130+-License: BSD3
131+--- XXX License-File: LICENSE
132+-Author: XXX
133+-Maintainer: XXX
134+-Synopsis: iserv allows GHC to delegate Tempalte Haskell computations
135+-Description:
136+- GHC can be provided with a path to the iserv binary with
137+- @-pgmi=/path/to/iserv-bin@, and will in combination with
138+- @-fexternal-interpreter@, compile Template Haskell though the
139+- @iserv-bin@ delegate. This is very similar to how ghcjs has been
140+- compiling Template Haskell, by spawning a separate delegate (so
141+- called runner on the javascript vm) and evaluating the splices
142+- there.
143+- .
144+- iserv can also be used in combination with cross compilation. For
145+- this, the @iserv-proxy@ needs to be built on the host, targeting the
146+- host (as it is running on the host). @cabal install -flibrary
147+- -fproxy@ will yield the proxy.
148+- .
149+- Using the cabal for the target @arch-platform-target-cabal install
150+- -flibrary@ will build the required library that contains the ffi
151+- @startSlave@ function, which needs to be invoked on the target
152+- (e.g. in an iOS application) to start the remote iserv slave.
153+- .
154+- calling the GHC cross compiler with @-fexternal-interpreter
155+- -pgmi=$HOME/.cabal/bin/iserv-proxy -opti\<ip address\> -opti\<port\>@
156+- will cause it to compile Template Haskell via the remote at \<ip address\>.
157+- .
158+- Thus to get cross compilation with Template Haskell follow the
159+- following receipt:
160+- .
161+- * compile the iserv library for your target
162+- .
163+- > iserv $ arch-platform-target-cabal install -flibrary
164+- .
165+- * setup an application for your target that calls the
166+- * startSlave function. This could be either haskell or your
167+- * targets ffi capable language, if needed.
168+- .
169+- > void startSlave(false /* verbose */, 5000 /* port */,
170+- > "/path/to/storagelocation/on/target");
171+- .
172+- * build the iserv-proxy
173+- .
174+- > iserv $ cabal install -flibrary -fproxy
175+- * Start your iserv-slave app on your target running on say @10.0.0.1:5000@
176+- * compiler your sources with -fexternal-interpreter and the proxy
177+- .
178+- > project $ arch-platform-target-ghc ModuleContainingTH.hs \
179+- > -fexternal-interpreter \
180+- > -pgmi=$HOME/.cabal/bin/iserv-proxy \
181+- > -opti10.0.0.1 -opti5000
182+- .
183+- Should something not work as expected, provide @-opti-v@ for verbose
184+- logging of the @iserv-proxy@.
185+-
186+-Category: Development
187+-build-type: Simple
188+-cabal-version: >=1.10
189+-
190+-Executable iserv-proxy
191+- Default-Language: Haskell2010
192+- Main-Is: Main.hs
193+- Hs-Source-Dirs: src
194+- Build-Depends: array >= 0.5 && < 0.6,
195+- base >= 4 && < 5,
196+- binary >= 0.7 && < 0.9,
197+- bytestring >= 0.10 && < 0.11,
198+- containers >= 0.5 && < 0.6,
199+- deepseq >= 1.4 && < 1.5,
200+- directory >= 1.3 && < 1.4,
201+- network >= 2.6,
202+- filepath >= 1.4 && < 1.5,
203+- ghci == 8.6.*,
204+- libiserv == 8.6.*
205+diff --git a/utils/iserv-proxy/iserv-proxy.cabal.in b/utils/iserv-proxy/iserv-proxy.cabal.in
206+new file mode 100644
207+index 0000000000..0819064601
208+--- /dev/null
209++++ b/utils/iserv-proxy/iserv-proxy.cabal.in
210+@@ -0,0 +1,82 @@
211++-- WARNING: iserv-proxy.cabal is automatically generated from iserv-proxy.cabal.in by
212++-- ../../configure. Make sure you are editing iserv-proxy.cabal.in, not
213++-- iserv-proxy.cabal.
214++
215++Name: iserv-proxy
216++Version: @ProjectVersion@
217++Copyright: XXX
218++License: BSD3
219++-- XXX License-File: LICENSE
220++Author: XXX
221++Maintainer: XXX
222++Synopsis: iserv allows GHC to delegate Tempalte Haskell computations
223++Description:
224++ GHC can be provided with a path to the iserv binary with
225++ @-pgmi=/path/to/iserv-bin@, and will in combination with
226++ @-fexternal-interpreter@, compile Template Haskell though the
227++ @iserv-bin@ delegate. This is very similar to how ghcjs has been
228++ compiling Template Haskell, by spawning a separate delegate (so
229++ called runner on the javascript vm) and evaluating the splices
230++ there.
231++ .
232++ iserv can also be used in combination with cross compilation. For
233++ this, the @iserv-proxy@ needs to be built on the host, targeting the
234++ host (as it is running on the host). @cabal install -flibrary
235++ -fproxy@ will yield the proxy.
236++ .
237++ Using the cabal for the target @arch-platform-target-cabal install
238++ -flibrary@ will build the required library that contains the ffi
239++ @startSlave@ function, which needs to be invoked on the target
240++ (e.g. in an iOS application) to start the remote iserv slave.
241++ .
242++ calling the GHC cross compiler with @-fexternal-interpreter
243++ -pgmi=$HOME/.cabal/bin/iserv-proxy -opti\<ip address\> -opti\<port\>@
244++ will cause it to compile Template Haskell via the remote at \<ip address\>.
245++ .
246++ Thus to get cross compilation with Template Haskell follow the
247++ following receipt:
248++ .
249++ * compile the iserv library for your target
250++ .
251++ > iserv $ arch-platform-target-cabal install -flibrary
252++ .
253++ * setup an application for your target that calls the
254++ * startSlave function. This could be either haskell or your
255++ * targets ffi capable language, if needed.
256++ .
257++ > void startSlave(false /* verbose */, 5000 /* port */,
258++ > "/path/to/storagelocation/on/target");
259++ .
260++ * build the iserv-proxy
261++ .
262++ > iserv $ cabal install -flibrary -fproxy
263++ * Start your iserv-slave app on your target running on say @10.0.0.1:5000@
264++ * compiler your sources with -fexternal-interpreter and the proxy
265++ .
266++ > project $ arch-platform-target-ghc ModuleContainingTH.hs \
267++ > -fexternal-interpreter \
268++ > -pgmi=$HOME/.cabal/bin/iserv-proxy \
269++ > -opti10.0.0.1 -opti5000
270++ .
271++ Should something not work as expected, provide @-opti-v@ for verbose
272++ logging of the @iserv-proxy@.
273++
274++Category: Development
275++build-type: Simple
276++cabal-version: >=1.10
277++
278++Executable iserv-proxy
279++ Default-Language: Haskell2010
280++ Main-Is: Main.hs
281++ Hs-Source-Dirs: src
282++ Build-Depends: array >= 0.5 && < 0.6,
283++ base >= 4 && < 5,
284++ binary >= 0.7 && < 0.9,
285++ bytestring >= 0.10 && < 0.11,
286++ containers >= 0.5 && < 0.6,
287++ deepseq >= 1.4 && < 1.5,
288++ directory >= 1.3 && < 1.4,
289++ network >= 2.6,
290++ filepath >= 1.4 && < 1.5,
291++ ghci == @ProjectVersionMunged@,
292++ libiserv == @ProjectVersionMunged@
293+diff --git a/utils/iserv-proxy/src/Main.hs b/utils/iserv-proxy/src/Main.hs
294+index c91b2d08c6..7805147b76 100644
295+--- a/utils/iserv-proxy/src/Main.hs
296++++ b/utils/iserv-proxy/src/Main.hs
297+@@ -1,4 +1,7 @@
298+-{-# LANGUAGE CPP, GADTs, OverloadedStrings #-}
299++{-# LANGUAGE CPP #-}
300++{-# LANGUAGE GADTs #-}
301++{-# LANGUAGE LambdaCase #-}
302++{-# LANGUAGE OverloadedStrings #-}
303+
304+ {-
305+ This is the proxy portion of iserv.
306+@@ -45,26 +48,33 @@ and object files.
307+
308+ module Main (main) where
309+
310+-import System.IO
311+-import GHCi.Message
312+-import GHCi.Utils
313+-import GHCi.Signals
314++import GHCi.Message
315++import GHCi.Signals
316++import GHCi.Utils
317++import System.IO
318+
319+-import Remote.Message
320++import Remote.Message
321+
322+-import Network.Socket
323+-import Data.IORef
324+-import Control.Monad
325+-import System.Environment
326+-import System.Exit
327+-import Text.Printf
328+-import GHC.Fingerprint (getFileHash)
329+-import System.Directory
330+-import System.FilePath (isAbsolute)
331++import Control.Concurrent (threadDelay)
332++import qualified Control.Exception as E
333++import Control.Monad
334++import Data.IORef
335++import GHC.Fingerprint (getFileHash)
336++import Network.Socket
337++import System.Directory
338++import System.Environment
339++import System.Exit
340++import System.FilePath (isAbsolute)
341++import Text.Printf
342+
343+-import Data.Binary
344++import Data.Binary
345+ import qualified Data.ByteString as BS
346+
347++import Debug.Trace (traceIO)
348++
349++trace :: String -> IO ()
350++trace s = getProgName >>= \name -> traceIO ("[" ++ name ++ "] " ++ s)
351++
352+ dieWithUsage :: IO a
353+ dieWithUsage = do
354+ prog <- getProgName
355+@@ -104,11 +114,16 @@ main = do
356+ let in_pipe = Pipe{pipeRead = inh, pipeWrite = outh, pipeLeftovers = lo_ref}
357+
358+ when verbose $
359+- putStrLn ("Trying to connect to " ++ host_ip ++ ":" ++ (show port))
360+- out_pipe <- connectTo host_ip port >>= socketToPipe
361+-
362+- putStrLn "Starting proxy"
363++ trace ("Trying to connect to " ++ host_ip ++ ":" ++ (show port))
364++ out_pipe <- do
365++ let go n = E.try (connectTo host_ip port >>= socketToPipe) >>= \case
366++ Left e | n == 0 -> E.throw (e :: E.SomeException)
367++ | n > 0 -> threadDelay 500000 >> go (n - 1)
368++ Right a -> return a
369++ in go 120 -- wait for up to 60seconds (polling every 0.5s).
370++ trace "Starting proxy"
371+ proxy verbose in_pipe out_pipe
372++ trace "Proxy done"
373+
374+ -- | A hook, to transform outgoing (proxy -> slave)
375+ -- messages prior to sending them to the slave.
376+@@ -140,10 +155,10 @@ fwdTHCall verbose local remote msg = do
377+ loopTH = do
378+ THMsg msg' <- readPipe remote getTHMessage
379+ when verbose $
380+- putStrLn ("| TH Msg: ghc <- proxy -- slave: " ++ show msg')
381++ trace ("| TH Msg: ghc <- proxy -- slave: " ++ show msg')
382+ res <- fwdTHMsg local msg'
383+ when verbose $
384+- putStrLn ("| Resp.: ghc -- proxy -> slave: " ++ show res)
385++ trace ("| Resp.: ghc -- proxy -> slave: " ++ show res)
386+ writePipe remote (put res)
387+ case msg' of
388+ RunTHDone -> return ()
389+@@ -161,8 +176,11 @@ fwdTHCall verbose local remote msg = do
390+ --
391+ fwdLoadCall :: (Binary a, Show a) => Bool -> Pipe -> Pipe -> Message a -> IO a
392+ fwdLoadCall verbose _ remote msg = do
393++ when verbose $ trace ("fwdLoadCall...")
394++ when verbose $ trace ("fwdLoadCall: writing remote pipe")
395+ writePipe remote (putMessage msg)
396+ loopLoad
397++ when verbose $ trace ("fwdLoadCall: reading remote pipe")
398+ readPipe remote get
399+ where
400+ truncateMsg :: Int -> String -> String
401+@@ -171,17 +189,19 @@ fwdLoadCall verbose _ remote msg = do
402+ reply :: (Binary a, Show a) => a -> IO ()
403+ reply m = do
404+ when verbose $
405+- putStrLn ("| Resp.: proxy -> slave: "
406++ trace ("| Resp.: proxy -> slave: "
407+ ++ truncateMsg 80 (show m))
408+ writePipe remote (put m)
409+ loopLoad :: IO ()
410+ loopLoad = do
411++ when verbose $ trace ("fwdLoadCall: reading remote pipe (slave message)")
412+ SlaveMsg msg' <- readPipe remote getSlaveMessage
413+ when verbose $
414+- putStrLn ("| Sl Msg: proxy <- slave: " ++ show msg')
415++ trace ("| Sl Msg: proxy <- slave: " ++ show msg')
416+ case msg' of
417+ Done -> return ()
418+ Missing path -> do
419++ trace("fwdLoadCall: missing path: " ++ path)
420+ reply =<< BS.readFile path
421+ loopLoad
422+ Have path remoteHash -> do
423+@@ -198,20 +218,23 @@ proxy verbose local remote = loop
424+ where
425+ fwdCall :: (Binary a, Show a) => Message a -> IO a
426+ fwdCall msg = do
427++ when verbose $ trace ("proxy/fwdCall: writing remote pipe")
428+ writePipe remote (putMessage msg)
429++ when verbose $ trace ("proxy/fwdCall: reading remote pipe")
430+ readPipe remote get
431+
432+ -- reply to ghc.
433+ reply :: (Show a, Binary a) => a -> IO ()
434+ reply msg = do
435+ when verbose $
436+- putStrLn ("Resp.: ghc <- proxy -- slave: " ++ show msg)
437++ trace ("Resp.: ghc <- proxy -- slave: " ++ show msg)
438+ writePipe local (put msg)
439+
440+ loop = do
441++ when verbose $ trace ("reading local pipe...")
442+ (Msg msg) <- readPipe local getMessage
443+ when verbose $
444+- putStrLn ("Msg: ghc -- proxy -> slave: " ++ show msg)
445++ trace ("Msg: ghc -- proxy -> slave: " ++ show msg)
446+ (Msg msg') <- hook (Msg msg)
447+ case msg' of
448+ -- TH might send some message back to ghc.
449+@@ -233,24 +256,29 @@ proxy verbose local remote = loop
450+ resp <- fwdLoadCall verbose local remote msg'
451+ reply resp
452+ loop
453+- LoadDLL path | isAbsolute path -> do
454+- resp <- fwdLoadCall verbose local remote msg'
455+- reply resp
456+- loop
457++ -- LoadDLL path | isAbsolute path -> do
458++ -- resp <- fwdLoadCall verbose local remote msg'
459++ -- reply resp
460++ -- loop
461+ Shutdown{} -> fwdCall msg' >> return ()
462+ _other -> fwdCall msg' >>= reply >> loop
463+
464+
465+ connectTo :: String -> PortNumber -> IO Socket
466+ connectTo host port = do
467+- let hints = defaultHints { addrFlags = [AI_NUMERICHOST, AI_NUMERICSERV]
468+- , addrSocketType = Stream }
469+- addr:_ <- getAddrInfo (Just hints) (Just host) (Just (show port))
470+- sock <- socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr)
471+- putStrLn $ "Created socket for " ++ host ++ ":" ++ show port
472+- connect sock (addrAddress addr)
473+- putStrLn "connected"
474+- return sock
475++ addr <- resolve host (show port)
476++ open addr
477++ where
478++ resolve host port = do
479++ let hints = defaultHints { addrSocketType = Stream }
480++ addr:_ <- getAddrInfo (Just hints) (Just host) (Just port)
481++ return addr
482++ open addr = do
483++ sock <- socket (addrFamily addr) (addrSocketType addr) (addrProtocol addr)
484++ trace $ "Created socket for " ++ host ++ ":" ++ show port
485++ connect sock $ addrAddress addr
486++ trace "connected"
487++ return sock
488+
489+ -- | Turn a socket into an unbuffered pipe.
490+ socketToPipe :: Socket -> IO Pipe
491+diff --git a/utils/iserv/iserv.cabal b/utils/iserv/iserv.cabal
492+deleted file mode 100644
493+index 6e78317ec4..0000000000
494+--- a/utils/iserv/iserv.cabal
495++++ /dev/null
496+@@ -1,44 +0,0 @@
497+-Name: iserv
498+-Version: 8.6.1
499+-Copyright: XXX
500+-License: BSD3
501+--- XXX License-File: LICENSE
502+-Author: XXX
503+-Maintainer: XXX
504+-Synopsis: iserv allows GHC to delegate Tempalte Haskell computations
505+-Description:
506+- GHC can be provided with a path to the iserv binary with
507+- @-pgmi=/path/to/iserv-bin@, and will in combination with
508+- @-fexternal-interpreter@, compile Template Haskell though the
509+- @iserv-bin@ delegate. This is very similar to how ghcjs has been
510+- compiling Template Haskell, by spawning a separate delegate (so
511+- called runner on the javascript vm) and evaluating the splices
512+- there.
513+- .
514+- To use iserv with cross compilers, please see @libraries/libiserv@
515+- and @utils/iserv-proxy@.
516+-
517+-Category: Development
518+-build-type: Simple
519+-cabal-version: >=1.10
520+-
521+-Executable iserv
522+- Default-Language: Haskell2010
523+- ghc-options: -no-hs-main
524+- Main-Is: Main.hs
525+- C-Sources: cbits/iservmain.c
526+- Hs-Source-Dirs: src
527+- include-dirs: .
528+- Build-Depends: array >= 0.5 && < 0.6,
529+- base >= 4 && < 5,
530+- binary >= 0.7 && < 0.11,
531+- bytestring >= 0.10 && < 0.11,
532+- containers >= 0.5 && < 0.7,
533+- deepseq >= 1.4 && < 1.5,
534+- ghci == 8.6.*,
535+- libiserv == 8.6.*
536+-
537+- if os(windows)
538+- Cpp-Options: -DWINDOWS
539+- else
540+- Build-Depends: unix >= 2.7 && < 2.9
541+diff --git a/utils/iserv/iserv.cabal.in b/utils/iserv/iserv.cabal.in
542+new file mode 100644
543+index 0000000000..356c8a444a
544+--- /dev/null
545++++ b/utils/iserv/iserv.cabal.in
546+@@ -0,0 +1,48 @@
547++-- WARNING: iserv.cabal is automatically generated from iserv.cabal.in by
548++-- ../../configure. Make sure you are editing iserv.cabal.in, not
549++-- iserv.cabal.
550++
551++Name: iserv
552++Version: @ProjectVersion@
553++Copyright: XXX
554++License: BSD3
555++-- XXX License-File: LICENSE
556++Author: XXX
557++Maintainer: XXX
558++Synopsis: iserv allows GHC to delegate Template Haskell computations
559++Description:
560++ GHC can be provided with a path to the iserv binary with
561++ @-pgmi=/path/to/iserv-bin@, and will in combination with
562++ @-fexternal-interpreter@, compile Template Haskell though the
563++ @iserv-bin@ delegate. This is very similar to how ghcjs has been
564++ compiling Template Haskell, by spawning a separate delegate (so
565++ called runner on the javascript vm) and evaluating the splices
566++ there.
567++ .
568++ To use iserv with cross compilers, please see @libraries/libiserv@
569++ and @utils/iserv-proxy@.
570++
571++Category: Development
572++build-type: Simple
573++cabal-version: >=1.10
574++
575++Executable iserv
576++ Default-Language: Haskell2010
577++ ghc-options: -no-hs-main
578++ Main-Is: Main.hs
579++ C-Sources: cbits/iservmain.c
580++ Hs-Source-Dirs: src
581++ include-dirs: .
582++ Build-Depends: array >= 0.5 && < 0.6,
583++ base >= 4 && < 5,
584++ binary >= 0.7 && < 0.11,
585++ bytestring >= 0.10 && < 0.11,
586++ containers >= 0.5 && < 0.7,
587++ deepseq >= 1.4 && < 1.5,
588++ ghci == @ProjectVersionMunged@,
589++ libiserv == @ProjectVersionMunged@
590++
591++ if os(windows)
592++ Cpp-Options: -DWINDOWS
593++ else
594++ Build-Depends: unix >= 2.7 && < 2.9
595+diff --git a/utils/remote-iserv/Makefile b/utils/remote-iserv/Makefile
596+new file mode 100644
597+index 0000000000..c659a21a20
598+--- /dev/null
599++++ b/utils/remote-iserv/Makefile
600+@@ -0,0 +1,15 @@
601++# -----------------------------------------------------------------------------
602++#
603++# (c) 2009 The University of Glasgow
604++#
605++# This file is part of the GHC build system.
606++#
607++# To understand how the build system works and how to modify it, see
608++# http://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
609++# http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
610++#
611++# -----------------------------------------------------------------------------
612++
613++dir = remote-iserv
614++TOP = ../..
615++include $(TOP)/mk/sub-makefile.mk
616+diff --git a/utils/remote-iserv/Setup.hs b/utils/remote-iserv/Setup.hs
617+new file mode 100644
618+index 0000000000..44671092b2
619+--- /dev/null
620++++ b/utils/remote-iserv/Setup.hs
621+@@ -0,0 +1,2 @@
622++import Distribution.Simple
623++main = defaultMain
624+diff --git a/utils/remote-iserv/ghc.mk b/utils/remote-iserv/ghc.mk
625+new file mode 100644
626+index 0000000000..db8f32fc22
627+--- /dev/null
628++++ b/utils/remote-iserv/ghc.mk
629+@@ -0,0 +1,113 @@
630++# -----------------------------------------------------------------------------
631++#
632++# (c) 2009-2012 The University of Glasgow
633++#
634++# This file is part of the GHC build system.
635++#
636++# To understand how the build system works and how to modify it, see
637++# http://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
638++# http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
639++#
640++# -----------------------------------------------------------------------------
641++
642++utils/remote-iserv_USES_CABAL = YES
643++utils/remote-iserv_PACKAGE = remote-iserv
644++utils/remote-iserv_EXECUTABLE = remote-iserv
645++
646++ifeq "$(GhcDebugged)" "YES"
647++utils/remote-iserv_stage2_MORE_HC_OPTS += -debug
648++utils/remote-iserv_stage2_p_MORE_HC_OPTS += -debug
649++utils/remote-iserv_stage2_dyn_MORE_HC_OPTS += -debug
650++endif
651++
652++ifeq "$(GhcThreaded)" "YES"
653++utils/remote-iserv_stage2_MORE_HC_OPTS += -threaded
654++utils/remote-iserv_stage2_p_MORE_HC_OPTS += -threaded
655++utils/remote-iserv_stage2_dyn_MORE_HC_OPTS += -threaded
656++endif
657++
658++# Add -Wl,--export-dynamic enables GHCi to load dynamic objects that
659++# refer to the RTS. This is harmless if you don't use it (adds a bit
660++# of overhead to startup and increases the binary sizes) but if you
661++# need it there's no alternative.
662++ifeq "$(TargetElf)" "YES"
663++ifneq "$(TargetOS_CPP)" "solaris2"
664++# The Solaris linker does not support --export-dynamic option. It also
665++# does not need it since it exports all dynamic symbols by default
666++utils/remote-iserv_stage2_MORE_HC_OPTS += -optl-Wl,--export-dynamic
667++utils/remote-iserv_stage2_p_MORE_HC_OPTS += -optl-Wl,--export-dynamic
668++utils/remote-iserv_stage2_dyn_MORE_HC_OPTS += -optl-Wl,--export-dynamic
669++endif
670++endif
671++
672++# Override the default way, because we want a specific version of this
673++# program for each way. Note that it's important to do this even for
674++# the vanilla version, otherwise we get a dynamic executable when
675++# DYNAMIC_GHC_PROGRAMS=YES.
676++utils/remote-iserv_stage2_PROGRAM_WAY = v
677++utils/remote-iserv_stage2_p_PROGRAM_WAY = p
678++utils/remote-iserv_stage2_dyn_PROGRAM_WAY = dyn
679++
680++utils/remote-iserv_stage2_PROGNAME = ghc-iserv
681++utils/remote-iserv_stage2_p_PROGNAME = ghc-iserv-prof
682++utils/remote-iserv_stage2_dyn_PROGNAME = ghc-iserv-dyn
683++
684++utils/remote-iserv_stage2_MORE_HC_OPTS += -no-hs-main
685++utils/remote-iserv_stage2_p_MORE_HC_OPTS += -no-hs-main
686++utils/remote-iserv_stage2_dyn_MORE_HC_OPTS += -no-hs-main
687++
688++utils/remote-iserv_stage2_INSTALL = YES
689++utils/remote-iserv_stage2_p_INSTALL = YES
690++utils/remote-iserv_stage2_dyn_INSTALL = YES
691++
692++# Install in $(libexec), not in $(bindir)
693++utils/remote-iserv_stage2_TOPDIR = YES
694++utils/remote-iserv_stage2_p_TOPDIR = YES
695++utils/remote-iserv_stage2_dyn_TOPDIR = YES
696++
697++utils/remote-iserv_stage2_INSTALL_INPLACE = YES
698++utils/remote-iserv_stage2_p_INSTALL_INPLACE = YES
699++utils/remote-iserv_stage2_dyn_INSTALL_INPLACE = YES
700++
701++ifeq "$(CLEANING)" "YES"
702++
703++NEED_iserv = YES
704++NEED_iserv_p = YES
705++NEED_iserv_dyn = YES
706++
707++else
708++
709++ifneq "$(findstring v, $(GhcLibWays))" ""
710++NEED_iserv = YES
711++else
712++NEED_iserv = NO
713++endif
714++
715++ifneq "$(findstring p, $(GhcLibWays))" ""
716++NEED_iserv_p = YES
717++else
718++NEED_iserv_p = NO
719++endif
720++
721++ifneq "$(findstring dyn, $(GhcLibWays))" ""
722++NEED_iserv_dyn = YES
723++else
724++NEED_iserv_dyn = NO
725++endif
726++endif
727++
728++ifeq "$(NEED_iserv)" "YES"
729++$(eval $(call build-prog,utils/remote-iserv,stage2,1))
730++endif
731++
732++ifeq "$(NEED_iserv_p)" "YES"
733++$(eval $(call build-prog,utils/remote-iserv,stage2_p,1))
734++endif
735++
736++ifeq "$(NEED_iserv_dyn)" "YES"
737++$(eval $(call build-prog,utils/remote-iserv,stage2_dyn,1))
738++endif
739++
740++all_ghc_stage2 : $(remote-iserv-stage2_INPLACE)
741++all_ghc_stage2 : $(remote-iserv-stage2_p_INPLACE)
742++all_ghc_stage2 : $(remote-iserv-stage2_dyn_INPLACE)
743+diff --git a/utils/remote-iserv/remote-iserv.cabal.in b/utils/remote-iserv/remote-iserv.cabal.in
744+new file mode 100644
745+index 0000000000..2e9123bf5e
746+--- /dev/null
747++++ b/utils/remote-iserv/remote-iserv.cabal.in
748+@@ -0,0 +1,27 @@
749++-- WARNING: iserv-proxy.cabal is automatically generated from iserv-proxy.cabal.in by
750++-- ../../configure. Make sure you are editing iserv-proxy.cabal.in, not
751++-- iserv-proxy.cabal.
752++
753++Name: remote-iserv
754++Version: @ProjectVersion@
755++Copyright: XXX
756++License: BSD3
757++-- XXX License-File: LICENSE
758++Author: Moritz Angermann <moritz.angermann@gmail.com>
759++Maintainer: Moritz Angermann <moritz.angermann@gmail.com>
760++Synopsis: iserv allows GHC to delegate Tempalte Haskell computations
761++Description:
762++ This is a very simple remote runner for iserv, to be used together
763++ with iserv-proxy. The foundamental idea is that this this wrapper
764++ starts running libiserv on a given port to which iserv-proxy will
765++ then connect.
766++Category: Development
767++build-type: Simple
768++cabal-version: >=1.10
769++
770++Executable remote-iserv
771++ Default-Language: Haskell2010
772++ Main-Is: Cli.hs
773++ Hs-Source-Dirs: src
774++ Build-Depends: base >= 4 && < 5,
775++ libiserv == @ProjectVersionMunged@
776+diff --git a/utils/remote-iserv/src/Cli.hs b/utils/remote-iserv/src/Cli.hs
777+new file mode 100644
778+index 0000000000..400105d80e
779+--- /dev/null
780++++ b/utils/remote-iserv/src/Cli.hs
781+@@ -0,0 +1,30 @@
782++module Main where
783++
784++import Remote.Slave (startSlave')
785++import System.Environment (getArgs, getProgName)
786++import System.Exit (die)
787++
788++main :: IO ()
789++main = getArgs >>= startSlave
790++
791++dieWithUsage :: IO a
792++dieWithUsage = do
793++ prog <- getProgName
794++ die $ prog ++ ": " ++ msg
795++ where
796++ msg = "usage: iserv-slave /path/to/storage PORT [-v]"
797++
798++startSlave :: [String] -> IO ()
799++startSlave args0
800++ | "--help" `elem` args0 = dieWithUsage
801++ | otherwise = do
802++ (path, port, rest) <- case args0 of
803++ arg0:arg1:rest -> return (arg0, read arg1, rest)
804++ _ -> dieWithUsage
805++ verbose <- case rest of
806++ ["-v"] -> return True
807++ [] -> return False
808++ _ -> dieWithUsage
809++
810++ startSlave' verbose path port
811++
overlays/patches/ghc/ghc-8.6.3-reinstallable-lib-ghc.patchnew file+5539

This diff is too big to show here.

overlays/patches/ghc/ghc-8.6.4-better-plusSimplCountErrors.patchnew file+26

This diff is too big to show here.

overlays/patches/ghc/ghc-8.6.4-reenable-th-qq-in-stage1.patchnew file+19

This diff is too big to show here.

overlays/patches/ghc/ghc-8.6.4-reinstallable-lib-ghc.patchnew file+4879

This diff is too big to show here.

overlays/patches/ghc/ghc-8.6.5-reinstallable-lib-ghc.patchnew file+4879

This diff is too big to show here.

overlays/patches/ghc/ghc-add-keepCAFs-to-rts.patchnew file+12

This diff is too big to show here.

overlays/patches/ghc/hsc2hs-8.4.2.patchnew file+1197

This diff is too big to show here.

overlays/patches/ghc/iserv-proxy-cleanup.patchnew file+912

This diff is too big to show here.

overlays/patches/ghc/lowercase-8.4.2.patchnew file+57

This diff is too big to show here.

overlays/patches/ghc/lowercase-8.6.patchnew file+37

This diff is too big to show here.

overlays/patches/ghc/mistuke-ghc-err_clean_up_error_handler-8ab1a89af89848f1713e6849f189de66c0ed7898.diffnew file+98

This diff is too big to show here.

overlays/patches/ghc/move-iserv-8.4.2.patchnew file+1001

This diff is too big to show here.

overlays/patches/ghc/outputtable-assert-8.4.patchnew file+30

This diff is too big to show here.

overlays/patches/ghc/outputtable-assert-8.6.patchnew file+13

This diff is too big to show here.

overlays/patches/ghc/various-8.4.2.patchnew file+57

This diff is too big to show here.

overlays/patches/http-client-0.5.14.patchnew file+18

This diff is too big to show here.

overlays/patches/streaming-commons-0.2.0.0.patchnew file+15

This diff is too big to show here.

overlays/patches/x509-system-1.6.6.patchnew file+13

This diff is too big to show here.

overlays/python.nixnew file+11

This diff is too big to show here.

overlays/release-19.03.nixnew file+14

This diff is too big to show here.

overlays/windows.nixnew file+128

This diff is too big to show here.

package-set.nix+19−4

This diff is too big to show here.

patches/darcs-setup.patchnew file+120

This diff is too big to show here.

pkgs/rocksdb-prebuilt.nixnew file+30

This diff is too big to show here.

snapshots.nix+7−2

This diff is too big to show here.

test-ghcjs.nixnew file+12

This diff is too big to show here.

test-mingw32.nixnew file+12

This diff is too big to show here.

test-rpi.nixnew file+12

This diff is too big to show here.

test.nixnew file+12

This diff is too big to show here.

test/default.nix+23−24

This diff is too big to show here.