diff --git a/android-activity/github.json b/android-activity/github.json index 6c07a527c..74234bc52 100644 --- a/android-activity/github.json +++ b/android-activity/github.json @@ -1,6 +1,6 @@ { "owner": "obsidiansystems", "repo": "android-activity", - "rev": "ac9dea4fc72604e8f82885dafcf17811d9a7c948", - "sha256": "19smn1vg3l41bs6b21qccj80dvy7nhziyisa000aphx3y8fryyg0" + "rev": "af7139857b33b8617539a3bb3d8ac91c91daa3de", + "sha256": "0wphsfpswbw5ihqsx456vh406rc8ca0anfkcaz4rxx4lm8prn444" } diff --git a/android/build.gradle.nix b/android/build.gradle.nix index 6914537d5..bba488d2c 100644 --- a/android/build.gradle.nix +++ b/android/build.gradle.nix @@ -26,7 +26,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 25 - buildToolsVersion '26.0.1' + buildToolsVersion '26.0.2' sourceSets { main { diff --git a/android/impl.nix b/android/impl.nix index 82381402f..063266360 100644 --- a/android/impl.nix +++ b/android/impl.nix @@ -16,7 +16,7 @@ let overrideAndroidCabal = package: overrideCabal package (drv: { EOF chmod +x "$out/bin/deploy" ''; - buildInputs = with nixpkgs; [ androidsdk ]; + buildInputs = [ nixpkgs.androidenv.androidsdk_8_0 ]; } ""; inherit (nixpkgs.lib) splitString escapeShellArg mapAttrs attrNames concatStrings optionalString; in { @@ -38,7 +38,6 @@ in { src = let splitApplicationId = splitString "." applicationId; appSOs = mapAttrs (abiVersion: { myNixpkgs, myHaskellPackages }: { - inherit (myNixpkgs) libiconv; hsApp = overrideAndroidCabal (package myHaskellPackages); }) { "arm64-v8a" = { @@ -90,16 +89,12 @@ in { ln -s "$applicationMk" "$out/jni/Application.mk" '' + concatStrings (builtins.map (arch: - let inherit (appSOs.${arch}) libiconv hsApp; + let inherit (appSOs.${arch}) hsApp; in '' { ARCH_LIB=$out/lib/${arch} mkdir -p $ARCH_LIB - # Move libiconv (per arch) to the correct place - cp --no-preserve=mode "${libiconv}/lib/libiconv.so" "$ARCH_LIB" - cp --no-preserve=mode "${libiconv}/lib/libcharset.so" "$ARCH_LIB" - local exe="${hsApp}/bin/lib${executableName}.so" if [ ! -f "$exe" ] ; then >&2 echo 'Error: executable "${executableName}" not found' diff --git a/default.nix b/default.nix index 200eec997..c0bf2bc3e 100644 --- a/default.nix +++ b/default.nix @@ -8,27 +8,11 @@ , useReflexOptimizer ? false , useTextJSString ? true , iosSdkVersion ? "10.2" -, iosSdkLocation ? "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS${iosSdkVersion}.sdk" -, iosSupportForce ? false , nixpkgsOverlays ? [] }: -let iosSupport = - if system != "x86_64-darwin" then false - else if iosSupportForce || builtins.pathExists iosSdkLocation then true - else lib.warn "No iOS sdk found at ${iosSdkLocation}; iOS support disabled. To enable, either install a version of Xcode that provides that SDK or override the value of iosSdkVersion to match your installed version." false; +let iosSupport = system == "x86_64-darwin"; androidSupport = lib.elem system [ "x86_64-linux" ]; - newerHackage = self: super: { - all-cabal-hashes = super.all-cabal-hashes.override { - src-spec = { - owner = "commercialhaskell"; - repo = "all-cabal-hashes"; - rev = "82a8a1a49240a1b465c95de6fa6bf56323ee858f"; - sha256 = "1jdzl5fyp1qcsi1anjig6kglq4jjsdll53nissjcnxpy3jscmarm"; - }; - }; - }; - bindHaskellOverlays = self: super: { haskell = super.haskell // { overlays = super.overlays or {} // import ./haskell-overlays { @@ -36,6 +20,7 @@ let iosSupport = inherit haskellLib fetchFromGitHub hackGet + ghcjsBaseSrc ghcjsBaseTextJSStringSrc useFastWeak useReflexOptimizer enableLibraryProfiling enableTraceReflexEvents useTextJSString enableExposeAllUnfoldings stage2Script @@ -49,11 +34,14 @@ let iosSupport = forceStaticLibs = self: super: { darwin = super.darwin // { libiconv = super.darwin.libiconv.overrideAttrs (_: - lib.optionalAttrs (self.stdenv.hostPlatform != self.stdenv.buildPlatform && self.stdenv.hostPlatform.isDarwin) { + lib.optionalAttrs (self.stdenv.hostPlatform != self.stdenv.buildPlatform) { postInstall = "rm $out/include/libcharset.h $out/include/localcharset.h"; configureFlags = ["--disable-shared" "--enable-static"]; }); }; + zlib = super.zlib.override (lib.optionalAttrs + (self.stdenv.hostPlatform != self.stdenv.buildPlatform) + { static = true; }); }; mobileGhcOverlay = import ./nixpkgs-overlays/mobile-ghc { inherit lib; }; @@ -61,22 +49,23 @@ let iosSupport = nixpkgsArgs = { inherit system; overlays = [ - newerHackage bindHaskellOverlays forceStaticLibs mobileGhcOverlay ] ++ nixpkgsOverlays; config = { - allowUnfree = true; - allowBroken = true; # GHCJS is marked broken in 011c149ed5e5a336c3039f0b9d4303020cff1d86 permittedInsecurePackages = [ "webkitgtk-2.4.11" ]; packageOverrides = pkgs: { - webkitgtk = pkgs.webkitgtk216x; + webkitgtk = pkgs.webkitgtk220x; # cabal2nix's tests crash on 32-bit linux; see https://github.com/NixOS/cabal2nix/issues/272 ${if system == "i686-linux" then "cabal2nix" else null} = pkgs.haskell.lib.dontCheck pkgs.cabal2nix; }; + + # XCode needed for native macOS app + # Obelisk needs it to for some reason + allowUnfree = true; } // config; }; @@ -85,34 +74,17 @@ let iosSupport = inherit (nixpkgs) lib fetchurl fetchgit fetchgitPrivate fetchFromGitHub; nixpkgsCross = { - android = lib.mapAttrs (_: args: if args == null then null else nixpkgsFunc args) rec { + android = lib.mapAttrs (_: args: nixpkgsFunc (nixpkgsArgs // args)) rec { aarch64 = { - system = "x86_64-linux"; - inherit (nixpkgsArgs) overlays; - crossSystem = { - config = "aarch64-unknown-linux-android"; - arch = "arm64"; - libc = "bionic"; - withTLS = true; - openssl.system = "linux-generic64"; - platform = lib.systems.examples.aarch64-multiplatform; - useAndroidPrebuilt = true; - }; - config.allowUnfree = true; + crossSystem = lib.systems.examples.aarch64-android-prebuilt; }; aarch32 = { - system = "x86_64-linux"; - inherit (nixpkgsArgs) overlays; - crossSystem = { - config = "arm-unknown-linux-androideabi"; - arch = "armv7"; - libc = "bionic"; - withTLS = true; - openssl.system = "linux-generic32"; - platform = lib.systems.exmamples.armv7l-hf-multiplatform; - useAndroidPrebuilt = true; + crossSystem = lib.systems.examples.armv7a-android-prebuilt // { + # Hard to find newer 32-bit phone to test with that's newer than + # this. Concretely, doing so resulted in: + # https://android.googlesource.com/platform/bionic/+/master/libc/arch-common/bionic/pthread_atfork.h#19 + sdkVer = "22"; }; - config.allowUnfree = true; }; # Back compat arm64 = lib.warn "nixpkgsCross.android.arm64 has been deprecated, using nixpkgsCross.android.aarch64 instead." aarch64; @@ -120,86 +92,21 @@ let iosSupport = arm64Impure = lib.warn "nixpkgsCross.android.arm64Impure has been deprecated, using nixpkgsCross.android.aarch64 instead." aarch64; armv7aImpure = lib.warn "nixpkgsCross.android.armv7aImpure has been deprecated, using nixpkgsCross.android.aarch32 instead." aarch32; }; - ios = - let config = { - allowUnfree = true; - packageOverrides = p: { - darwin = p.darwin // { - ios-cross = p.darwin.ios-cross.override { - # Depending on where ghcHEAD is in your nixpkgs checkout, you may need llvm 39 here instead - inherit (p.llvmPackages_39) llvm clang; - }; - }; - buildPackages = p.buildPackages // { - osx_sdk = p.buildPackages.callPackage ({ stdenv }: - let version = "10"; - in stdenv.mkDerivation rec { - name = "iOS.sdk"; - - src = p.stdenv.cc.sdk; - - unpackPhase = "true"; - configurePhase = "true"; - buildPhase = "true"; - target_prefix = stdenv.lib.replaceStrings ["-"] ["_"] p.targetPlatform.config; - setupHook = ./scripts/setup-hook-ios.sh; - - installPhase = '' - mkdir -p $out/ - echo "Source is: $src" - cp -r $src/* $out/ - ''; - - meta = with stdenv.lib; { - description = "The IOS OS ${version} SDK"; - maintainers = with maintainers; [ copumpkin ]; - platforms = platforms.darwin; - license = licenses.unfree; - }; - }) {}; - }; - }; - }; - in lib.mapAttrs (_: args: if args == null then null else nixpkgsFunc args) rec { + ios = lib.mapAttrs (_: args: nixpkgsFunc (nixpkgsArgs // args)) rec { simulator64 = { - system = "x86_64-darwin"; - inherit (nixpkgsArgs) overlays; - crossSystem = { - useIosPrebuilt = true; - # You can change config/arch/isiPhoneSimulator depending on your target: - # aarch64-apple-darwin14 | arm64 | false - # arm-apple-darwin10 | armv7 | false - # i386-apple-darwin11 | i386 | true - # x86_64-apple-darwin14 | x86_64 | true - config = "x86_64-apple-darwin14"; - arch = "x86_64"; - isiPhoneSimulator = true; + crossSystem = lib.systems.examples.iphone64-simulator // { sdkVer = iosSdkVersion; - useiOSCross = true; - openssl.system = "darwin64-x86_64-cc"; - libc = "libSystem"; }; - inherit config; }; aarch64 = { - system = "x86_64-darwin"; - inherit (nixpkgsArgs) overlays; - crossSystem = { - useIosPrebuilt = true; - # You can change config/arch/isiPhoneSimulator depending on your target: - # aarch64-apple-darwin14 | arm64 | false - # arm-apple-darwin10 | armv7 | false - # i386-apple-darwin11 | i386 | true - # x86_64-apple-darwin14 | x86_64 | true - config = "aarch64-apple-darwin14"; - arch = "arm64"; - isiPhoneSimulator = false; + crossSystem = lib.systems.examples.iphone64 // { + sdkVer = iosSdkVersion; + }; + }; + aarch32 = { + crossSystem = lib.systems.examples.iphone32 // { sdkVer = iosSdkVersion; - useiOSCross = true; - openssl.system = "ios64-cross"; - libc = "libSystem"; }; - inherit config; }; # Back compat arm64 = lib.warn "nixpkgsCross.ios.arm64 has been deprecated, using nixpkgsCross.ios.aarch64 instead." aarch64; @@ -212,12 +119,13 @@ let iosSupport = # Retrieve source that is controlled by the hack-* scripts; it may be either a stub or a checked-out git repo hackGet = p: - if builtins.pathExists (p + "/git.json") then ( - let gitArgs = builtins.fromJSON (builtins.readFile (p + "/git.json")); + let filterArgs = x: removeAttrs x [ "branch" ]; + in if builtins.pathExists (p + "/git.json") then ( + let gitArgs = filterArgs (builtins.fromJSON (builtins.readFile (p + "/git.json"))); in if builtins.elem "@" (lib.stringToCharacters gitArgs.url) then fetchgitPrivate gitArgs else fetchgit gitArgs) - else if builtins.pathExists (p + "/github.json") then fetchFromGitHub (builtins.fromJSON (builtins.readFile (p + "/github.json"))) + else if builtins.pathExists (p + "/github.json") then fetchFromGitHub (filterArgs (builtins.fromJSON (builtins.readFile (p + "/github.json")))) else { name = baseNameOf p; outPath = filterGit p; @@ -234,6 +142,16 @@ let iosSupport = optionalExtension = cond: overlay: if cond then overlay else _: _: {}; + applyPatch = patch: src: nixpkgs.runCommand "applyPatch" { + inherit src patch; + } '' + cp -r "$src" "$out" + + cd "$out" + chmod -R +w . + patch -p1 <"$patch" + ''; + overrideCabal = pkg: f: if pkg == null then null else haskellLib.overrideCabal pkg f; replaceSrc = pkg: src: version: overrideCabal pkg (drv: { @@ -284,67 +202,191 @@ let iosSupport = ]; } ""; - ghcjsCompiler = ghc.callPackage (nixpkgs.path + "/pkgs/development/compilers/ghcjs/base.nix") { - bootPkgs = ghc; + ghcjsApplyFastWeak = ghcjs: ghcjs.overrideAttrs (drv: { + patches = (drv.patches or []) + ++ lib.optional useFastWeak ./fast-weak.patch; + phases = [ "unpackPhase" "patchPhase" "buildPhase" ]; + }); + useTextJSStringAsBootPkg = ghcjs: if !useTextJSString then ghcjs else ghcjs.overrideAttrs (_: { + postUnpack = '' + set -x + ( + echo $sourceRoot + cd $sourceRoot + rm -r lib/boot/pkg/text + cp --no-preserve=mode -r "${textSrc}" lib/boot/pkg/text + cp --no-preserve=mode -r "${ghcjsBaseTextJSStringSrc}" lib/boot/pkg/ghcjs-base + cp --no-preserve=mode -r "${dlistSrc}" lib/boot/pkg/dlist + rm -r lib/boot/pkg/vector + cp --no-preserve=mode -r "${vectorSrc}" lib/boot/pkg/vector + sed -i 's/.\/pkg\/mtl/.\/pkg\/mtl\n - .\/pkg\/ghcjs-base\n - .\/pkg\/dlist\n - .\/pkg\/primitive\n - .\/pkg\/vector/' lib/boot/boot.yaml + cat lib/boot/boot.yaml + ) + ''; + }); + ghcjsBaseSrc = fetchgit { + url = "https://github.com/ghcjs/ghcjs-base.git"; + rev = "01014ade3f8f5ae677df192d7c2a208bd795b96c"; + sha256 = "173h98m7namxj0kfy8fj29qcxmcz6ilg04x8mwkc3ydjqrvk77hh"; + postFetch = '' + ( cd $out + patch -p1 < ${nixpkgs.fetchpatch { + url = "https://github.com/ghcjs/ghcjs-base/commit/2d0d674e54c273ed5fcb9a13f588819c3303a865.patch"; #ghcjs-base/114 + sha256 = "15vbxnxa1fpdcmmx5zx1z92bzsxyb0cbs3hs3g7fb1rkds5qbvgp"; + }} + patch -p1 < ${nixpkgs.fetchpatch { + url = "https://github.com/ghcjs/ghcjs-base/commit/8eccb8d937041ba323d62dea6fe8eb1b04b3cc47.patch"; #ghcjs-base/116 + sha256 = "1lqjpg46ydpm856wcq1g7c97d69qcnnqs5jxp2b788z9cfd5n64c"; + }} + patch -p1 < ${nixpkgs.fetchpatch { + url = "https://github.com/ghcjs/ghcjs-base/commit/ce91c525b5d4377ba4aefd0d8072dc1659f75ef1.patch"; #ghcjs-base/118 + sha256 = "0f6qca1i60cjzpbq4bc74baa7xrf417cja8nmhfims1fflvsx3wy"; + }} + patch -p1 < ${nixpkgs.fetchpatch { + url = "https://github.com/ghcjs/ghcjs-base/commit/213bfc74a051242668edf0533e11a3fafbbb1bfe.patch"; #ghcjs-base/120 + sha256 = "0d5dwy22hxa79l8b4y6nn53nbcs74686s0rmfr5l63sdvqxhdy3x"; + }} + patch -p1 < ${nixpkgs.fetchpatch { + url = "https://github.com/ghcjs/ghcjs-base/commit/82d76814ab40dc9116990f69f16df330462f27d4.patch"; #ghcjs-base/121 + sha256 = "0qa74h6w8770csad0bky4hhss1b1s86i6ccpd3ky4ljx00272gqh"; + }} + patch -p1 < ${nixpkgs.fetchpatch { + url = "https://github.com/ghcjs/ghcjs-base/commit/5eb34b3dfc6fc9196931178a7a6e2c8a331a8e53.patch"; #ghcjs-base/122 + sha256 = "1wrfi0rscy8qa9pi4siv54pq5alplmy56ym1fbs8n93xwlqhddii"; + }} + patch -p1 < ${nixpkgs.fetchpatch { + url = "https://github.com/ghcjs/ghcjs-base/commit/0cf64df77cdd6275d86ec6276fcf947fa58e548b.patch"; #ghcjs-base/122 + sha256 = "16wdghfsrzrb1y7lscbf9aawgxi3kvbgdjwvl1ga2zzm4mq139dr"; + }} + cat ghcjs-base.cabal + ) + ''; + }; + ghcjsBaseTextJSStringSrc = ghcjsBaseSrc.overrideAttrs (drv: { + outputHash = "1ggfklrmawqh54ins98rpr7qy3zbcqaqp1w7qmh90mq5jf711x9r"; + postFetch = (drv.postFetch or "") + '' + ( cd $out + patch -p1 < ${./haskell-overlays/text-jsstring/ghcjs-base-text-jsstring.patch} + ) + ''; + }); + + textSrc = fetchgit { + url = "https://github.com/obsidiansystems/text.git"; + rev = "50076be0262203f0d2afdd0b190a341878a08e21"; + sha256 = "1vy7a81b1vcbfhv7l3m7p4hx365ss13mzbzkjn9751bn4n7x2ydd"; + }; + dlistSrc = fetchgit { + url = "https://github.com/spl/dlist.git"; + rev = "03d91a3000cba49bd2c8588cf1b0d71e229ad3b0"; #v0.8.0.4 + sha256 = "0asvz1a2rp174r3vvgs1qaidxbdxly4mnlra33dipd0gxrrk15sq"; + }; + vectorSrc = fetchgit { + url = "https://github.com/haskell/vector.git"; + rev = "1d208ee9e3a252941ebd112e14e8cd5a982ac2bb"; #v0.12.0.1 + sha256 = "18qm1c2zqr8h150917djfc0xk62hv99b1clxfs9a79aavrsqi5hs"; + postFetch = '' + substituteInPlace $out/vector.cabal --replace 'base >= 4.5 && < 4.10' 'base >= 4.5 && < 5' + ''; + }; + + ghcjs = ghcjs8_4; + ghcjs8_4 = (makeRecursivelyOverridable (nixpkgs.haskell.packages.ghcjs84.override (old: { + ghc = useTextJSStringAsBootPkg (ghcjsApplyFastWeak (old.ghc.override { + ghcjsSrc = fetchgit { + url = "https://github.com/obsidiansystems/ghcjs.git"; + rev = "584eaa138c32c5debb3aae571c4153d537ff58f1"; + sha256 = "1ib0vsv2wrwf5iivnq6jw2l9g5izs0fjpp80jrd71qyywx4xcm66"; + fetchSubmodules = true; + }; + })); + }))).override { + overrides = nixpkgs.haskell.overlays.combined; + }; + ghcjs8_2 = (makeRecursivelyOverridable (nixpkgs.haskell.packages.ghcjs82.override (old: { + ghc = ghcjsApplyFastWeak (old.ghc.override { + ghcjsDepOverrides = self: super: { + haddock-library-ghcjs = haskellLib.doJailbreak super.haddock-library-ghcjs; + }; + }); + }))).override { + overrides = nixpkgs.haskell.overlays.combined; + }; + ghcjs8_0 = (makeRecursivelyOverridable (nixpkgs.haskell.packages.ghcjs80.override (old: { + ghc = (import "${nixpkgs.path}/pkgs/development/compilers/ghcjs/8.0" { + bootPkgs = nixpkgs.haskell.packages.ghc802.override { + overrides = self: super: { + # Newer versions no longer export `(<>)`, because that is now + # understand to be monoid/semigroup append. + wl-pprint-text = haskellLib.doJailbreak (self.callHackage "wl-pprint-text" "1.1.1.0" {}); + # Old `wl-pprint-text` in turn doesn't expect `base-compat` to provide + # a `(<>)`, since it is defining its own. + base-compat = self.callHackage "base-compat" "0.9.3" {}; + }; + }; + inherit (nixpkgs) cabal-install; + inherit (nixpkgs.buildPackages) fetchgit fetchFromGitHub; + }).override { ghcjsSrc = sources.ghcjs8_0.ghcjs; ghcjsBootSrc = sources.ghcjs8_0.boot; shims = sources.ghcjs8_0.shims; stage2 = import stage2Script; }; - - ghcjsPackages = nixpkgs.callPackage (nixpkgs.path + "/pkgs/development/haskell-modules") { - ghc = ghcjsCompiler; - compilerConfig = nixpkgs.callPackage (nixpkgs.path + "/pkgs/development/haskell-modules/configuration-ghc-8.0.x.nix") { inherit haskellLib; }; - packageSetConfig = nixpkgs.callPackage (nixpkgs.path + "/pkgs/development/haskell-modules/configuration-ghcjs.nix") { inherit haskellLib; }; - inherit haskellLib; - }; - -# TODO: Figure out why this approach doesn't work; it doesn't seem to evaluate our overridden ghc at all -# ghcjsPackages = nixpkgs.haskell.packages.ghcjs.override { -# ghc = builtins.trace "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" ghcjsCompiler; -# }; - ghcjs = ghcjs8_0; - ghcjs8_0 = (makeRecursivelyOverridable ghcjsPackages).override { + }))).override { overrides = nixpkgs.haskell.overlays.combined; }; + + ghc = ghc8_4; ghcHEAD = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghcHEAD).override { overrides = nixpkgs.haskell.overlays.combined; }; - - ghc = ghc8_0; - ghc8_2 = ghc8_2_1; - ghc8_2_1 = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghc821).override { + ghc8_4 = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghc843).override { overrides = nixpkgs.haskell.overlays.combined; }; - ghc8_0 = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghc802).override { + ghc8_2 = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghc822).override { overrides = nixpkgs.haskell.overlays.combined; }; - ghc7 = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghc7103).override { + ghc8_0 = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghc802).override { overrides = nixpkgs.haskell.overlays.combined; }; - ghc7_8 = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghc784).override { + ghc7 = (makeRecursivelyOverridable nixpkgs.haskell.packages.ghc7103).override { overrides = nixpkgs.haskell.overlays.combined; }; - ghcAndroidAarch64 = ghcAndroidAarch64-8_2; - ghcAndroidAarch64-8_2 = (makeRecursivelyOverridable nixpkgsCross.android.aarch64.haskell.packages.ghc821).override { + ghcAndroidAarch64 = ghcAndroidAarch64-8_4; + ghcAndroidAarch64-8_4 = (makeRecursivelyOverridable nixpkgsCross.android.aarch64.haskell.packages.integer-simple.ghc843).override { overrides = nixpkgsCross.android.aarch64.haskell.overlays.combined; }; - ghcAndroidAarch32 = ghcAndroidAarch32-8_2; - ghcAndroidAarch32-8_2 = (makeRecursivelyOverridable nixpkgsCross.android.aarch32.haskell.packages.ghc821).override { + ghcAndroidAarch64-8_2 = (makeRecursivelyOverridable nixpkgsCross.android.aarch64.haskell.packages.integer-simple.ghc822).override { + overrides = nixpkgsCross.android.aarch64.haskell.overlays.combined; + }; + ghcAndroidAarch32 = ghcAndroidAarch32-8_4; + ghcAndroidAarch32-8_4 = (makeRecursivelyOverridable nixpkgsCross.android.aarch32.haskell.packages.integer-simple.ghc843).override { + overrides = nixpkgsCross.android.aarch32.haskell.overlays.combined; + }; + ghcAndroidAarch32-8_2 = (makeRecursivelyOverridable nixpkgsCross.android.aarch32.haskell.packages.integer-simple.ghc822).override { overrides = nixpkgsCross.android.aarch32.haskell.overlays.combined; }; - ghcIosSimulator64 = ghcIosSimulator64-8_2; - ghcIosSimulator64-8_2 = (makeRecursivelyOverridable nixpkgsCross.ios.simulator64.haskell.packages.ghc821).override { + ghcIosSimulator64 = ghcIosSimulator64-8_4; + ghcIosSimulator64-8_4 = (makeRecursivelyOverridable nixpkgsCross.ios.simulator64.haskell.packages.integer-simple.ghc843).override { + overrides = nixpkgsCross.ios.simulator64.haskell.overlays.combined; + }; + ghcIosSimulator64-8_2 = (makeRecursivelyOverridable nixpkgsCross.ios.simulator64.haskell.packages.integer-simple.ghc822).override { overrides = nixpkgsCross.ios.simulator64.haskell.overlays.combined; }; - ghcIosAarch64 = ghcIosAarch64-8_2; - ghcIosAarch64-8_2 = (makeRecursivelyOverridable nixpkgsCross.ios.aarch64.haskell.packages.ghc821).override { + ghcIosAarch64 = ghcIosAarch64-8_4; + ghcIosAarch64-8_4 = (makeRecursivelyOverridable nixpkgsCross.ios.aarch64.haskell.packages.integer-simple.ghc843).override { overrides = nixpkgsCross.ios.aarch64.haskell.overlays.combined; }; - ghcIosAarch32 = ghcIosAarch32-8_2; - ghcIosAarch32-8_2 = (makeRecursivelyOverridable nixpkgsCross.ios.aarch32.haskell.packages.ghc821).override { + ghcIosAarch64-8_2 = (makeRecursivelyOverridable nixpkgsCross.ios.aarch64.haskell.packages.integer-simple.ghc822).override { + overrides = nixpkgsCross.ios.aarch64.haskell.overlays.combined; + }; + ghcIosAarch32 = ghcIosAarch32-8_4; + ghcIosAarch32-8_4 = (makeRecursivelyOverridable nixpkgsCross.ios.aarch32.haskell.packages.integer-simple.ghc843).override { + overrides = nixpkgsCross.ios.aarch32.haskell.overlays.combined; + }; + ghcIosAarch32-8_2 = (makeRecursivelyOverridable nixpkgsCross.ios.aarch32.haskell.packages.integer-simple.ghc822).override { overrides = nixpkgsCross.ios.aarch32.haskell.overlays.combined; }; @@ -353,31 +395,25 @@ let iosSupport = android = androidWithHaskellPackages { inherit ghcAndroidAarch64 ghcAndroidAarch32; }; + android-8_4 = androidWithHaskellPackages { + ghcAndroidAarch64 = ghcAndroidAarch64-8_4; + ghcAndroidAarch32 = ghcAndroidAarch32-8_4; + }; android-8_2 = androidWithHaskellPackages { ghcAndroidAarch64 = ghcAndroidAarch64-8_2; ghcAndroidAarch32 = ghcAndroidAarch32-8_2; }; androidWithHaskellPackages = { ghcAndroidAarch64, ghcAndroidAarch32 }: import ./android { - nixpkgs = nixpkgsFunc { system = "x86_64-linux"; }; - inherit nixpkgsCross ghcAndroidAarch64 ghcAndroidAarch32 overrideCabal; + inherit nixpkgs nixpkgsCross ghcAndroidAarch64 ghcAndroidAarch32 overrideCabal; }; - - nix-darwin = fetchFromGitHub { - owner = "3noch"; # TODO: Update to LnL7 once PR is merged: https://github.com/LnL7/nix-darwin/pull/78 - repo = "nix-darwin"; - rev = "adfe63988d8e0f07739bc7dafd7249c3a78faf96"; - sha256 = "0rca00lajdzf8lf2hgwn6mbmii656dnw725y6nnraz4qf87907zq"; - }; - # TODO: This should probably be upstreamed to nixpkgs. - plistLib = import (nix-darwin + /modules/launchd/lib.nix) { inherit lib; }; - - ios = iosWithHaskellPackages ghcIosAarch64; - ios-8_2 = iosWithHaskellPackages ghcIosAarch64-8_2; - iosWithHaskellPackages = ghcIosAarch64: { - buildApp = import ./ios { - inherit ghcIosAarch64 plistLib; - nixpkgs = nixpkgsFunc { system = "x86_64-darwin"; }; - }; + iosAarch64 = iosWithHaskellPackages ghcIosAarch64; + iosAarch64-8_4 = iosWithHaskellPackages ghcIosAarch64-8_4; + iosAarch64-8_2 = iosWithHaskellPackages ghcIosAarch64-8_2; + iosAarch32 = iosWithHaskellPackages ghcIosAarch32; + iosAarch32-8_4 = iosWithHaskellPackages ghcIosAarch32-8_4; + iosAarch32-8_2 = iosWithHaskellPackages ghcIosAarch32-8_2; + iosWithHaskellPackages = ghc: { + buildApp = import ./ios { inherit nixpkgs ghc; }; }; in let this = rec { @@ -389,28 +425,36 @@ in let this = rec { stage2Script ghc ghcHEAD + ghc8_4 ghc8_2 ghc8_0 ghc7 - ghc7_8 ghcIosSimulator64 ghcIosAarch64 + ghcIosAarch64-8_4 ghcIosAarch64-8_2 ghcIosAarch32 + ghcIosAarch32-8_4 ghcIosAarch32-8_2 ghcAndroidAarch64 + ghcAndroidAarch64-8_4 ghcAndroidAarch64-8_2 ghcAndroidAarch32 + ghcAndroidAarch32-8_4 ghcAndroidAarch32-8_2 ghcjs ghcjs8_0 + ghcjs8_2 + ghcjs8_4 android androidWithHaskellPackages - ios + iosAarch32 + iosAarch64 iosWithHaskellPackages filterGit; # Back compat + ios = iosAarch64; ghcAndroidArm64 = lib.warn "ghcAndroidArm64 has been deprecated, using ghcAndroidAarch64 instead." ghcAndroidAarch64; ghcAndroidArmv7a = lib.warn "ghcAndroidArmv7a has been deprecated, using ghcAndroidAarch32 instead." ghcAndroidAarch32; ghcIosArm64 = lib.warn "ghcIosArm64 has been deprecated, using ghcIosAarch64 instead." ghcIosAarch64; @@ -421,10 +465,16 @@ in let this = rec { applicationId = "org.reflexfrp.todomvc"; displayName = "Reflex TodoMVC"; }; + androidReflexTodomvc-8_4 = android-8_4.buildApp { + package = p: p.reflex-todomvc; + executableName = "reflex-todomvc"; + applicationId = "org.reflexfrp.todomvc.via_8_4"; + displayName = "Reflex TodoMVC via GHC 8.4"; + }; androidReflexTodomvc-8_2 = android-8_2.buildApp { package = p: p.reflex-todomvc; executableName = "reflex-todomvc"; - applicationId = "org.reflexfrp.todomvc"; + applicationId = "org.reflexfrp.todomvc.via_8_2"; displayName = "Reflex TodoMVC via GHC 8.2"; }; iosReflexTodomvc = ios.buildApp { @@ -433,10 +483,16 @@ in let this = rec { bundleIdentifier = "org.reflexfrp.todomvc"; bundleName = "Reflex TodoMVC"; }; - iosReflexTodomvc-8_2 = ios-8_2.buildApp { + iosReflexTodomvc-8_4 = iosAarch64-8_4.buildApp { package = p: p.reflex-todomvc; executableName = "reflex-todomvc"; - bundleIdentifier = "org.reflexfrp.todomvc"; + bundleIdentifier = "org.reflexfrp.todomvc.via_8_4"; + bundleName = "Reflex TodoMVC via GHC 8.4"; + }; + iosReflexTodomvc-8_2 = iosAarch64-8_2.buildApp { + package = p: p.reflex-todomvc; + executableName = "reflex-todomvc"; + bundleIdentifier = "org.reflexfrp.todomvc.via_8_2"; bundleName = "Reflex TodoMVC via GHC 8.2"; }; setGhcLibdir = ghcLibdir: inputGhcjs: @@ -507,7 +563,8 @@ in let this = rec { ln -s "$sdist" "$docs" "$out" ''; - # 'checked' isn't used, but it is here so that the build will fail if tests fail + # 'checked' isn't used, but it is here so that the build will fail + # if tests fail checked = overrideCabal pkg (drv: { doCheck = true; src = sdist; @@ -613,7 +670,9 @@ in let this = rec { workOnMulti = env: packageNames: workOnMulti' { inherit env packageNames; }; - # A simple derivation that just creates a file with the names of all of its inputs. If built, it will have a runtime dependency on all of the given build inputs. + # A simple derivation that just creates a file with the names of all + # of its inputs. If built, it will have a runtime dependency on all + # of the given build inputs. pinBuildInputs = drvName: buildInputs: otherDeps: nixpkgs.runCommand drvName { buildCommand = '' mkdir "$out" @@ -626,7 +685,7 @@ in let this = rec { cacheTargetSystems = lib.warn "cacheTargetSystems has been deprecated, use cacheBuildSystems" cacheBuildSystems; cacheBuildSystems = [ "x86_64-linux" - "i686-linux" + # "i686-linux" "x86_64-darwin" ]; @@ -636,8 +695,13 @@ in let this = rec { reflexEnv = platform: let haskellPackages = builtins.getAttr platform this; - ghcWithStuff = if platform == "ghc" || platform == "ghcjs" then haskellPackages.ghcWithHoogle else haskellPackages.ghcWithPackages; - in ghcWithStuff (p: import ./packages.nix { haskellPackages = p; inherit platform; }); + ghcWithStuff = if platform == "ghc" || platform == "ghcjs" + then haskellPackages.ghcWithHoogle + else haskellPackages.ghcWithPackages; + in ghcWithStuff (p: import ./packages.nix { + haskellPackages = p; + inherit platform; + }); tryReflexPackages = generalDevTools ghc ++ builtins.map reflexEnv platforms; @@ -656,7 +720,6 @@ in let this = rec { iosReflexTodomvc ]; - demoVM = (import "${nixpkgs.path}/nixos" { configuration = { imports = [ @@ -664,6 +727,7 @@ in let this = rec { "${nixpkgs.path}/nixos/modules/profiles/demo.nix" ]; environment.systemPackages = tryReflexPackages; + nixpkgs = { localSystem.system = "x86_64-linux"; }; }; }).config.system.build.virtualBoxOVA; diff --git a/fast-weak.patch b/fast-weak.patch new file mode 100644 index 000000000..bccc057d0 --- /dev/null +++ b/fast-weak.patch @@ -0,0 +1,85 @@ +diff --git a/lib/boot/shims/src/gc.js b/lib/boot/shims/src/gc.js +index 384cd77..d21757a 100644 +--- a/lib/boot/shims/src/gc.js ++++ b/lib/boot/shims/src/gc.js +@@ -435,6 +435,49 @@ function h$follow(obj, sp) { + TRACE_GC("adding static marks"); + for(var i=0;i)` definitions. + # Seems to be that semigroup-monoid stuff is being CPP'd incorrectly. + base-compat= self.callHackage "base-compat" "0.9.3" {}; +} diff --git a/haskell-overlays/ghc-head.nix b/haskell-overlays/any-head.nix similarity index 100% rename from haskell-overlays/ghc-head.nix rename to haskell-overlays/any-head.nix diff --git a/haskell-overlays/default.nix b/haskell-overlays/default.nix index e40aae47b..8ad5c374e 100644 --- a/haskell-overlays/default.nix +++ b/haskell-overlays/default.nix @@ -1,6 +1,7 @@ { lib , haskellLib , nixpkgs, fetchFromGitHub, hackGet +, ghcjsBaseSrc, ghcjsBaseTextJSStringSrc , useFastWeak, useReflexOptimizer, enableLibraryProfiling, enableTraceReflexEvents , useTextJSString, enableExposeAllUnfoldings , stage2Script @@ -17,6 +18,10 @@ rec { foldExtensions = lib.foldr lib.composeExtensions (_: _: {}); + getGhcVersion = ghc: + if ghc.isGhcjs or false + then ghc.ghcVersion + else ghc.version; ## ## Conventional roll ups of all the constituent overlays below. @@ -31,57 +36,98 @@ rec { (optionalExtension enableExposeAllUnfoldings exposeAllUnfoldings) + combined-any (optionalExtension (!(super.ghc.isGhcjs or false)) combined-ghc) - (optionalExtension (super.ghc.isGhcjs or false) ghcjs) + (optionalExtension (super.ghc.isGhcjs or false) combined-ghcjs) (optionalExtension (super.ghc.isGhcjs or false && useTextJSString) textJSString) (optionalExtension (with nixpkgs.stdenv; hostPlatform != buildPlatform) disableTemplateHaskell) (optionalExtension (nixpkgs.stdenv.hostPlatform.useAndroidPrebuilt or false) android) - (optionalExtension (nixpkgs.stdenv.hostPlatform.useIosPrebuilt or false) ios) + (optionalExtension (nixpkgs.stdenv.hostPlatform.isiOS or false) ios) ] self super; - combined-ghc = self: super: foldExtensions [ - ghc - (optionalExtension (versionWildcard [ 7 ] super.ghc.version) combined-ghc-7) - (optionalExtension (versionWildcard [ 8 ] super.ghc.version) combined-ghc-8) + combined-any = self: super: foldExtensions [ + any + (optionalExtension (versionWildcard [ 7 ] (getGhcVersion super.ghc)) combined-any-7) + (optionalExtension (versionWildcard [ 8 ] (getGhcVersion super.ghc)) combined-any-8) + ] self super; + + combined-any-7 = self: super: foldExtensions [ + any-7 + (optionalExtension (versionWildcard [ 7 8 ] (getGhcVersion super.ghc)) any-7_8) ] self super; - combined-ghc-7 = self: super: foldExtensions [ - ghc-7 - (optionalExtension (versionWildcard [ 7 8 ] super.ghc.version) ghc-7_8) + combined-any-8 = self: super: foldExtensions [ + any-8 + (optionalExtension (versionWildcard [ 8 0 ] (getGhcVersion super.ghc)) any-8_0) + (optionalExtension (versionWildcard [ 8 2 ] (getGhcVersion super.ghc)) any-8_2) + (optionalExtension (versionWildcard [ 8 4 ] (getGhcVersion super.ghc)) any-8_4) + (optionalExtension (lib.versionOlder "8.5" (getGhcVersion super.ghc)) any-head) ] self super; - combined-ghc-8 = self: super: foldExtensions [ - ghc-8 + combined-ghc = self: super: foldExtensions [ + (optionalExtension (versionWildcard [ 8 0 ] super.ghc.version) ghc-8_0) (optionalExtension (versionWildcard [ 8 2 ] super.ghc.version) ghc-8_2) + (optionalExtension (versionWildcard [ 8 4 ] super.ghc.version) ghc-8_4) + (optionalExtension (lib.versionOlder "8.5" super.ghc.version) ghc-head) ] self super; + combined-ghcjs = self: super: foldExtensions [ + ghcjs + (optionalExtension (versionWildcard [ 8 0 ] super.ghc.ghcVersion) ghcjs-8_0) + (optionalExtension (versionWildcard [ 8 2 ] super.ghc.ghcVersion) ghcjs-8_2) + (optionalExtension (versionWildcard [ 8 4 ] super.ghc.ghcVersion) ghcjs-8_4) + ] self super; ## ## Constituent ## reflexPackages = import ./reflex-packages.nix { - inherit haskellLib nixpkgs fetchFromGitHub hackGet useFastWeak useReflexOptimizer enableTraceReflexEvents; + inherit haskellLib lib nixpkgs fetchFromGitHub hackGet useFastWeak useReflexOptimizer enableTraceReflexEvents enableLibraryProfiling; }; disableTemplateHaskell = import ./disable-template-haskell.nix { inherit haskellLib fetchFromGitHub; }; exposeAllUnfoldings = import ./expose-all-unfoldings.nix { }; textJSString = import ./text-jsstring { - inherit haskellLib fetchFromGitHub; + inherit lib haskellLib fetchFromGitHub hackGet ghcjsBaseTextJSStringSrc versionWildcard; + inherit (nixpkgs) fetchpatch; }; - ghc = import ./ghc.nix { inherit haskellLib stage2Script; }; - ghc-7 = import ./ghc-7.nix { inherit haskellLib; }; - ghc-7_8 = import ./ghc-7.8.nix { inherit haskellLib; }; - ghc-8 = import ./ghc-8.nix { }; - ghc-8_2 = import ./ghc-8.2.nix { inherit haskellLib nixpkgs fetchFromGitHub; }; - ghc-head = import ./ghc-head.nix { inherit haskellLib fetchFromGitHub; }; - + # For GHC and GHCJS + any = _: _: {}; + any-7 = import ./any-7.nix { inherit haskellLib; }; + any-7_8 = import ./any-7.8.nix { inherit haskellLib; }; + any-8 = import ./any-8.nix { inherit haskellLib lib getGhcVersion; }; + any-8_0 = _: _: {}; + any-8_2 = import ./any-8.2.nix { inherit haskellLib fetchFromGitHub; }; + any-8_4 = import ./any-8.4.nix { inherit haskellLib fetchFromGitHub; inherit (nixpkgs) pkgs; }; + any-head = import ./any-head.nix { inherit haskellLib fetchFromGitHub; }; + + # Just for GHC, usually to sync with GHCJS + ghc-8_0 = import ./ghc-8.0.nix { inherit haskellLib stage2Script; }; + ghc-8_2 = _: _: {}; + ghc-8_4 = _: _: {}; + ghc-head = _: _: {}; + + # Just for GHCJS ghcjs = import ./ghcjs.nix { - inherit haskellLib nixpkgs fetchFromGitHub useReflexOptimizer; + inherit haskellLib nixpkgs fetchFromGitHub ghcjsBaseSrc useReflexOptimizer hackGet; + }; + ghcjs-8_0 = self: super: { + hashable = self.callHackage "hashable" "1.2.7.0" {}; + # `configure` cannot be generated on the fly from `configure.ac` with older Cabal. + old-time = haskellLib.addBuildTool super.old-time nixpkgs.autoreconfHook; + }; + ghcjs-8_2 = _: _: { + }; + ghcjs-8_4 = _: _: { + dlist = null; + ghcjs-base = null; + primitive = null; + vector = null; }; android = import ./android { @@ -93,8 +139,6 @@ rec { untriaged = import ./untriaged.nix { inherit haskellLib; - inherit lib; - inherit nixpkgs; inherit fetchFromGitHub; inherit enableLibraryProfiling; }; diff --git a/haskell-overlays/disable-template-haskell.nix b/haskell-overlays/disable-template-haskell.nix index b6c0468ff..ff151f809 100644 --- a/haskell-overlays/disable-template-haskell.nix +++ b/haskell-overlays/disable-template-haskell.nix @@ -14,7 +14,7 @@ in self: super: { # Export all modules, and some additional functions preConfigure = '' sed -i '/^library/,/^test-suite/ s/other-modules:/exposed-modules:/' *.cabal - sed -i "/^module Data.Aeson.TH/,/) where/ { /^module/b; /) where/ { s/) where/, LookupField (..), parseTypeMismatch, parseTypeMismatch', valueConName, keyValuePairWith) where/; b }; }" Data/Aeson/TH.hs + sed -i "/^module Data.Aeson.TH/,/) where/ { /^module/b; /) where/ { s/) where/, LookupField (..), parseTypeMismatch, parseTypeMismatch', valueConName) where/; b }; }" Data/Aeson/TH.hs ${drv.preConfigure or ""} ''; }); diff --git a/haskell-overlays/ghc.nix b/haskell-overlays/ghc-8.0.nix similarity index 100% rename from haskell-overlays/ghc.nix rename to haskell-overlays/ghc-8.0.nix diff --git a/haskell-overlays/ghc-8.2.nix b/haskell-overlays/ghc-8.2.nix deleted file mode 100644 index d0929d4ba..000000000 --- a/haskell-overlays/ghc-8.2.nix +++ /dev/null @@ -1,35 +0,0 @@ -{ haskellLib, nixpkgs, fetchFromGitHub}: - -with haskellLib; -self: super: { - ChasingBottoms = dontCheck (self.callHackage "ChasingBottoms" "1.3.1.3" {}); - base-orphans = self.callHackage "base-orphans" "0.6" {}; - cabal-install = self.callCabal2nix "cabal-install" ((fetchFromGitHub { - owner = "haskell"; - repo = "cabal"; - rev = "082cf2066b7206d3b12a9f92d832236e2484b4c1"; - sha256 = "0xzkwwim3chx9sd94b7n41ii9d51xzjlj48ikgn5dqjnxryz2r4k"; - }) + "/cabal-install") {}; - comonad = self.callHackage "comonad" "5.0.2" {}; - distributive = self.callHackage "distributive" "0.5.3" {}; - doctest = self.callHackage "doctest" "0.13.0" {}; - gtk2hs-buildtools = self.callHackage "gtk2hs-buildtools" "0.13.3.0" {}; - hackage-security = dontCheck (doJailbreak super.hackage-security); - haddock = null; - haddock-api = null; #dontCheck super.haddock-api; - haddock-library = null; #dontHaddock (dontCheck (self.callPackage ./haddock-library.nix {})); - hspec-meta = self.callHackage "hspec-meta" "2.4.4" {}; - primitive = self.callHackage "primitive" "0.6.2.0" {}; - profunctors = self.callHackage "profunctors" "5.2.1" {}; - semigroupoids = self.callHackage "semigroupoids" "5.2.1" {}; - # Runs out of registers, this is a famous example of that according to - # https://ghc.haskell.org/trac/ghc/wiki/Commentary/Compiler/Backends/NCG/RegisterAllocator - SHA = if nixpkgs.stdenv.hostPlatform.is32bit - then appendConfigureFlag super.SHA "--ghc-option=-O0" - else super.SHA; - shelly = doJailbreak super.shelly; - syb = self.callHackage "syb" "0.7" {}; - # Tests were failing. - vector = (if nixpkgs.stdenv.hostPlatform.is32bit then dontCheck else nixpkgs.lib.id) - (self.callHackage "vector" "0.12.0.1" {}); -} diff --git a/haskell-overlays/ghc-8.nix b/haskell-overlays/ghc-8.nix deleted file mode 100644 index 26751801f..000000000 --- a/haskell-overlays/ghc-8.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ }: - -self: super: { - ghcjs-prim = null; -} diff --git a/haskell-overlays/ghcjs.nix b/haskell-overlays/ghcjs.nix index b20c4f946..55535dad6 100644 --- a/haskell-overlays/ghcjs.nix +++ b/haskell-overlays/ghcjs.nix @@ -1,31 +1,41 @@ -{ haskellLib, nixpkgs, fetchFromGitHub, useReflexOptimizer }: +{ haskellLib, nixpkgs, fetchFromGitHub, useReflexOptimizer, hackGet, ghcjsBaseSrc }: let inherit (nixpkgs) lib; in +with haskellLib; self: super: { ghcWithPackages = selectFrom: self.callPackage (nixpkgs.path + "/pkgs/development/haskell-modules/with-packages-wrapper.nix") { inherit (self) llvmPackages; - haskellPackages = self; packages = selectFrom self; - ${if useReflexOptimizer then "ghcLibdir" else null} = "${self.ghc.bootPackages.ghcWithPackages (p: [ p.reflex ])}/lib/${self.ghc.bootPackages.ghc.name}"; + } // nixpkgs.lib.optionalAttrs useReflexOptimizer { + ghcLibdir = "${self.ghc.bootPackages.ghcWithPackages (p: [ p.reflex ])}/lib/${self.ghc.bootPackages.ghc.name}"; }; - ghcjs-base = haskellLib.doJailbreak (self.callCabal2nix "ghcjs-base" (fetchFromGitHub { - owner = "ghcjs"; - repo = "ghcjs-base"; - rev = "43804668a887903d27caada85693b16673283c57"; - sha256 = "1pqmgkan6xhpvsb64rh2zaxymxk4jg9c3hdxdb2cnn6jpx7jsl44"; - }) {}); + ghcjs-base = doJailbreak (dontCheck (self.callCabal2nix "ghcjs-base" ghcjsBaseSrc {})); ghc = super.ghc // { withPackages = self.ghcWithPackages; }; - diagrams-lib = haskellLib.dontCheck super.diagrams-lib; - linear = haskellLib.dontCheck super.linear; - bytes = haskellLib.dontCheck super.bytes; + hlint = null; + hscolour = null; + cabal-macosx = null; # doctest doesn't work on ghcjs, but sometimes dontCheck doesn't seem to get rid of the dependency doctest = lib.warn "ignoring dependency on doctest" null; + # These packages require doctest + comonad = dontCheck super.comonad; + http-types = dontCheck super.http-types; + lens = disableCabalFlag (disableCabalFlag (dontCheck super.lens) "test-properties") "test-doctests"; + semigroupoids = disableCabalFlag super.semigroupoids "doctests"; + these = dontCheck super.these; + + # Need newer version of colour for some reason. + colour = dontCheck (super.colour.overrideAttrs (drv: { + src = nixpkgs.buildPackages.fetchurl { + url = "http://hackage.haskell.org/package/colour-2.3.4/colour-2.3.4.tar.gz"; + sha256 = "1sy51nz096sv91nxqk6yk7b92b5a40axv9183xakvki2nc09yhqg"; + }; + })); } diff --git a/haskell-overlays/ios.nix b/haskell-overlays/ios.nix index 3aeb84e6e..4deef6f87 100644 --- a/haskell-overlays/ios.nix +++ b/haskell-overlays/ios.nix @@ -13,6 +13,12 @@ self: super: { cabal-doctest = null; syb = haskellLib.overrideCabal super.syb (drv: { jailbreak = true; }); + # HACK(matthewbauer): + # Temporary fix for https://github.com/ekmett/free/issues/176 + # Optimizations are broken on some ARM-based systems for some reason. + free = haskellLib.appendConfigureFlag super.free "--enable-optimization=0"; + jsaddle = haskellLib.appendConfigureFlag super.jsaddle "--enable-optimization=0"; + blaze-textual = haskellLib.enableCabalFlag super.blaze-textual "integer-simple"; reflex-todomvc = haskellLib.overrideCabal super.reflex-todomvc (drv: { diff --git a/haskell-overlays/reflex-packages.nix b/haskell-overlays/reflex-packages.nix index a867c7689..7b97889e5 100644 --- a/haskell-overlays/reflex-packages.nix +++ b/haskell-overlays/reflex-packages.nix @@ -1,7 +1,7 @@ { haskellLib -, nixpkgs +, lib, nixpkgs , fetchFromGitHub, hackGet -, useFastWeak, useReflexOptimizer, enableTraceReflexEvents +, useFastWeak, useReflexOptimizer, enableTraceReflexEvents, enableLibraryProfiling }: with haskellLib; @@ -10,7 +10,7 @@ self: super: let reflexDom = import (hackGet ../reflex-dom) self nixpkgs; - jsaddlePkgs = import (hackGet ../jsaddle) self; + jsaddleSrc = hackGet ../jsaddle; gargoylePkgs = self.callPackage (hackGet ../gargoyle) self; ghcjsDom = import (hackGet ../ghcjs-dom) self; addReflexTraceEventsFlag = drv: if enableTraceReflexEvents @@ -28,30 +28,52 @@ in ## Reflex family ## - reflex = addFastWeakFlag (addReflexTraceEventsFlag (addReflexOptimizerFlag (self.callPackage (hackGet ../reflex) {}))); - reflex-dom = addReflexOptimizerFlag (doJailbreak reflexDom.reflex-dom); - reflex-dom-core = addReflexOptimizerFlag (doJailbreak reflexDom.reflex-dom-core); + reflex = dontCheck (addFastWeakFlag (addReflexTraceEventsFlag (addReflexOptimizerFlag (self.callPackage (hackGet ../reflex) {})))); reflex-todomvc = self.callPackage (hackGet ../reflex-todomvc) {}; reflex-aeson-orphans = self.callCabal2nix "reflex-aeson-orphans" (hackGet ../reflex-aeson-orphans) {}; + # Broken Haddock - Please fix! + # : error is: haddock: internal error: internal: extractDecl + # No idea where it hits? + reflex-dom = dontHaddock (addReflexOptimizerFlag reflexDom.reflex-dom); + reflex-dom-core = appendConfigureFlags + (dontHaddock (addReflexOptimizerFlag reflexDom.reflex-dom-core)) + (lib.optional enableLibraryProfiling "-fprofile-reflex"); + ## ## GHCJS and JSaddle ## - inherit (jsaddlePkgs) jsaddle jsaddle-clib jsaddle-wkwebview jsaddle-webkit2gtk jsaddle-webkitgtk; - jsaddle-warp = dontCheck jsaddlePkgs.jsaddle-warp; + jsaddle = self.callCabal2nix "jsaddle" "${jsaddleSrc}/jsaddle" {}; + jsaddle-clib = self.callCabal2nix "jsaddle-clib" "${jsaddleSrc}/jsaddle-clib" {}; + jsaddle-webkit2gtk = self.callCabal2nix "jsaddle-webkit2gtk" "${jsaddleSrc}/jsaddle-webkit2gtk" {}; + jsaddle-webkitgtk = self.callCabal2nix "jsaddle-webkitgtk" "${jsaddleSrc}/jsaddle-webkitgtk" {}; + jsaddle-wkwebview = overrideCabal (self.callCabal2nix "jsaddle-wkwebview" "${jsaddleSrc}/jsaddle-wkwebview" {}) (drv: { + # HACK(matthewbauer): Can’t figure out why cf-private framework is + # not getting pulled in correctly. Has something + # to with how headers are looked up in xcode. + preBuild = lib.optionalString (!nixpkgs.stdenv.hostPlatform.useiOSPrebuilt) '' + mkdir include + ln -s ${nixpkgs.buildPackages.darwin.cf-private}/Library/Frameworks/CoreFoundation.framework/Headers include/CoreFoundation + export NIX_CFLAGS_COMPILE="-I$PWD/include $NIX_CFLAGS_COMPILE" + ''; - jsaddle-dom = overrideCabal (self.callPackage (hackGet ../jsaddle-dom) {}) (drv: { - # On macOS, the jsaddle-dom build will run out of file handles the first time it runs - preBuild = ''./setup build || true''; + libraryFrameworkDepends = (drv.libraryFrameworkDepends or []) ++ + (if nixpkgs.stdenv.hostPlatform.useiOSPrebuilt then [ + "${nixpkgs.buildPackages.darwin.xcode}/Contents/Developer/Platforms/${nixpkgs.stdenv.hostPlatform.xcodePlatform}.platform/Developer/SDKs/${nixpkgs.stdenv.hostPlatform.xcodePlatform}.sdk/System" + ] else with nixpkgs.buildPackages.darwin; with apple_sdk.frameworks; [ + Cocoa + WebKit + ]); }); - inherit (ghcjsDom) ghcjs-dom-jsffi; + # another broken test + # phantomjs has issues with finding the right port + # jsaddle-warp = dontCheck (addTestToolDepend (self.callCabal2nix "jsaddle-warp" "${jsaddleSrc}/jsaddle-warp" {})); + jsaddle-warp = dontCheck (self.callCabal2nix "jsaddle-warp" "${jsaddleSrc}/jsaddle-warp" {}); - # TODO: Fix this in Cabal - # When building a package with no haskell files, cabal haddock shouldn't fail - ghcjs-dom-jsaddle = dontHaddock ghcjsDom.ghcjs-dom-jsaddle; - ghcjs-dom = dontHaddock ghcjsDom.ghcjs-dom; + jsaddle-dom = self.callPackage (hackGet ../jsaddle-dom) {}; + inherit (ghcjsDom) ghcjs-dom-jsffi; ## ## Gargoyle @@ -63,10 +85,35 @@ in ## Misc other dependencies ## + haskell-gi-overloading = dontHaddock (self.callHackage "haskell-gi-overloading" "0.0" {}); + monoidal-containers = self.callCabal2nix "monoidal-containers" (fetchFromGitHub { owner = "obsidiansystems"; repo = "monoidal-containers"; rev = "79c25ac6bb469bfa92f8fd226684617b6753e955"; sha256 = "0j2mwf5zhz7cmn01x9v51w8vpx16hrl9x9rcx8fggf21slva8lf8"; }) {}; + + # Needs additional instances + dependent-sum = self.callCabal2nix "dependent-sum" (fetchFromGitHub { + owner = "obsidiansystems"; + repo = "dependent-sum"; + rev = "9c649ba33fa95601621b4a3fa3808104dd1ababd"; + sha256 = "1msnzdb79bal1xl2xq2j415n66gi48ynb02pf03wkahymi5dy4yj"; + }) {}; + # Misc new features since Hackage relasese + dependent-sum-template = self.callCabal2nix "dependent-sum-template" (fetchFromGitHub { + owner = "mokus0"; + repo = "dependent-sum-template"; + rev = "bfe9c37f4eaffd8b17c03f216c06a0bfb66f7df7"; + sha256 = "1w3s7nvw0iw5li3ry7s8r4651qwgd22hmgz6by0iw3rm64fy8x0y"; + }) {}; + # Not on Hackage yet + dependent-sum-universe-orphans = self.callCabal2nix "dependent-sum-universe-orphans" (fetchFromGitHub { + owner = "obsidiansystems"; + repo = "dependent-sum-universe-orphans"; + rev = "8c28c09991cd7c3588ae6db1be59a0540758f5f5"; + sha256 = "0dg32s2mgxav68yw6g7b15w0h0z116zx0qri26gprafgy23bxanm"; + }) {}; + } diff --git a/haskell-overlays/text-jsstring/conduit-extra-text-jsstring.patch b/haskell-overlays/text-jsstring/conduit-extra-text-jsstring.patch new file mode 100644 index 000000000..eff8db2d7 --- /dev/null +++ b/haskell-overlays/text-jsstring/conduit-extra-text-jsstring.patch @@ -0,0 +1,48 @@ +diff --git a/Data/Conduit/Attoparsec.hs b/Data/Conduit/Attoparsec.hs +index bd889f8..a620675 100644 +--- a/Data/Conduit/Attoparsec.hs ++++ b/Data/Conduit/Attoparsec.hs +@@ -1,4 +1,5 @@ + {-# LANGUAGE BangPatterns #-} ++{-# LANGUAGE CPP #-} + {-# LANGUAGE DeriveDataTypeable #-} + {-# LANGUAGE FlexibleContexts #-} + {-# LANGUAGE RankNTypes #-} +@@ -33,6 +34,9 @@ import qualified Data.Text as T + import qualified Data.Text.Internal as TI + import Data.Typeable (Typeable) + import Prelude hiding (lines) ++#ifdef __GHCJS__ ++import qualified Data.JSString.Raw as JSS ++#endif + + import qualified Data.Attoparsec.ByteString + import qualified Data.Attoparsec.Text +@@ -105,8 +109,13 @@ instance AttoparsecInput T.Text where + f (Position l c o) ch + | ch == '\n' = Position (l + 1) 0 (o + 1) + | otherwise = Position l (c + 1) (o + 1) ++#ifndef __GHCJS__ + stripFromEnd (TI.Text arr1 off1 len1) (TI.Text _ _ len2) = + TI.text arr1 off1 (len1 - len2) ++#else ++ stripFromEnd (TI.Text str1) (TI.Text str2) = ++ TI.Text $ JSS.rawDropEnd (JSS.rawLength str1 - JSS.rawLength str2) str1 ++#endif + + -- | Convert an Attoparsec 'A.Parser' into a 'Sink'. The parser will + -- be streamed bytes until it returns 'A.Done' or 'A.Fail'. +diff --git a/conduit-extra.cabal b/conduit-extra.cabal +index f6dfe7a..b5b2515 100644 +--- a/conduit-extra.cabal ++++ b/conduit-extra.cabal +@@ -58,6 +58,9 @@ Library + , unliftio-core + , typed-process >= 0.2 + ++ if impl(ghcjs) ++ Build-depends: ghcjs-base ++ + ghc-options: -Wall + + test-suite test diff --git a/haskell-overlays/text-jsstring/default.nix b/haskell-overlays/text-jsstring/default.nix index 14eb32fd3..537d68bf0 100644 --- a/haskell-overlays/text-jsstring/default.nix +++ b/haskell-overlays/text-jsstring/default.nix @@ -1,26 +1,26 @@ -{ haskellLib, fetchFromGitHub }: +{ lib, haskellLib, fetchFromGitHub, hackGet, fetchpatch, ghcjsBaseTextJSStringSrc, versionWildcard }: + +with lib; +with haskellLib; self: super: { - text = self.callCabal2nix "text" (fetchFromGitHub { - owner = "luigy"; - repo = "text"; - rev = "6cc95ebb07c07001666d84ace5c13caefaaa0cad"; - sha256 = "1zplzy9mfpwjrk5l22gmla1vmk7wmwmgmjfk64b57ysn7madlv19"; - }) {}; - ghcjs-base = haskellLib.overrideCabal super.ghcjs-base (drv: { - src = fetchFromGitHub { - owner = "luigy"; - repo = "ghcjs-base"; - rev = "e287c5752064a2d3b2c4776a1520e4b0189881b0"; - sha256 = "01k7wj60gmmf9larjm3gqbsyxwb5xhqr4dyz4xswy78ql845qljd"; - }; - libraryHaskellDepends = with self; [ - base bytestring containers deepseq dlist ghc-prim - ghcjs-prim integer-gmp primitive time - transformers vector + # text = (doCheck (self.callCabal2nix "text" (fetchFromGitHub { + # owner = "obsidiansystems"; + # repo = "text"; + # rev = "50076be0262203f0d2afdd0b190a341878a08e21"; + # sha256 = "1vy7a81b1vcbfhv7l3m7p4hx365ss13mzbzkjn9751bn4n7x2ydd"; + # }) {})).overrideScope (self: super: { + # text = null; + # QuickCheck = haskellLib.addBuildDepend (self.callHackage "QuickCheck" "2.9.2" {}) self.tf-random; + # }); + # parsec = dontCheck (self.callHackage "parsec" "3.1.13.0" {}); + jsaddle = overrideCabal super.jsaddle (drv: { + buildDepends = (drv.buildDepends or []) ++ [ + self.ghcjs-base + self.ghcjs-prim ]; }); - attoparsec = haskellLib.overrideCabal super.attoparsec (drv: { + attoparsec = overrideCabal super.attoparsec (drv: { src = fetchFromGitHub { owner = "luigy"; repo = "attoparsec"; @@ -28,7 +28,7 @@ self: super: { sha256 = "106fn187hw9z3bidbkp7r4wafmhk7g2iv2k0hybirv63f8727x3x"; }; }); - buffer-builder = haskellLib.overrideCabal super.buffer-builder (drv: { + buffer-builder = overrideCabal super.buffer-builder (drv: { doCheck = false; src = fetchFromGitHub { owner = "obsidiansystems"; @@ -37,21 +37,20 @@ self: super: { sha256 = "18dd2ydva3hnsfyrzmi3y3r41g2l4r0kfijaan85y6rc507k6x5c"; }; }); - hashable = haskellLib.addBuildDepend (self.callCabal2nix "hashable" (fetchFromGitHub { - owner = "obsidiansystems"; - repo = "hashable"; - rev = "1008a580f2dd3ebd4931e7d8cb36d1347a1e9dc6"; - sha256 = "1zdd7qjv9k6332h4c6frjjfavknzzffw4ayv8q4f2zh9w774hzli"; - }) {}) self.text; - conduit-extra = haskellLib.overrideCabal super.conduit-extra (drv: { - src = "${fetchFromGitHub { - owner = "luigy"; - repo = "conduit"; - rev = "aeb20e4eb7f7bfc07ec401c82821cbb04018b571"; - sha256 = "10kz2m2yxyhk46xdglj7wdn5ba2swqzhyznxasj0jvnjcnv3jriw"; - }}/conduit-extra"; + hashable = overrideCabal super.hashable (drv: { + revision = null; + editedCabalFile = null; + jailbreak = true; + doCheck = false; + libraryHaskellDepends = (drv.libraryHaskellDepends or []) ++ [ + self.text + ] ++ optional (versionWildcard [ 8 0 ] super.ghc.ghcVersion) self.ghcjs-base; + patches = (drv.patches or []) ++ [ + ./hashable.patch + ]; }); - double-conversion = haskellLib.overrideCabal super.double-conversion (drv: { + conduit-extra = dontCheck (appendPatch super.conduit-extra ./conduit-extra-text-jsstring.patch); + double-conversion = overrideCabal super.double-conversion (drv: { src = fetchFromGitHub { owner = "obsidiansystems"; repo = "double-conversion"; @@ -59,13 +58,26 @@ self: super: { sha256 = "0sjljf1sbwalw1zycpjf6bqhljag9i1k77b18b0fd1pzrc29wnks"; }; }); - say = haskellLib.overrideCabal super.say (drv: { + say = overrideCabal super.say (drv: { patches = (drv.patches or []) ++ [ - ./say-text-jsstring.patch + ./say.patch ]; buildDepends = (drv.buildDepends or []) ++ [ self.ghcjs-base ]; }); - aeson = haskellLib.appendPatch super.aeson ./aeson.patch; + aeson = appendPatch super.aeson ./aeson.patch; + # Bellow 8.4 text was not a boot pkg. + text = if !(versionWildcard [ 8 0 ] super.ghc.ghcVersion) + then super.text + else haskellLib.dontCheck (self.callCabal2nix "text" + (fetchFromGitHub { # TODO use this src in useTextJSStringAsBootPkg; Currently here to avoid ghcjs8.4 boot rebuild + owner = "obsidiansystems"; + repo = "text"; + rev = "3ea808e8cabede6e67f565376376afcb2dfb94b8"; + sha256 = "1ffiyvfq4diwpmm8sv8k7fm58p37rbr24baxbmm8b2h8bkrnwg9y"; + }) {}); + ghcjs-base = with haskellLib; if (versionWildcard [ 8 0 ] super.ghc.ghcVersion) + then dontCheck (doJailbreak (self.callCabal2nix "ghcjs-base" ghcjsBaseTextJSStringSrc {})) + else super.ghcjs-base; } diff --git a/haskell-overlays/text-jsstring/ghcjs-base-text-jsstring.patch b/haskell-overlays/text-jsstring/ghcjs-base-text-jsstring.patch new file mode 100644 index 000000000..01a5743a8 --- /dev/null +++ b/haskell-overlays/text-jsstring/ghcjs-base-text-jsstring.patch @@ -0,0 +1,463 @@ +diff --git a/Data/JSString.hs b/Data/JSString.hs +index 176aad4..9ca6693 100644 +--- a/Data/JSString.hs ++++ b/Data/JSString.hs +@@ -99,6 +99,7 @@ module Data.JSString ( JSString + , breakOnEnd + , break + , span ++ , span_ + , group + , group' + , groupBy +@@ -1231,19 +1232,23 @@ splitAt (I# n) x = case js_splitAt n x of (# y, z #) -> (y, z) + -- of @t@ of elements that satisfy @p@, and whose second is the + -- remainder of the list. + span :: (Char -> Bool) -> JSString -> (JSString, JSString) +-span p x = case js_length x of +- 0# -> (empty, empty) +- l -> let c0 = js_uncheckedIndex 0# x +- in if p (C# (chr# c0)) then loop 0# l else (empty, x) ++span p x = let (# a, b #) = span_ p x in (a, b) ++{-# INLINE span #-} ++ ++span_ :: (Char -> Bool) -> JSString -> (# JSString, JSString #) ++span_ p x = case js_length x of ++ 0# -> (# empty, empty #) ++ l -> let c0 = js_uncheckedIndex 0# x ++ in if p (C# (chr# c0)) then loop 0# l else (# empty, x #) + where + loop i l +- | isTrue# (i >=# l) = (x, empty) ++ | isTrue# (i >=# l) = (# x, empty #) + | otherwise = + let c = js_uncheckedIndex i x + in if p (C# (chr# c)) + then loop (i +# charWidth c) l +- else (js_substr 0# i x, js_substr1 i x) +-{-# INLINE span #-} ++ else (# js_substr 0# i x, js_substr1 i x #) ++{-# INLINE span_ #-} + + -- | /O(n)/ 'break' is like 'span', but the prefix returned is + -- over elements that fail the predicate @p@. +diff --git a/GHCJS/Foreign.hs b/GHCJS/Foreign.hs +index 5bbc5c5..b128f24 100644 +--- a/GHCJS/Foreign.hs ++++ b/GHCJS/Foreign.hs +@@ -82,7 +82,7 @@ import GHCJS.Marshal + import GHCJS.Marshal.Pure + -} + import Data.String (IsString(..)) +-import qualified Data.Text as T ++-- import qualified Data.Text as T + + + class ToJSString a where +diff --git a/GHCJS/Foreign/Internal.hs b/GHCJS/Foreign/Internal.hs +index 5ac81f0..449bfe4 100644 +--- a/GHCJS/Foreign/Internal.hs ++++ b/GHCJS/Foreign/Internal.hs +@@ -100,10 +100,10 @@ import Data.Typeable (Typeable) + import Data.ByteString (ByteString) + import Data.ByteString.Unsafe (unsafePackAddressLen) + +-import qualified Data.Text.Array as A +-import qualified Data.Text as T +-import qualified Data.Text.Internal as T +-import qualified Data.Text.Lazy as TL (Text, toStrict, fromStrict) ++-- import qualified Data.Text.Array as A ++-- import qualified Data.Text as T ++-- import qualified Data.Text.Internal as T ++-- import qualified Data.Text.Lazy as TL (Text, toStrict, fromStrict) + + import Unsafe.Coerce + +diff --git a/GHCJS/Marshal.hs b/GHCJS/Marshal.hs +index a36aca2..6256a73 100644 +--- a/GHCJS/Marshal.hs ++++ b/GHCJS/Marshal.hs +@@ -16,7 +16,7 @@ + + module GHCJS.Marshal ( FromJSVal(..) + , ToJSVal(..) +- , toJSVal_aeson ++ -- , toJSVal_aeson + , toJSVal_pure + ) where + +@@ -24,17 +24,17 @@ import Control.Applicative + import Control.Monad + import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT) + +-import qualified Data.Aeson as AE +-import Data.Attoparsec.Number (Number(..)) ++-- import qualified Data.Aeson as AE ++-- import Data.Attoparsec.Number (Number(..)) + import Data.Bits ((.&.)) + import Data.Char (chr, ord) +-import qualified Data.HashMap.Strict as H ++-- import qualified Data.HashMap.Strict as H + import Data.Int (Int8, Int16, Int32) + import qualified Data.JSString as JSS +-import qualified Data.JSString.Text as JSS ++-- import qualified Data.JSString.Text as JSS + import Data.Maybe +-import Data.Scientific (Scientific, scientific, fromFloatDigits) +-import Data.Text (Text) ++-- import Data.Scientific (Scientific, scientific, fromFloatDigits) ++-- import Data.Text (Text) + import qualified Data.Vector as V + import Data.Word (Word8, Word16, Word32, Word) + import Data.Primitive.ByteArray +@@ -85,11 +85,11 @@ instance FromJSVal JSString where + {-# INLINE fromJSValUnchecked #-} + fromJSVal = fromJSVal_pure + {-# INLINE fromJSVal #-} +-instance FromJSVal Text where +- fromJSValUnchecked = fromJSValUnchecked_pure +- {-# INLINE fromJSValUnchecked #-} +- fromJSVal = fromJSVal_pure +- {-# INLINE fromJSVal #-} ++-- instance FromJSVal Text where ++-- fromJSValUnchecked = fromJSValUnchecked_pure ++-- {-# INLINE fromJSValUnchecked #-} ++-- fromJSVal = fromJSVal_pure ++-- {-# INLINE fromJSVal #-} + instance FromJSVal Char where + fromJSValUnchecked = fromJSValUnchecked_pure + {-# INLINE fromJSValUnchecked #-} +@@ -154,24 +154,24 @@ instance FromJSVal Double where + {-# INLINE fromJSValUnchecked #-} + fromJSVal = fromJSVal_pure + {-# INLINE fromJSVal #-} +-instance FromJSVal AE.Value where +- fromJSVal r = case jsonTypeOf r of +- JSONNull -> return (Just AE.Null) +- JSONInteger -> liftM (AE.Number . flip scientific 0 . (toInteger :: Int -> Integer)) +- <$> fromJSVal r +- JSONFloat -> liftM (AE.Number . (fromFloatDigits :: Double -> Scientific)) +- <$> fromJSVal r +- JSONBool -> liftM AE.Bool <$> fromJSVal r +- JSONString -> liftM AE.String <$> fromJSVal r +- JSONArray -> liftM (AE.Array . V.fromList) <$> fromJSVal r +- JSONObject -> do +- props <- OI.listProps (OI.Object r) +- runMaybeT $ do +- propVals <- forM props $ \p -> do +- v <- MaybeT (fromJSVal =<< OI.getProp p (OI.Object r)) +- return (JSS.textFromJSString p, v) +- return (AE.Object (H.fromList propVals)) +- {-# INLINE fromJSVal #-} ++-- instance FromJSVal AE.Value where ++-- fromJSVal r = case jsonTypeOf r of ++-- JSONNull -> return (Just AE.Null) ++-- JSONInteger -> liftM (AE.Number . flip scientific 0 . (toInteger :: Int -> Integer)) ++-- <$> fromJSVal r ++-- JSONFloat -> liftM (AE.Number . (fromFloatDigits :: Double -> Scientific)) ++-- <$> fromJSVal r ++-- JSONBool -> liftM AE.Bool <$> fromJSVal r ++-- JSONString -> liftM AE.String <$> fromJSVal r ++-- JSONArray -> liftM (AE.Array . V.fromList) <$> fromJSVal r ++-- JSONObject -> do ++-- props <- OI.listProps (OI.Object r) ++-- runMaybeT $ do ++-- propVals <- forM props $ \p -> do ++-- v <- MaybeT (fromJSVal =<< OI.getProp p (OI.Object r)) ++-- return (JSS.textFromJSString p, v) ++-- return (AE.Object (H.fromList propVals)) ++-- {-# INLINE fromJSVal #-} + instance (FromJSVal a, FromJSVal b) => FromJSVal (a,b) where + fromJSVal r = runMaybeT $ (,) <$> jf r 0 <*> jf r 1 + {-# INLINE fromJSVal #-} +@@ -204,15 +204,15 @@ jf r n = MaybeT $ do + instance ToJSVal JSVal where + toJSVal = toJSVal_pure + {-# INLINE toJSVal #-} +-instance ToJSVal AE.Value where +- toJSVal = toJSVal_aeson +- {-# INLINE toJSVal #-} ++-- instance ToJSVal AE.Value where ++-- toJSVal = toJSVal_aeson ++-- {-# INLINE toJSVal #-} + instance ToJSVal JSString where + toJSVal = toJSVal_pure + {-# INLINE toJSVal #-} +-instance ToJSVal Text where +- toJSVal = toJSVal_pure +- {-# INLINE toJSVal #-} ++-- instance ToJSVal Text where ++-- toJSVal = toJSVal_pure ++-- {-# INLINE toJSVal #-} + instance ToJSVal Char where + toJSVal = return . pToJSVal + {-# INLINE toJSVal #-} +@@ -285,21 +285,21 @@ foreign import javascript unsafe "[$1,$2,$3,$4,$5]" arr5 :: JSVal -> J + foreign import javascript unsafe "[$1,$2,$3,$4,$5,$6]" arr6 :: JSVal -> JSVal -> JSVal -> JSVal -> JSVal -> JSVal -> IO JSVal + foreign import javascript unsafe "[$1,$2,$3,$4,$5,$6,$7]" arr7 :: JSVal -> JSVal -> JSVal -> JSVal -> JSVal -> JSVal -> JSVal -> IO JSVal + +-toJSVal_aeson :: AE.ToJSON a => a -> IO JSVal +-toJSVal_aeson x = cv (AE.toJSON x) +- where +- cv = convertValue ++-- toJSVal_aeson :: AE.ToJSON a => a -> IO JSVal ++-- toJSVal_aeson x = cv (AE.toJSON x) ++-- where ++-- cv = convertValue + +- convertValue :: AE.Value -> IO JSVal +- convertValue AE.Null = return jsNull +- convertValue (AE.String t) = return (pToJSVal t) +- convertValue (AE.Array a) = (\(AI.SomeJSArray x) -> x) <$> +- (AI.fromListIO =<< mapM convertValue (V.toList a)) +- convertValue (AE.Number n) = toJSVal (realToFrac n :: Double) +- convertValue (AE.Bool b) = return (toJSBool b) +- convertValue (AE.Object o) = do +- obj@(OI.Object obj') <- OI.create +- mapM_ (\(k,v) -> convertValue v >>= \v' -> OI.setProp (JSS.textToJSString k) v' obj) (H.toList o) +- return obj' ++-- convertValue :: AE.Value -> IO JSVal ++-- convertValue AE.Null = return jsNull ++-- convertValue (AE.String t) = return (pToJSVal t) ++-- convertValue (AE.Array a) = (\(AI.SomeJSArray x) -> x) <$> ++-- (AI.fromListIO =<< mapM convertValue (V.toList a)) ++-- convertValue (AE.Number n) = toJSVal (realToFrac n :: Double) ++-- convertValue (AE.Bool b) = return (toJSBool b) ++-- convertValue (AE.Object o) = do ++-- obj@(OI.Object obj') <- OI.create ++-- mapM_ (\(k,v) -> convertValue v >>= \v' -> OI.setProp (JSS.textToJSString k) v' obj) (H.toList o) ++-- return obj' + + +diff --git a/GHCJS/Marshal/Pure.hs b/GHCJS/Marshal/Pure.hs +index 902fa20..268489d 100644 +--- a/GHCJS/Marshal/Pure.hs ++++ b/GHCJS/Marshal/Pure.hs +@@ -28,11 +28,11 @@ import Data.Data + import Data.Int (Int8, Int16, Int32) + import Data.JSString.Internal.Type + import Data.Maybe +-import Data.Text (Text) ++-- import Data.Text (Text) + import Data.Typeable + import Data.Word (Word8, Word16, Word32, Word) + import Data.JSString +-import Data.JSString.Text ++-- import Data.JSString.Text + import Data.Bits ((.&.)) + import Unsafe.Coerce (unsafeCoerce) + import GHC.Int +@@ -65,8 +65,8 @@ instance PFromJSVal JSString where pFromJSVal = JSString + {-# INLINE pFromJSVal #-} + instance PFromJSVal [Char] where pFromJSVal = Prim.fromJSString + {-# INLINE pFromJSVal #-} +-instance PFromJSVal Text where pFromJSVal = textFromJSVal +- {-# INLINE pFromJSVal #-} ++-- instance PFromJSVal Text where pFromJSVal = textFromJSVal ++-- {-# INLINE pFromJSVal #-} + instance PFromJSVal Char where pFromJSVal x = C# (jsvalToChar x) + {-# INLINE pFromJSVal #-} + instance PFromJSVal Bool where pFromJSVal = isTruthy +@@ -103,8 +103,8 @@ instance PToJSVal JSString where pToJSVal = jsval + {-# INLINE pToJSVal #-} + instance PToJSVal [Char] where pToJSVal = Prim.toJSString + {-# INLINE pToJSVal #-} +-instance PToJSVal Text where pToJSVal = jsval . textToJSString +- {-# INLINE pToJSVal #-} ++-- instance PToJSVal Text where pToJSVal = jsval . textToJSString ++-- {-# INLINE pToJSVal #-} + instance PToJSVal Char where pToJSVal (C# c) = charToJSVal c + {-# INLINE pToJSVal #-} + instance PToJSVal Bool where pToJSVal True = jsTrue +diff --git a/JavaScript/JSON/Types/Instances.hs b/JavaScript/JSON/Types/Instances.hs +index 2b288ec..6d7074c 100644 +--- a/JavaScript/JSON/Types/Instances.hs ++++ b/JavaScript/JSON/Types/Instances.hs +@@ -57,7 +57,7 @@ import Control.Applicative ((<$>), (<*>), (<|>), pure, empty) + + import Data.JSString (JSString) + import qualified Data.JSString as JSS +-import qualified Data.JSString.Text as JSS ++-- import qualified Data.JSString.Text as JSS + + import JavaScript.Array (JSArray) + import qualified JavaScript.Array as JSA +@@ -335,21 +335,21 @@ instance FromJSON JSString where + parseJSON = withJSString "JSString" pure + {-# INLINE parseJSON #-} + +-instance ToJSON Text where +- toJSON = stringValue . JSS.textToJSString +- {-# INLINE toJSON #-} ++-- instance ToJSON Text where ++-- toJSON = stringValue . JSS.textToJSString ++-- {-# INLINE toJSON #-} + +-instance FromJSON Text where +- parseJSON = withJSString "Text" ( pure . JSS.textFromJSString ) +- {-# INLINE parseJSON #-} ++-- instance FromJSON Text where ++-- parseJSON = withJSString "Text" ( pure . JSS.textFromJSString ) ++-- {-# INLINE parseJSON #-} + +-instance ToJSON LT.Text where +- toJSON = stringValue . JSS.textToJSString . LT.toStrict +- {-# INLINE toJSON #-} ++-- instance ToJSON LT.Text where ++-- toJSON = stringValue . JSS.textToJSString . LT.toStrict ++-- {-# INLINE toJSON #-} + +-instance FromJSON LT.Text where +- parseJSON = withJSString "Lazy Text" $ pure . LT.fromStrict . JSS.textFromJSString +- {-# INLINE parseJSON #-} ++-- instance FromJSON LT.Text where ++-- parseJSON = withJSString "Lazy Text" $ pure . LT.fromStrict . JSS.textFromJSString ++-- {-# INLINE parseJSON #-} + + instance (ToJSON a) => ToJSON [a] where + toJSON = arrayValue . arrayValueList . map toJSON +diff --git a/JavaScript/Web/Canvas.hs b/JavaScript/Web/Canvas.hs +index 0a7684c..74490c2 100644 +--- a/JavaScript/Web/Canvas.hs ++++ b/JavaScript/Web/Canvas.hs +@@ -69,7 +69,7 @@ import Control.Monad + + import Data.Data + import Data.Maybe (fromJust) +-import Data.Text (Text) ++-- import Data.Text (Text) + import Data.Typeable + + import GHCJS.Foreign +diff --git a/ghcjs-base.cabal b/ghcjs-base.cabal +index 4a64694..acf8806 100644 +--- a/ghcjs-base.cabal ++++ b/ghcjs-base.cabal +@@ -55,7 +55,7 @@ library + Data.JSString.RealFloat + Data.JSString.RegExp + Data.JSString.Internal +- Data.JSString.Text ++ -- Data.JSString.Text + Data.JSString.Internal.Fusion + Data.JSString.Internal.Fusion.Types + Data.JSString.Internal.Fusion.Common +@@ -78,12 +78,12 @@ library + JavaScript.Array.Internal + JavaScript.Array.ST + JavaScript.Cast +- JavaScript.JSON +- JavaScript.JSON.Types +- JavaScript.JSON.Types.Class +- JavaScript.JSON.Types.Generic +- JavaScript.JSON.Types.Instances +- JavaScript.JSON.Types.Internal ++ -- JavaScript.JSON ++ -- JavaScript.JSON.Types ++ -- JavaScript.JSON.Types.Class ++ -- JavaScript.JSON.Types.Generic ++ -- JavaScript.JSON.Types.Instances ++ -- JavaScript.JSON.Types.Internal + JavaScript.Number + JavaScript.Object + JavaScript.Object.Internal +@@ -115,11 +115,11 @@ library + JavaScript.Web.Storage + JavaScript.Web.Storage.Internal + JavaScript.Web.StorageEvent +- JavaScript.Web.XMLHttpRequest ++ -- JavaScript.Web.XMLHttpRequest + JavaScript.Web.WebSocket + JavaScript.Web.Worker +- other-modules: GHCJS.Internal.Types + Data.JSString.Internal.Type ++ other-modules: GHCJS.Internal.Types + JavaScript.TypedArray.Internal.Types + JavaScript.TypedArray.ArrayBuffer.Internal + JavaScript.TypedArray.DataView.Internal +@@ -129,48 +129,48 @@ library + integer-gmp, + binary >= 0.8 && < 0.9, + bytestring >= 0.10 && < 0.11, +- text >= 1.1 && < 1.3, +- aeson >= 0.8 && < 1.3, +- scientific >= 0.3 && < 0.4, ++ -- text >= 1.1 && < 1.3, ++ -- aeson >= 0.8 && < 1.3, ++ -- scientific >= 0.3 && < 0.4, + vector >= 0.10 && < 0.13, + containers >= 0.5 && < 0.6, + time >= 1.5 && < 1.9, +- hashable >= 1.2 && < 1.3, +- unordered-containers >= 0.2 && < 0.3, +- attoparsec >= 0.11 && < 0.14, ++ -- hashable >= 1.2 && < 1.3, ++ -- unordered-containers >= 0.2 && < 0.3, ++ -- attoparsec >= 0.11 && < 0.14, + transformers >= 0.3 && < 0.6, + primitive >= 0.5 && < 0.7, + deepseq >= 1.3 && < 1.5, + dlist >= 0.7 && < 0.9 + +-test-suite tests +- type: exitcode-stdio-1.0 +- hs-source-dirs: test +- main-is: Tests.hs +- other-modules: Tests.Marshal +- Tests.Properties +- Tests.Properties.Numeric +- Tests.SlowFunctions +- Tests.QuickCheckUtils +- Tests.Regressions +- Tests.Utils +- ghc-options: +- -Wall -rtsopts +- build-depends: +- HUnit >= 1.2, +- QuickCheck >= 2.7, +- array, +- text, +- base, +- bytestring, +- deepseq, +- directory, +- ghc-prim, +- ghcjs-prim, +- ghcjs-base, +- primitive, +- quickcheck-unicode, +- random, +- test-framework >= 0.4, +- test-framework-hunit >= 0.2, +- test-framework-quickcheck2 >= 0.2 ++-- test-suite tests ++-- type: exitcode-stdio-1.0 ++-- hs-source-dirs: test ++-- main-is: Tests.hs ++-- other-modules: Tests.Marshal ++-- Tests.Properties ++-- Tests.Properties.Numeric ++-- Tests.SlowFunctions ++-- Tests.QuickCheckUtils ++-- Tests.Regressions ++-- Tests.Utils ++-- ghc-options: ++-- -Wall -rtsopts ++-- build-depends: ++-- HUnit >= 1.2, ++-- QuickCheck >= 2.7, ++-- array, ++-- text, ++-- base, ++-- bytestring, ++-- deepseq, ++-- directory, ++-- ghc-prim, ++-- ghcjs-prim, ++-- ghcjs-base, ++-- primitive, ++-- quickcheck-unicode, ++-- random, ++-- test-framework >= 0.4, ++-- test-framework-hunit >= 0.2, ++-- test-framework-quickcheck2 >= 0.2 diff --git a/haskell-overlays/text-jsstring/ghcjs-disable-string-compactor.patch b/haskell-overlays/text-jsstring/ghcjs-disable-string-compactor.patch new file mode 100644 index 000000000..27bcb4996 --- /dev/null +++ b/haskell-overlays/text-jsstring/ghcjs-disable-string-compactor.patch @@ -0,0 +1,53 @@ +diff --git a/src/Gen2/Compactor.hs b/src/Gen2/Compactor.hs +index 1150b28..a4d1507 100644 +--- a/src/Gen2/Compactor.hs ++++ b/src/Gen2/Compactor.hs +@@ -109,8 +109,8 @@ packStrings settings dflags cstate code = + isExisting bs = isJust (HM.lookup bs $ stOffsets origStringTable) + + staticString :: StaticVal -> Maybe ByteString +- staticString (StaticUnboxed (StaticUnboxedString bs)) = Just bs +- staticString (StaticUnboxed (StaticUnboxedStringOffset bs)) = Just bs ++ -- staticString (StaticUnboxed (StaticUnboxedString bs)) = Just bs ++ -- staticString (StaticUnboxed (StaticUnboxedStringOffset bs)) = Just bs + staticString _ = Nothing + + allStringsList :: [ByteString] +@@ -178,10 +178,10 @@ packStrings settings dflags cstate code = + + newIdentsMap :: HashMap Text (Either Int Int) + newIdentsMap = +- let f (StaticInfo s (StaticUnboxed (StaticUnboxedString bs)) _) +- = Just (s, Left . fst $ newOffsetsMap HM.! bs) +- f (StaticInfo s (StaticUnboxed (StaticUnboxedStringOffset bs)) _) +- = Just (s, Right . snd $ newOffsetsMap HM.! bs) ++ let -- f (StaticInfo s (StaticUnboxed (StaticUnboxedString bs)) _) ++ -- = Just (s, Left . fst $ newOffsetsMap HM.! bs) ++ -- f (StaticInfo s (StaticUnboxed (StaticUnboxedStringOffset bs)) _) ++ -- = Just (s, Right . snd $ newOffsetsMap HM.! bs) + f _ = Nothing + in HM.union (stIdents origStringTable) + (HM.fromList $ mapMaybe f allStatics) +@@ -222,14 +222,14 @@ packStrings settings dflags cstate code = + rewriteStat st = st & valsS %~ rewriteVals + + rewriteStatic :: StaticInfo -> Maybe StaticInfo +- rewriteStatic (StaticInfo i +- (StaticUnboxed (StaticUnboxedString {})) +- cc) = +- Nothing +- rewriteStatic (StaticInfo i +- (StaticUnboxed (StaticUnboxedStringOffset {})) +- cc) = +- Nothing ++ -- rewriteStatic (StaticInfo i ++ -- (StaticUnboxed (StaticUnboxedString {})) ++ -- cc) = ++ -- Nothing ++ -- rewriteStatic (StaticInfo i ++ -- (StaticUnboxed (StaticUnboxedStringOffset {})) ++ -- cc) = ++ -- Nothing + rewriteStatic si = Just (si & staticInfoArgs %~ rewriteStaticArg) + + rewriteStaticArg :: StaticArg -> StaticArg diff --git a/haskell-overlays/text-jsstring/hashable.patch b/haskell-overlays/text-jsstring/hashable.patch new file mode 100644 index 000000000..b57e0036f --- /dev/null +++ b/haskell-overlays/text-jsstring/hashable.patch @@ -0,0 +1,93 @@ +diff --git a/Data/Hashable/Class.hs b/Data/Hashable/Class.hs +index 93470db..f641d40 100644 +--- a/Data/Hashable/Class.hs ++++ b/Data/Hashable/Class.hs +@@ -1,5 +1,8 @@ + {-# LANGUAGE BangPatterns, CPP, ForeignFunctionInterface, MagicHash, + ScopedTypeVariables, UnliftedFFITypes #-} ++#ifdef __GHCJS__ ++{-# LANGUAGE JavaScriptFFI, UnboxedTuples, GHCForeignImportPrim #-} ++#endif + + #if __GLASGOW_HASKELL__ < 710 + {-# LANGUAGE DeriveDataTypeable #-} +@@ -75,7 +78,9 @@ import Data.Int (Int8, Int16, Int32, Int64) + import Data.List (foldl') + import Data.Ratio (Ratio, denominator, numerator) + import qualified Data.Text as T ++#ifndef __GHCJS__ + import qualified Data.Text.Array as TA ++#endif + import qualified Data.Text.Internal as T + import qualified Data.Text.Lazy as TL + import Data.Version (Version(..)) +@@ -90,6 +95,9 @@ import GHC.Prim (ThreadId#) + import System.IO.Unsafe (unsafeDupablePerformIO) + import System.Mem.StableName + import Data.Unique (Unique, hashUnique) ++#ifdef __GHCJS__ ++import Data.JSString (JSString) ++#endif + + -- As we use qualified F.Foldable, we don't get warnings with newer base + import qualified Data.Foldable as F +@@ -156,7 +164,11 @@ import qualified Data.ByteString.Short.Internal as BSI + # define MIN_VERSION_integer_gmp_1_0_0 + # endif + ++#ifndef __GHCJS__ + import GHC.Exts (Int(..)) ++#else ++import GHC.Exts (Int(..), Int#) ++#endif + import GHC.Integer.GMP.Internals (Integer(..)) + # if defined(MIN_VERSION_integer_gmp_1_0_0) + import GHC.Exts (sizeofByteArray#) +@@ -629,9 +641,15 @@ instance Hashable BSI.ShortByteString where + #endif + + instance Hashable T.Text where ++#ifndef __GHCJS__ + hashWithSalt salt (T.Text arr off len) = + hashByteArrayWithSalt (TA.aBA arr) (off `shiftL` 1) (len `shiftL` 1) + salt ++#else ++ hashWithSalt salt (T.Text txt) = ++ let (# ba, len #) = js_textFromJSString txt ++ in hashByteArrayWithSalt ba (0 `shiftL` 1) (I# len `shiftL` 1) salt ++#endif + + instance Hashable TL.Text where + hashWithSalt = TL.foldlChunks hashWithSalt +@@ -829,6 +847,12 @@ instance Hashable a => Hashable (Option a) where + hashWithSalt p (Option a) = hashWithSalt p a + #endif + ++#ifdef __GHCJS__ ++foreign import javascript unsafe ++ "h$textFromString" ++ js_textFromJSString :: JSString -> (# ByteArray#, Int# #) ++#endif ++ + -- instances for @Data.Functor.{Product,Sum,Compose}@, present + -- in base-4.9 and onward. + #if MIN_VERSION_base(4,9,0) +@@ -917,4 +941,3 @@ instance Show1 Hashed where + liftShowsPrec sp _ d (Hashed a _) = showsUnaryWith sp "hashed" d a + #endif + +- +diff --git a/hashable.cabal b/hashable.cabal +index 74f6512..4182f38 100644 +--- a/hashable.cabal ++++ b/hashable.cabal +@@ -51,6 +51,9 @@ Library + Build-depends: base >= 4.4 && < 4.12, + bytestring >= 0.9 && < 0.11, + deepseq >= 1.3 && < 1.5 ++ ++ if impl(ghcjs) ++ Build-depends: ghcjs-base + if impl(ghc) + Build-depends: ghc-prim, + text >= 0.11.0.5 diff --git a/haskell-overlays/text-jsstring/say-text-jsstring.patch b/haskell-overlays/text-jsstring/say.patch similarity index 100% rename from haskell-overlays/text-jsstring/say-text-jsstring.patch rename to haskell-overlays/text-jsstring/say.patch diff --git a/haskell-overlays/untriaged.nix b/haskell-overlays/untriaged.nix index 87b62b89d..b6d782061 100644 --- a/haskell-overlays/untriaged.nix +++ b/haskell-overlays/untriaged.nix @@ -1,5 +1,4 @@ { haskellLib -, lib, nixpkgs , fetchFromGitHub , enableLibraryProfiling }: @@ -7,76 +6,16 @@ with haskellLib; self: super: { - haven = self.callHackage "haven" "0.2.0.0" {}; - base-compat = self.callHackage "base-compat" "0.9.2" {}; - constraints = self.callHackage "constraints" "0.9" {}; - servant-auth-server = self.callHackage "servant-auth-server" "0.3.1.0" {}; - vector = doJailbreak super.vector; - these = doJailbreak super.these; - aeson-compat = doJailbreak super.aeson-compat; - timezone-series = self.callCabal2nix "timezone-series" (fetchFromGitHub { - owner = "ygale"; - repo = "timezone-series"; - rev = "9f42baf542c54ad554bd53582819eaa454ed633d"; - sha256 = "1axrx8lziwi6pixws4lq3yz871vxi81rib6cpdl62xb5bh9y03j6"; - }) {}; - timezone-olson = self.callCabal2nix "timezone-olson" (fetchFromGitHub { - owner = "ygale"; - repo = "timezone-olson"; - rev = "aecec86be48580f23145ffb3bf12a4ae191d12d3"; - sha256 = "1xxbwb8z27qbcscbg5qdyzlc2czg5i3b0y04s9h36hfcb07hasnz"; - }) {}; - quickcheck-instances = doJailbreak super.quickcheck-instances; - - haskell-src-meta = self.callHackage "haskell-src-meta" "0.8.0.1" {}; - gtk2hs-buildtools = doJailbreak super.gtk2hs-buildtools; - - # hindent was overriden with a newer version of haskell-src-exts for some reason - hindent = super.hindent.override { haskell-src-exts = self.haskell-src-exts; }; - # Not sure why these tests fail... - hfmt = dontCheck super.hfmt; - - ######################################################################## - # Tweaks - ######################################################################## - gi-glib = self.callPackage ../gi-glib.nix {}; - gi-gio = self.callPackage ../gi-gio.nix {}; - gi-gtk = self.callPackage ../gi-gtk.nix { - gtk3 = nixpkgs.gnome3.gtk; - }; - gi-javascriptcore = self.callPackage ../gi-javascriptcore.nix {}; - gi-webkit2 = self.callPackage ../gi-webkit2.nix { - webkitgtk = nixpkgs.webkitgtk216x; - }; - gi-gtksource = super.gi-gtksource.override { - inherit (nixpkgs.gnome3) gtksourceview; - }; - ghcjs-base-stub = dontHaddock super.ghcjs-base-stub; - - haskell-gi-overloading = super.haskell-gi-overloading_0_0; - - webkit2gtk3-javascriptcore = super.webkit2gtk3-javascriptcore.override { - webkitgtk = nixpkgs.webkitgtk216x; - }; - - cabal-macosx = overrideCabal super.cabal-macosx (drv: { - src = fetchFromGitHub { - owner = "obsidiansystems"; - repo = "cabal-macosx"; - rev = "b1e22331ffa91d66da32763c0d581b5d9a61481b"; - sha256 = "1y2qk61ciflbxjm0b1ab3h9lk8cm7m6ln5ranpf1lg01z1qk28m8"; - }; - doCheck = false; - }); - - ######################################################################## - # Fixes to be upstreamed - ######################################################################## - foundation = dontCheck super.foundation; - MonadCatchIO-transformers = doJailbreak super.MonadCatchIO-transformers; - blaze-builder-enumerator = doJailbreak super.blaze-builder-enumerator; - process-extras = dontCheck super.process-extras; - miso = addBuildDepend (self.callHackage "miso" "0.12.0.0" {}) self.ghcjs-base; + language-nix = dontCheck super.language-nix; + hasktags = dontCheck super.hasktags; + http-reverse-proxy = dontCheck super.http-reverse-proxy; + xmlhtml = dontCheck super.xmlhtml; + haven = doJailbreak super.haven; + mmorph = doJailbreak super.mmorph; + async = self.callHackage "async" "2.2.1" {}; + lifted-async = self.callHackage "lifted-async" "0.10.0.2" {}; + hinotify = self.callHackage "hinotify" "0.3.10" {}; + fsnotify = self.callHackage "fsnotify" "0.3.0.1" {}; ######################################################################## # Packages not in hackage @@ -96,21 +35,11 @@ self: super: { direct-sqlite = self.callCabal2nix "direct-sqlite" (fetchFromGitHub { owner = "IreneKnapp"; repo = "direct-sqlite"; - rev = "cd1ab3c0ee7894d888be826fc653b75813fd53c9"; - sha256 = "13i6lz99x0jb9fgns7brlqnv5s5w4clp26l8c3kxd318r1krvr6w"; + rev = "8e3da41c46b5de19942cc7bf421c3deb5117ba7a"; + sha256 = "0ffk5j1db2y1drn0przh4jw9gc3vygwd987wl1g1m3dw7ry4dxy6"; }) {}; - superconstraints = - # Remove override when assertion fails - assert (super.superconstraints or null) == null; - self.callPackage (self.haskellSrc2nix { - name = "superconstraints"; - src = fetchurl { - url = "https://hackage.haskell.org/package/superconstraints-0.0.1/superconstraints.cabal"; - sha256 = "0bgc8ldml3533522gp1x2bjiazllknslpl2rvdkd1k1zfdbh3g9m"; - }; - sha256 = "1gx9p9i5jli91dnvvrc30j04h1v2m3d71i8sxli6qrhplq5y63dk"; - }) {}; -} // lib.optionalAttrs enableLibraryProfiling { - mkDerivation = expr: super.mkDerivation (expr // { enableLibraryProfiling = true; }); + mkDerivation = expr: super.mkDerivation (expr // { + inherit enableLibraryProfiling; + }); } diff --git a/ios/default.nix b/ios/default.nix index 7024c65ce..857ade779 100644 --- a/ios/default.nix +++ b/ios/default.nix @@ -1,6 +1,4 @@ -{ nixpkgs, ghcIosAarch64 -, plistLib # Set of functions for generating plist files from nix types -}: +{ nixpkgs, ghc }: { #TODO bundleName @@ -107,18 +105,18 @@ let ''; in nixpkgs.runCommand "${executableName}-app" (rec { - exePath = package ghcIosAarch64; - infoPlist = builtins.toFile "Info.plist" (plistLib.toPLIST infoPlistData); - resourceRulesPlist = builtins.toFile "ResourceRules.plist" (plistLib.toPLIST { + exePath = package ghc; + infoPlist = builtins.toFile "Info.plist" (nixpkgs.lib.generators.toPlist {} infoPlistData); + resourceRulesPlist = builtins.toFile "ResourceRules.plist" (nixpkgs.lib.generators.toPlist {} { rules = { - ${".*"} = true; - ${"Info.plist"} = { + ".*" = true; + "Info.plist" = { omit = true; - weight = plistLib.types.real 10; + weight = 10; }; - ${"ResourceRules.plist"} = { + "ResourceRules.plist" = { omit = true; - weight = plistLib.types.real 100; + weight = 100; }; }; }); @@ -130,13 +128,13 @@ nixpkgs.runCommand "${executableName}-app" (rec { ''; - xcent = builtins.toFile "xcent" (plistLib.toPLIST { + xcent = builtins.toFile "xcent" (nixpkgs.lib.generators.toPlist {} { application-identifier = ".${bundleIdentifier}"; - ${"com.apple.developer.team-identifier"} = ""; + "com.apple.developer.team-identifier" = ""; get-task-allow = true; keychain-access-groups = [ ".${bundleIdentifier}" ]; aps-environment = apsEnv; - ${"com.apple.developer.associated-domains"} = + "com.apple.developer.associated-domains" = if hosts == [] then null else map (host: "applinks:${host}") hosts; }); deployScript = nixpkgs.writeText "deploy" '' diff --git a/js-framework-benchmark/git.json b/js-framework-benchmark/git.json index 7c7de7201..1ca8fde32 100644 --- a/js-framework-benchmark/git.json +++ b/js-framework-benchmark/git.json @@ -1,6 +1,6 @@ { - "url": "https://github.com/obsidiansystems/js-framework-benchmark", - "rev": "a4dce00fdd004e5451317a2f57ec257c76659b06", - "sha256": "0acjmvj0lchmiqhx0qyvq6nggsmjj8s4cqx0ih7xczsm3kva1ym8", - "fetchSubmodules": true + "url": "git://github.com/obsidiansystems/js-framework-benchmark.git", + "rev": "aa54b5a5dc532264f82b6b0fd3bdc218409ba2ff", + "sha256": "1naa1w199rysysjswzw2iy2mag47j8ssvhdr2b1hrddn71jlmjz0", + "fetchSubmodules": false } diff --git a/jsaddle-dom/github.json b/jsaddle-dom/github.json index 5debd34c5..cf368f827 100644 --- a/jsaddle-dom/github.json +++ b/jsaddle-dom/github.json @@ -1,6 +1,6 @@ { "owner": "ghcjs", "repo": "jsaddle-dom", - "rev": "a565feac5df24d26e6fec5463bcb70e3e2fd683b", - "sha256": "0na40w2zc6v3vr60vjpjl8v9nm39ias7kxxs4ci6mk1p0ylv45rp" + "rev": "6ba167147476adebe7783e1521591aa3fd13da28", + "sha256": "0nj2g2lmcx880v6bgy3y7aalhfrpsx7kz8kswjbkyscxws6vkfli" } diff --git a/jsaddle/github.json b/jsaddle/github.json index d5a8dad96..eb9cd17e4 100644 --- a/jsaddle/github.json +++ b/jsaddle/github.json @@ -1,6 +1,6 @@ { "owner": "ghcjs", "repo": "jsaddle", - "rev": "50126cdcc15caeecb5910a15ac6cb67e3ab638ae", - "sha256": "0pnn36h6a8sfwhhf34px6a1lvzr447p7z0r0ky7shv7d78awfvgc" + "rev": "471b4426e73613086229895b8a8d26e20d89a78a", + "sha256": "0c12dfql336pbq6vnhgarfy8hklam56jm7dqbwf96fwmf5wv6myg" } diff --git a/nixpkgs-overlays/mobile-ghc/8.2.y/android-patches/enable-fPIC.patch b/nixpkgs-overlays/mobile-ghc/8.2.y/android-patches/enable-fPIC.patch deleted file mode 100644 index 2af097357..000000000 --- a/nixpkgs-overlays/mobile-ghc/8.2.y/android-patches/enable-fPIC.patch +++ /dev/null @@ -1,20 +0,0 @@ -diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs -index 0bc119a783..a7b45bfb9d 100644 ---- a/compiler/main/DynFlags.hs -+++ b/compiler/main/DynFlags.hs -@@ -4982,15 +4982,6 @@ makeDynFlagsConsistent dflags - = let dflags' = dflags { hscTarget = HscLlvm } - warn = "No native code generator, so using LLVM" - in loop dflags' warn -- | hscTarget dflags == HscLlvm && -- not ((arch == ArchX86_64) && (os == OSLinux || os == OSDarwin || os == OSFreeBSD)) && -- not ((isARM arch) && (os == OSLinux)) && -- (gopt Opt_PIC dflags || WayDyn `elem` ways dflags) -- = if cGhcWithNativeCodeGen == "YES" -- then let dflags' = dflags { hscTarget = HscAsm } -- warn = "Using native code generator rather than LLVM, as LLVM is incompatible with -fPIC and -dynamic on this platform" -- in loop dflags' warn -- else throwGhcException $ CmdLineError "Can't use -fPIC or -dynamic on this platform" - | os == OSDarwin && - arch == ArchX86_64 && - not (gopt Opt_PIC dflags) diff --git a/nixpkgs-overlays/mobile-ghc/8.2.y/fixed-ios.patch b/nixpkgs-overlays/mobile-ghc/8.2.y/fixed-ios.patch new file mode 100644 index 000000000..a0fe69a02 --- /dev/null +++ b/nixpkgs-overlays/mobile-ghc/8.2.y/fixed-ios.patch @@ -0,0 +1,1925 @@ +diff --git a/aclocal.m4 b/aclocal.m4 +index d5078de92f..a493f736a1 100644 +--- a/aclocal.m4 ++++ b/aclocal.m4 +@@ -20,14 +20,8 @@ AC_DEFUN([GHC_SELECT_FILE_EXTENSIONS], + $2='.exe' + $3='.dll' + ;; +- i386-apple-darwin|powerpc-apple-darwin) +- $3='.dylib' +- ;; +- x86_64-apple-darwin) +- $3='.dylib' +- ;; +- arm-apple-darwin10|i386-apple-darwin11|aarch64-apple-darwin14|x86_64-apple-darwin14) +- $2='.a' ++ # apple platform uses .dylib (macOS, iOS, ...) ++ *-apple-*) + $3='.dylib' + ;; + esac +@@ -115,6 +109,8 @@ AC_DEFUN([FPTOOLS_SET_PLATFORM_VARS], + GHC_CONVERT_OS([$target_os], [$TargetArch], [TargetOS]) + fi + ++ GHC_LLVM_TARGET([$target_cpu],[$target_vendor],[$target_os],[LlvmTarget]) ++ + GHC_SELECT_FILE_EXTENSIONS([$host], [exeext_host], [soext_host]) + GHC_SELECT_FILE_EXTENSIONS([$target], [exeext_target], [soext_target]) + windows=NO +@@ -142,9 +138,13 @@ AC_DEFUN([FPTOOLS_SET_PLATFORM_VARS], + TargetVendor_CPP=` echo "$TargetVendor" | sed -e 's/\./_/g' -e 's/-/_/g'` + TargetOS_CPP=` echo "$TargetOS" | sed -e 's/\./_/g' -e 's/-/_/g'` + ++ # we intend to pass trough --targets to llvm as is. ++ LLVMTarget_CPP=` echo "$LlvmTarget"` ++ + echo "GHC build : $BuildPlatform" + echo "GHC host : $HostPlatform" + echo "GHC target : $TargetPlatform" ++ echo "LLVM target: $LlvmTarget" + + AC_SUBST(BuildPlatform) + AC_SUBST(HostPlatform) +@@ -160,6 +160,7 @@ AC_DEFUN([FPTOOLS_SET_PLATFORM_VARS], + AC_SUBST(HostOS_CPP) + AC_SUBST(BuildOS_CPP) + AC_SUBST(TargetOS_CPP) ++ AC_SUBST(LLVMTarget_CPP) + + AC_SUBST(HostVendor_CPP) + AC_SUBST(BuildVendor_CPP) +@@ -238,13 +239,12 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], + + checkOS() { + case [$]1 in +- linux) ++ linux|linux-android) + test -z "[$]2" || eval "[$]2=OSLinux" + ;; +- ios) +- test -z "[$]2" || eval "[$]2=OSiOS" +- ;; +- darwin) ++ # Plain "darwin" is turned into "macos" in FPTOOLS_SET_PLATFORM_VARS, ++ # which must be and always is called first. ++ macos|ios|watchos|tvos) + test -z "[$]2" || eval "[$]2=OSDarwin" + ;; + solaris2) +@@ -280,9 +280,6 @@ AC_DEFUN([FPTOOLS_SET_HASKELL_PLATFORM_VARS], + aix) + test -z "[$]2" || eval "[$]2=OSAIX" + ;; +- linux-android) +- test -z "[$]2" || eval "[$]2=OSAndroid" +- ;; + *) + echo "Unknown OS '[$]1'" + exit 1 +@@ -482,6 +479,12 @@ AC_DEFUN([FP_SETTINGS], + SettingsLibtoolCommand="libtool" + SettingsTouchCommand='touch' + fi ++ if test -z "$ClangCmd" ++ then ++ SettingsClangCommand="clang" ++ else ++ SettingsClangCommand="$ClangCmd" ++ fi + if test -z "$LlcCmd" + then + SettingsLlcCommand="llc" +@@ -512,6 +515,7 @@ AC_DEFUN([FP_SETTINGS], + AC_SUBST(SettingsWindresCommand) + AC_SUBST(SettingsLibtoolCommand) + AC_SUBST(SettingsTouchCommand) ++ AC_SUBST(SettingsClangCommand) + AC_SUBST(SettingsLlcCommand) + AC_SUBST(SettingsOptCommand) + ]) +@@ -865,20 +869,17 @@ AC_CACHE_CHECK([leading underscore in symbol names], [fptools_cv_leading_undersc + # Hack!: nlist() under Digital UNIX insist on there being an _, + # but symbol table listings shows none. What is going on here?!? + case $TargetPlatform in +-*linux-android*) fptools_cv_leading_underscore=no;; +-*openbsd*) # x86 openbsd is ELF from 3.4 >, meaning no leading uscore +- case $build in +- i386-*2\.@<:@0-9@:>@ | i386-*3\.@<:@0-3@:>@ ) fptools_cv_leading_underscore=yes ;; +- *) fptools_cv_leading_underscore=no ;; +- esac ;; +-i386-unknown-mingw32) fptools_cv_leading_underscore=yes;; +-x86_64-unknown-mingw32) fptools_cv_leading_underscore=no;; +- +- # HACK: Apple doesn't seem to provide nlist in the 64-bit-libraries +-x86_64-apple-darwin*) fptools_cv_leading_underscore=yes;; +-*-apple-ios) fptools_cv_leading_underscore=yes;; +- +-*) AC_RUN_IFELSE([AC_LANG_SOURCE([[#ifdef HAVE_NLIST_H ++ # Apples mach-o platforms use leading underscores ++ *-apple-*) fptools_cv_leading_underscore=yes;; ++ *linux-android*) fptools_cv_leading_underscore=no;; ++ *openbsd*) # x86 openbsd is ELF from 3.4 >, meaning no leading uscore ++ case $build in ++ i386-*2\.@<:@0-9@:>@ | i386-*3\.@<:@0-3@:>@ ) fptools_cv_leading_underscore=yes ;; ++ *) fptools_cv_leading_underscore=no ;; ++ esac ;; ++ i386-unknown-mingw32) fptools_cv_leading_underscore=yes;; ++ x86_64-unknown-mingw32) fptools_cv_leading_underscore=no;; ++ *) AC_RUN_IFELSE([AC_LANG_SOURCE([[#ifdef HAVE_NLIST_H + #include + struct nlist xYzzY1[] = {{"xYzzY1", 0},{0}}; + struct nlist xYzzY2[] = {{"_xYzzY2", 0},{0}}; +@@ -1214,7 +1215,7 @@ AC_DEFUN([FP_PROG_AR_NEEDS_RANLIB],[ + if test $fp_prog_ar_is_gnu = yes + then + fp_cv_prog_ar_needs_ranlib=no +- elif test "$TargetOS_CPP" = "darwin" ++ elif test "$TargetVendor_CPP" = "apple" + then + # It's quite tedious to check for Apple's crazy timestamps in + # .a files, so we hardcode it. +@@ -1926,6 +1927,24 @@ case "$1" in + esac + ]) + ++# GHC_LLVM_TARGET(target_cpu, target_vendor, target_os, llvm_target_var) ++# -------------------------------- ++# converts the canonicalized target into someting llvm can understand ++AC_DEFUN([GHC_LLVM_TARGET], [ ++ case "$2-$3" in ++ hardfloat-*eabi) ++ llvm_target_vendor="unknown" ++ llvm_target_os="$3""hf" ++ ;; ++ *) ++ GHC_CONVERT_VENDOR([$2],[llvm_target_vendor]) ++ GHC_CONVERT_OS([$3],[$1],[llvm_target_os]) ++ ;; ++ esac ++ $4="$1-$llvm_target_vendor-$llvm_target_os" ++]) ++ ++ + # GHC_CONVERT_VENDOR(vendor, target_var) + # -------------------------------- + # converts vendor from gnu to ghc naming, and assigns the result to $target_var +@@ -1951,12 +1970,11 @@ AC_DEFUN([GHC_CONVERT_VENDOR],[ + # -------------------------------- + # converts os from gnu to ghc naming, and assigns the result to $target_var + AC_DEFUN([GHC_CONVERT_OS],[ +-case "$1-$2" in +- darwin10-arm|darwin11-i386|darwin14-aarch64|darwin14-x86_64) +- $3="ios" +- ;; +- *) + case "$1" in ++ # watchos and tvos are ios variant as of May 2017. ++ ios|watchos|tvos) ++ $3="ios" ++ ;; + linux-android*) + $3="linux-android" + ;; +@@ -1964,12 +1982,17 @@ case "$1-$2" in + $3="linux" + ;; + # As far as I'm aware, none of these have relevant variants +- freebsd|netbsd|openbsd|dragonfly|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|mingw32|darwin|gnu|nextstep2|nextstep3|sunos4|ultrix|haiku) ++ freebsd|netbsd|openbsd|dragonfly|hpux|linuxaout|kfreebsdgnu|freebsd2|solaris2|mingw32|gnu|nextstep2|nextstep3|sunos4|ultrix|haiku) + $3="$1" + ;; + aix*) # e.g. powerpc-ibm-aix7.1.3.0 + $3="aix" + ;; ++ darwin*|macos*) # like aarch64-apple-darwin14 ++ # aarch64-apple-macos ++ # aarch64-apple-macosx ++ $3="macos" ++ ;; + freebsd*) # like i686-gentoo-freebsd7 + # i686-gentoo-freebsd8 + # i686-gentoo-freebsd8.2 +@@ -1983,8 +2006,6 @@ case "$1-$2" in + exit 1 + ;; + esac +- ;; +- esac + ]) + + # BOOTSTRAPPING_GHC_INFO_FIELD +@@ -2016,7 +2037,7 @@ AC_SUBST(LIBRARY_[]translit([$1], [-], [_])[]_VERSION) + # -------------------------------- + # Gets the version number of XCode, if on a Mac + AC_DEFUN([XCODE_VERSION],[ +- if test "$TargetOS_CPP" = "darwin" ++ if test "$TargetVendor_CPP" = "apple" + then + AC_MSG_CHECKING(XCode version) + XCodeVersion=`xcodebuild -version | grep Xcode | sed "s/Xcode //"` +diff --git a/compiler/ghc.mk b/compiler/ghc.mk +index 614d193d94..6e3708a83f 100644 +--- a/compiler/ghc.mk ++++ b/compiler/ghc.mk +@@ -160,6 +160,8 @@ compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/. + @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@ + @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@ + @echo >> $@ ++ @echo "#define LLVM_TARGET \"$(LLVMTarget_CPP)\"" >> $@ ++ @echo >> $@ + @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@ + @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@ + @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@ +@@ -178,6 +180,16 @@ compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/. + @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@ + @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@ + @echo >> $@ ++ @echo "#if defined(macos_BUILD_OS) || defined(ios_BUILD_OS)" >> $@ ++ @echo "# define darwin_BUILD_OS 1" >> $@ ++ @echo "#endif" >> $@ ++ @echo "#if defined(macos_HOST_OS) || defined(ios_HOST_OS)" >> $@ ++ @echo "# define darwin_HOST_OS 1" >> $@ ++ @echo "#endif" >> $@ ++ @echo "#if defined(macos_TARGET_OS) || defined(ios_TARGET_OS)" >> $@ ++ @echo "# define darwin_TARGET_OS 1" >> $@ ++ @echo "#endif" >> $@ ++ @echo >> $@ + @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@ + @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@ + @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@ +@@ -201,6 +213,8 @@ compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/. + @echo "#define HostPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@ + @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@ + @echo >> $@ ++ @echo "#define LLVM_TARGET \"$(LLVMTarget_CPP)\"" >> $@ ++ @echo >> $@ + @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@ + @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@ + @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@ +@@ -219,6 +233,16 @@ compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/. + @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@ + @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@ + @echo >> $@ ++ @echo "#if defined(macos_BUILD_OS) || defined(ios_BUILD_OS)" >> $@ ++ @echo "# define darwin_BUILD_OS 1" >> $@ ++ @echo "#endif" >> $@ ++ @echo "#if defined(macos_HOST_OS) || defined(ios_HOST_OS)" >> $@ ++ @echo "# define darwin_HOST_OS 1" >> $@ ++ @echo "#endif" >> $@ ++ @echo "#if defined(macos_TARGET_OS) || defined(ios_TARGET_OS)" >> $@ ++ @echo "# define darwin_TARGET_OS 1" >> $@ ++ @echo "#endif" >> $@ ++ @echo >> $@ + @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@ + @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@ + @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@ +diff --git a/compiler/llvmGen/LlvmCodeGen.hs b/compiler/llvmGen/LlvmCodeGen.hs +index 5596d599c4..d5d76ea4ba 100644 +--- a/compiler/llvmGen/LlvmCodeGen.hs ++++ b/compiler/llvmGen/LlvmCodeGen.hs +@@ -71,7 +71,7 @@ llvmCodeGen dflags h us cmm_stream + llvmCodeGen' :: Stream.Stream LlvmM RawCmmGroup () -> LlvmM () + llvmCodeGen' cmm_stream + = do -- Preamble +- renderLlvm pprLlvmHeader ++ renderLlvm header + ghcInternalFunctions + cmmMetaLlvmPrelude + +@@ -84,6 +84,15 @@ llvmCodeGen' cmm_stream + + -- Postamble + cmmUsedLlvmGens ++ where ++ header :: SDoc ++ header = sdocWithDynFlags $ \dflags -> ++ let target = LLVM_TARGET ++ layout = case lookup target (llvmTargets dflags) of ++ Just (LlvmTarget dl _ _) -> dl ++ Nothing -> error $ "Failed to lookup the datalayout for " ++ target ++ "; available targets: " ++ show (map fst $ llvmTargets dflags) ++ in text ("target datalayout = \"" ++ layout ++ "\"") ++ $+$ text ("target triple = \"" ++ target ++ "\"") + + llvmGroupLlvmGens :: RawCmmGroup -> LlvmM () + llvmGroupLlvmGens cmm = do +diff --git a/compiler/llvmGen/LlvmCodeGen/Ppr.hs b/compiler/llvmGen/LlvmCodeGen/Ppr.hs +index 37d1391519..e7444ee226 100644 +--- a/compiler/llvmGen/LlvmCodeGen/Ppr.hs ++++ b/compiler/llvmGen/LlvmCodeGen/Ppr.hs +@@ -4,7 +4,7 @@ + -- | Pretty print helpers for the LLVM Code generator. + -- + module LlvmCodeGen.Ppr ( +- pprLlvmHeader, pprLlvmCmmDecl, pprLlvmData, infoSection ++ pprLlvmCmmDecl, pprLlvmData, infoSection + ) where + + #include "HsVersions.h" +@@ -15,7 +15,6 @@ import LlvmCodeGen.Data + + import CLabel + import Cmm +-import Platform + + import FastString + import Outputable +@@ -26,66 +25,6 @@ import Unique + -- * Top level + -- + +--- | Header code for LLVM modules +-pprLlvmHeader :: SDoc +-pprLlvmHeader = moduleLayout +- +- +--- | LLVM module layout description for the host target +-moduleLayout :: SDoc +-moduleLayout = sdocWithPlatform $ \platform -> +- case platform of +- Platform { platformArch = ArchX86, platformOS = OSDarwin } -> +- text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32\"" +- $+$ text "target triple = \"i386-apple-darwin9.8\"" +- Platform { platformArch = ArchX86, platformOS = OSMinGW32 } -> +- text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f80:128:128-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32\"" +- $+$ text "target triple = \"i686-pc-win32\"" +- Platform { platformArch = ArchX86, platformOS = OSLinux } -> +- text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32\"" +- $+$ text "target triple = \"i386-pc-linux-gnu\"" +- Platform { platformArch = ArchX86_64, platformOS = OSDarwin } -> +- text "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64\"" +- $+$ text "target triple = \"x86_64-apple-darwin10.0.0\"" +- Platform { platformArch = ArchX86_64, platformOS = OSLinux } -> +- text "target datalayout = \"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64\"" +- $+$ text "target triple = \"x86_64-linux-gnu\"" +- Platform { platformArch = ArchARM {}, platformOS = OSLinux } -> +- text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32\"" +- $+$ text "target triple = \"armv6-unknown-linux-gnueabihf\"" +- Platform { platformArch = ArchARM {}, platformOS = OSAndroid } -> +- text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32\"" +- $+$ text "target triple = \"arm-unknown-linux-androideabi\"" +- Platform { platformArch = ArchARM {}, platformOS = OSQNXNTO } -> +- text "target datalayout = \"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:64:128-a0:0:64-n32\"" +- $+$ text "target triple = \"arm-unknown-nto-qnx8.0.0eabi\"" +- Platform { platformArch = ArchARM {}, platformOS = OSiOS } -> +- text "target datalayout = \"e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32\"" +- $+$ text "target triple = \"thumbv7-apple-ios7.0.0\"" +- Platform { platformArch = ArchARM64, platformOS = OSiOS } -> +- text "target datalayout = \"e-m:o-i64:64-i128:128-n32:64-S128\"" +- $+$ text "target triple = \"arm64-apple-ios7.0.0\"" +- Platform { platformArch = ArchX86, platformOS = OSiOS } -> +- text "target datalayout = \"e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128\"" +- $+$ text "target triple = \"i386-apple-ios7.0.0\"" +- Platform { platformArch = ArchX86_64, platformOS = OSiOS } -> +- text "target datalayout = \"e-m:o-i64:64-f80:128-n8:16:32:64-S128\"" +- $+$ text "target triple = \"x86_64-apple-ios7.0.0\"" +- Platform { platformArch = ArchARM64, platformOS = OSLinux } -> +- text "target datalayout = \"e-m:e-i64:64-i128:128-n32:64-S128\"" +- $+$ text "target triple = \"aarch64-unknown-linux-gnu\"" +- _ -> +- if platformIsCrossCompiling platform +- then panic "LlvmCodeGen.Ppr: Cross compiling without valid target info." +- else empty +- -- If you see the above panic, GHC is missing the required target datalayout +- -- and triple information. You can obtain this info by compiling a simple +- -- 'hello world' C program with the clang C compiler eg: +- -- clang -S hello.c -emit-llvm -o - +- -- and the first two lines of hello.ll should provide the 'target datalayout' +- -- and 'target triple' lines required. +- +- + -- | Pretty print LLVM data code + pprLlvmData :: LlvmData -> SDoc + pprLlvmData (globals, types) = +diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs +index 40e6a8dead..4cfc48eaa3 100644 +--- a/compiler/main/DriverPipeline.hs ++++ b/compiler/main/DriverPipeline.hs +@@ -67,7 +67,7 @@ import System.Directory + import System.FilePath + import System.IO + import Control.Monad +-import Data.List ( isSuffixOf ) ++import Data.List ( isSuffixOf, intercalate ) + import Data.Maybe + import Data.Version + +@@ -378,7 +378,7 @@ link' dflags batch_attempt_linking hpt + let + staticLink = case ghcLink dflags of + LinkStaticLib -> True +- _ -> platformBinariesAreStaticLibs (targetPlatform dflags) ++ _ -> False + + home_mod_infos = eltsHpt hpt + +@@ -818,6 +818,63 @@ getOutputFilename stop_phase output basename dflags next_phase maybe_location + | Just d <- odir = d persistent + | otherwise = persistent + ++ ++-- | The fast LLVM Pipeline skips the mangler and assembler, ++-- emiting object code dirctly from llc. ++-- ++-- slow: opt -> llc -> .s -> mangler -> as -> .o ++-- fast: opt -> llc -> .o ++-- ++-- hidden flag: -ffast-llvm ++-- ++-- if keep-s-files is specified, we need to go through ++-- the slow pipeline (Kavon Farvardin requested this). ++fastLlvmPipeline :: DynFlags -> Bool ++fastLlvmPipeline dflags ++ = not (gopt Opt_KeepSFiles dflags) && gopt Opt_FastLlvm dflags ++ ++-- | LLVM Options. These are flags to be passed to opt and llc, to ensure ++-- consistency we list them in pairs, so that they form groups. ++llvmOptions :: DynFlags ++ -> [(String, String)] -- ^ pairs of (opt, llc) arguments ++llvmOptions dflags = ++ [("-enable-tbaa -tbaa", "-enable-tbaa") | gopt Opt_LlvmTBAA dflags ] ++ ++ [("-relocation-model=" ++ rmodel ++ ,"-relocation-model=" ++ rmodel) | not (null rmodel)] ++ ++ [("-stack-alignment=" ++ (show align) ++ ,"-stack-alignment=" ++ (show align)) | align > 0 ] ++ ++ [("", "-filetype=obj") | fastLlvmPipeline dflags ] ++ ++ -- Additional llc flags ++ ++ [("", "-mcpu=" ++ mcpu) | not (null mcpu) ] ++ ++ [("", "-mattr=" ++ attrs) | not (null attrs) ] ++ ++ where target = LLVM_TARGET ++ Just (LlvmTarget _ mcpu mattr) = lookup target (llvmTargets dflags) ++ ++ -- Relocation models ++ rmodel | gopt Opt_PIC dflags = "pic" ++ | positionIndependent dflags = "pic" ++ | WayDyn `elem` ways dflags = "dynamic-no-pic" ++ | otherwise = "static" ++ ++ align :: Int ++ align = case platformArch (targetPlatform dflags) of ++ ArchX86_64 | isAvxEnabled dflags -> 32 ++ _ -> 0 ++ ++ attrs :: String ++ attrs = intercalate "," $ mattr ++ ++ ["+sse42" | isSse4_2Enabled dflags ] ++ ++ ["+sse2" | isSse2Enabled dflags ] ++ ++ ["+sse" | isSseEnabled dflags ] ++ ++ ["+avx512f" | isAvx512fEnabled dflags ] ++ ++ ["+avx2" | isAvx2Enabled dflags ] ++ ++ ["+avx" | isAvxEnabled dflags ] ++ ++ ["+avx512cd"| isAvx512cdEnabled dflags ] ++ ++ ["+avx512er"| isAvx512erEnabled dflags ] ++ ++ ["+avx512pf"| isAvx512pfEnabled dflags ] ++ + -- ----------------------------------------------------------------------------- + -- | Each phase in the pipeline returns the next phase to execute, and the + -- name of the file in which the output was placed. +@@ -1419,121 +1476,115 @@ runPhase (RealPhase SplitAs) _input_fn dflags + + ----------------------------------------------------------------------------- + -- LlvmOpt phase +- + runPhase (RealPhase LlvmOpt) input_fn dflags + = do +- let opt_lvl = max 0 (min 2 $ optLevel dflags) +- -- don't specify anything if user has specified commands. We do this +- -- for opt but not llc since opt is very specifically for optimisation +- -- passes only, so if the user is passing us extra options we assume +- -- they know what they are doing and don't get in the way. +- optFlag = if null (getOpts dflags opt_lo) +- then map SysTools.Option $ words (llvmOpts !! opt_lvl) +- else [] +- tbaa | gopt Opt_LlvmTBAA dflags = "--enable-tbaa=true" +- | otherwise = "--enable-tbaa=false" +- +- + output_fn <- phaseOutputFilename LlvmLlc + + liftIO $ SysTools.runLlvmOpt dflags +- ([ SysTools.FileOption "" input_fn, +- SysTools.Option "-o", +- SysTools.FileOption "" output_fn] +- ++ optFlag +- ++ [SysTools.Option tbaa]) ++ ( optFlag ++ ++ defaultOptions ++ ++ [ SysTools.FileOption "" input_fn ++ , SysTools.Option "-o" ++ , SysTools.FileOption "" output_fn] ++ ) + + return (RealPhase LlvmLlc, output_fn) + where + -- we always (unless -optlo specified) run Opt since we rely on it to + -- fix up some pretty big deficiencies in the code we generate +- llvmOpts = [ "-mem2reg -globalopt" +- , "-O1 -globalopt" +- , "-O2" +- ] ++ llvmOpts = case optLevel dflags of ++ 0 -> "-mem2reg -globalopt" ++ 1 -> "-O1 -globalopt" ++ _ -> "-O2" ++ ++ -- don't specify anything if user has specified commands. We do this ++ -- for opt but not llc since opt is very specifically for optimisation ++ -- passes only, so if the user is passing us extra options we assume ++ -- they know what they are doing and don't get in the way. ++ optFlag = if null (getOpts dflags opt_lo) ++ then map SysTools.Option $ words llvmOpts ++ else [] ++ ++ defaultOptions = map SysTools.Option . concat . fmap words . fst ++ $ unzip (llvmOptions dflags) + + ----------------------------------------------------------------------------- + -- LlvmLlc phase + + runPhase (RealPhase LlvmLlc) input_fn dflags + = do +- let opt_lvl = max 0 (min 2 $ optLevel dflags) +- -- iOS requires external references to be loaded indirectly from the +- -- DATA segment or dyld traps at runtime writing into TEXT: see #7722 +- rmodel | platformOS (targetPlatform dflags) == OSiOS = "dynamic-no-pic" +- | positionIndependent dflags = "pic" +- | WayDyn `elem` ways dflags = "dynamic-no-pic" +- | otherwise = "static" +- tbaa | gopt Opt_LlvmTBAA dflags = "--enable-tbaa=true" +- | otherwise = "--enable-tbaa=false" +- +- -- hidden debugging flag '-dno-llvm-mangler' to skip mangling +- let next_phase = case gopt Opt_NoLlvmMangler dflags of +- False -> LlvmMangle +- True | gopt Opt_SplitObjs dflags -> Splitter +- True -> As False ++ next_phase <- if fastLlvmPipeline dflags ++ then maybeMergeForeign ++ -- hidden debugging flag '-dno-llvm-mangler' to skip mangling ++ else case gopt Opt_NoLlvmMangler dflags of ++ False -> return LlvmMangle ++ True | gopt Opt_SplitObjs dflags -> return Splitter ++ True -> return (As False) + + output_fn <- phaseOutputFilename next_phase + + liftIO $ SysTools.runLlvmLlc dflags +- ([ SysTools.Option (llvmOpts !! opt_lvl), +- SysTools.Option $ "-relocation-model=" ++ rmodel, +- SysTools.FileOption "" input_fn, +- SysTools.Option "-o", SysTools.FileOption "" output_fn] +- ++ [SysTools.Option tbaa] +- ++ map SysTools.Option fpOpts +- ++ map SysTools.Option abiOpts +- ++ map SysTools.Option sseOpts +- ++ map SysTools.Option avxOpts +- ++ map SysTools.Option avx512Opts +- ++ map SysTools.Option stackAlignOpts) ++ ( optFlag ++ ++ defaultOptions ++ ++ [ SysTools.FileOption "" input_fn ++ , SysTools.Option "-o" ++ , SysTools.FileOption "" output_fn ++ ] ++ ) + + return (RealPhase next_phase, output_fn) + where +- -- Bug in LLVM at O3 on OSX. +- llvmOpts = if platformOS (targetPlatform dflags) == OSDarwin +- then ["-O1", "-O2", "-O2"] +- else ["-O1", "-O2", "-O3"] +- -- On ARMv7 using LLVM, LLVM fails to allocate floating point registers +- -- while compiling GHC source code. It's probably due to fact that it +- -- does not enable VFP by default. Let's do this manually here +- fpOpts = case platformArch (targetPlatform dflags) of +- ArchARM ARMv7 ext _ -> if (elem VFPv3 ext) +- then ["-mattr=+v7,+vfp3"] +- else if (elem VFPv3D16 ext) +- then ["-mattr=+v7,+vfp3,+d16"] +- else [] +- ArchARM ARMv6 ext _ -> if (elem VFPv2 ext) +- then ["-mattr=+v6,+vfp2"] +- else ["-mattr=+v6"] +- _ -> [] +- -- On Ubuntu/Debian with ARM hard float ABI, LLVM's llc still +- -- compiles into soft-float ABI. We need to explicitly set abi +- -- to hard +- abiOpts = case platformArch (targetPlatform dflags) of +- ArchARM _ _ HARD -> ["-float-abi=hard"] +- ArchARM _ _ _ -> [] +- _ -> [] +- +- sseOpts | isSse4_2Enabled dflags = ["-mattr=+sse42"] +- | isSse2Enabled dflags = ["-mattr=+sse2"] +- | isSseEnabled dflags = ["-mattr=+sse"] +- | otherwise = [] +- +- avxOpts | isAvx512fEnabled dflags = ["-mattr=+avx512f"] +- | isAvx2Enabled dflags = ["-mattr=+avx2"] +- | isAvxEnabled dflags = ["-mattr=+avx"] +- | otherwise = [] +- +- avx512Opts = +- [ "-mattr=+avx512cd" | isAvx512cdEnabled dflags ] ++ +- [ "-mattr=+avx512er" | isAvx512erEnabled dflags ] ++ +- [ "-mattr=+avx512pf" | isAvx512pfEnabled dflags ] +- +- stackAlignOpts = +- case platformArch (targetPlatform dflags) of +- ArchX86_64 | isAvxEnabled dflags -> ["-stack-alignment=32"] +- _ -> [] ++ -- Note [Clamping of llc optimizations] ++ -- ++ -- See #13724 ++ -- ++ -- we clamp the llc optimization between [1,2]. This is because passing -O0 ++ -- to llc 3.9 or llc 4.0, the naive register allocator can fail with ++ -- ++ -- Error while trying to spill R1 from class GPR: Cannot scavenge register ++ -- without an emergency spill slot! ++ -- ++ -- Observed at least with target 'arm-unknown-linux-gnueabihf'. ++ -- ++ -- ++ -- With LLVM4, llc -O3 crashes when ghc-stage1 tries to compile ++ -- rts/HeapStackCheck.cmm ++ -- ++ -- llc -O3 '-mtriple=arm-unknown-linux-gnueabihf' -enable-tbaa /var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc33674_0/ghc_6.bc -o /var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc33674_0/ghc_7.lm_s ++ -- 0 llc 0x0000000102ae63e8 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 40 ++ -- 1 llc 0x0000000102ae69a6 SignalHandler(int) + 358 ++ -- 2 libsystem_platform.dylib 0x00007fffc23f4b3a _sigtramp + 26 ++ -- 3 libsystem_c.dylib 0x00007fffc226498b __vfprintf + 17876 ++ -- 4 llc 0x00000001029d5123 llvm::SelectionDAGISel::LowerArguments(llvm::Function const&) + 5699 ++ -- 5 llc 0x0000000102a21a35 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 3381 ++ -- 6 llc 0x0000000102a202b1 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1457 ++ -- 7 llc 0x0000000101bdc474 (anonymous namespace)::ARMDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 20 ++ -- 8 llc 0x00000001025573a6 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 134 ++ -- 9 llc 0x000000010274fb12 llvm::FPPassManager::runOnFunction(llvm::Function&) + 498 ++ -- 10 llc 0x000000010274fd23 llvm::FPPassManager::runOnModule(llvm::Module&) + 67 ++ -- 11 llc 0x00000001027501b8 llvm::legacy::PassManagerImpl::run(llvm::Module&) + 920 ++ -- 12 llc 0x000000010195f075 compileModule(char**, llvm::LLVMContext&) + 12133 ++ -- 13 llc 0x000000010195bf0b main + 491 ++ -- 14 libdyld.dylib 0x00007fffc21e5235 start + 1 ++ -- Stack dump: ++ -- 0. Program arguments: llc -O3 -mtriple=arm-unknown-linux-gnueabihf -enable-tbaa /var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc33674_0/ghc_6.bc -o /var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc33674_0/ghc_7.lm_s ++ -- 1. Running pass 'Function Pass Manager' on module '/var/folders/fv/xqjrpfj516n5xq_m_ljpsjx00000gn/T/ghc33674_0/ghc_6.bc'. ++ -- 2. Running pass 'ARM Instruction Selection' on function '@"stg_gc_f1$def"' ++ -- ++ -- Observed at least with -mtriple=arm-unknown-linux-gnueabihf -enable-tbaa ++ -- ++ llvmOpts = case optLevel dflags of ++ 0 -> "-O1" -- required to get the non-naive reg allocator. Passing -regalloc=greedy is not sufficient. ++ 1 -> "-O1" ++ _ -> "-O2" ++ ++ optFlag = if null (getOpts dflags opt_lc) ++ then map SysTools.Option $ words llvmOpts ++ else [] ++ ++ defaultOptions = map SysTools.Option . concat . fmap words . snd ++ $ unzip (llvmOptions dflags) ++ + + ----------------------------------------------------------------------------- + -- LlvmMangle phase +@@ -1892,22 +1943,19 @@ linkBinary' staticLink dflags o_files dep_packages = do + -- Here are some libs that need to be linked at the *end* of + -- the command line, because they contain symbols that are referred to + -- by the RTS. We can't therefore use the ordinary way opts for these. +- let +- debug_opts | WayDebug `elem` ways dflags = [ ++ let debug_opts | WayDebug `elem` ways dflags = [ + #if defined(HAVE_LIBBFD) + "-lbfd", "-liberty" + #endif + ] +- | otherwise = [] ++ | otherwise = [] + +- let thread_opts +- | WayThreaded `elem` ways dflags = +- let os = platformOS (targetPlatform dflags) +- in if os `elem` [OSMinGW32, OSFreeBSD, OSOpenBSD, OSAndroid, +- OSNetBSD, OSHaiku, OSQNXNTO, OSiOS, OSDarwin] +- then [] +- else ["-lpthread"] +- | otherwise = [] ++ thread_opts | WayThreaded `elem` ways dflags = [ ++#if NEED_PTHREAD_LIB ++ "-lpthread" ++#endif ++ ] ++ | otherwise = [] + + rc_objs <- maybeCreateManifest dflags output_fn + +@@ -1942,7 +1990,7 @@ linkBinary' staticLink dflags o_files dep_packages = do + -- on x86. + ++ (if sLdSupportsCompactUnwind mySettings && + not staticLink && +- (platformOS platform == OSDarwin || platformOS platform == OSiOS) && ++ (platformOS platform == OSDarwin) && + case platformArch platform of + ArchX86 -> True + ArchX86_64 -> True +@@ -1952,13 +2000,6 @@ linkBinary' staticLink dflags o_files dep_packages = do + then ["-Wl,-no_compact_unwind"] + else []) + +- -- '-no_pie' +- -- iOS uses 'dynamic-no-pic', so we must pass this to ld to suppress a warning; see #7722 +- ++ (if platformOS platform == OSiOS && +- not staticLink +- then ["-Wl,-no_pie"] +- else []) +- + -- '-Wl,-read_only_relocs,suppress' + -- ld gives loads of warnings like: + -- ld: warning: text reloc in _base_GHCziArr_unsafeArray_info to _base_GHCziArr_unsafeArray_closure +@@ -2073,10 +2114,7 @@ linkDynLibCheck dflags o_files dep_packages + + linkStaticLibCheck :: DynFlags -> [String] -> [InstalledUnitId] -> IO () + linkStaticLibCheck dflags o_files dep_packages +- = do +- when (platformOS (targetPlatform dflags) `notElem` [OSiOS, OSDarwin]) $ +- throwGhcExceptionIO (ProgramError "Static archive creation only supported on Darwin/OS X/iOS") +- linkBinary' True dflags o_files dep_packages ++ = linkBinary' True dflags o_files dep_packages + + -- ----------------------------------------------------------------------------- + -- Running CPP +diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs +index f5f5f00dd2..2cde3b7700 100644 +--- a/compiler/main/DynFlags.hs ++++ b/compiler/main/DynFlags.hs +@@ -76,6 +76,9 @@ module DynFlags ( + safeDirectImpsReq, safeImplicitImpsReq, + unsafeFlags, unsafeFlagsForInfer, + ++ -- ** LLVM Targets ++ LlvmTarget(..), LlvmTargets, ++ + -- ** System tool settings and locations + Settings(..), + targetPlatform, programName, projectVersion, +@@ -83,9 +86,9 @@ module DynFlags ( + versionedAppDir, + extraGccViaCFlags, systemPackageConfig, + pgm_L, pgm_P, pgm_F, pgm_c, pgm_s, pgm_a, pgm_l, pgm_dll, pgm_T, +- pgm_windres, pgm_libtool, pgm_lo, pgm_lc, pgm_i, ++ pgm_windres, pgm_libtool, pgm_lo, pgm_lc, pgm_lcc, pgm_i, + opt_L, opt_P, opt_F, opt_c, opt_a, opt_l, opt_i, +- opt_windres, opt_lo, opt_lc, ++ opt_windres, opt_lo, opt_lc, opt_lcc, + + + -- ** Manipulating DynFlags +@@ -407,6 +410,7 @@ data GeneralFlag + | Opt_DoAsmLinting + | Opt_DoAnnotationLinting + | Opt_NoLlvmMangler -- hidden flag ++ | Opt_FastLlvm -- hidden flag + + | Opt_WarnIsError -- -Werror; makes warnings fatal + | Opt_ShowWarnGroups -- Show the group a warning belongs to +@@ -695,6 +699,7 @@ data DynFlags = DynFlags { + ghcLink :: GhcLink, + hscTarget :: HscTarget, + settings :: Settings, ++ llvmTargets :: LlvmTargets, + verbosity :: Int, -- ^ Verbosity level: see Note [Verbosity levels] + optLevel :: Int, -- ^ Optimisation level + debugLevel :: Int, -- ^ How much debug information to produce +@@ -999,6 +1004,14 @@ data ProfAuto + | ProfAutoCalls -- ^ annotate call-sites + deriving (Eq,Enum) + ++data LlvmTarget = LlvmTarget ++ { lDataLayout :: String ++ , lCPU :: String ++ , lAttributes :: [String] ++ } ++ ++type LlvmTargets = [(String, LlvmTarget)] ++ + data Settings = Settings { + sTargetPlatform :: Platform, -- Filled in by SysTools + sGhcUsagePath :: FilePath, -- Filled in by SysTools +@@ -1031,6 +1044,7 @@ data Settings = Settings { + sPgm_libtool :: String, + sPgm_lo :: (String,[Option]), -- LLVM: opt llvm optimiser + sPgm_lc :: (String,[Option]), -- LLVM: llc static compiler ++ sPgm_lcc :: (String,[Option]), -- LLVM: c compiler + sPgm_i :: String, + -- options for particular phases + sOpt_L :: [String], +@@ -1042,6 +1056,7 @@ data Settings = Settings { + sOpt_windres :: [String], + sOpt_lo :: [String], -- LLVM: llvm optimiser + sOpt_lc :: [String], -- LLVM: llc static compiler ++ sOpt_lcc :: [String], -- LLVM: c compiler + sOpt_i :: [String], -- iserv options + + sPlatformConstants :: PlatformConstants +@@ -1089,6 +1104,8 @@ pgm_windres :: DynFlags -> String + pgm_windres dflags = sPgm_windres (settings dflags) + pgm_libtool :: DynFlags -> String + pgm_libtool dflags = sPgm_libtool (settings dflags) ++pgm_lcc :: DynFlags -> (String,[Option]) ++pgm_lcc dflags = sPgm_lcc (settings dflags) + pgm_lo :: DynFlags -> (String,[Option]) + pgm_lo dflags = sPgm_lo (settings dflags) + pgm_lc :: DynFlags -> (String,[Option]) +@@ -1112,6 +1129,8 @@ opt_l dflags = concatMap (wayOptl (targetPlatform dflags)) (ways dflags) + ++ sOpt_l (settings dflags) + opt_windres :: DynFlags -> [String] + opt_windres dflags = sOpt_windres (settings dflags) ++opt_lcc :: DynFlags -> [String] ++opt_lcc dflags = sOpt_lcc (settings dflags) + opt_lo :: DynFlags -> [String] + opt_lo dflags = sOpt_lo (settings dflags) + opt_lc :: DynFlags -> [String] +@@ -1547,8 +1566,8 @@ initDynFlags dflags = do + + -- | The normal 'DynFlags'. Note that they are not suitable for use in this form + -- and must be fully initialized by 'GHC.runGhc' first. +-defaultDynFlags :: Settings -> DynFlags +-defaultDynFlags mySettings = ++defaultDynFlags :: Settings -> LlvmTargets -> DynFlags ++defaultDynFlags mySettings myLlvmTargets = + -- See Note [Updating flag description in the User's Guide] + DynFlags { + ghcMode = CompManager, +@@ -1641,6 +1660,8 @@ defaultDynFlags mySettings = + rtsBuildTag = mkBuildTag (defaultWays mySettings), + splitInfo = Nothing, + settings = mySettings, ++ llvmTargets = myLlvmTargets, ++ + -- ghc -M values + depMakefile = "Makefile", + depIncludePkgDeps = False, +@@ -3067,6 +3088,8 @@ dynamic_flags_deps = [ + (NoArg (setGeneralFlag Opt_D_faststring_stats)) + , make_ord_flag defGhcFlag "dno-llvm-mangler" + (NoArg (setGeneralFlag Opt_NoLlvmMangler)) -- hidden flag ++ , make_ord_flag defGhcFlag "fast-llvm" ++ (NoArg (setGeneralFlag Opt_FastLlvm)) -- hidden flag + , make_ord_flag defGhcFlag "ddump-debug" + (setDumpFlag Opt_D_dump_debug) + , make_ord_flag defGhcFlag "ddump-json" +@@ -5244,9 +5267,10 @@ makeDynFlagsConsistent dflags + -- initialized. + defaultGlobalDynFlags :: DynFlags + defaultGlobalDynFlags = +- (defaultDynFlags settings) { verbosity = 2 } ++ (defaultDynFlags settings llvmTargets) { verbosity = 2 } + where +- settings = panic "v_unsafeGlobalDynFlags: not initialised" ++ settings = panic "v_unsafeGlobalDynFlags: settings not initialised" ++ llvmTargets = panic "v_unsafeGlobalDynFlags: llvmTargets not initialised" + + #if STAGE < 2 + GLOBAL_VAR(v_unsafeGlobalDynFlags, defaultGlobalDynFlags, DynFlags) +diff --git a/compiler/main/GHC.hs b/compiler/main/GHC.hs +index 8f508411b6..700e4826d1 100644 +--- a/compiler/main/GHC.hs ++++ b/compiler/main/GHC.hs +@@ -489,7 +489,8 @@ initGhcMonad :: GhcMonad m => Maybe FilePath -> m () + initGhcMonad mb_top_dir + = do { env <- liftIO $ + do { mySettings <- initSysTools mb_top_dir +- ; dflags <- initDynFlags (defaultDynFlags mySettings) ++ ; myLlvmTargets <- initLlvmTargets mb_top_dir ++ ; dflags <- initDynFlags (defaultDynFlags mySettings myLlvmTargets) + ; checkBrokenTablesNextToCode dflags + ; setUnsafeGlobalDynFlags dflags + -- c.f. DynFlags.parseDynamicFlagsFull, which +diff --git a/compiler/main/HscTypes.hs b/compiler/main/HscTypes.hs +index 56d2ac5eb9..e16452bca1 100644 +--- a/compiler/main/HscTypes.hs ++++ b/compiler/main/HscTypes.hs +@@ -2578,7 +2578,6 @@ soExt :: Platform -> FilePath + soExt platform + = case platformOS platform of + OSDarwin -> "dylib" +- OSiOS -> "dylib" + OSMinGW32 -> "dll" + _ -> "so" + +diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs +index b2d85a782a..61cc24efcf 100644 +--- a/compiler/main/SysTools.hs ++++ b/compiler/main/SysTools.hs +@@ -13,6 +13,7 @@ + module SysTools ( + -- Initialisation + initSysTools, ++ initLlvmTargets, + + -- Interface to system tools + runUnlit, runCpp, runCc, -- [Option] -> IO () +@@ -187,6 +188,20 @@ stuff. + ************************************************************************ + -} + ++initLlvmTargets :: Maybe String ++ -> IO LlvmTargets ++initLlvmTargets mbMinusB ++ = do top_dir <- findTopDir mbMinusB ++ let llvmTargetsFile = top_dir "llvm-targets" ++ llvmTargetsStr <- readFile llvmTargetsFile ++ case maybeReadFuzzy llvmTargetsStr of ++ Just s -> return (fmap mkLlvmTarget <$> s) ++ Nothing -> pgmError ("Can't parse " ++ show llvmTargetsFile) ++ where ++ mkLlvmTarget :: (String, String, String) -> LlvmTarget ++ mkLlvmTarget (dl, cpu, attrs) = LlvmTarget dl cpu (words attrs) ++ ++ + initSysTools :: Maybe String -- Maybe TopDir path (without the '-B' prefix) + -> IO Settings -- Set all the mutable variables above, holding + -- (a) the system programs +@@ -322,6 +337,7 @@ initSysTools mbMinusB + -- We just assume on command line + lc_prog <- getSetting "LLVM llc command" + lo_prog <- getSetting "LLVM opt command" ++ lcc_prog <- getSetting "LLVM clang command" + + let iserv_prog = libexec "ghc-iserv" + +@@ -365,6 +381,7 @@ initSysTools mbMinusB + sPgm_libtool = libtool_path, + sPgm_lo = (lo_prog,[]), + sPgm_lc = (lc_prog,[]), ++ sPgm_lcc = (lcc_prog,[]), + sPgm_i = iserv_prog, + sOpt_L = [], + sOpt_P = [], +@@ -373,6 +390,7 @@ initSysTools mbMinusB + sOpt_a = [], + sOpt_l = [], + sOpt_windres = [], ++ sOpt_lcc = [], + sOpt_lo = [], + sOpt_lc = [], + sOpt_i = [], +@@ -587,8 +605,7 @@ runLlvmLlc dflags args = do + -- assembler) + runClang :: DynFlags -> [Option] -> IO () + runClang dflags args = do +- -- we simply assume its available on the PATH +- let clang = "clang" ++ let (clang,_) = pgm_lcc dflags + -- be careful what options we call clang with + -- see #5903 and #7617 for bugs caused by this. + (_,args0) = pgm_a dflags +@@ -818,9 +835,6 @@ getLinkerInfo' dflags = do + -- that doesn't support --version. We can just assume that's + -- what we're using. + return $ DarwinLD [] +- OSiOS -> +- -- Ditto for iOS +- return $ DarwinLD [] + OSMinGW32 -> + -- GHC doesn't support anything but GNU ld on Windows anyway. + -- Process creation is also fairly expensive on win32, so +@@ -1666,7 +1680,7 @@ linkDynLib dflags0 o_files dep_packages + ++ pkg_lib_path_opts + ++ pkg_link_opts + )) +- OSDarwin -> do ++ _ | os == OSDarwin -> do + ------------------------------------------------------------------- + -- Making a darwin dylib + ------------------------------------------------------------------- +@@ -1726,7 +1740,6 @@ linkDynLib dflags0 o_files dep_packages + ++ map Option pkg_link_opts + ++ map Option pkg_framework_opts + ) +- OSiOS -> throwGhcExceptionIO (ProgramError "dynamic libraries are not supported on iOS target") + _ -> do + ------------------------------------------------------------------- + -- Making a DSO +diff --git a/compiler/nativeGen/RegAlloc/Linear/Main.hs b/compiler/nativeGen/RegAlloc/Linear/Main.hs +index b7721880c3..c98a8e4773 100644 +--- a/compiler/nativeGen/RegAlloc/Linear/Main.hs ++++ b/compiler/nativeGen/RegAlloc/Linear/Main.hs +@@ -496,7 +496,7 @@ genRaInsn block_live new_instrs block_id instr r_dying w_dying = do + -- debugging + {- freeregs <- getFreeRegsR + assig <- getAssigR +- pprDebugAndThen (defaultDynFlags Settings{ sTargetPlatform=platform }) trace "genRaInsn" ++ pprDebugAndThen (defaultDynFlags Settings{ sTargetPlatform=platform } undefined) trace "genRaInsn" + (ppr instr + $$ text "r_dying = " <+> ppr r_dying + $$ text "w_dying = " <+> ppr w_dying +diff --git a/compiler/specialise/SpecConstr.hs b/compiler/specialise/SpecConstr.hs +index f686f0fba1..647f696640 100644 +--- a/compiler/specialise/SpecConstr.hs ++++ b/compiler/specialise/SpecConstr.hs +@@ -514,7 +514,7 @@ for nested bindings. (So really it should be passed around explicitly + and not stored in ScEnv.) Trac #14379 turned out to be caused by + f SPEC x = let g1 x = ... + in ... +-We force-specialise f (becuase of the SPEC), but that generates a specialised ++We force-specialise f (because of the SPEC), but that generates a specialised + copy of g1 (as well as the original). Alas g1 has a nested binding g2; and + in each copy of g1 we get an unspecialised and specialised copy of g2; and so + on. Result, exponential. So the force-spec flag now only applies to one +@@ -524,7 +524,7 @@ Mechanism for this one-level-only thing: + + - Switch it on at the call to specRec, in scExpr and scTopBinds + - Switch it off when doing the RHSs; +- this can be done very conveneniently in decreaseSpecCount ++ this can be done very conveniently in decreaseSpecCount + + What alternatives did I consider? + +diff --git a/compiler/typecheck/TcCanonical.hs b/compiler/typecheck/TcCanonical.hs +index 0221a3e3ac..0635b4a0dd 100644 +--- a/compiler/typecheck/TcCanonical.hs ++++ b/compiler/typecheck/TcCanonical.hs +@@ -1575,7 +1575,7 @@ canEqTyVarTyVar, are these + + Note [Avoid unnecessary swaps] + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +-If we swap without actually improving matters, we can get an infnite loop. ++If we swap without actually improving matters, we can get an infinite loop. + Consider + work item: a ~ b + inert item: b ~ c +diff --git a/compiler/typecheck/TcInteract.hs b/compiler/typecheck/TcInteract.hs +index 5bbc5f86aa..9af719812a 100644 +--- a/compiler/typecheck/TcInteract.hs ++++ b/compiler/typecheck/TcInteract.hs +@@ -2009,9 +2009,9 @@ favour of alpha. If we instead had + then we would unify alpha := gamma1; and kick out the wanted + constraint. But when we grough it back in, it'd look like + [W] TF (gamma1, beta) ~ fuv +-and exactly the same thing would happen again! Infnite loop. ++and exactly the same thing would happen again! Infinite loop. + +-This all sesms fragile, and it might seem more robust to avoid ++This all seems fragile, and it might seem more robust to avoid + introducing gamma1 in the first place, in the case where the + actual argument (alpha, beta) partly matches the improvement + template. But that's a bit tricky, esp when we remember that the +diff --git a/compiler/utils/Platform.hs b/compiler/utils/Platform.hs +index 86c70a9789..8cd1fa75e3 100644 +--- a/compiler/utils/Platform.hs ++++ b/compiler/utils/Platform.hs +@@ -16,7 +16,6 @@ module Platform ( + osMachOTarget, + osSubsectionsViaSymbols, + platformUsesFrameworks, +- platformBinariesAreStaticLibs, + ) + + where +@@ -76,7 +75,6 @@ data OS + = OSUnknown + | OSLinux + | OSDarwin +- | OSiOS + | OSSolaris2 + | OSMinGW32 + | OSFreeBSD +@@ -86,7 +84,6 @@ data OS + | OSKFreeBSD + | OSHaiku + | OSQNXNTO +- | OSAndroid + | OSAIX + deriving (Read, Show, Eq) + +@@ -132,12 +129,10 @@ osElfTarget OSOpenBSD = True + osElfTarget OSNetBSD = True + osElfTarget OSSolaris2 = True + osElfTarget OSDarwin = False +-osElfTarget OSiOS = False + osElfTarget OSMinGW32 = False + osElfTarget OSKFreeBSD = True + osElfTarget OSHaiku = True + osElfTarget OSQNXNTO = False +-osElfTarget OSAndroid = True + osElfTarget OSAIX = False + osElfTarget OSUnknown = False + -- Defaulting to False is safe; it means don't rely on any +@@ -152,21 +147,12 @@ osMachOTarget _ = False + + osUsesFrameworks :: OS -> Bool + osUsesFrameworks OSDarwin = True +-osUsesFrameworks OSiOS = True + osUsesFrameworks _ = False + + platformUsesFrameworks :: Platform -> Bool + platformUsesFrameworks = osUsesFrameworks . platformOS + +-osBinariesAreStaticLibs :: OS -> Bool +-osBinariesAreStaticLibs OSiOS = True +-osBinariesAreStaticLibs _ = False +- + osSubsectionsViaSymbols :: OS -> Bool + osSubsectionsViaSymbols OSDarwin = True +-osSubsectionsViaSymbols OSiOS = True + osSubsectionsViaSymbols _ = False + +-platformBinariesAreStaticLibs :: Platform -> Bool +-platformBinariesAreStaticLibs = osBinariesAreStaticLibs . platformOS +- +diff --git a/configure.ac b/configure.ac +index 846f5596f2..c79ecc524a 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -201,7 +201,8 @@ dnl we ask the bootstrapping compiler what platform it is for + if test "${WithGhc}" != "" + then + bootstrap_host=`"${WithGhc}" +RTS --info | grep '^ ,("Host platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'` +- bootstrap_target=`"${WithGhc}" +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r'` ++ # Turn darwin -> macos to deal with the changing default ++ bootstrap_target=`"${WithGhc}" +RTS --info | grep '^ ,("Target platform"' | sed -e 's/.*, "//' -e 's/")//' | tr -d '\r' | sed s/darwin/macos/` + if test "$bootstrap_host" != "$bootstrap_target" + then + echo "Bootstrapping GHC is a cross compiler. This probably isn't going to work" +@@ -513,7 +514,8 @@ dnl ** Which nm to use? + dnl -------------------------------------------------------------- + FP_ARG_WITH_PATH_GNU_PROG([NM], [nm], [nm]) + +-if test "$TargetOS_CPP" = "darwin" ++# Use `HaskellTargetOs` in order to conflate Darwin variants ++if test "$HaskellTargetOs" = "OSDarwin" + then + AC_MSG_CHECKING(whether nm program is broken) + # Some versions of XCode ship a broken version of `nm`. Detect and work +@@ -587,6 +589,12 @@ AC_SUBST([LlvmVersion]) + sUPPORTED_LLVM_VERSION=$(echo \($LlvmVersion\) | sed 's/\./,/') + AC_DEFINE_UNQUOTED([sUPPORTED_LLVM_VERSION], ${sUPPORTED_LLVM_VERSION}, [The supported LLVM version number]) + ++dnl ** Which LLVM clang to use? ++dnl -------------------------------------------------------------- ++AC_CHECK_TARGET_TOOL([CLANG], [clang]) ++ClangCmd="$CLANG" ++AC_SUBST([ClangCmd]) ++ + dnl ** Which LLVM llc to use? + dnl -------------------------------------------------------------- + FIND_LLVM_PROG([LLC], [llc], [llc], [$LlvmVersion]) +@@ -729,9 +737,15 @@ dnl ** check for dtrace (currently only implemented for Mac OS X) + HaveDtrace=NO + AC_PATH_PROG(DtraceCmd,dtrace) + if test -n "$DtraceCmd"; then +- if test "x$TargetOS_CPP-$TargetVendor_CPP" = "xdarwin-apple" -o "x$TargetOS_CPP-$TargetVendor_CPP" = "xsolaris2-unknown"; then +- HaveDtrace=YES +- fi ++ # Use `HaskellTargetOs` in order to conflate Darwin variants ++ case "$HaskellTargetOs-$TargetVendor_CPP" in ++ OSDarwin-apple|OSSolaris2-unknown) ++ HaveDtrace=YES ++ ;; ++ *) ++ HaveDtrace=NO ++ ;; ++ esac + fi + AC_SUBST(HaveDtrace) + +@@ -1065,14 +1079,18 @@ AC_ARG_ENABLE(large-address-space, + use_large_address_space=no + if test "$ac_cv_sizeof_void_p" -eq 8 ; then + if test "x$EnableLargeAddressSpace" = "xyes" ; then +- if test "$ghc_host_os" = "darwin" ; then ++ case "$ghc_host_os" in ++ # Darwin for back-compat ++ darwin|macos|ios|watchos|tvos) + use_large_address_space=yes +- elif test "$ghc_host_os" = "openbsd" ; then +- # as of OpenBSD 5.8 (2015), OpenBSD does not support mmap with MAP_NORESERVE. +- # The flag MAP_NORESERVE is supported for source compatibility reasons, +- # but is completely ignored by OS mmap ++ ;; ++ openbsd) ++ # as of OpenBSD 5.8 (2015), OpenBSD does not support mmap with MAP_NORESERVE. ++ # The flag MAP_NORESERVE is supported for source compatibility reasons, ++ # but is completely ignored by OS mmap + use_large_address_space=no +- else ++ ;; ++ *) + AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],[],[], + [ + #include +@@ -1085,7 +1103,8 @@ if test "$ac_cv_sizeof_void_p" -eq 8 ; then + test "$ac_cv_have_decl_MADV_DONTNEED" = "yes" ; then + use_large_address_space=yes + fi +- fi ++ ;; ++ esac + fi + fi + if test "$use_large_address_space" = "yes" ; then +@@ -1099,8 +1118,8 @@ case ${TargetOS} in + linux|linux-android|freebsd|dragonfly|netbsd|openbsd|kfreebsdgnu|gnu|solaris2) + RtsLinkerUseMmap=1 + ;; +- darwin) +- # Don't use mmap on powerpc/darwin as the mmap there doesn't support ++ macos|ios|watchos|tvos) ++ # Don't use mmap on PowerPC/Darwin as the mmap there doesn't support + # reallocating. Reallocating is needed to allocate jump islands just + # after each object image. Jumps to these jump islands use relative + # branches which are limited to offsets that can be represented in +@@ -1263,6 +1282,7 @@ echo "\ + xelatex : $XELATEX + + Using LLVM tools ++ clang : $ClangCmd + llc : $LlcCmd + opt : $OptCmd" + +diff --git a/docs/users_guide/phases.rst b/docs/users_guide/phases.rst +index afb3a8be5c..6288961b14 100644 +--- a/docs/users_guide/phases.rst ++++ b/docs/users_guide/phases.rst +@@ -551,11 +551,9 @@ for example). + + .. ghc-flag:: -staticlib + +- On Darwin/OS X/iOS only, link all passed files into a static library +- suitable for linking into an iOS (when using a cross-compiler) or +- Mac Xcode project. To control the name, use the :ghc-flag:`-o ⟨file⟩` option +- as usual. The default name is ``liba.a``. This should nearly always +- be passed when compiling for iOS with a cross-compiler. ++ Link all passed files into a static library suitable for linking. ++ To control the name, use the :ghc-flag:`-o` ⟨name⟩ option ++ as usual. The default name is ``liba.a``. + + .. ghc-flag:: -L ⟨dir⟩ + +diff --git a/ghc.mk b/ghc.mk +index 5b9cf22454..87628166ff 100644 +--- a/ghc.mk ++++ b/ghc.mk +@@ -541,9 +541,6 @@ utils/ghc-pkg/dist-install/package-data.mk: $(fixed_pkg_prev) + utils/hsc2hs/dist-install/package-data.mk: $(fixed_pkg_prev) + utils/compare_sizes/dist-install/package-data.mk: $(fixed_pkg_prev) + utils/runghc/dist-install/package-data.mk: $(fixed_pkg_prev) +-iserv/stage2/package-data.mk: $(fixed_pkg_prev) +-iserv/stage2_p/package-data.mk: $(fixed_pkg_prev) +-iserv/stage2_dyn/package-data.mk: $(fixed_pkg_prev) + + # the GHC package doesn't live in libraries/, so we add its dependency manually: + compiler/stage2/package-data.mk: $(fixed_pkg_prev) +@@ -694,7 +691,6 @@ BUILD_DIRS += utils/mkUserGuidePart + BUILD_DIRS += docs/users_guide + BUILD_DIRS += utils/count_lines + BUILD_DIRS += utils/compare_sizes +-BUILD_DIRS += iserv + + # ---------------------------------------------- + # Actually include the sub-ghc.mk's +@@ -1035,6 +1031,7 @@ $(eval $(call bindist-list,.,\ + INSTALL \ + configure config.sub config.guess install-sh \ + settings.in \ ++ llvm-targets \ + packages \ + Makefile \ + mk/config.mk.in \ +@@ -1061,7 +1058,7 @@ $(eval $(call bindist-list,.,\ + $(wildcard compiler/stage2/doc) \ + $(wildcard libraries/*/dist-install/doc/) \ + $(wildcard libraries/*/*/dist-install/doc/) \ +- $(filter-out settings,$(INSTALL_LIBS)) \ ++ $(filter-out settings llvm-targets,$(INSTALL_LIBS)) \ + $(RTS_INSTALL_LIBS) \ + $(filter-out %/project.mk mk/config.mk %/mk/install.mk,$(MAKEFILE_LIST)) \ + mk/project.mk \ +@@ -1094,7 +1091,7 @@ BIN_DIST_MK = $(BIN_DIST_PREP_DIR)/bindist.mk + unix-binary-dist-prep: + $(call removeTrees,bindistprep/) + "$(MKDIRHIER)" $(BIN_DIST_PREP_DIR) +- set -e; for i in packages LICENSE compiler ghc iserv rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh settings.in ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL; do ln -s ../../$$i $(BIN_DIST_PREP_DIR)/; done ++ set -e; for i in packages LICENSE compiler ghc rts libraries utils docs libffi includes driver mk rules Makefile aclocal.m4 config.sub config.guess install-sh settings.in llvm-targets ghc.mk inplace distrib/configure.ac distrib/README distrib/INSTALL; do ln -s ../../$$i $(BIN_DIST_PREP_DIR)/; done + echo "HADDOCK_DOCS = $(HADDOCK_DOCS)" >> $(BIN_DIST_MK) + echo "BUILD_SPHINX_HTML = $(BUILD_SPHINX_HTML)" >> $(BIN_DIST_MK) + echo "BUILD_SPHINX_PDF = $(BUILD_SPHINX_PDF)" >> $(BIN_DIST_MK) +@@ -1188,11 +1185,11 @@ SRC_DIST_TESTSUITE_TARBALL = $(SRC_DIST_ROOT)/$(SRC_DIST_TESTSUITE_NAME). + # Files to include in source distributions + # + SRC_DIST_GHC_DIRS = mk rules docs distrib bindisttest libffi includes \ +- utils docs rts compiler ghc driver libraries libffi-tarballs iserv ++ utils docs rts compiler ghc driver libraries libffi-tarballs + SRC_DIST_GHC_FILES += \ + configure.ac config.guess config.sub configure \ + aclocal.m4 README.md ANNOUNCE HACKING.md INSTALL.md LICENSE Makefile \ +- install-sh settings.in VERSION GIT_COMMIT_ID \ ++ install-sh settings.in llvm-targets VERSION GIT_COMMIT_ID \ + boot packages ghc.mk MAKEHELP.md + + .PHONY: VERSION +diff --git a/ghc/GHCi/UI.hs b/ghc/GHCi/UI.hs +index f677e995d0..47aa83baff 100644 +--- a/ghc/GHCi/UI.hs ++++ b/ghc/GHCi/UI.hs +@@ -2519,7 +2519,7 @@ showDynFlags show_all dflags = do + is_on = test f dflags + quiet = not show_all && test f default_dflags == is_on + +- default_dflags = defaultDynFlags (settings dflags) ++ default_dflags = defaultDynFlags (settings dflags) (llvmTargets dflags) + + (ghciFlags,others) = partition (\f -> flagSpecFlag f `elem` flgs) + DynFlags.fFlags +@@ -2930,7 +2930,7 @@ showLanguages' show_all dflags = + quiet = not show_all && test f default_dflags == is_on + + default_dflags = +- defaultDynFlags (settings dflags) `lang_set` ++ defaultDynFlags (settings dflags) (llvmTargets dflags) `lang_set` + case language dflags of + Nothing -> Just Haskell2010 + other -> other +diff --git a/ghc/Main.hs b/ghc/Main.hs +index cc6d08ee45..5926718f3f 100644 +--- a/ghc/Main.hs ++++ b/ghc/Main.hs +@@ -804,7 +804,7 @@ dumpFastStringStats dflags = do + ]) + -- we usually get more "has z-encoding" than "z-encoded", because + -- when we z-encode a string it might hash to the exact same string, +- -- which will is not counted as "z-encoded". Only strings whose ++ -- which is not counted as "z-encoded". Only strings whose + -- Z-encoding is different from the original string are counted in + -- the "z-encoded" total. + putMsg dflags msg +diff --git a/ghc/ghc.mk b/ghc/ghc.mk +index 8d4c1dfe8e..921e5666af 100644 +--- a/ghc/ghc.mk ++++ b/ghc/ghc.mk +@@ -133,6 +133,9 @@ all_ghc_stage3 : $(GHC_STAGE3) + $(INPLACE_LIB)/settings : settings + "$(CP)" $< $@ + ++$(INPLACE_LIB)/llvm-targets : llvm-targets ++ "$(CP)" $< $@ ++ + $(INPLACE_LIB)/platformConstants: $(includes_GHCCONSTANTS_HASKELL_VALUE) + "$(CP)" $< $@ + +@@ -141,6 +144,7 @@ $(INPLACE_LIB)/platformConstants: $(includes_GHCCONSTANTS_HASKELL_VALUE) + + GHC_DEPENDENCIES += $$(unlit_INPLACE) + GHC_DEPENDENCIES += $(INPLACE_LIB)/settings ++GHC_DEPENDENCIES += $(INPLACE_LIB)/llvm-targets + GHC_DEPENDENCIES += $(INPLACE_LIB)/platformConstants + + $(GHC_STAGE1) : | $(GHC_DEPENDENCIES) +@@ -168,6 +172,7 @@ $(GHC_STAGE2) : $(foreach w,$(GhcLibWays),libraries/base/dist-install/build/GHC/ + endif + + INSTALL_LIBS += settings ++INSTALL_LIBS += llvm-targets + + ifeq "$(Windows_Host)" "NO" + install: install_ghc_link +diff --git a/includes/ghc.mk b/includes/ghc.mk +index d08ecfbc07..31efbb0cd0 100644 +--- a/includes/ghc.mk ++++ b/includes/ghc.mk +@@ -144,6 +144,13 @@ $(includes_H_PLATFORM) : includes/Makefile | $$(dir $$@)/. + @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@ + @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@ + @echo >> $@ ++ @echo "#if defined(macos_BUILD_OS) || defined(ios_BUILD_OS)" >> $@ ++ @echo "# define darwin_BUILD_OS 1" >> $@ ++ @echo "#endif" >> $@ ++ @echo "#if defined(macos_HOST_OS) || defined(ios_HOST_OS)" >> $@ ++ @echo "# define darwin_HOST_OS 1" >> $@ ++ @echo "#endif" >> $@ ++ @echo >> $@ + @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@ + @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@ + @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@ +diff --git a/libraries/base/GHC/Event/Manager.hs b/libraries/base/GHC/Event/Manager.hs +index 013850b5d2..cee0579f3c 100644 +--- a/libraries/base/GHC/Event/Manager.hs ++++ b/libraries/base/GHC/Event/Manager.hs +@@ -146,7 +146,7 @@ callbackTableVar mgr fd = emFds mgr ! hashFd fd + + haveOneShot :: Bool + {-# INLINE haveOneShot #-} +-#if defined(darwin_HOST_OS) || defined(ios_HOST_OS) ++#ifdef darwin_HOST_OS + haveOneShot = False + #elif defined(HAVE_EPOLL) || defined(HAVE_KQUEUE) + haveOneShot = True +@@ -372,7 +372,7 @@ registerFd mgr cb fd evs lt = do + -} + -- | Wake up the event manager. + wakeManager :: EventManager -> IO () +-#if defined(darwin_HOST_OS) || defined(ios_HOST_OS) ++#ifdef darwin_HOST_OS + wakeManager mgr = sendWakeup (emControl mgr) + #elif defined(HAVE_EPOLL) || defined(HAVE_KQUEUE) + wakeManager _ = return () +diff --git a/libraries/base/cbits/DarwinUtils.c b/libraries/base/cbits/DarwinUtils.c +index d080934104..b8cd9da966 100644 +--- a/libraries/base/cbits/DarwinUtils.c ++++ b/libraries/base/cbits/DarwinUtils.c +@@ -1,6 +1,6 @@ + #include "HsBase.h" + +-#if defined(darwin_HOST_OS) || defined(ios_HOST_OS) ++#ifdef darwin_HOST_OS + #include + + static double scaling_factor = 0.0; +diff --git a/libraries/base/configure.ac b/libraries/base/configure.ac +index 69ea800a7f..f472319a7e 100644 +--- a/libraries/base/configure.ac ++++ b/libraries/base/configure.ac +@@ -69,7 +69,7 @@ if test "$ac_cv_header_poll_h" = yes && test "$ac_cv_func_poll" = yes; then + AC_DEFINE([HAVE_POLL], [1], [Define if you have poll support.]) + fi + +-# Linux open file description locks ++# Linux open file descriptor locks + AC_CHECK_DECL([F_OFD_SETLK], [ + AC_DEFINE([HAVE_OFD_LOCKING], [1], [Define if you have open file descriptor lock support.]) + ]) +diff --git a/libraries/base/include/HsBase.h b/libraries/base/include/HsBase.h +index cfe046426d..401359a562 100644 +--- a/libraries/base/include/HsBase.h ++++ b/libraries/base/include/HsBase.h +@@ -534,11 +534,15 @@ INLINE int __hscore_open(char *file, int how, mode_t mode) { + } + #endif + +-#if darwin_HOST_OS ++#if macos_HOST_OS + // You should not access _environ directly on Darwin in a bundle/shared library. + // See #2458 and http://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man7/environ.7.html + #include + INLINE char **__hscore_environ(void) { return *(_NSGetEnviron()); } ++#elif ios_HOST_OS ++// _NSGetEnviron is a "private API" and will cause an app store rejection. ++char* const __hscore_fake_envion[] = { NULL }; ++INLINE char **__hscore_environ(void) { return __hscore_fake_envion; } + #else + /* ToDo: write a feature test that doesn't assume 'environ' to + * be in scope at link-time. */ +diff --git a/llvm-targets b/llvm-targets +new file mode 100644 +index 0000000000..b67ee6ccfa +--- /dev/null ++++ b/llvm-targets +@@ -0,0 +1,25 @@ ++[("i386-unknown-windows", ("e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32", "pentium4", "")) ++,("i686-unknown-windows", ("e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32", "pentium4", "")) ++,("x86_64-unknown-windows", ("e-m:w-i64:64-f80:128-n8:16:32:64-S128", "x86-64", "")) ++,("arm-unknown-linux-gnueabihf", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "arm1176jzf-s", "+strict-align")) ++,("armv6-unknown-linux-gnueabihf", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "arm1136jf-s", "+strict-align")) ++,("armv6l-unknown-linux-gnueabihf", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "arm1176jzf-s", "+strict-align")) ++,("armv7-unknown-linux-gnueabihf", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "generic", "")) ++,("armv7a-unknown-linux-gnueabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "generic", "")) ++,("armv7l-unknown-linux-gnueabihf", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "generic", "")) ++,("aarch64-unknown-linux-gnu", ("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128", "generic", "+neon")) ++,("aarch64-unknown-linux", ("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128", "generic", "+neon")) ++,("i386-unknown-linux-gnu", ("e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128", "pentium4", "")) ++,("i386-unknown-linux", ("e-m:e-p:32:32-f64:32:64-f80:32-n8:16:32-S128", "pentium4", "")) ++,("x86_64-unknown-linux-gnu", ("e-m:e-i64:64-f80:128-n8:16:32:64-S128", "x86-64", "")) ++,("x86_64-unknown-linux", ("e-m:e-i64:64-f80:128-n8:16:32:64-S128", "x86-64", "")) ++,("armv7-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "generic", "")) ++,("aarch64-unknown-linux-android", ("e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128", "generic", "+neon")) ++,("arm-unknown-nto-qnx-eabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "arm7tdmi", "+strict-align")) ++,("i386-apple-darwin", ("e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128", "yonah", "")) ++,("x86_64-apple-darwin", ("e-m:o-i64:64-f80:128-n8:16:32:64-S128", "core2", "")) ++,("armv7-apple-ios", ("e-m:o-p:32:32-f64:32:64-v64:32:64-v128:32:128-a:0:32-n32-S32", "generic", "")) ++,("aarch64-apple-ios", ("e-m:o-i64:64-i128:128-n32:64-S128", "generic", "+neon")) ++,("i386-apple-ios", ("e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128", "yonah", "")) ++,("x86_64-apple-ios", ("e-m:o-i64:64-f80:128-n8:16:32:64-S128", "core2", "")) ++] +diff --git a/mk/config.mk.in b/mk/config.mk.in +index fcbc32d7df..c740f64e2e 100644 +--- a/mk/config.mk.in ++++ b/mk/config.mk.in +@@ -745,6 +745,7 @@ NM = @NmCmd@ + AR = @ArCmd@ + OBJDUMP = @ObjdumpCmd@ + ++CLANG = @ClangCmd@ + LLC = @LlcCmd@ + OPT = @OptCmd@ + +diff --git a/mk/project.mk.in b/mk/project.mk.in +index 03bd7441cb..d620ed5a61 100644 +--- a/mk/project.mk.in ++++ b/mk/project.mk.in +@@ -12,7 +12,7 @@ + # Versioning scheme: A.B.C + # A: major version, decimal, any number of digits + # B: minor version, decimal, any number of digits +-# C: patchlevel, one digit, omitted if zero. ++# C: patchlevel, one digit, omitted if zero. + # + # ProjectVersionInt does *not* contain the patchlevel (rationale: this + # figure is used for conditional compilations, and library interfaces +@@ -35,7 +35,7 @@ ProjectGitCommitId = @ProjectGitCommitId@ + + ################################################################################ + # +-# Platform variables ++# Platform variables + # + ################################################################################ + +@@ -81,24 +81,25 @@ ProjectGitCommitId = @ProjectGitCommitId@ + # You have to do a lot of work by hand to cross compile: see the + # section on "Porting GHC" in the Building Guide. + +-HOSTPLATFORM = @HostPlatform@ +-TARGETPLATFORM = @TargetPlatform@ +-BUILDPLATFORM = @BuildPlatform@ ++HOSTPLATFORM = @HostPlatform@ ++TARGETPLATFORM = @TargetPlatform@ ++BUILDPLATFORM = @BuildPlatform@ + +-HostPlatform_CPP = @HostPlatform_CPP@ +-HostArch_CPP = @HostArch_CPP@ +-HostOS_CPP = @HostOS_CPP@ +-HostVendor_CPP = @HostVendor_CPP@ ++HostPlatform_CPP = @HostPlatform_CPP@ ++HostArch_CPP = @HostArch_CPP@ ++HostOS_CPP = @HostOS_CPP@ ++HostVendor_CPP = @HostVendor_CPP@ + +-TargetPlatform_CPP = @TargetPlatform_CPP@ +-TargetArch_CPP = @TargetArch_CPP@ +-TargetOS_CPP = @TargetOS_CPP@ +-TargetVendor_CPP = @TargetVendor_CPP@ ++TargetPlatform_CPP = @TargetPlatform_CPP@ ++TargetArch_CPP = @TargetArch_CPP@ ++TargetOS_CPP = @TargetOS_CPP@ ++TargetVendor_CPP = @TargetVendor_CPP@ ++LLVMTarget_CPP = @LLVMTarget_CPP@ + +-BuildPlatform_CPP = @BuildPlatform_CPP@ +-BuildArch_CPP = @BuildArch_CPP@ +-BuildOS_CPP = @BuildOS_CPP@ +-BuildVendor_CPP = @BuildVendor_CPP@ ++BuildPlatform_CPP = @BuildPlatform_CPP@ ++BuildArch_CPP = @BuildArch_CPP@ ++BuildOS_CPP = @BuildOS_CPP@ ++BuildVendor_CPP = @BuildVendor_CPP@ + + @HostPlatform_CPP@_HOST = 1 + @TargetPlatform_CPP@_TARGET = 1 +@@ -118,7 +119,7 @@ BuildVendor_CPP = @BuildVendor_CPP@ + + ################################################################################ + # +-# Global configuration options ++# Global configuration options + # + ################################################################################ + +diff --git a/rts/StgCRun.c b/rts/StgCRun.c +index 5f7f2b910f..725f4fb127 100644 +--- a/rts/StgCRun.c ++++ b/rts/StgCRun.c +@@ -116,7 +116,7 @@ StgWord8 *win32AllocStack(void) + + #ifdef i386_HOST_ARCH + +-#if defined(darwin_HOST_OS) || defined(ios_HOST_OS) ++#if defined(darwin_HOST_OS) + #define STG_GLOBAL ".globl " + #define STG_HIDDEN ".private_extern " + #else +@@ -245,7 +245,7 @@ StgRunIsImplementedInAssembler(void) + + #define STG_GLOBAL ".globl " + +-#if defined(darwin_HOST_OS) || defined(ios_HOST_OS) ++#if defined(darwin_HOST_OS) + #define STG_HIDDEN ".private_extern " + #else + #define STG_HIDDEN ".hidden " +diff --git a/rts/linker/LoadArchive.c b/rts/linker/LoadArchive.c +index 4d6b2fecb7..d43e53cea9 100644 +--- a/rts/linker/LoadArchive.c ++++ b/rts/linker/LoadArchive.c +@@ -28,7 +28,7 @@ + + #define DEBUG_LOG(...) IF_DEBUG(linker, debugBelch("loadArchive: " __VA_ARGS__)) + +-#if defined(darwin_HOST_OS) || defined(ios_HOST_OS) ++#if defined(darwin_HOST_OS) + /* Read 4 bytes and convert to host byte order */ + static uint32_t read4Bytes(const char buf[static 4]) + { +@@ -151,7 +151,7 @@ static StgBool checkFatArchive(char magic[static 20], FILE* f, pathchar* path) + { + StgBool success; + success = false; +-#if defined(darwin_HOST_OS) || defined(ios_HOST_OS) ++#if defined(darwin_HOST_OS) + /* Not a standard archive, look for a fat archive magic number: */ + if (read4Bytes(magic) == FAT_MAGIC) + success = loadFatArchive(magic, f, path); +@@ -343,7 +343,7 @@ static HsInt loadArchive_ (pathchar *path) + } + } + +-#if defined(darwin_HOST_OS) || defined(ios_HOST_OS) ++#if defined(darwin_HOST_OS) + if (strncmp(fileName, "!\n", 8) == 0) { + DEBUG_LOG("found the start of another archive, breaking\n"); + break; +@@ -502,7 +502,7 @@ static HsInt loadArchive_ (pathchar *path) + // cannot currently allocate blocks large enough. + image = allocateImageAndTrampolines(path, fileName, f, memberSize, + isThin); +-#elif defined(darwin_HOST_OS) || defined(ios_HOST_OS) ++#elif defined(darwin_HOST_OS) + if (RTS_LINKER_USE_MMAP) + image = mmapForLinker(memberSize, MAP_ANONYMOUS, -1, 0); + else { +diff --git a/rts/linker/MachO.c b/rts/linker/MachO.c +index 55b2bf1ebc..9e85489115 100644 +--- a/rts/linker/MachO.c ++++ b/rts/linker/MachO.c +@@ -1,7 +1,6 @@ + #include "Rts.h" + + #ifdef darwin_HOST_OS +- + #include "RtsUtils.h" + #include "GetEnv.h" + #include "LinkerInternals.h" +@@ -16,6 +15,9 @@ + #include + #include + #include ++#endif /* darwin_HOST_OS */ ++ ++#ifdef macos_HOST_OS + + #if defined(HAVE_SYS_MMAN_H) + # include +@@ -39,7 +41,7 @@ + *) add still more sanity checks. + */ + +-#if x86_64_HOST_ARCH || powerpc64_HOST_ARCH ++#if x86_64_HOST_ARCH || powerpc64_HOST_ARCH || aarch64_HOST_ARCH + #define mach_header mach_header_64 + #define segment_command segment_command_64 + #define section section_64 +@@ -153,7 +155,7 @@ ocVerifyImage_MachO(ObjectCode * oc) + + IF_DEBUG(linker, debugBelch("ocVerifyImage_MachO: start\n")); + +-#if x86_64_HOST_ARCH || powerpc64_HOST_ARCH ++#if x86_64_HOST_ARCH || powerpc64_HOST_ARCH || aarch64_HOST_ARCH + if(header->magic != MH_MAGIC_64) { + errorBelch("Could not load image %s: bad magic!\n" + " Expected %08x (64bit), got %08x%s\n", +@@ -1205,6 +1207,9 @@ machoInitSymbolsWithoutUnderscore(void) + } + #endif + ++#endif /* macos_HOST_OS */ ++ ++#ifdef darwin_HOST_OS + /* + * Figure out by how much to shift the entire Mach-O file in memory + * when loading so that its single segment ends up 16-byte-aligned +@@ -1223,7 +1228,7 @@ machoGetMisalignment( FILE * f ) + } + fseek(f, -sizeof(header), SEEK_CUR); + +-#if x86_64_HOST_ARCH || powerpc64_HOST_ARCH ++#if x86_64_HOST_ARCH || powerpc64_HOST_ARCH || aarch64_HOST_ARCH + if(header.magic != MH_MAGIC_64) { + barf("Bad magic. Expected: %08x, got: %08x.", + MH_MAGIC_64, header.magic); +@@ -1240,5 +1245,4 @@ machoGetMisalignment( FILE * f ) + + return misalignment ? (16 - misalignment) : 0; + } +- +-#endif /* darwin_HOST_OS */ ++#endif /* darwin_HOST_O */ +diff --git a/rts/posix/GetEnv.c b/rts/posix/GetEnv.c +index e3f731cfed..4527e71155 100644 +--- a/rts/posix/GetEnv.c ++++ b/rts/posix/GetEnv.c +@@ -9,7 +9,7 @@ + #include "Rts.h" + #include "GetEnv.h" + +-#if defined(darwin_HOST_OS) ++#if defined(macos_HOST_OS) + + /* While the "extern char** environ" var does exist on OSX, it is not + * available to shared libs. See ghc ticket #2458 and +@@ -19,6 +19,13 @@ + + static char** get_environ(void) { return *(_NSGetEnviron()); } + ++#elif defined(ios_HOST_OS) ++ ++/* `_NSGetEnviron` is a "private API" and will cause an app store rejection. ++ */ ++static char* const fake_envion[] = { NULL }; ++static char** get_environ(void) { return fake_envion; } ++ + #else + + /* On proper unix systems the environ is just a global var. +diff --git a/rts/posix/Itimer.c b/rts/posix/Itimer.c +index 59d34be5fb..787718fc0b 100644 +--- a/rts/posix/Itimer.c ++++ b/rts/posix/Itimer.c +@@ -32,9 +32,9 @@ + /* + * We want to avoid using the SIGALRM signals whenever possible as these signals + * interrupt system calls (see #10840) and can be overridden by user code. On +- * Darwin we can use a dedicated thread and usleep. ++ * macOS we can use a dedicated thread and usleep. + */ +-#if defined(darwin_HOST_OS) ++#if defined(macos_HOST_OS) + #define USE_PTHREAD_FOR_ITIMER + #endif + +diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c +index d25aaf86de..4d3c869705 100644 +--- a/rts/posix/OSMem.c ++++ b/rts/posix/OSMem.c +@@ -39,7 +39,7 @@ + + #include + +-#if darwin_HOST_OS || ios_HOST_OS ++#ifdef darwin_HOST_OS + #include + #include + #include +@@ -368,7 +368,7 @@ StgWord64 getPhysicalMemorySize (void) + { + static StgWord64 physMemSize = 0; + if (!physMemSize) { +-#if defined(darwin_HOST_OS) || defined(ios_HOST_OS) ++#ifdef darwin_HOST_OS + /* So, darwin doesn't support _SC_PHYS_PAGES, but it does + support getting the raw memory size in bytes through + sysctlbyname(hw.memsize); */ +diff --git a/settings.in b/settings.in +index 04b913b86c..e4deb05b3c 100644 +--- a/settings.in ++++ b/settings.in +@@ -29,6 +29,7 @@ + ("target has RTS linker", "@HaskellHaveRTSLinker@"), + ("Unregisterised", "@Unregisterised@"), + ("LLVM llc command", "@SettingsLlcCommand@"), +- ("LLVM opt command", "@SettingsOptCommand@") ++ ("LLVM opt command", "@SettingsOptCommand@"), ++ ("LLVM clang command", "@SettingsClangCommand@") + ] + +diff --git a/utils/llvm-targets/gen-data-layout.sh b/utils/llvm-targets/gen-data-layout.sh +new file mode 100755 +index 0000000000..3d9ded1a51 +--- /dev/null ++++ b/utils/llvm-targets/gen-data-layout.sh +@@ -0,0 +1,104 @@ ++#!/usr/bin/env bash ++# ++# llvm-target generator ++# ++# Author: Moritz Angermann ++# ++# This file generates the `llvm-targets` file, which contains the ++# data-layout, cpu and attributes for the target. This is done by ++# querying `clang` for the data-layout, cpu and attributes based ++# on a given target. ++# ++# To utilize it run it as ++# ++# $ ./gen-data-layout.sh > llvm-targets ++# ++# Add missing targets to the list below to have them included in ++# llvm-targets file. ++ ++# Target sets for which to generate the llvm-targets file ++TARGETS=( ++ # Windows x86 ++ "i386-unknown-windows" "i686-unknown-windows" "x86_64-unknown-windows" ++ ++ # Linux ARM ++ "arm-unknown-linux-gnueabihf" "armv6-unknown-linux-gnueabihf" "armv6l-unknown-linux-gnueabihf" ++ "armv7-unknown-linux-gnueabihf" "armv7a-unknown-linux-gnueabi" "armv7l-unknown-linux-gnueabihf" ++ "aarch64-unknown-linux-gnu" "aarch64-unknown-linux" ++ # Linux x86 ++ "i386-unknown-linux-gnu" "i386-unknown-linux" "x86_64-unknown-linux-gnu" "x86_64-unknown-linux" ++ # Linux Android ++ "armv7-unknown-linux-androideabi" "aarch64-unknown-linux-android" ++ ++ # QNX ++ "arm-unknown-nto-qnx-eabi" ++ ++ # macOS ++ "i386-apple-darwin" "x86_64-apple-darwin" ++ # iOS ++ "armv7-apple-ios arm64-apple-ios" "i386-apple-ios x86_64-apple-ios" ++) ++ ++# given the call to clang -c11 that clang --target -v generates, ++# parse the -target-cpu and -target-feature from ++# the output. ++function get_cpu_and_attr() { ++ # echo $@ ++ while [ "$#" -gt 0 ]; do ++ case "$1" in ++ -target-cpu) CPU=$2; shift 2;; ++ -target-feature) ++ # translate clang to opt/llc target features ++ case "$2" in ++ # we don't have support in GHC for proper soft-float. ++ # if we extend the `llvm-target` file to contain two ++ # additional columns for opt and llc flags, we could ++ # pass -float-abi=soft; However ghc will use float ++ # registers unconditionally on arm, and as such true ++ # soft float with the registerised llvm backend is ++ # currently not possible. ++ +soft-float-abi) shift 2;; ++ *) ATTR+=("$2"); shift 2;; ++ esac ++ ;; ++ *) shift 1;; ++ esac ++ done ++} ++ ++# first marker to discrimiate the first line being outputted. ++FST=1 ++# a dummy file to use for the clang invocation. ++FILE=_____dummy.c ++touch $FILE ++ ++for target in "${TARGETS[@]}"; do ++ # find the cpu and attributes emitte by clang for the given $target ++ CPU="" ++ ATTR=() ++ args=$(clang --target=$target -S $FILE -o /dev/null -v 2>&1 |grep $FILE) ++ get_cpu_and_attr $args ++ ++ # find the data-layout from the llvm code emitted by clang. ++ dl=$(clang --target=$target -S $FILE -emit-llvm -o -|grep datalayout |awk -F\ '{ print $4 }') ++ # GNU and Apple/LLVM can't agree on the aarch64 target. ++ # aarch64-apple-ios, is understood by autotools but not by LLVM. ++ # arm64-apple-ios, is understood by LLVM, but not by autotools. ++ # ++ # therefore, while we query clang with arm64-apple-ios, we put ++ # aarch64-apple-ios into the llvm-target list, as that is what ++ # we have to configure ghc with --target with anyway. Also we ++ # want to retain the GNU naming for compatibility with libraries ++ # that use autotools. ++ if [ "$target" == "arm64-apple-ios" ]; then ++ target="aarch64-apple-ios" ++ fi ++ if [ $FST -eq 1 ]; then ++ echo "[(\"${target}\", ($dl, \"$CPU\", \"${ATTR[*]}\"))" ++ FST=0 ++ else ++ echo ",(\"${target}\", ($dl, \"$CPU\", \"${ATTR[*]}\"))" ++ fi ++done ++rm $FILE ++echo "]" +diff --git a/utils/mkUserGuidePart/Options/Linking.hs b/utils/mkUserGuidePart/Options/Linking.hs +index 23e32fac78..f0b6ea55d6 100644 +--- a/utils/mkUserGuidePart/Options/Linking.hs ++++ b/utils/mkUserGuidePart/Options/Linking.hs +@@ -11,9 +11,10 @@ linkingOptions = + } + , flag { flagName = "-staticlib" + , flagDescription = +- "On Darwin/OS X/iOS only, generate a standalone static library " ++ +- "(as opposed to an executable). This is the usual way to " ++ +- "compile for iOS." ++ "Generate a standalone static library (as opposed to an " ++ ++ "executable). This is useful when cross compiling. The " ++ ++ "library together with all its dependencies ends up in in a " ++ ++ "single static library that can be linked against." + , flagType = DynamicFlag + } + , flag { flagName = "-fPIC" diff --git a/nixpkgs-overlays/mobile-ghc/8.2.y/ios-rump-linker.patch b/nixpkgs-overlays/mobile-ghc/8.2.y/ios-rump-linker.patch deleted file mode 100644 index a635e1224..000000000 --- a/nixpkgs-overlays/mobile-ghc/8.2.y/ios-rump-linker.patch +++ /dev/null @@ -1,62 +0,0 @@ -From 642f7ee4fc019baa2844e8f70459b7c6f45101d4 Mon Sep 17 00:00:00 2001 -From: John Ericson -Date: Sat, 23 Sep 2017 13:33:19 -0400 -Subject: [PATCH] MachO.c: Expose at least machoGetMisalignment on ios - -A middling subset of 938392c8515ccbe894714f43852fe604a21ce30b ---- - rts/linker/MachO.c | 14 +++++++++----- - 1 file changed, 9 insertions(+), 5 deletions(-) - -diff --git a/rts/linker/MachO.c b/rts/linker/MachO.c -index 55b2bf1ebc..c1fc149eae 100644 ---- a/rts/linker/MachO.c -+++ b/rts/linker/MachO.c -@@ -1,7 +1,6 @@ - #include "Rts.h" - --#ifdef darwin_HOST_OS -- -+#if defined(darwin_HOST_OS) || defined(ios_HOST_OS) - #include "RtsUtils.h" - #include "GetEnv.h" - #include "LinkerInternals.h" -@@ -16,6 +15,9 @@ - #include - #include - #include -+#endif /* darwin_HOST_OS, ios_HOST_OS */ -+ -+#ifdef darwin_HOST_OS - - #if defined(HAVE_SYS_MMAN_H) - # include -@@ -1205,6 +1207,9 @@ machoInitSymbolsWithoutUnderscore(void) - } - #endif - -+#endif /* darwin_HOST_OS */ -+ -+#if defined(darwin_HOST_OS) || defined(ios_HOST_OS) - /* - * Figure out by how much to shift the entire Mach-O file in memory - * when loading so that its single segment ends up 16-byte-aligned -@@ -1223,7 +1228,7 @@ machoGetMisalignment( FILE * f ) - } - fseek(f, -sizeof(header), SEEK_CUR); - --#if x86_64_HOST_ARCH || powerpc64_HOST_ARCH -+#if x86_64_HOST_ARCH || powerpc64_HOST_ARCH || aarch64_HOST_ARCH - if(header.magic != MH_MAGIC_64) { - barf("Bad magic. Expected: %08x, got: %08x.", - MH_MAGIC_64, header.magic); -@@ -1240,5 +1245,4 @@ machoGetMisalignment( FILE * f ) - - return misalignment ? (16 - misalignment) : 0; - } -- --#endif /* darwin_HOST_OS */ -+#endif /* darwin_HOST_OS, ios_HOST_OS */ --- -2.14.1 - diff --git a/nixpkgs-overlays/mobile-ghc/8.4.y/android-patches/force-relocation.patch b/nixpkgs-overlays/mobile-ghc/8.4.y/android-patches/force-relocation.patch new file mode 100644 index 000000000..cd3701250 --- /dev/null +++ b/nixpkgs-overlays/mobile-ghc/8.4.y/android-patches/force-relocation.patch @@ -0,0 +1,13 @@ +diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs +index 86dd913461..e6d6defdb9 100644 +--- a/compiler/main/DriverPipeline.hs ++++ b/compiler/main/DriverPipeline.hs +@@ -830,7 +830,7 @@ llvmOptions dflags = + rmodel | gopt Opt_PIC dflags = "pic" + | positionIndependent dflags = "pic" + | WayDyn `elem` ways dflags = "dynamic-no-pic" +- | otherwise = "static" ++ | otherwise = "pic" -- "static" + + align :: Int + align = case platformArch (targetPlatform dflags) of diff --git a/nixpkgs-overlays/mobile-ghc/default.nix b/nixpkgs-overlays/mobile-ghc/default.nix index cc38b254a..c1832d3a0 100644 --- a/nixpkgs-overlays/mobile-ghc/default.nix +++ b/nixpkgs-overlays/mobile-ghc/default.nix @@ -3,20 +3,27 @@ self: super: { haskell = super.haskell // { compiler = super.haskell.compiler // { - ghc821 = super.haskell.compiler.ghc821.overrideAttrs (drv: { - patches = (drv.patches or []) ++ lib.optionals (self.stdenv.targetPlatform.useAndroidPrebuilt or false) [ + ghc822 = super.haskell.compiler.ghc822.overrideAttrs (drv: { + patches = (drv.patches or []) ++ lib.optionals self.stdenv.targetPlatform.useAndroidPrebuilt [ ./8.2.y/android-patches/add-llvm-target-data-layout.patch ./8.2.y/android-patches/unix-posix_vdisable.patch ./8.2.y/android-patches/force_CC_SUPPORTS_TLS_equal_zero.patch ./8.2.y/android-patches/undefine_MYTASK_USE_TLV_for_CC_SUPPORTS_TLS_zero.patch ./8.2.y/android-patches/force-relocation-equal-pic.patch ./8.2.y/android-patches/rts_android_log_write.patch - ] ++ lib.optionals (self.stdenv.targetPlatform != self.stdenv.hostPlatform) [ - ./8.2.y/android-patches/enable-fPIC.patch - ] ++ lib.optionals (with self.stdenv.targetPlatform; (isDarwin && (isAarch64 || isArm))) [ - ./8.2.y/ios-rump-linker.patch + ] ++ lib.optionals self.stdenv.targetPlatform.isiOS [ + ./8.2.y/fixed-ios.patch + #(self.buildPackages.fetchpatch { + # url = "https://patch-diff.githubusercontent.com/raw/obsidiansystems/ghc/pull/1.patch"; + # sha256 = "0h34fd55qng3xrnm6x6jy56f7rbmng55afy56r84lvrlk1y8gjwf"; + # excludes = [ "testsuite" ]; + #}) ]; }); - }; + } // lib.mapAttrs (n: v: v.overrideAttrs (drv: { + patches = (drv.patches or []) ++ lib.optionals self.stdenv.targetPlatform.useAndroidPrebuilt [ + ./8.4.y/android-patches/force-relocation.patch + ]; + })) { inherit (super.haskell.compiler) ghc843 ghcHEAD; }; }; } diff --git a/nixpkgs/github.json b/nixpkgs/github.json index 145bfe2e5..46ad31463 100644 --- a/nixpkgs/github.json +++ b/nixpkgs/github.json @@ -1,6 +1,6 @@ { - "owner": "obsidiansystems", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "6e9c0e5085a2374906c0a8d754944be032c27ed0", - "sha256": "0ic2wyrwjg5n9nc9mbwclz0hqznh4i5md17fs6fn5q7rbcd5fgwh" + "rev": "3e55299b41428ec92516568120a31f79b13f878e", + "sha256": "0m34i9whnjmc4fzscmfqbxsraqg9mmi76fnp7yldv1qq564h2vrv" } diff --git a/reflex-dom/github.json b/reflex-dom/github.json index 18a792375..eacb68b16 100644 --- a/reflex-dom/github.json +++ b/reflex-dom/github.json @@ -1,6 +1,6 @@ { "owner": "reflex-frp", "repo": "reflex-dom", - "rev": "56aa06e94e5c9c6c2eb19cd988ed8de0d76cae38", - "sha256": "0di64r4pl6kbxiayl1wp2vi9rfbzyj6mkyfs6qnm49kx6fm1zp4a" + "rev": "8bde2d72193369c92a995820ca1f56690d3c8ec3", + "sha256": "0ffvg9v84y7i9j5bls9kp1wr768z6fpdgddzg9vdd766pjfyzi6y" } diff --git a/reflex-todomvc/github.json b/reflex-todomvc/github.json index 811d0f78b..4a1b6723a 100644 --- a/reflex-todomvc/github.json +++ b/reflex-todomvc/github.json @@ -1,6 +1,6 @@ { "owner": "reflex-frp", "repo": "reflex-todomvc", - "rev": "83769ffe9783c12029e5bd2e7d8f438edf4836bf", - "sha256": "1v4wmsgh0nf3zcf34fpqxhvnlppkaz82bkwy101rlvz9kk4c41mr" + "rev": "27fcfe1d5e6aab1ce9c6b9369a5af7ee84e69bde", + "sha256": "0zikp2zafd2dpz7vr7vpdylgq7b1rsa0hx4rcnlzlig43frfjvma" } diff --git a/reflex/github.json b/reflex/github.json index 1a91197b6..56b218e2a 100644 --- a/reflex/github.json +++ b/reflex/github.json @@ -1,6 +1,6 @@ { "owner": "reflex-frp", "repo": "reflex", - "rev": "f4db125ed82bac9cb2c80672a31c0de93801b32e", - "sha256": "04qclkgqp89mwhyjgd771sf05lic422sy9xbjfbyszgjvj6n2y9f" + "rev": "4a32a8202e180f0919ec36e6770f6af5ce88818e", + "sha256": "12mj7mppc1ap2f0d18d1a825y0qdbpzaxkkr0mxi2yd8q3k5ymls" } diff --git a/release.nix b/release.nix index 75a83c85d..6d487b848 100644 --- a/release.nix +++ b/release.nix @@ -19,7 +19,7 @@ let local-reflex-platform = import ./. {}; perPlatform = lib.genAttrs local-reflex-platform.cacheBuildSystems (system: let - reflex-platform = import ./. { inherit system; iosSupportForce = system == "x86_64-darwin"; }; + reflex-platform = import ./. { inherit system; }; otherDeps = getOtherDeps reflex-platform; jsexeHydra = exe: exe.overrideAttrs (attrs: { @@ -34,10 +34,15 @@ let local-reflex-platform = import ./. {}; tryReflexShell = reflex-platform.tryReflexShell; ghcjs.reflexTodomvc = jsexeHydra reflex-platform.ghcjs.reflex-todomvc; ghcjs8_0.reflexTodomvc = jsexeHydra reflex-platform.ghcjs8_0.reflex-todomvc; + # Doesn't currently build. Removing from CI until fixed. + # ghcjs8_2.reflexTodomvc = jsexeHydra reflex-platform.ghcjs8_2.reflex-todomvc; + ghcjs8_4.reflexTodomvc = jsexeHydra reflex-platform.ghcjs8_4.reflex-todomvc; ghc.ReflexTodomvc = reflex-platform.ghc.reflex-todomvc; ghc8_0.reflexTodomvc = reflex-platform.ghc8_0.reflex-todomvc; ghc8_2.reflexTodomvc = reflex-platform.ghc8_2.reflex-todomvc; + ghc8_4.reflexTodomvc = reflex-platform.ghc8_4.reflex-todomvc; skeleton-test = import ./skeleton-test.nix { inherit reflex-platform; }; + benchmark = import ./scripts/benchmark.nix { inherit reflex-platform; }; cache = reflex-platform.pinBuildInputs "reflex-platform-${system}" (lib.concatMap builtins.attrValues (builtins.attrValues reflex-platform.sources) @@ -49,9 +54,11 @@ let local-reflex-platform = import ./. {}; } // lib.optionalAttrs (reflex-platform.androidSupport) { inherit (reflex-platform) androidReflexTodomvc; inherit (reflex-platform) androidReflexTodomvc-8_2; + inherit (reflex-platform) androidReflexTodomvc-8_4; } // lib.optionalAttrs (reflex-platform.iosSupport) { inherit (reflex-platform) iosReflexTodomvc; inherit (reflex-platform) iosReflexTodomvc-8_2; + inherit (reflex-platform) iosReflexTodomvc-8_4; } // drvListToAttrs otherDeps // drvListToAttrs (lib.filter lib.isDerivation reflex-platform.cachePackages) # TODO no filter ); diff --git a/scripts/setup-hook-ios.sh b/scripts/setup-hook-ios.sh deleted file mode 100644 index d415a407b..000000000 --- a/scripts/setup-hook-ios.sh +++ /dev/null @@ -1,5 +0,0 @@ -prependSearchPath() { - export NIX_@target_prefix@_CFLAGS_COMPILE="-F@out@/System/Library/Frameworks -F@out@/System/Library/PrivateFrameworks -I@out@/usr/include ${NIX_@target_prefix@_CFLAGS_COMPILE}" -} - -preConfigureHooks+=(prependSearchPath) diff --git a/scripts/setup-hook.sh b/scripts/setup-hook.sh deleted file mode 100644 index c2253b182..000000000 --- a/scripts/setup-hook.sh +++ /dev/null @@ -1,5 +0,0 @@ -prependSearchPath() { - NIX_CFLAGS_COMPILE="-F@out@/Developer/SDKs/System/Library/Frameworks -I@out@/Developer/SDKs/@name@/usr/include ${NIX_CFLAGS_COMPILE}" -} - -preConfigureHooks+=(prependSearchPath) diff --git a/skeleton-test.nix b/skeleton-test.nix index b427cfb6a..1fe4c3f2a 100644 --- a/skeleton-test.nix +++ b/skeleton-test.nix @@ -18,7 +18,7 @@ let ''; buildPhase = '' HOME=$NIX_BUILD_TOP - cabal new-build all --project-file=${projectFile} + cabal new-build all --project-file=${projectFile} ${if reflex-platform.nixpkgs.stdenv.isDarwin then "--ghc-option=-dynamic" else ""} ''; installPhase = '' mv ./dist-newstyle $out