Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

Merge pull request #139040 from obsidiansystems/ghc-8_10_7-20.09

[backport release-20.09] ghc 8.10.7: init

authored by John Ericson and committed by GitHub 751ad2b5 068984c0

Changed files
+417
pkgs
development
os-specific
darwin
xattr
top-level
+298
pkgs/development/compilers/ghc/8.10.7.nix
··· 1 + { lib, stdenv, pkgsBuildTarget, targetPackages 2 + 3 + # build-tools 4 + , bootPkgs 5 + , autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx, xattr 6 + , bash 7 + 8 + , libiconv ? null, ncurses 9 + 10 + , # GHC can be built with system libffi or a bundled one. 11 + libffi ? null 12 + 13 + , useLLVM ? !stdenv.targetPlatform.isx86 14 + , # LLVM is conceptually a run-time-only depedendency, but for 15 + # non-x86, we need LLVM to bootstrap later stages, so it becomes a 16 + # build-time dependency too. 17 + buildLlvmPackages, llvmPackages 18 + 19 + , # If enabled, GHC will be built with the GPL-free but slower integer-simple 20 + # library instead of the faster but GPLed integer-gmp library. 21 + enableIntegerSimple ? !(lib.any (lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp 22 + 23 + , # If enabled, use -fPIC when compiling static libs. 24 + enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform 25 + 26 + # aarch64 outputs otherwise exceed 2GB limit 27 + , enableProfiledLibs ? !stdenv.targetPlatform.isAarch64 28 + 29 + , # Whether to build dynamic libs for the standard library (on the target 30 + # platform). Static libs are always built. 31 + enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt 32 + 33 + , # Whether to build terminfo. 34 + enableTerminfo ? !stdenv.targetPlatform.isWindows 35 + 36 + , # What flavour to build. An empty string indicates no 37 + # specific flavour and falls back to ghc default values. 38 + ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) 39 + (if useLLVM then "perf-cross" else "perf-cross-ncg") 40 + 41 + , # Whether to disable the large address space allocator 42 + # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ 43 + disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64 44 + }: 45 + 46 + assert !enableIntegerSimple -> gmp != null; 47 + 48 + let 49 + inherit (stdenv) buildPlatform hostPlatform targetPlatform; 50 + 51 + inherit (bootPkgs) ghc; 52 + 53 + # TODO(@Ericson2314) Make unconditional 54 + targetPrefix = lib.optionalString 55 + (targetPlatform != hostPlatform) 56 + "${targetPlatform.config}-"; 57 + 58 + buildMK = '' 59 + BuildFlavour = ${ghcFlavour} 60 + ifneq \"\$(BuildFlavour)\" \"\" 61 + include mk/flavours/\$(BuildFlavour).mk 62 + endif 63 + DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} 64 + INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"} 65 + '' + lib.optionalString (targetPlatform != hostPlatform) '' 66 + Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"} 67 + CrossCompilePrefix = ${targetPrefix} 68 + HADDOCK_DOCS = NO 69 + BUILD_SPHINX_HTML = NO 70 + BUILD_SPHINX_PDF = NO 71 + '' + lib.optionalString (!enableProfiledLibs) '' 72 + GhcLibWays = "v dyn" 73 + '' + lib.optionalString enableRelocatedStaticLibs '' 74 + GhcLibHcOpts += -fPIC 75 + GhcRtsHcOpts += -fPIC 76 + '' + lib.optionalString targetPlatform.useAndroidPrebuilt '' 77 + EXTRA_CC_OPTS += -std=gnu99 78 + '' 79 + # While split sections are now enabled by default in ghc 8.8 for windows, 80 + # they seem to lead to `too many sections` errors when building base for 81 + # profiling. 82 + + lib.optionalString targetPlatform.isWindows '' 83 + SplitSections = NO 84 + ''; 85 + 86 + # Splicer will pull out correct variations 87 + libDeps = platform: lib.optional enableTerminfo ncurses 88 + ++ [libffi] 89 + ++ lib.optional (!enableIntegerSimple) gmp 90 + ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; 91 + 92 + toolsForTarget = [ 93 + pkgsBuildTarget.targetPackages.stdenv.cc 94 + ] ++ lib.optional useLLVM buildLlvmPackages.llvm; 95 + 96 + targetCC = builtins.head toolsForTarget; 97 + 98 + # ld.gold is disabled for musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856 99 + # see #84670 and #49071 for more background. 100 + useLdGold = targetPlatform.isLinux && !(targetPlatform.useLLVM or false) && !targetPlatform.isMusl && !targetPlatform.isWindows; 101 + 102 + runtimeDeps = [ 103 + targetPackages.stdenv.cc.bintools 104 + coreutils 105 + ] 106 + # On darwin, we need unwrapped bintools as well (for otool) 107 + ++ lib.optionals (stdenv.targetPlatform.isDarwin) [ 108 + targetPackages.stdenv.cc.bintools.bintools 109 + ]; 110 + 111 + in 112 + stdenv.mkDerivation (rec { 113 + version = "8.10.7"; 114 + name = "${targetPrefix}ghc-${version}"; 115 + 116 + src = fetchurl { 117 + url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz"; 118 + sha256 = "e3eef6229ce9908dfe1ea41436befb0455fefb1932559e860ad4c606b0d03c9d"; 119 + }; 120 + 121 + enableParallelBuilding = true; 122 + 123 + outputs = [ "out" "doc" ]; 124 + 125 + patches = [ 126 + # See upstream patch at 127 + # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4885. Since we build 128 + # from source distributions, the auto-generated configure script needs to be 129 + # patched as well, therefore we use an in-tree patch instead of pulling the 130 + # upstream patch. Don't forget to check backport status of the upstream patch 131 + # when adding new GHC releases in nixpkgs. 132 + ./respect-ar-path.patch 133 + 134 + # cabal passes incorrect --host= when cross-compiling 135 + # https://github.com/haskell/cabal/issues/5887 136 + (fetchpatch { 137 + url = "https://raw.githubusercontent.com/input-output-hk/haskell.nix/122bd81150386867da07fdc9ad5096db6719545a/overlays/patches/ghc/cabal-host.patch"; 138 + sha256 = "sha256:0yd0sajgi24sc1w5m55lkg2lp6kfkgpp3lgija2c8y3cmkwfpdc1"; 139 + }) 140 + 141 + # In order to build ghcjs packages, the Cabal of the ghc used for the ghcjs 142 + # needs to be patched. Ref https://github.com/haskell/cabal/pull/7575 143 + (fetchpatch { 144 + url = "https://github.com/haskell/cabal/commit/369c4a0a54ad08a9e6b0d3bd303fedd7b5e5a336.patch"; 145 + sha256 = "120f11hwyaqa0pq9g5l1300crqij49jg0rh83hnp9sa49zfdwx1n"; 146 + stripLen = 3; 147 + extraPrefix = "libraries/Cabal/Cabal/"; 148 + }) 149 + ] ++ lib.optionals stdenv.isDarwin [ 150 + # Make Block.h compile with c++ compilers. Remove with the next release 151 + (fetchpatch { 152 + url = "https://gitlab.haskell.org/ghc/ghc/-/commit/97d0b0a367e4c6a52a17c3299439ac7de129da24.patch"; 153 + sha256 = "0r4zjj0bv1x1m2dgxp3adsf2xkr94fjnyj1igsivd9ilbs5ja0b5"; 154 + }) 155 + ]; 156 + 157 + postPatch = "patchShebangs ."; 158 + 159 + # GHC is a bit confused on its cross terminology. 160 + preConfigure = '' 161 + for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do 162 + export "''${env#TARGET_}=''${!env}" 163 + done 164 + # GHC is a bit confused on its cross terminology, as these would normally be 165 + # the *host* tools. 166 + export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" 167 + export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx" 168 + # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177 169 + export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}" 170 + export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as" 171 + export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar" 172 + export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm" 173 + export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" 174 + export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" 175 + export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" 176 + 177 + echo -n "${buildMK}" > mk/build.mk 178 + sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure 179 + '' + lib.optionalString (!stdenv.isDarwin) '' 180 + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" 181 + '' + lib.optionalString stdenv.isDarwin '' 182 + export NIX_LDFLAGS+=" -no_dtrace_dof" 183 + 184 + # GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7 185 + export XATTR=${lib.getBin xattr}/bin/xattr 186 + '' + lib.optionalString targetPlatform.useAndroidPrebuilt '' 187 + sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets 188 + '' + lib.optionalString targetPlatform.isMusl '' 189 + echo "patching llvm-targets for musl targets..." 190 + echo "Cloning these existing '*-linux-gnu*' targets:" 191 + grep linux-gnu llvm-targets | sed 's/^/ /' 192 + echo "(go go gadget sed)" 193 + sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets 194 + echo "llvm-targets now contains these '*-linux-musl*' targets:" 195 + grep linux-musl llvm-targets | sed 's/^/ /' 196 + 197 + echo "And now patching to preserve '-musleabi' as done with '-gnueabi'" 198 + # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen) 199 + for x in configure aclocal.m4; do 200 + substituteInPlace $x \ 201 + --replace '*-android*|*-gnueabi*)' \ 202 + '*-android*|*-gnueabi*|*-musleabi*)' 203 + done 204 + ''; 205 + 206 + # TODO(@Ericson2314): Always pass "--target" and always prefix. 207 + configurePlatforms = [ "build" "host" ] 208 + ++ lib.optional (targetPlatform != hostPlatform) "target"; 209 + 210 + # `--with` flags for libraries needed for RTS linker 211 + configureFlags = [ 212 + "--datadir=$doc/share/doc/ghc" 213 + "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" 214 + ] ++ lib.optionals (libffi != null) [ 215 + "--with-system-libffi" 216 + "--with-ffi-includes=${targetPackages.libffi.dev}/include" 217 + "--with-ffi-libraries=${targetPackages.libffi.out}/lib" 218 + ] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [ 219 + "--with-gmp-includes=${targetPackages.gmp.dev}/include" 220 + "--with-gmp-libraries=${targetPackages.gmp.out}/lib" 221 + ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ 222 + "--with-iconv-includes=${libiconv}/include" 223 + "--with-iconv-libraries=${libiconv}/lib" 224 + ] ++ lib.optionals (targetPlatform != hostPlatform) [ 225 + "--enable-bootstrap-with-devel-snapshot" 226 + ] ++ lib.optionals useLdGold [ 227 + "CFLAGS=-fuse-ld=gold" 228 + "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold" 229 + "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" 230 + ] ++ lib.optionals (disableLargeAddressSpace) [ 231 + "--disable-large-address-space" 232 + ]; 233 + 234 + # Make sure we never relax`$PATH` and hooks support for compatibility. 235 + strictDeps = true; 236 + 237 + # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself. 238 + dontAddExtraLibs = true; 239 + 240 + nativeBuildInputs = [ 241 + perl autoconf automake m4 python3 sphinx 242 + ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour 243 + ]; 244 + 245 + # For building runtime libs 246 + depsBuildTarget = toolsForTarget; 247 + 248 + buildInputs = [ perl bash ] ++ (libDeps hostPlatform); 249 + 250 + propagatedBuildInputs = [ targetPackages.stdenv.cc ] 251 + ++ lib.optional useLLVM llvmPackages.llvm; 252 + 253 + depsTargetTarget = map lib.getDev (libDeps targetPlatform); 254 + depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform); 255 + 256 + # required, because otherwise all symbols from HSffi.o are stripped, and 257 + # that in turn causes GHCi to abort 258 + stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; 259 + 260 + checkTarget = "test"; 261 + 262 + hardeningDisable = [ "format" ] ++ lib.optional stdenv.targetPlatform.isMusl "pie"; 263 + 264 + postInstall = '' 265 + # Install the bash completion file. 266 + install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc 267 + 268 + # Patch scripts to include "readelf" and "cat" in $PATH. 269 + for i in "$out/bin/"*; do 270 + test ! -h $i || continue 271 + egrep --quiet '^#!' <(head -n 1 $i) || continue 272 + sed -i -e '2i export PATH="$PATH:${lib.makeBinPath runtimeDeps}"' $i 273 + done 274 + ''; 275 + 276 + passthru = { 277 + inherit bootPkgs targetPrefix; 278 + 279 + inherit llvmPackages; 280 + inherit enableShared; 281 + 282 + # Our Cabal compiler name 283 + haskellCompilerName = "ghc-${version}"; 284 + }; 285 + 286 + meta = { 287 + homepage = "http://haskell.org/ghc"; 288 + description = "The Glasgow Haskell Compiler"; 289 + maintainers = with lib.maintainers; [ marcweber andres peti ]; 290 + timeout = 24 * 3600; 291 + inherit (ghc.meta) license platforms; 292 + }; 293 + 294 + } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { 295 + dontStrip = true; 296 + dontPatchELF = true; 297 + noAuditTmpdir = true; 298 + })
+25
pkgs/development/compilers/ghc/respect-ar-path.patch
··· 1 + diff -urd a/aclocal.m4 b/aclocal.m4 2 + --- a/aclocal.m4 3 + +++ b/aclocal.m4 4 + @@ -1199,7 +1199,8 @@ 5 + # thinks that target == host so it never checks the unqualified 6 + # tools for Windows. See #14274. 7 + AC_DEFUN([FP_PROG_AR], 8 + -[if test -z "$fp_prog_ar"; then 9 + +[AC_SUBST(fp_prog_ar,$AR) 10 + +if test -z "$fp_prog_ar"; then 11 + if test "$HostOS" = "mingw32" 12 + then 13 + AC_PATH_PROG([fp_prog_ar], [ar]) 14 + diff -urd a/configure b/configure 15 + --- a/configure 16 + +++ b/configure 17 + @@ -10744,6 +10744,8 @@ 18 + test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' 19 + 20 + 21 + +fp_prog_ar=$AR 22 + + 23 + if test -z "$fp_prog_ar"; then 24 + if test "$HostOS" = "mingw32" 25 + then
+73
pkgs/os-specific/darwin/xattr/default.nix
··· 1 + { lib 2 + , stdenv 3 + , fetchzip 4 + , buildPythonPackage 5 + , python 6 + , ed 7 + , unifdef 8 + }: 9 + 10 + buildPythonPackage rec { 11 + pname = "xattr"; 12 + version = "61.60.1"; 13 + 14 + src = fetchzip rec { 15 + url = "https://opensource.apple.com/tarballs/python_modules/python_modules-${version}.tar.gz"; 16 + sha256 = "19kydl7w4vpdi7zmfd5z9vjkq24jfk2cv4j0pppw69j06czhdwwi"; 17 + }; 18 + 19 + sourceRoot = "${src.name}/Modules/xattr-0.6.4"; 20 + format = "other"; 21 + 22 + nativeBuildInputs = [ 23 + ed 24 + unifdef 25 + ]; 26 + 27 + makeFlags = [ 28 + "OBJROOT=$(PWD)" 29 + "DSTROOT=${placeholder "out"}" 30 + "OSL=${placeholder "doc"}/share/xattr/OpenSourceLicenses" 31 + "OSV=${placeholder "doc"}/share/xattr/OpenSourceVersions" 32 + ]; 33 + 34 + # need to use `out` instead of `bin` since buildPythonPackage ignores the latter 35 + outputs = [ "out" "doc" "python" ]; 36 + 37 + # We need to patch a reference to gnutar in an included Makefile 38 + postUnpack = '' 39 + chmod u+w $sourceRoot/.. 40 + ''; 41 + 42 + postPatch = '' 43 + substituteInPlace ../Makefile.inc --replace gnutar tar 44 + substituteInPlace Makefile --replace "/usr" "" 45 + ''; 46 + 47 + preInstall = '' 48 + # prevent setup.py from trying to download setuptools 49 + sed -i xattr-*/setup.py -e '/ez_setup/d' 50 + 51 + # create our custom target dirs we patch in 52 + mkdir -p "$doc/share/xattr/"OpenSource{Licenses,Versions} 53 + mkdir -p "$python/lib/${python.libPrefix}" 54 + ''; 55 + 56 + # move python package to its own output to reduce clutter 57 + postInstall = '' 58 + mv "$out/lib/python" "$python/${python.sitePackages}" 59 + rmdir "$out/lib" 60 + ''; 61 + 62 + makeWrapperArgs = [ 63 + "--prefix" "PYTHONPATH" ":" "${placeholder "python"}/${python.sitePackages}" 64 + ]; 65 + 66 + meta = with lib; { 67 + description = "Display and manipulate extended attributes"; 68 + license = [ licenses.psfl licenses.mit ]; # see $doc/share/xattr/OpenSourceLicenses 69 + maintainers = [ maintainers.sternenseemann ]; 70 + homepage = "https://opensource.apple.com/source/python_modules/"; 71 + platforms = lib.platforms.darwin; 72 + }; 73 + }
+2
pkgs/top-level/darwin-packages.nix
··· 68 68 69 69 usr-include = callPackage ../os-specific/darwin/usr-include { }; 70 70 71 + xattr = pkgs.python3Packages.callPackage ../os-specific/darwin/xattr { }; 72 + 71 73 inherit (callPackages ../os-specific/darwin/xcode { }) 72 74 xcode_8_1 xcode_8_2 73 75 xcode_9_1 xcode_9_2 xcode_9_4 xcode_9_4_1
+19
pkgs/top-level/haskell-packages.nix
··· 124 124 buildLlvmPackages = buildPackages.llvmPackages_9; 125 125 llvmPackages = pkgs.llvmPackages_9; 126 126 }; 127 + ghc8107 = callPackage ../development/compilers/ghc/8.10.7.nix { 128 + # aarch64 ghc865Binary gets SEGVs due to haskell#15449 or similar 129 + bootPkgs = if stdenv.isAarch64 || stdenv.isAarch32 then 130 + packages.ghc8102BinaryMinimal 131 + else 132 + packages.ghc865Binary; 133 + inherit (buildPackages.python3Packages) sphinx; 134 + # Need to use apple's patched xattr until 135 + # https://github.com/xattr/xattr/issues/44 and 136 + # https://github.com/xattr/xattr/issues/55 are solved. 137 + inherit (buildPackages.darwin) xattr; 138 + buildLlvmPackages = buildPackages.llvmPackages_9; 139 + llvmPackages = pkgs.llvmPackages_9; 140 + }; 127 141 ghcHEAD = callPackage ../development/compilers/ghc/head.nix { 128 142 bootPkgs = packages.ghc883; # no binary yet 129 143 inherit (buildPackages.python3Packages) sphinx; ··· 228 242 ghc8104 = callPackage ../development/haskell-modules { 229 243 buildHaskellPackages = bh.packages.ghc8104; 230 244 ghc = bh.compiler.ghc8104; 245 + compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-8.10.x.nix { }; 246 + }; 247 + ghc8107 = callPackage ../development/haskell-modules { 248 + buildHaskellPackages = bh.packages.ghc8107; 249 + ghc = bh.compiler.ghc8107; 231 250 compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-8.10.x.nix { }; 232 251 }; 233 252 ghcHEAD = callPackage ../development/haskell-modules {