aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc
diff options
context:
space:
mode:
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/development/compilers/ghc')
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.10.1.nix258
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.10.2-binary.nix222
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.10.2.nix259
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.2.2-binary.nix191
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.6.5-binary.nix176
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.6.5.nix267
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.8.2.nix253
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.8.3.nix258
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.8.4.nix262
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/9.0.1.nix248
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/backport-dylib-command-size-limit.patch24
-rwxr-xr-xinfra/libkookie/nixpkgs/pkgs/development/compilers/ghc/gcc-clang-wrapper.sh46
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/head.nix266
-rw-r--r--infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/issue-18549.patch296
14 files changed, 3026 insertions, 0 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.10.1.nix b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.10.1.nix
new file mode 100644
index 000000000000..42eb994b8fe2
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.10.1.nix
@@ -0,0 +1,258 @@
+{ stdenv, pkgsBuildTarget, targetPackages
+
+# build-tools
+, bootPkgs
+, autoconf, automake, coreutils, fetchurl, perl, python3, m4, sphinx
+, bash
+
+, libiconv ? null, ncurses
+
+, # GHC can be built with system libffi or a bundled one.
+ libffi ? null
+
+, useLLVM ? !stdenv.targetPlatform.isx86
+, # LLVM is conceptually a run-time-only depedendency, but for
+ # non-x86, we need LLVM to bootstrap later stages, so it becomes a
+ # build-time dependency too.
+ buildLlvmPackages, llvmPackages
+
+, # If enabled, GHC will be built with the GPL-free but slower integer-simple
+ # library instead of the faster but GPLed integer-gmp library.
+ enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+
+, # If enabled, use -fPIC when compiling static libs.
+ enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
+
+ # aarch64 outputs otherwise exceed 2GB limit
+, enableProfiledLibs ? !stdenv.targetPlatform.isAarch64
+
+, # Whether to build dynamic libs for the standard library (on the target
+ # platform). Static libs are always built.
+ enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
+
+, # Whether to build terminfo.
+ enableTerminfo ? !stdenv.targetPlatform.isWindows
+
+, # What flavour to build. An empty string indicates no
+ # specific flavour and falls back to ghc default values.
+ ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+ (if useLLVM then "perf-cross" else "perf-cross-ncg")
+
+, # Whether to disable the large address space allocator
+ # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
+ disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64
+}:
+
+assert !enableIntegerSimple -> gmp != null;
+
+let
+ inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
+ inherit (bootPkgs) ghc;
+
+ # TODO(@Ericson2314) Make unconditional
+ targetPrefix = stdenv.lib.optionalString
+ (targetPlatform != hostPlatform)
+ "${targetPlatform.config}-";
+
+ buildMK = dontStrip: ''
+ BuildFlavour = ${ghcFlavour}
+ ifneq \"\$(BuildFlavour)\" \"\"
+ include mk/flavours/\$(BuildFlavour).mk
+ endif
+ DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
+ INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
+ ''
+ # We only need to build stage1 on most cross-compilation because
+ # we will be running the compiler on the native system. In some
+ # situations, like native Musl compilation, we need the compiler
+ # to actually link to our new Libc. The iOS simulator is a special
+ # exception because we can’t actually run simulators binaries
+ # ourselves.
+ + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+ Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
+ CrossCompilePrefix = ${targetPrefix}
+ HADDOCK_DOCS = NO
+ BUILD_SPHINX_HTML = NO
+ BUILD_SPHINX_PDF = NO
+ '' + stdenv.lib.optionalString dontStrip ''
+ STRIP_CMD = :
+ '' + stdenv.lib.optionalString (!enableProfiledLibs) ''
+ GhcLibWays = "v dyn"
+ '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+ GhcLibHcOpts += -fPIC
+ GhcRtsHcOpts += -fPIC
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ EXTRA_CC_OPTS += -std=gnu99
+ '';
+
+ # Splicer will pull out correct variations
+ libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+ ++ [libffi]
+ ++ stdenv.lib.optional (!enableIntegerSimple) gmp
+ ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+
+ toolsForTarget = [
+ pkgsBuildTarget.targetPackages.stdenv.cc
+ ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+
+ targetCC = builtins.head toolsForTarget;
+
+ # ld.gold is disabled for musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
+ # see #84670 and #49071 for more background.
+ useLdGold = targetPlatform.isLinux && !(targetPlatform.useLLVM or false) && !targetPlatform.isMusl;
+
+in
+stdenv.mkDerivation (rec {
+ version = "8.10.1";
+ name = "${targetPrefix}ghc-${version}";
+
+ src = fetchurl {
+ url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
+ sha256 = "1xgdl6ig5jzli3bg054vfryfkg0y6wggf68g66c32sr67bw0ffsf";
+ };
+
+ enableParallelBuilding = true;
+
+ outputs = [ "out" "doc" ];
+
+ postPatch = "patchShebangs .";
+
+ # GHC is a bit confused on its cross terminology.
+ preConfigure = ''
+ for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
+ export "''${env#TARGET_}=''${!env}"
+ done
+ # GHC is a bit confused on its cross terminology, as these would normally be
+ # the *host* tools.
+ export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
+ export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
+ # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
+ export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+ export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
+ export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
+ export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
+ export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
+ export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
+ export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
+
+ echo -n "${buildMK dontStrip}" > mk/build.mk
+ sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
+ '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+ export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
+ export NIX_LDFLAGS+=" -no_dtrace_dof"
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ 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
+ '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+ echo "patching llvm-targets for musl targets..."
+ echo "Cloning these existing '*-linux-gnu*' targets:"
+ grep linux-gnu llvm-targets | sed 's/^/ /'
+ echo "(go go gadget sed)"
+ sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
+ echo "llvm-targets now contains these '*-linux-musl*' targets:"
+ grep linux-musl llvm-targets | sed 's/^/ /'
+
+ echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
+ # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
+ for x in configure aclocal.m4; do
+ substituteInPlace $x \
+ --replace '*-android*|*-gnueabi*)' \
+ '*-android*|*-gnueabi*|*-musleabi*)'
+ done
+ '';
+
+ # TODO(@Ericson2314): Always pass "--target" and always prefix.
+ configurePlatforms = [ "build" "host" ]
+ ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+
+ # `--with` flags for libraries needed for RTS linker
+ configureFlags = [
+ "--datadir=$doc/share/doc/ghc"
+ "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
+ ] ++ stdenv.lib.optionals (libffi != null) [
+ "--with-system-libffi"
+ "--with-ffi-includes=${targetPackages.libffi.dev}/include"
+ "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+ "--with-gmp-includes=${targetPackages.gmp.dev}/include"
+ "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+ "--with-iconv-includes=${libiconv}/include"
+ "--with-iconv-libraries=${libiconv}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+ "--enable-bootstrap-with-devel-snapshot"
+ ] ++ stdenv.lib.optionals useLdGold [
+ "CFLAGS=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
+ ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+ "--disable-large-address-space"
+ ];
+
+ # Make sure we never relax`$PATH` and hooks support for compatibility.
+ strictDeps = true;
+
+ # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
+ dontAddExtraLibs = true;
+
+ nativeBuildInputs = [
+ perl autoconf automake m4 python3 sphinx
+ ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
+ ];
+
+ # For building runtime libs
+ depsBuildTarget = toolsForTarget;
+
+ buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
+
+ propagatedBuildInputs = [ targetPackages.stdenv.cc ]
+ ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+
+ depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
+ depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+
+ # required, because otherwise all symbols from HSffi.o are stripped, and
+ # that in turn causes GHCi to abort
+ stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+
+ checkTarget = "test";
+
+ hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+
+ postInstall = ''
+ # Install the bash completion file.
+ install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
+
+ # Patch scripts to include "readelf" and "cat" in $PATH.
+ for i in "$out/bin/"*; do
+ test ! -h $i || continue
+ egrep --quiet '^#!' <(head -n 1 $i) || continue
+ sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+ done
+ '';
+
+ passthru = {
+ inherit bootPkgs targetPrefix;
+
+ inherit llvmPackages;
+ inherit enableShared;
+
+ # Our Cabal compiler name
+ haskellCompilerName = "ghc-${version}";
+ };
+
+ meta = {
+ homepage = "http://haskell.org/ghc";
+ description = "The Glasgow Haskell Compiler";
+ maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+ timeout = 24 * 3600;
+ inherit (ghc.meta) license platforms;
+ };
+
+ dontStrip = (targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm);
+
+} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
+ dontPatchELF = true;
+ noAuditTmpdir = true;
+})
diff --git a/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.10.2-binary.nix b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.10.2-binary.nix
new file mode 100644
index 000000000000..1a1a9ca0160e
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.10.2-binary.nix
@@ -0,0 +1,222 @@
+{ stdenv
+, fetchurl, perl, gcc
+, ncurses6, gmp, glibc, libiconv, numactl
+, llvmPackages
+
+ # minimal = true; will remove files that aren't strictly necessary for
+ # regular builds and GHC bootstrapping.
+ # This is "useful" for staying within hydra's output limits for at least the
+ # aarch64-linux architecture.
+, minimal ? false
+}:
+
+# Prebuilt only does native
+assert stdenv.targetPlatform == stdenv.hostPlatform;
+
+let
+ useLLVM = !stdenv.targetPlatform.isx86;
+
+ libPath = stdenv.lib.makeLibraryPath ([
+ ncurses6 gmp
+ ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv
+ ++ stdenv.lib.optional (stdenv.hostPlatform.isAarch64) numactl);
+
+ libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
+ + "LD_LIBRARY_PATH";
+
+ glibcDynLinker = assert stdenv.isLinux;
+ if stdenv.hostPlatform.libc == "glibc" then
+ # Could be stdenv.cc.bintools.dynamicLinker, keeping as-is to avoid rebuild.
+ ''"$(cat $NIX_CC/nix-support/dynamic-linker)"''
+ else
+ "${stdenv.lib.getLib glibc}/lib/ld-linux*";
+
+in
+
+stdenv.mkDerivation rec {
+ version = "8.10.2";
+
+ name = "ghc-${version}-binary";
+
+ # https://downloads.haskell.org/~ghc/8.10.2/
+ src = fetchurl ({
+ i686-linux = {
+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
+ sha256 = "0bvwisl4w0z5z8z0da10m9sv0mhm9na2qm43qxr8zl23mn32mblx";
+ };
+ x86_64-linux = {
+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-deb10-linux.tar.xz";
+ sha256 = "0chnzy9j23b2wa8clx5arwz8wnjfxyjmz9qkj548z14cqf13slcl";
+ };
+ armv7l-linux = {
+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-armv7-deb10-linux.tar.xz";
+ sha256 = "1j41cq5d3rmlgz7hzw8f908fs79gc5mn3q5wz277lk8zdf19g75v";
+ };
+ aarch64-linux = {
+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz";
+ sha256 = "14smwl3741ixnbgi0l51a7kh7xjkiannfqx15b72svky0y4l3wjw";
+ };
+ x86_64-darwin = {
+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
+ sha256 = "1hngyq14l4f950hzhh2d204ca2gfc98pc9xdasxihzqd1jq75dzd";
+ };
+ }.${stdenv.hostPlatform.system}
+ or (throw "cannot bootstrap GHC on this platform"));
+
+ nativeBuildInputs = [ perl ];
+ propagatedBuildInputs = stdenv.lib.optionals useLLVM [ llvmPackages.llvm ];
+
+ # Cannot patchelf beforehand due to relative RPATHs that anticipate
+ # the final install location/
+ ${libEnvVar} = libPath;
+
+ postUnpack =
+ # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
+ # during linking
+ stdenv.lib.optionalString stdenv.isDarwin ''
+ export NIX_LDFLAGS+=" -no_dtrace_dof"
+ # not enough room in the object files for the full path to libiconv :(
+ for exe in $(find . -type f -executable); do
+ isScript $exe && continue
+ ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
+ install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
+ done
+ '' +
+
+ # Some scripts used during the build need to have their shebangs patched
+ ''
+ patchShebangs ghc-${version}/utils/
+ patchShebangs ghc-${version}/configure
+ '' +
+ # We have to patch the GMP paths for the integer-gmp package.
+ ''
+ find . -name integer-gmp.buildinfo \
+ -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
+ find . -name base.buildinfo \
+ -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
+ '' +
+ # aarch64 does HAVE_NUMA so -lnuma requires it in library-dirs in rts/package.conf.in
+ # FFI_LIB_DIR is a good indication of places it must be needed.
+ stdenv.lib.optionalString stdenv.hostPlatform.isAarch64 ''
+ find . -name package.conf.in \
+ -exec sed -i "s@FFI_LIB_DIR@FFI_LIB_DIR ${numactl.out}/lib@g" {} \;
+ '' +
+ # Rename needed libraries and binaries, fix interpreter
+ stdenv.lib.optionalString stdenv.isLinux ''
+ find . -type f -perm -0100 -exec patchelf \
+ --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.6 libncurses.so \
+ --interpreter ${glibcDynLinker} {} \;
+
+ sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
+ sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
+ '' +
+ # We're kludging a glibc bindist into working with non-glibc...
+ # Here we patch up the use of `__strdup` (part of glibc binary ABI)
+ # to instead use `strdup` since musl doesn't provide __strdup
+ # (`__strdup` is defined to be an alias of `strdup` anyway[1]).
+ # [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html
+ # Use objcopy magic to make the change:
+ stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+ find ./ghc-${version}/rts -name "libHSrts*.a" -exec ''${OBJCOPY:-objcopy} --redefine-sym __strdup=strdup {} \;
+ '';
+
+ # fix for `configure: error: Your linker is affected by binutils #16177`
+ preConfigure = stdenv.lib.optionalString
+ stdenv.targetPlatform.isAarch32
+ "LD=ld.gold";
+
+ configurePlatforms = [ ];
+ configureFlags = [
+ "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib"
+ "--with-gmp-includes=${stdenv.lib.getDev gmp}/include"
+ ] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
+ ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
+
+ # No building is necessary, but calling make without flags ironically
+ # calls install-strip ...
+ dontBuild = true;
+
+ # On Linux, use patchelf to modify the executables so that they can
+ # find editline/gmp.
+ postFixup = stdenv.lib.optionalString stdenv.isLinux
+ (if stdenv.hostPlatform.isAarch64 then
+ # Keep rpath as small as possible on aarch64 for patchelf#244. All Elfs
+ # are 2 directories deep from $out/lib, so pooling symlinks there makes
+ # a short rpath.
+ ''
+ (cd $out/lib; ln -s ${ncurses6.out}/lib/libtinfo.so.6)
+ (cd $out/lib; ln -s ${gmp.out}/lib/libgmp.so.10)
+ (cd $out/lib; ln -s ${numactl.out}/lib/libnuma.so.1)
+ for p in $(find "$out/lib" -type f -name "*\.so*"); do
+ (cd $out/lib; ln -s $p)
+ done
+
+ for p in $(find "$out/lib" -type f -executable); do
+ if isELF "$p"; then
+ echo "Patchelfing $p"
+ patchelf --set-rpath "\$ORIGIN:\$ORIGIN/../.." $p
+ fi
+ done
+ ''
+ else
+ ''
+ for p in $(find "$out" -type f -executable); do
+ if isELF "$p"; then
+ echo "Patchelfing $p"
+ patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
+ fi
+ done
+ '') + stdenv.lib.optionalString stdenv.isDarwin ''
+ # not enough room in the object files for the full path to libiconv :(
+ for exe in $(find "$out" -type f -executable); do
+ isScript $exe && continue
+ ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
+ install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
+ done
+
+ for file in $(find "$out" -name setup-config); do
+ substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
+ done
+ '' +
+ stdenv.lib.optionalString minimal ''
+ # Remove profiling files
+ find $out -type f -name '*.p_o' -delete
+ find $out -type f -name '*.p_hi' -delete
+ find $out -type f -name '*_p.a' -delete
+ rm $out/lib/ghc-*/bin/ghc-iserv-prof
+ # Hydra will redistribute this derivation, so we have to keep the docs for
+ # legal reasons (retaining the legal notices etc)
+ # As a last resort we could unpack the docs separately and symlink them in.
+ # They're in $out/share/{doc,man}.
+ '';
+
+ doInstallCheck = true;
+ installCheckPhase = ''
+ unset ${libEnvVar}
+ # Sanity check, can ghc create executables?
+ cd $TMP
+ mkdir test-ghc; cd test-ghc
+ cat > main.hs << EOF
+ {-# LANGUAGE TemplateHaskell #-}
+ module Main where
+ main = putStrLn \$([|"yes"|])
+ EOF
+ $out/bin/ghc --make main.hs || exit 1
+ echo compilation ok
+ [ $(./main) == "yes" ]
+ '';
+
+ passthru = {
+ targetPrefix = "";
+ enableShared = true;
+ };
+
+ meta = {
+ homepage = "http://haskell.org/ghc";
+ description = "The Glasgow Haskell Compiler";
+ license = stdenv.lib.licenses.bsd3;
+ platforms = ["x86_64-linux" "armv7l-linux" "aarch64-linux" "i686-linux" "x86_64-darwin"];
+ maintainers = with stdenv.lib.maintainers; [ lostnet ];
+ };
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.10.2.nix b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.10.2.nix
new file mode 100644
index 000000000000..fac12099d5db
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.10.2.nix
@@ -0,0 +1,259 @@
+{ stdenv, pkgsBuildTarget, targetPackages
+
+# build-tools
+, bootPkgs
+, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
+, bash
+
+, libiconv ? null, ncurses
+
+, # GHC can be built with system libffi or a bundled one.
+ libffi ? null
+
+, useLLVM ? !stdenv.targetPlatform.isx86
+, # LLVM is conceptually a run-time-only depedendency, but for
+ # non-x86, we need LLVM to bootstrap later stages, so it becomes a
+ # build-time dependency too.
+ buildLlvmPackages, llvmPackages
+
+, # If enabled, GHC will be built with the GPL-free but slower integer-simple
+ # library instead of the faster but GPLed integer-gmp library.
+ enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+
+, # If enabled, use -fPIC when compiling static libs.
+ enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
+
+ # aarch64 outputs otherwise exceed 2GB limit
+, enableProfiledLibs ? !stdenv.targetPlatform.isAarch64
+
+, # Whether to build dynamic libs for the standard library (on the target
+ # platform). Static libs are always built.
+ enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
+
+, # Whether to build terminfo.
+ enableTerminfo ? !stdenv.targetPlatform.isWindows
+
+, # What flavour to build. An empty string indicates no
+ # specific flavour and falls back to ghc default values.
+ ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+ (if useLLVM then "perf-cross" else "perf-cross-ncg")
+
+, # Whether to disable the large address space allocator
+ # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
+ disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64
+}:
+
+assert !enableIntegerSimple -> gmp != null;
+
+let
+ inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
+ inherit (bootPkgs) ghc;
+
+ # TODO(@Ericson2314) Make unconditional
+ targetPrefix = stdenv.lib.optionalString
+ (targetPlatform != hostPlatform)
+ "${targetPlatform.config}-";
+
+ buildMK = ''
+ BuildFlavour = ${ghcFlavour}
+ ifneq \"\$(BuildFlavour)\" \"\"
+ include mk/flavours/\$(BuildFlavour).mk
+ endif
+ DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
+ INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
+ '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+ Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
+ CrossCompilePrefix = ${targetPrefix}
+ HADDOCK_DOCS = NO
+ BUILD_SPHINX_HTML = NO
+ BUILD_SPHINX_PDF = NO
+ '' + stdenv.lib.optionalString (!enableProfiledLibs) ''
+ GhcLibWays = "v dyn"
+ '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+ GhcLibHcOpts += -fPIC
+ GhcRtsHcOpts += -fPIC
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ EXTRA_CC_OPTS += -std=gnu99
+ '';
+
+ # Splicer will pull out correct variations
+ libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+ ++ [libffi]
+ ++ stdenv.lib.optional (!enableIntegerSimple) gmp
+ ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+
+ toolsForTarget = [
+ pkgsBuildTarget.targetPackages.stdenv.cc
+ ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+
+ targetCC = builtins.head toolsForTarget;
+
+ # ld.gold is disabled for musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
+ # see #84670 and #49071 for more background.
+ useLdGold = targetPlatform.isLinux && !(targetPlatform.useLLVM or false) && !targetPlatform.isMusl;
+
+in
+stdenv.mkDerivation (rec {
+ version = "8.10.2";
+ name = "${targetPrefix}ghc-${version}";
+
+ src = fetchurl {
+ url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
+ sha256 = "02w8n085bw38vyp694j0lfk5wcnwkdaj7hhp0saj71x74533lmww";
+ };
+
+ enableParallelBuilding = true;
+
+ outputs = [ "out" "doc" ];
+
+ # https://gitlab.haskell.org/ghc/ghc/-/issues/18549
+ patches = [
+ ./issue-18549.patch
+ ] ++ stdenv.lib.optionals stdenv.isDarwin [
+ # Make Block.h compile with c++ compilers. Remove with the next release
+ (fetchpatch {
+ url = "https://gitlab.haskell.org/ghc/ghc/-/commit/97d0b0a367e4c6a52a17c3299439ac7de129da24.patch";
+ sha256 = "0r4zjj0bv1x1m2dgxp3adsf2xkr94fjnyj1igsivd9ilbs5ja0b5";
+ })
+ ];
+
+ postPatch = "patchShebangs .";
+
+ # GHC is a bit confused on its cross terminology.
+ preConfigure = ''
+ for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
+ export "''${env#TARGET_}=''${!env}"
+ done
+ # GHC is a bit confused on its cross terminology, as these would normally be
+ # the *host* tools.
+ export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
+ export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
+ # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
+ export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+ export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
+ export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
+ export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
+ export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
+ export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
+ export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
+
+ echo -n "${buildMK}" > mk/build.mk
+ sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
+ '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+ export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
+ export NIX_LDFLAGS+=" -no_dtrace_dof"
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ 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
+ '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+ echo "patching llvm-targets for musl targets..."
+ echo "Cloning these existing '*-linux-gnu*' targets:"
+ grep linux-gnu llvm-targets | sed 's/^/ /'
+ echo "(go go gadget sed)"
+ sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
+ echo "llvm-targets now contains these '*-linux-musl*' targets:"
+ grep linux-musl llvm-targets | sed 's/^/ /'
+
+ echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
+ # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
+ for x in configure aclocal.m4; do
+ substituteInPlace $x \
+ --replace '*-android*|*-gnueabi*)' \
+ '*-android*|*-gnueabi*|*-musleabi*)'
+ done
+ '';
+
+ # TODO(@Ericson2314): Always pass "--target" and always prefix.
+ configurePlatforms = [ "build" "host" ]
+ ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+
+ # `--with` flags for libraries needed for RTS linker
+ configureFlags = [
+ "--datadir=$doc/share/doc/ghc"
+ "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
+ ] ++ stdenv.lib.optionals (libffi != null) [
+ "--with-system-libffi"
+ "--with-ffi-includes=${targetPackages.libffi.dev}/include"
+ "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+ "--with-gmp-includes=${targetPackages.gmp.dev}/include"
+ "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+ "--with-iconv-includes=${libiconv}/include"
+ "--with-iconv-libraries=${libiconv}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+ "--enable-bootstrap-with-devel-snapshot"
+ ] ++ stdenv.lib.optionals useLdGold [
+ "CFLAGS=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
+ ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+ "--disable-large-address-space"
+ ];
+
+ # Make sure we never relax`$PATH` and hooks support for compatibility.
+ strictDeps = true;
+
+ # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
+ dontAddExtraLibs = true;
+
+ nativeBuildInputs = [
+ perl autoconf automake m4 python3 sphinx
+ ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
+ ];
+
+ # For building runtime libs
+ depsBuildTarget = toolsForTarget;
+
+ buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
+
+ propagatedBuildInputs = [ targetPackages.stdenv.cc ]
+ ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+
+ depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
+ depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+
+ # required, because otherwise all symbols from HSffi.o are stripped, and
+ # that in turn causes GHCi to abort
+ stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+
+ checkTarget = "test";
+
+ hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+
+ postInstall = ''
+ # Install the bash completion file.
+ install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
+
+ # Patch scripts to include "readelf" and "cat" in $PATH.
+ for i in "$out/bin/"*; do
+ test ! -h $i || continue
+ egrep --quiet '^#!' <(head -n 1 $i) || continue
+ sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+ done
+ '';
+
+ passthru = {
+ inherit bootPkgs targetPrefix;
+
+ inherit llvmPackages;
+ inherit enableShared;
+
+ # Our Cabal compiler name
+ haskellCompilerName = "ghc-${version}";
+ };
+
+ meta = {
+ homepage = "http://haskell.org/ghc";
+ description = "The Glasgow Haskell Compiler";
+ maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+ timeout = 24 * 3600;
+ inherit (ghc.meta) license platforms;
+ };
+
+} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
+ dontStrip = true;
+ dontPatchELF = true;
+ noAuditTmpdir = true;
+})
diff --git a/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.2.2-binary.nix b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.2.2-binary.nix
new file mode 100644
index 000000000000..9f546bcb541c
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.2.2-binary.nix
@@ -0,0 +1,191 @@
+{ stdenv, substituteAll
+, fetchurl, perl, gcc, llvm
+, ncurses5, gmp, glibc, libiconv
+, llvmPackages
+}:
+
+# Prebuilt only does native
+assert stdenv.targetPlatform == stdenv.hostPlatform;
+
+let
+ useLLVM = !stdenv.targetPlatform.isx86;
+
+ libPath = stdenv.lib.makeLibraryPath ([
+ ncurses5 gmp
+ ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
+
+ libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
+ + "LD_LIBRARY_PATH";
+
+ glibcDynLinker = assert stdenv.isLinux;
+ if stdenv.hostPlatform.libc == "glibc" then
+ # Could be stdenv.cc.bintools.dynamicLinker, keeping as-is to avoid rebuild.
+ ''"$(cat $NIX_CC/nix-support/dynamic-linker)"''
+ else
+ "${stdenv.lib.getLib glibc}/lib/ld-linux*";
+
+in
+
+stdenv.mkDerivation rec {
+ version = "8.2.2";
+
+ name = "ghc-${version}-binary";
+
+ src = fetchurl ({
+ i686-linux = {
+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-deb8-linux.tar.xz";
+ sha256 = "08w2ik55dp3n95qikmrflc91lsiq01xp53ki3jlhnbj8fqnxfrwy";
+ };
+ x86_64-linux = {
+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-deb8-linux.tar.xz";
+ sha256 = "0ahv26304pqi3dm7i78si4pxwvg5f5dc2jwsfgvcrhcx5g30bqj8";
+ };
+ armv7l-linux = {
+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-armv7-deb8-linux.tar.xz";
+ sha256 = "1jmv8qmnh5bn324fivbwdcaj55kvw7cb2zq9pafmlmv3qwwx7s46";
+ };
+ aarch64-linux = {
+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-aarch64-deb8-linux.tar.xz";
+ sha256 = "1k2amylcp1ad67c75h1pqf7czf9m0zj1i7hdc45ghjklnfq9hrk7";
+ };
+ x86_64-darwin = {
+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
+ sha256 = "09swx71gh5habzbx55shz2xykgr96xkcy09nzinnm4z0yxicy3zr";
+ };
+ }.${stdenv.hostPlatform.system}
+ or (throw "cannot bootstrap GHC on this platform"));
+
+ nativeBuildInputs = [ perl ];
+ propagatedBuildInputs = stdenv.lib.optionals useLLVM [ llvmPackages.llvm ];
+
+ # Cannot patchelf beforehand due to relative RPATHs that anticipate
+ # the final install location/
+ ${libEnvVar} = libPath;
+
+ postUnpack =
+ # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
+ # during linking
+ stdenv.lib.optionalString stdenv.isDarwin ''
+ export NIX_LDFLAGS+=" -no_dtrace_dof"
+ # not enough room in the object files for the full path to libiconv :(
+ for exe in $(find . -type f -executable); do
+ isScript $exe && continue
+ ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
+ install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
+ done
+ '' +
+
+ # Some scripts used during the build need to have their shebangs patched
+ ''
+ patchShebangs ghc-${version}/utils/
+ patchShebangs ghc-${version}/configure
+ '' +
+
+ # Strip is harmful, see also below. It's important that this happens
+ # first. The GHC Cabal build system makes use of strip by default and
+ # has hardcoded paths to /usr/bin/strip in many places. We replace
+ # those below, making them point to our dummy script.
+ ''
+ mkdir "$TMP/bin"
+ for i in strip; do
+ echo '#! ${stdenv.shell}' > "$TMP/bin/$i"
+ chmod +x "$TMP/bin/$i"
+ done
+ PATH="$TMP/bin:$PATH"
+ '' +
+ # We have to patch the GMP paths for the integer-gmp package.
+ ''
+ find . -name integer-gmp.buildinfo \
+ -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
+ find . -name base.buildinfo \
+ -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
+ '' +
+ # Rename needed libraries and binaries, fix interpreter
+ stdenv.lib.optionalString stdenv.isLinux ''
+ find . -type f -perm -0100 -exec patchelf \
+ --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
+ --replace-needed libtinfo.so libtinfo.so.5 \
+ --interpreter ${glibcDynLinker} {} \;
+
+ sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
+ sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
+ '' +
+ # We're kludging a glibc bindist into working with non-glibc...
+ # Here we patch up the use of `__strdup` (part of glibc binary ABI)
+ # to instead use `strdup` since musl doesn't provide __strdup
+ # (`__strdup` is defined to be an alias of `strdup` anyway[1]).
+ # [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html
+ # Use objcopy magic to make the change:
+ stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+ find ./ghc-${version}/rts -name "libHSrts*.a" -exec ''${OBJCOPY:-objcopy} --redefine-sym __strdup=strdup {} \;
+ '';
+
+ configurePlatforms = [ ];
+ configureFlags =
+ let
+ gcc-clang-wrapper = substituteAll {
+ inherit (stdenv) shell;
+ isExecutable = true;
+ src = ./gcc-clang-wrapper.sh;
+ };
+ in
+ [ "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib"
+ "--with-gmp-includes=${stdenv.lib.getDev gmp}/include"
+ ] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${gcc-clang-wrapper}"
+ ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
+
+ # Stripping combined with patchelf breaks the executables (they die
+ # with a segfault or the kernel even refuses the execve). (NIXPKGS-85)
+ dontStrip = true;
+
+ # No building is necessary, but calling make without flags ironically
+ # calls install-strip ...
+ dontBuild = true;
+
+ # On Linux, use patchelf to modify the executables so that they can
+ # find editline/gmp.
+ preFixup = stdenv.lib.optionalString stdenv.isLinux ''
+ for p in $(find "$out" -type f -executable); do
+ if isELF "$p"; then
+ echo "Patchelfing $p"
+ patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
+ fi
+ done
+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
+ # not enough room in the object files for the full path to libiconv :(
+ for exe in $(find "$out" -type f -executable); do
+ isScript $exe && continue
+ ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
+ install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
+ done
+
+ for file in $(find "$out" -name setup-config); do
+ substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
+ done
+ '';
+
+ doInstallCheck = true;
+ installCheckPhase = ''
+ unset ${libEnvVar}
+ # Sanity check, can ghc create executables?
+ cd $TMP
+ mkdir test-ghc; cd test-ghc
+ cat > main.hs << EOF
+ {-# LANGUAGE TemplateHaskell #-}
+ module Main where
+ main = putStrLn \$([|"yes"|])
+ EOF
+ $out/bin/ghc --make main.hs || exit 1
+ echo compilation ok
+ [ $(./main) == "yes" ]
+ '';
+
+ passthru = {
+ targetPrefix = "";
+ enableShared = true;
+ };
+
+ meta.license = stdenv.lib.licenses.bsd3;
+ meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin" "armv7l-linux" "aarch64-linux"];
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.6.5-binary.nix b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.6.5-binary.nix
new file mode 100644
index 000000000000..9234e3b14571
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.6.5-binary.nix
@@ -0,0 +1,176 @@
+{ stdenv
+, fetchurl, perl, gcc
+, ncurses5, ncurses6, gmp, glibc, libiconv
+, llvmPackages
+}:
+
+# Prebuilt only does native
+assert stdenv.targetPlatform == stdenv.hostPlatform;
+
+let
+ useLLVM = !stdenv.targetPlatform.isx86;
+
+ useNcurses6 = stdenv.hostPlatform.system == "x86_64-linux";
+
+ ourNcurses = if useNcurses6 then ncurses6 else ncurses5;
+
+ libPath = stdenv.lib.makeLibraryPath ([
+ ourNcurses gmp
+ ] ++ stdenv.lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
+
+ libEnvVar = stdenv.lib.optionalString stdenv.hostPlatform.isDarwin "DY"
+ + "LD_LIBRARY_PATH";
+
+ glibcDynLinker = assert stdenv.isLinux;
+ if stdenv.hostPlatform.libc == "glibc" then
+ # Could be stdenv.cc.bintools.dynamicLinker, keeping as-is to avoid rebuild.
+ ''"$(cat $NIX_CC/nix-support/dynamic-linker)"''
+ else
+ "${stdenv.lib.getLib glibc}/lib/ld-linux*";
+
+in
+
+stdenv.mkDerivation rec {
+ version = "8.6.5";
+
+ name = "ghc-${version}-binary";
+
+ # https://downloads.haskell.org/~ghc/8.6.5/
+ src = fetchurl ({
+ i686-linux = {
+ # Don't use the Fedora27 build (as below) because there isn't one!
+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
+ sha256 = "1p2h29qghql19ajk755xa0yxkn85slbds8m9n5196ris743vkp8w";
+ };
+ x86_64-linux = {
+ # This is the Fedora build because it links against ncurses6 where the
+ # deb9 one links against ncurses5, see here
+ # https://github.com/NixOS/nixpkgs/issues/85924 for a discussion
+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-fedora27-linux.tar.xz";
+ sha256 = "18dlqm5d028fqh6ghzn7pgjspr5smw030jjzl3kq6q1kmwzbay6g";
+ };
+ aarch64-linux = {
+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-aarch64-ubuntu18.04-linux.tar.xz";
+ sha256 = "11n7l2a36i5vxzzp85la2555q4m34l747g0pnmd81cp46y85hlhq";
+ };
+ x86_64-darwin = {
+ url = "http://haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
+ sha256 = "0s9188vhhgf23q3rjarwhbr524z6h2qga5xaaa2pma03sfqvvhfz";
+ };
+ }.${stdenv.hostPlatform.system}
+ or (throw "cannot bootstrap GHC on this platform"));
+
+ nativeBuildInputs = [ perl ];
+ propagatedBuildInputs = stdenv.lib.optionals useLLVM [ llvmPackages.llvm ];
+
+ # Cannot patchelf beforehand due to relative RPATHs that anticipate
+ # the final install location/
+ ${libEnvVar} = libPath;
+
+ postUnpack =
+ # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
+ # during linking
+ stdenv.lib.optionalString stdenv.isDarwin ''
+ export NIX_LDFLAGS+=" -no_dtrace_dof"
+ # not enough room in the object files for the full path to libiconv :(
+ for exe in $(find . -type f -executable); do
+ isScript $exe && continue
+ ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
+ install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
+ done
+ '' +
+
+ # Some scripts used during the build need to have their shebangs patched
+ ''
+ patchShebangs ghc-${version}/utils/
+ patchShebangs ghc-${version}/configure
+ '' +
+
+ # We have to patch the GMP paths for the integer-gmp package.
+ ''
+ find . -name integer-gmp.buildinfo \
+ -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
+ find . -name base.buildinfo \
+ -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
+ '' +
+ # Rename needed libraries and binaries, fix interpreter
+ stdenv.lib.optionalString stdenv.isLinux ''
+ find . -type f -perm -0100 \
+ -exec patchelf \
+ --replace-needed libncurses${stdenv.lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
+ ${ # This isn't required for x86_64-linux where we use ncurses6
+ stdenv.lib.optionalString (!useNcurses6) "--replace-needed libtinfo.so libtinfo.so.5"
+ } \
+ --interpreter ${glibcDynLinker} {} \;
+
+ sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
+ sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
+ '' +
+ # We're kludging a glibc bindist into working with non-glibc...
+ # Here we patch up the use of `__strdup` (part of glibc binary ABI)
+ # to instead use `strdup` since musl doesn't provide __strdup
+ # (`__strdup` is defined to be an alias of `strdup` anyway[1]).
+ # [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html
+ # Use objcopy magic to make the change:
+ stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
+ find ./ghc-${version}/rts -name "libHSrts*.a" -exec ''${OBJCOPY:-objcopy} --redefine-sym __strdup=strdup {} \;
+ '';
+
+ configurePlatforms = [ ];
+ configureFlags = [
+ "--with-gmp-libraries=${stdenv.lib.getLib gmp}/lib"
+ "--with-gmp-includes=${stdenv.lib.getDev gmp}/include"
+ ] ++ stdenv.lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
+ ++ stdenv.lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
+
+ # No building is necessary, but calling make without flags ironically
+ # calls install-strip ...
+ dontBuild = true;
+
+ # On Linux, use patchelf to modify the executables so that they can
+ # find editline/gmp.
+ postFixup = stdenv.lib.optionalString stdenv.isLinux ''
+ for p in $(find "$out" -type f -executable); do
+ if isELF "$p"; then
+ echo "Patchelfing $p"
+ patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
+ fi
+ done
+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
+ # not enough room in the object files for the full path to libiconv :(
+ for exe in $(find "$out" -type f -executable); do
+ isScript $exe && continue
+ ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
+ install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
+ done
+
+ for file in $(find "$out" -name setup-config); do
+ substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
+ done
+ '';
+
+ doInstallCheck = true;
+ installCheckPhase = ''
+ unset ${libEnvVar}
+ # Sanity check, can ghc create executables?
+ cd $TMP
+ mkdir test-ghc; cd test-ghc
+ cat > main.hs << EOF
+ {-# LANGUAGE TemplateHaskell #-}
+ module Main where
+ main = putStrLn \$([|"yes"|])
+ EOF
+ $out/bin/ghc --make main.hs || exit 1
+ echo compilation ok
+ [ $(./main) == "yes" ]
+ '';
+
+ passthru = {
+ targetPrefix = "";
+ enableShared = true;
+ };
+
+ meta.license = stdenv.lib.licenses.bsd3;
+ meta.platforms = ["x86_64-linux" "aarch64-linux" "i686-linux" "x86_64-darwin"];
+}
diff --git a/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.6.5.nix b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.6.5.nix
new file mode 100644
index 000000000000..7adacff597ca
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.6.5.nix
@@ -0,0 +1,267 @@
+{ stdenv, pkgsBuildTarget, targetPackages
+
+# build-tools
+, bootPkgs
+, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4, sphinx
+, bash
+
+, libiconv ? null, ncurses
+
+, # GHC can be built with system libffi or a bundled one.
+ libffi ? null
+
+, useLLVM ? !stdenv.targetPlatform.isx86 || stdenv.targetPlatform.isiOS
+, # LLVM is conceptually a run-time-only depedendency, but for
+ # non-x86, we need LLVM to bootstrap later stages, so it becomes a
+ # build-time dependency too.
+ buildLlvmPackages, llvmPackages
+
+, # If enabled, GHC will be built with the GPL-free but slower integer-simple
+ # library instead of the faster but GPLed integer-gmp library.
+ enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+
+, # If enabled, use -fPIC when compiling static libs.
+ enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
+
+, # Whether to build dynamic libs for the standard library (on the target
+ # platform). Static libs are always built.
+ enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
+
+, # Whether to build terminfo.
+ enableTerminfo ? !stdenv.targetPlatform.isWindows
+
+, # What flavour to build. An empty string indicates no
+ # specific flavour and falls back to ghc default values.
+ ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+ (if useLLVM then "perf-cross" else "perf-cross-ncg")
+
+, # Whether to disable the large address space allocator
+ # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
+ disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64
+}:
+
+assert !enableIntegerSimple -> gmp != null;
+
+let
+ inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
+ inherit (bootPkgs) ghc;
+
+ # TODO(@Ericson2314) Make unconditional
+ targetPrefix = stdenv.lib.optionalString
+ (targetPlatform != hostPlatform)
+ "${targetPlatform.config}-";
+
+ buildMK = ''
+ BuildFlavour = ${ghcFlavour}
+ ifneq \"\$(BuildFlavour)\" \"\"
+ include mk/flavours/\$(BuildFlavour).mk
+ endif
+ DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
+ INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
+ ''
+ # We only need to build stage1 on most cross-compilation because
+ # we will be running the compiler on the native system. In some
+ # situations, like native Musl compilation, we need the compiler
+ # to actually link to our new Libc. The iOS simulator is a special
+ # exception because we can’t actually run simulators binaries
+ # ourselves.
+ + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+ Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
+ CrossCompilePrefix = ${targetPrefix}
+ HADDOCK_DOCS = NO
+ BUILD_SPHINX_HTML = NO
+ BUILD_SPHINX_PDF = NO
+ '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+ GhcLibHcOpts += -fPIC
+ GhcRtsHcOpts += -fPIC
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ EXTRA_CC_OPTS += -std=gnu99
+ '';
+
+ # Splicer will pull out correct variations
+ libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+ ++ [libffi]
+ ++ stdenv.lib.optional (!enableIntegerSimple) gmp
+ ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+
+ toolsForTarget = [
+ pkgsBuildTarget.targetPackages.stdenv.cc
+ ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+
+ targetCC = builtins.head toolsForTarget;
+
+ # ld.gold is disabled for musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
+ # see #84670 and #49071 for more background.
+ useLdGold = targetPlatform.isLinux && !(targetPlatform.useLLVM or false) && !targetPlatform.isMusl;
+
+in
+stdenv.mkDerivation (rec {
+ version = "8.6.5";
+ name = "${targetPrefix}ghc-${version}";
+
+ src = fetchurl {
+ url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
+ sha256 = "0qg3zsmbk4rkwkc3jpas3zs74qaxmw4sp4v1mhsbj0a0dzls2jjd";
+ };
+
+ enableParallelBuilding = true;
+
+ outputs = [ "out" "doc" ];
+
+ patches = [
+ (fetchpatch { # https://phabricator.haskell.org/D5123
+ url = "https://gitlab.haskell.org/ghc/ghc/-/commit/13ff0b7ced097286e0d7b054f050871effe07f86.diff";
+ name = "D5123.diff";
+ sha256 = "140lmnqxra7xkwy370c5pyf8dgdwgmbpcrs1dapnwr2dh8bavn8c";
+ })
+ (fetchpatch { # https://github.com/haskell/haddock/issues/900
+ url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/983.diff";
+ name = "loadpluginsinmodules.diff";
+ sha256 = "0bvvv0zsfq2581zsir97zfkggc1kkircbbajc2fz3b169ycpbha1";
+ extraPrefix = "utils/haddock/";
+ stripLen = 1;
+ })
+ ];
+
+ postPatch = "patchShebangs .";
+
+ # GHC is a bit confused on its cross terminology.
+ preConfigure = ''
+ for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
+ export "''${env#TARGET_}=''${!env}"
+ done
+ # GHC is a bit confused on its cross terminology, as these would normally be
+ # the *host* tools.
+ export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
+ export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
+ # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
+ export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+ export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
+ export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
+ export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
+ export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
+ export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
+ export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
+
+ echo -n "${buildMK}" > mk/build.mk
+ sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
+ '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+ export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
+ export NIX_LDFLAGS+=" -no_dtrace_dof"
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ 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
+ '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+ echo "patching llvm-targets for musl targets..."
+ echo "Cloning these existing '*-linux-gnu*' targets:"
+ grep linux-gnu llvm-targets | sed 's/^/ /'
+ echo "(go go gadget sed)"
+ sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
+ echo "llvm-targets now contains these '*-linux-musl*' targets:"
+ grep linux-musl llvm-targets | sed 's/^/ /'
+
+ echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
+ # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
+ for x in configure aclocal.m4; do
+ substituteInPlace $x \
+ --replace '*-android*|*-gnueabi*)' \
+ '*-android*|*-gnueabi*|*-musleabi*)'
+ done
+ '';
+
+ # TODO(@Ericson2314): Always pass "--target" and always prefix.
+ configurePlatforms = [ "build" "host" ]
+ ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+ # `--with` flags for libraries needed for RTS linker
+ configureFlags = [
+ "--datadir=$doc/share/doc/ghc"
+ "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
+ ] ++ stdenv.lib.optionals (libffi != null) ["--with-system-libffi" "--with-ffi-includes=${targetPackages.libffi.dev}/include" "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+ "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+ "--enable-bootstrap-with-devel-snapshot"
+ ] ++ stdenv.lib.optionals useLdGold [
+ "CFLAGS=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
+ ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+ "--disable-large-address-space"
+ ];
+
+ # Make sure we never relax`$PATH` and hooks support for compatibility.
+ strictDeps = true;
+
+ # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
+ dontAddExtraLibs = true;
+
+ nativeBuildInputs = [
+ perl autoconf automake m4 python3 sphinx
+ ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
+ ];
+
+ # For building runtime libs
+ depsBuildTarget = toolsForTarget;
+
+ buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
+
+ propagatedBuildInputs = [ targetPackages.stdenv.cc ]
+ ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+
+ depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
+ depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+
+ # required, because otherwise all symbols from HSffi.o are stripped, and
+ # that in turn causes GHCi to abort
+ stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+
+ # See #63511 - the only unstripped file is the debug rts which isn't meant to
+ # be stripped.
+ dontStrip = true;
+
+ checkTarget = "test";
+
+ hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+
+ postInstall = ''
+ # Install the bash completion file.
+ install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
+
+ # Patch scripts to include "readelf" and "cat" in $PATH.
+ for i in "$out/bin/"*; do
+ test ! -h $i || continue
+ egrep --quiet '^#!' <(head -n 1 $i) || continue
+ sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+ done
+ ''
+ # Temporary work-around for https://github.com/NixOS/nixpkgs/issues/66277
+ + stdenv.lib.optionalString hostPlatform.isAarch64 ''
+ rm -rf "$doc/share/doc/ghc/html/libraries"
+ '';
+
+ passthru = {
+ inherit bootPkgs targetPrefix;
+
+ inherit llvmPackages;
+ inherit enableShared;
+
+ # Our Cabal compiler name
+ haskellCompilerName = "ghc-${version}";
+ };
+
+ meta = {
+ homepage = "http://haskell.org/ghc";
+ description = "The Glasgow Haskell Compiler";
+ maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+ timeout = 24 * 3600;
+ inherit (ghc.meta) license platforms;
+ };
+
+} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
+ dontStrip = true;
+ dontPatchELF = true;
+ noAuditTmpdir = true;
+})
diff --git a/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.8.2.nix b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.8.2.nix
new file mode 100644
index 000000000000..fbb75637df65
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.8.2.nix
@@ -0,0 +1,253 @@
+{ stdenv, pkgsBuildTarget, targetPackages
+
+# build-tools
+, bootPkgs
+, autoconf, automake, coreutils, fetchurl, perl, python3, m4, sphinx
+, bash
+
+, libiconv ? null, ncurses
+
+, # GHC can be built with system libffi or a bundled one.
+ libffi ? null
+
+, useLLVM ? !stdenv.targetPlatform.isx86
+, # LLVM is conceptually a run-time-only depedendency, but for
+ # non-x86, we need LLVM to bootstrap later stages, so it becomes a
+ # build-time dependency too.
+ buildLlvmPackages, llvmPackages
+
+, # If enabled, GHC will be built with the GPL-free but slower integer-simple
+ # library instead of the faster but GPLed integer-gmp library.
+ enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+
+, # If enabled, use -fPIC when compiling static libs.
+ enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
+
+, # Whether to build dynamic libs for the standard library (on the target
+ # platform). Static libs are always built.
+ enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
+
+, # Whether to build terminfo.
+ enableTerminfo ? !stdenv.targetPlatform.isWindows
+
+, # What flavour to build. An empty string indicates no
+ # specific flavour and falls back to ghc default values.
+ ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+ (if useLLVM then "perf-cross" else "perf-cross-ncg")
+
+, # Whether to disable the large address space allocator
+ # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
+ disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64
+}:
+
+assert !enableIntegerSimple -> gmp != null;
+
+let
+ inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
+ inherit (bootPkgs) ghc;
+
+ # TODO(@Ericson2314) Make unconditional
+ targetPrefix = stdenv.lib.optionalString
+ (targetPlatform != hostPlatform)
+ "${targetPlatform.config}-";
+
+ buildMK = dontStrip: ''
+ BuildFlavour = ${ghcFlavour}
+ ifneq \"\$(BuildFlavour)\" \"\"
+ include mk/flavours/\$(BuildFlavour).mk
+ endif
+ DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
+ INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
+ ''
+ # We only need to build stage1 on most cross-compilation because
+ # we will be running the compiler on the native system. In some
+ # situations, like native Musl compilation, we need the compiler
+ # to actually link to our new Libc. The iOS simulator is a special
+ # exception because we can’t actually run simulators binaries
+ # ourselves.
+ + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+ Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
+ CrossCompilePrefix = ${targetPrefix}
+ HADDOCK_DOCS = NO
+ BUILD_SPHINX_HTML = NO
+ BUILD_SPHINX_PDF = NO
+ '' + stdenv.lib.optionalString dontStrip ''
+ STRIP_CMD = :
+ '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+ GhcLibHcOpts += -fPIC
+ GhcRtsHcOpts += -fPIC
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ EXTRA_CC_OPTS += -std=gnu99
+ '';
+
+ # Splicer will pull out correct variations
+ libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+ ++ [libffi]
+ ++ stdenv.lib.optional (!enableIntegerSimple) gmp
+ ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+
+ toolsForTarget = [
+ pkgsBuildTarget.targetPackages.stdenv.cc
+ ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+
+ targetCC = builtins.head toolsForTarget;
+
+ # ld.gold is disabled for musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
+ # see #84670 and #49071 for more background.
+ useLdGold = targetPlatform.isLinux && !(targetPlatform.useLLVM or false) && !targetPlatform.isMusl;
+
+in
+stdenv.mkDerivation (rec {
+ version = "8.8.2";
+ name = "${targetPrefix}ghc-${version}";
+
+ src = fetchurl {
+ url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
+ sha256 = "02qa6wgjpxgakg7hv4zfdlrx9k7zxa5i02wnr6y9fsv8j16sbkh1";
+ };
+
+ enableParallelBuilding = true;
+
+ outputs = [ "out" "doc" ];
+
+ postPatch = "patchShebangs .";
+
+ # GHC is a bit confused on its cross terminology.
+ preConfigure = ''
+ for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
+ export "''${env#TARGET_}=''${!env}"
+ done
+ # GHC is a bit confused on its cross terminology, as these would normally be
+ # the *host* tools.
+ export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
+ export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
+ # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
+ export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+ export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
+ export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
+ export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
+ export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
+ export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
+ export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
+
+ echo -n "${buildMK dontStrip}" > mk/build.mk
+ sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
+ '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+ export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
+ export NIX_LDFLAGS+=" -no_dtrace_dof"
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ 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
+ '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+ echo "patching llvm-targets for musl targets..."
+ echo "Cloning these existing '*-linux-gnu*' targets:"
+ grep linux-gnu llvm-targets | sed 's/^/ /'
+ echo "(go go gadget sed)"
+ sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
+ echo "llvm-targets now contains these '*-linux-musl*' targets:"
+ grep linux-musl llvm-targets | sed 's/^/ /'
+
+ echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
+ # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
+ for x in configure aclocal.m4; do
+ substituteInPlace $x \
+ --replace '*-android*|*-gnueabi*)' \
+ '*-android*|*-gnueabi*|*-musleabi*)'
+ done
+ '';
+
+ # TODO(@Ericson2314): Always pass "--target" and always prefix.
+ configurePlatforms = [ "build" "host" ]
+ ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+
+ # `--with` flags for libraries needed for RTS linker
+ configureFlags = [
+ "--datadir=$doc/share/doc/ghc"
+ "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
+ ] ++ stdenv.lib.optionals (libffi != null) [
+ "--with-system-libffi"
+ "--with-ffi-includes=${targetPackages.libffi.dev}/include"
+ "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+ "--with-gmp-includes=${targetPackages.gmp.dev}/include"
+ "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+ "--with-iconv-includes=${libiconv}/include"
+ "--with-iconv-libraries=${libiconv}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+ "--enable-bootstrap-with-devel-snapshot"
+ ] ++ stdenv.lib.optionals useLdGold [
+ "CFLAGS=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
+ ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+ "--disable-large-address-space"
+ ];
+
+ # Make sure we never relax`$PATH` and hooks support for compatibility.
+ strictDeps = true;
+
+ # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
+ dontAddExtraLibs = true;
+
+ nativeBuildInputs = [
+ perl autoconf automake m4 python3 sphinx
+ ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
+ ];
+
+ # For building runtime libs
+ depsBuildTarget = toolsForTarget;
+
+ buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
+
+ propagatedBuildInputs = [ targetPackages.stdenv.cc ]
+ ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+
+ depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
+ depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+
+ # required, because otherwise all symbols from HSffi.o are stripped, and
+ # that in turn causes GHCi to abort
+ stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+
+ checkTarget = "test";
+
+ hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+
+ postInstall = ''
+ # Install the bash completion file.
+ install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
+
+ # Patch scripts to include "readelf" and "cat" in $PATH.
+ for i in "$out/bin/"*; do
+ test ! -h $i || continue
+ egrep --quiet '^#!' <(head -n 1 $i) || continue
+ sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+ done
+ '';
+
+ passthru = {
+ inherit bootPkgs targetPrefix;
+
+ inherit llvmPackages;
+ inherit enableShared;
+
+ # Our Cabal compiler name
+ haskellCompilerName = "ghc-${version}";
+ };
+
+ meta = {
+ homepage = "http://haskell.org/ghc";
+ description = "The Glasgow Haskell Compiler";
+ maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+ timeout = 24 * 3600;
+ inherit (ghc.meta) license platforms;
+ };
+
+ dontStrip = (targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm);
+
+} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
+ dontPatchELF = true;
+ noAuditTmpdir = true;
+})
diff --git a/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.8.3.nix b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.8.3.nix
new file mode 100644
index 000000000000..538655a0d056
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.8.3.nix
@@ -0,0 +1,258 @@
+{ stdenv, pkgsBuildTarget, targetPackages
+
+# build-tools
+, bootPkgs
+, autoconf, automake, coreutils, fetchurl, perl, python3, m4, sphinx
+, bash
+
+, libiconv ? null, ncurses
+
+, # GHC can be built with system libffi or a bundled one.
+ libffi ? null
+
+, useLLVM ? !stdenv.targetPlatform.isx86
+, # LLVM is conceptually a run-time-only depedendency, but for
+ # non-x86, we need LLVM to bootstrap later stages, so it becomes a
+ # build-time dependency too.
+ buildLlvmPackages, llvmPackages
+
+, # If enabled, GHC will be built with the GPL-free but slower integer-simple
+ # library instead of the faster but GPLed integer-gmp library.
+ enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+
+, # If enabled, use -fPIC when compiling static libs.
+ enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
+
+ # aarch64 outputs otherwise exceed 2GB limit
+, enableProfiledLibs ? !stdenv.targetPlatform.isAarch64
+
+, # Whether to build dynamic libs for the standard library (on the target
+ # platform). Static libs are always built.
+ enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
+
+, # Whether to build terminfo.
+ enableTerminfo ? !stdenv.targetPlatform.isWindows
+
+, # What flavour to build. An empty string indicates no
+ # specific flavour and falls back to ghc default values.
+ ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+ (if useLLVM then "perf-cross" else "perf-cross-ncg")
+
+, # Whether to disable the large address space allocator
+ # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
+ disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64
+}:
+
+assert !enableIntegerSimple -> gmp != null;
+
+let
+ inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
+ inherit (bootPkgs) ghc;
+
+ # TODO(@Ericson2314) Make unconditional
+ targetPrefix = stdenv.lib.optionalString
+ (targetPlatform != hostPlatform)
+ "${targetPlatform.config}-";
+
+ buildMK = dontStrip: ''
+ BuildFlavour = ${ghcFlavour}
+ ifneq \"\$(BuildFlavour)\" \"\"
+ include mk/flavours/\$(BuildFlavour).mk
+ endif
+ DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
+ INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
+ ''
+ # We only need to build stage1 on most cross-compilation because
+ # we will be running the compiler on the native system. In some
+ # situations, like native Musl compilation, we need the compiler
+ # to actually link to our new Libc. The iOS simulator is a special
+ # exception because we can’t actually run simulators binaries
+ # ourselves.
+ + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+ Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
+ CrossCompilePrefix = ${targetPrefix}
+ HADDOCK_DOCS = NO
+ BUILD_SPHINX_HTML = NO
+ BUILD_SPHINX_PDF = NO
+ '' + stdenv.lib.optionalString dontStrip ''
+ STRIP_CMD = :
+ '' + stdenv.lib.optionalString (!enableProfiledLibs) ''
+ GhcLibWays = "v dyn"
+ '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+ GhcLibHcOpts += -fPIC
+ GhcRtsHcOpts += -fPIC
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ EXTRA_CC_OPTS += -std=gnu99
+ '';
+
+ # Splicer will pull out correct variations
+ libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+ ++ [libffi]
+ ++ stdenv.lib.optional (!enableIntegerSimple) gmp
+ ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+
+ toolsForTarget = [
+ pkgsBuildTarget.targetPackages.stdenv.cc
+ ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+
+ targetCC = builtins.head toolsForTarget;
+
+ # ld.gold is disabled for musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
+ # see #84670 and #49071 for more background.
+ useLdGold = targetPlatform.isLinux && !(targetPlatform.useLLVM or false) && !targetPlatform.isMusl;
+
+in
+stdenv.mkDerivation (rec {
+ version = "8.8.3";
+ name = "${targetPrefix}ghc-${version}";
+
+ src = fetchurl {
+ url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
+ sha256 = "128g932i3wix6ic03v04nh5755vyjiidzri9iybwad72yfmc1p70";
+ };
+
+ enableParallelBuilding = true;
+
+ outputs = [ "out" "doc" ];
+
+ postPatch = "patchShebangs .";
+
+ # GHC is a bit confused on its cross terminology.
+ preConfigure = ''
+ for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
+ export "''${env#TARGET_}=''${!env}"
+ done
+ # GHC is a bit confused on its cross terminology, as these would normally be
+ # the *host* tools.
+ export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
+ export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
+ # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
+ export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+ export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
+ export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
+ export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
+ export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
+ export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
+ export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
+
+ echo -n "${buildMK dontStrip}" > mk/build.mk
+ sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
+ '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+ export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
+ export NIX_LDFLAGS+=" -no_dtrace_dof"
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ 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
+ '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+ echo "patching llvm-targets for musl targets..."
+ echo "Cloning these existing '*-linux-gnu*' targets:"
+ grep linux-gnu llvm-targets | sed 's/^/ /'
+ echo "(go go gadget sed)"
+ sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
+ echo "llvm-targets now contains these '*-linux-musl*' targets:"
+ grep linux-musl llvm-targets | sed 's/^/ /'
+
+ echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
+ # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
+ for x in configure aclocal.m4; do
+ substituteInPlace $x \
+ --replace '*-android*|*-gnueabi*)' \
+ '*-android*|*-gnueabi*|*-musleabi*)'
+ done
+ '';
+
+ # TODO(@Ericson2314): Always pass "--target" and always prefix.
+ configurePlatforms = [ "build" "host" ]
+ ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+
+ # `--with` flags for libraries needed for RTS linker
+ configureFlags = [
+ "--datadir=$doc/share/doc/ghc"
+ "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
+ ] ++ stdenv.lib.optionals (libffi != null) [
+ "--with-system-libffi"
+ "--with-ffi-includes=${targetPackages.libffi.dev}/include"
+ "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+ "--with-gmp-includes=${targetPackages.gmp.dev}/include"
+ "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+ "--with-iconv-includes=${libiconv}/include"
+ "--with-iconv-libraries=${libiconv}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+ "--enable-bootstrap-with-devel-snapshot"
+ ] ++ stdenv.lib.optionals useLdGold [
+ "CFLAGS=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
+ ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+ "--disable-large-address-space"
+ ];
+
+ # Make sure we never relax`$PATH` and hooks support for compatibility.
+ strictDeps = true;
+
+ # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
+ dontAddExtraLibs = true;
+
+ nativeBuildInputs = [
+ perl autoconf automake m4 python3 sphinx
+ ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
+ ];
+
+ # For building runtime libs
+ depsBuildTarget = toolsForTarget;
+
+ buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
+
+ propagatedBuildInputs = [ targetPackages.stdenv.cc ]
+ ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+
+ depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
+ depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+
+ # required, because otherwise all symbols from HSffi.o are stripped, and
+ # that in turn causes GHCi to abort
+ stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+
+ checkTarget = "test";
+
+ hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+
+ postInstall = ''
+ # Install the bash completion file.
+ install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
+
+ # Patch scripts to include "readelf" and "cat" in $PATH.
+ for i in "$out/bin/"*; do
+ test ! -h $i || continue
+ egrep --quiet '^#!' <(head -n 1 $i) || continue
+ sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+ done
+ '';
+
+ passthru = {
+ inherit bootPkgs targetPrefix;
+
+ inherit llvmPackages;
+ inherit enableShared;
+
+ # Our Cabal compiler name
+ haskellCompilerName = "ghc-${version}";
+ };
+
+ meta = {
+ homepage = "http://haskell.org/ghc";
+ description = "The Glasgow Haskell Compiler";
+ maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+ timeout = 24 * 3600;
+ inherit (ghc.meta) license platforms;
+ };
+
+ dontStrip = (targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm);
+
+} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
+ dontPatchELF = true;
+ noAuditTmpdir = true;
+})
diff --git a/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.8.4.nix b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.8.4.nix
new file mode 100644
index 000000000000..e69766bccdaa
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/8.8.4.nix
@@ -0,0 +1,262 @@
+{ stdenv, pkgsBuildTarget, targetPackages
+
+# build-tools
+, bootPkgs
+, autoconf, automake, coreutils, fetchurl, perl, python3, m4, sphinx
+, bash
+
+, libiconv ? null, ncurses
+
+, # GHC can be built with system libffi or a bundled one.
+ libffi ? null
+
+, useLLVM ? !stdenv.targetPlatform.isx86
+, # LLVM is conceptually a run-time-only depedendency, but for
+ # non-x86, we need LLVM to bootstrap later stages, so it becomes a
+ # build-time dependency too.
+ buildLlvmPackages, llvmPackages
+
+, # If enabled, GHC will be built with the GPL-free but slower integer-simple
+ # library instead of the faster but GPLed integer-gmp library.
+ enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+
+, # If enabled, use -fPIC when compiling static libs.
+ enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
+
+ # aarch64 outputs otherwise exceed 2GB limit
+, enableProfiledLibs ? !stdenv.targetPlatform.isAarch64
+
+, # Whether to build dynamic libs for the standard library (on the target
+ # platform). Static libs are always built.
+ enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
+
+, # Whether to build terminfo.
+ enableTerminfo ? !stdenv.targetPlatform.isWindows
+
+, # What flavour to build. An empty string indicates no
+ # specific flavour and falls back to ghc default values.
+ ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+ (if useLLVM then "perf-cross" else "perf-cross-ncg")
+
+, # Whether to disable the large address space allocator
+ # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
+ disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64
+}:
+
+assert !enableIntegerSimple -> gmp != null;
+
+let
+ inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
+ inherit (bootPkgs) ghc;
+
+ # TODO(@Ericson2314) Make unconditional
+ targetPrefix = stdenv.lib.optionalString
+ (targetPlatform != hostPlatform)
+ "${targetPlatform.config}-";
+
+ buildMK = dontStrip: ''
+ BuildFlavour = ${ghcFlavour}
+ ifneq \"\$(BuildFlavour)\" \"\"
+ include mk/flavours/\$(BuildFlavour).mk
+ endif
+ DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
+ INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
+ ''
+ # We only need to build stage1 on most cross-compilation because
+ # we will be running the compiler on the native system. In some
+ # situations, like native Musl compilation, we need the compiler
+ # to actually link to our new Libc. The iOS simulator is a special
+ # exception because we can’t actually run simulators binaries
+ # ourselves.
+ + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+ Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
+ CrossCompilePrefix = ${targetPrefix}
+ HADDOCK_DOCS = NO
+ BUILD_SPHINX_HTML = NO
+ BUILD_SPHINX_PDF = NO
+ '' + stdenv.lib.optionalString dontStrip ''
+ STRIP_CMD = :
+ '' + stdenv.lib.optionalString (!enableProfiledLibs) ''
+ GhcLibWays = "v dyn"
+ '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+ GhcLibHcOpts += -fPIC
+ GhcRtsHcOpts += -fPIC
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ EXTRA_CC_OPTS += -std=gnu99
+ '';
+
+ # Splicer will pull out correct variations
+ libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+ ++ [libffi]
+ ++ stdenv.lib.optional (!enableIntegerSimple) gmp
+ ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+
+ toolsForTarget = [
+ pkgsBuildTarget.targetPackages.stdenv.cc
+ ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+
+ targetCC = builtins.head toolsForTarget;
+
+ # ld.gold is disabled for musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
+ # see #84670 and #49071 for more background.
+ useLdGold = targetPlatform.isLinux && !(targetPlatform.useLLVM or false) && !targetPlatform.isMusl;
+
+in
+stdenv.mkDerivation (rec {
+ version = "8.8.4";
+ name = "${targetPrefix}ghc-${version}";
+
+ src = fetchurl {
+ url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
+ sha256 = "0bgwbxxvdn56l91bp9p5d083gzcfdi6z8l8b17qzjpr3n8w5wl7h";
+ };
+
+ enableParallelBuilding = true;
+
+ outputs = [ "out" "doc" ];
+
+ postPatch = "patchShebangs .";
+
+ # GHC is a bit confused on its cross terminology.
+ preConfigure = stdenv.lib.optionalString stdenv.isAarch64 ''
+ # Aarch64 allow backward bootstrapping since earlier versions are unstable.
+ find . -name \*\.cabal\* -exec sed -i -e 's/\(base.*\)4.14/\14.16/' {} \; \
+ -exec sed -i -e 's/\(prim.*\)0.6/\10.8/' {} \;
+ '' + ''
+ for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
+ export "''${env#TARGET_}=''${!env}"
+ done
+ # GHC is a bit confused on its cross terminology, as these would normally be
+ # the *host* tools.
+ export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
+ export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
+ # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
+ export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+ export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
+ export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
+ export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
+ export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
+ export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
+ export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
+
+ echo -n "${buildMK dontStrip}" > mk/build.mk
+ sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
+ '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+ export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
+ export NIX_LDFLAGS+=" -no_dtrace_dof"
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ 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
+ '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+ echo "patching llvm-targets for musl targets..."
+ echo "Cloning these existing '*-linux-gnu*' targets:"
+ grep linux-gnu llvm-targets | sed 's/^/ /'
+ echo "(go go gadget sed)"
+ sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
+ echo "llvm-targets now contains these '*-linux-musl*' targets:"
+ grep linux-musl llvm-targets | sed 's/^/ /'
+
+ echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
+ # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
+ for x in configure aclocal.m4; do
+ substituteInPlace $x \
+ --replace '*-android*|*-gnueabi*)' \
+ '*-android*|*-gnueabi*|*-musleabi*)'
+ done
+ '';
+
+ # TODO(@Ericson2314): Always pass "--target" and always prefix.
+ configurePlatforms = [ "build" "host" ]
+ ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+
+ # `--with` flags for libraries needed for RTS linker
+ configureFlags = [
+ "--datadir=$doc/share/doc/ghc"
+ "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
+ ] ++ stdenv.lib.optionals (libffi != null) [
+ "--with-system-libffi"
+ "--with-ffi-includes=${targetPackages.libffi.dev}/include"
+ "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+ "--with-gmp-includes=${targetPackages.gmp.dev}/include"
+ "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+ "--with-iconv-includes=${libiconv}/include"
+ "--with-iconv-libraries=${libiconv}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+ "--enable-bootstrap-with-devel-snapshot"
+ ] ++ stdenv.lib.optionals useLdGold [
+ "CFLAGS=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
+ ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+ "--disable-large-address-space"
+ ];
+
+ # Make sure we never relax`$PATH` and hooks support for compatibility.
+ strictDeps = true;
+
+ # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
+ dontAddExtraLibs = true;
+
+ nativeBuildInputs = [
+ perl autoconf automake m4 python3 sphinx
+ ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
+ ];
+
+ # For building runtime libs
+ depsBuildTarget = toolsForTarget;
+
+ buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
+
+ propagatedBuildInputs = [ targetPackages.stdenv.cc ]
+ ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+
+ depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
+ depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+
+ # required, because otherwise all symbols from HSffi.o are stripped, and
+ # that in turn causes GHCi to abort
+ stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+
+ checkTarget = "test";
+
+ hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+
+ postInstall = ''
+ # Install the bash completion file.
+ install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
+
+ # Patch scripts to include "readelf" and "cat" in $PATH.
+ for i in "$out/bin/"*; do
+ test ! -h $i || continue
+ egrep --quiet '^#!' <(head -n 1 $i) || continue
+ sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+ done
+ '';
+
+ passthru = {
+ inherit bootPkgs targetPrefix;
+
+ inherit llvmPackages;
+ inherit enableShared;
+
+ # Our Cabal compiler name
+ haskellCompilerName = "ghc-${version}";
+ };
+
+ meta = {
+ homepage = "http://haskell.org/ghc";
+ description = "The Glasgow Haskell Compiler";
+ maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+ timeout = 24 * 3600;
+ inherit (ghc.meta) license platforms;
+ };
+
+ dontStrip = (targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm);
+
+} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
+ dontPatchELF = true;
+ noAuditTmpdir = true;
+})
diff --git a/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/9.0.1.nix b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/9.0.1.nix
new file mode 100644
index 000000000000..bdb1a7555c21
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/9.0.1.nix
@@ -0,0 +1,248 @@
+{ stdenv, pkgsBuildTarget, targetPackages
+
+# build-tools
+, bootPkgs
+, autoconf, automake, coreutils, fetchurl, perl, python3, m4, sphinx
+, bash
+
+, libiconv ? null, ncurses
+
+, # GHC can be built with system libffi or a bundled one.
+ libffi ? null
+
+, useLLVM ? !stdenv.targetPlatform.isx86
+, # LLVM is conceptually a run-time-only depedendency, but for
+ # non-x86, we need LLVM to bootstrap later stages, so it becomes a
+ # build-time dependency too.
+ buildLlvmPackages, llvmPackages
+
+, # If enabled, GHC will be built with the GPL-free but slower integer-simple
+ # library instead of the faster but GPLed integer-gmp library.
+ enableIntegerSimple ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms), gmp
+
+, # If enabled, use -fPIC when compiling static libs.
+ enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
+
+ # aarch64 outputs otherwise exceed 2GB limit
+, enableProfiledLibs ? !stdenv.targetPlatform.isAarch64
+
+, # Whether to build dynamic libs for the standard library (on the target
+ # platform). Static libs are always built.
+ enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
+
+, # Whether to build terminfo.
+ enableTerminfo ? !stdenv.targetPlatform.isWindows
+
+, # What flavour to build. An empty string indicates no
+ # specific flavour and falls back to ghc default values.
+ ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+ (if useLLVM then "perf-cross" else "perf-cross-ncg")
+
+, # Whether to disable the large address space allocator
+ # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
+ disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64
+}:
+
+assert !enableIntegerSimple -> gmp != null;
+
+let
+ inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
+ inherit (bootPkgs) ghc;
+
+ # TODO(@Ericson2314) Make unconditional
+ targetPrefix = stdenv.lib.optionalString
+ (targetPlatform != hostPlatform)
+ "${targetPlatform.config}-";
+
+ buildMK = ''
+ BuildFlavour = ${ghcFlavour}
+ ifneq \"\$(BuildFlavour)\" \"\"
+ include mk/flavours/\$(BuildFlavour).mk
+ endif
+ DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
+ INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
+ '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+ Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
+ CrossCompilePrefix = ${targetPrefix}
+ HADDOCK_DOCS = NO
+ BUILD_SPHINX_HTML = NO
+ BUILD_SPHINX_PDF = NO
+ '' + stdenv.lib.optionalString (!enableProfiledLibs) ''
+ GhcLibWays = "v dyn"
+ '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+ GhcLibHcOpts += -fPIC
+ GhcRtsHcOpts += -fPIC
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ EXTRA_CC_OPTS += -std=gnu99
+ '';
+
+ # Splicer will pull out correct variations
+ libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+ ++ [libffi]
+ ++ stdenv.lib.optional (!enableIntegerSimple) gmp
+ ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
+
+ toolsForTarget = [
+ pkgsBuildTarget.targetPackages.stdenv.cc
+ ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+
+ targetCC = builtins.head toolsForTarget;
+
+ # ld.gold is disabled for musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
+ # see #84670 and #49071 for more background.
+ useLdGold = targetPlatform.isLinux && !(targetPlatform.useLLVM or false) && !targetPlatform.isMusl;
+
+in
+stdenv.mkDerivation (rec {
+ version = "9.0.0.20200925";
+ name = "${targetPrefix}ghc-${version}";
+
+ src = fetchurl {
+ url = "https://downloads.haskell.org/ghc/9.0.1-alpha1/ghc-${version}-src.tar.xz";
+ sha256 = "1c6vgic0bx0c4c6gszq7znvc5gxf0lgh630283mivbs1lyiqj88l";
+ };
+
+ enableParallelBuilding = true;
+
+ outputs = [ "out" "doc" ];
+
+ postPatch = "patchShebangs .";
+
+ # GHC is a bit confused on its cross terminology.
+ preConfigure = ''
+ for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
+ export "''${env#TARGET_}=''${!env}"
+ done
+ # GHC is a bit confused on its cross terminology, as these would normally be
+ # the *host* tools.
+ export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
+ export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
+ # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
+ export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+ export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
+ export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
+ export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
+ export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
+ export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
+ export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
+
+ echo -n "${buildMK}" > mk/build.mk
+ sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
+ '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+ export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
+ export NIX_LDFLAGS+=" -no_dtrace_dof"
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ 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
+ '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+ echo "patching llvm-targets for musl targets..."
+ echo "Cloning these existing '*-linux-gnu*' targets:"
+ grep linux-gnu llvm-targets | sed 's/^/ /'
+ echo "(go go gadget sed)"
+ sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
+ echo "llvm-targets now contains these '*-linux-musl*' targets:"
+ grep linux-musl llvm-targets | sed 's/^/ /'
+
+ echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
+ # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
+ for x in configure aclocal.m4; do
+ substituteInPlace $x \
+ --replace '*-android*|*-gnueabi*)' \
+ '*-android*|*-gnueabi*|*-musleabi*)'
+ done
+ '';
+
+ # TODO(@Ericson2314): Always pass "--target" and always prefix.
+ configurePlatforms = [ "build" "host" ]
+ ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+
+ # `--with` flags for libraries needed for RTS linker
+ configureFlags = [
+ "--datadir=$doc/share/doc/ghc"
+ "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
+ ] ++ stdenv.lib.optionals (libffi != null) [
+ "--with-system-libffi"
+ "--with-ffi-includes=${targetPackages.libffi.dev}/include"
+ "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
+ "--with-gmp-includes=${targetPackages.gmp.dev}/include"
+ "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+ "--with-iconv-includes=${libiconv}/include"
+ "--with-iconv-libraries=${libiconv}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+ "--enable-bootstrap-with-devel-snapshot"
+ ] ++ stdenv.lib.optionals useLdGold [
+ "CFLAGS=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
+ ] ++ stdenv.lib.optionals (disableLargeAddressSpace) [
+ "--disable-large-address-space"
+ ];
+
+ # Make sure we never relax`$PATH` and hooks support for compatibility.
+ strictDeps = true;
+
+ # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
+ dontAddExtraLibs = true;
+
+ nativeBuildInputs = [
+ perl autoconf automake m4 python3 sphinx
+ ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
+ ];
+
+ # For building runtime libs
+ depsBuildTarget = toolsForTarget;
+
+ buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
+
+ propagatedBuildInputs = [ targetPackages.stdenv.cc ]
+ ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+
+ depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
+ depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+
+ # required, because otherwise all symbols from HSffi.o are stripped, and
+ # that in turn causes GHCi to abort
+ stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+
+ checkTarget = "test";
+
+ hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+
+ postInstall = ''
+ # Install the bash completion file.
+ install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
+
+ # Patch scripts to include "readelf" and "cat" in $PATH.
+ for i in "$out/bin/"*; do
+ test ! -h $i || continue
+ egrep --quiet '^#!' <(head -n 1 $i) || continue
+ sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+ done
+ '';
+
+ passthru = {
+ inherit bootPkgs targetPrefix;
+
+ inherit llvmPackages;
+ inherit enableShared;
+
+ # Our Cabal compiler name
+ haskellCompilerName = "ghc-${version}";
+ };
+
+ meta = {
+ homepage = "http://haskell.org/ghc";
+ description = "The Glasgow Haskell Compiler";
+ maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+ timeout = 24 * 3600;
+ inherit (ghc.meta) license platforms;
+ };
+
+} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
+ dontStrip = true;
+ dontPatchELF = true;
+ noAuditTmpdir = true;
+})
diff --git a/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/backport-dylib-command-size-limit.patch b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/backport-dylib-command-size-limit.patch
new file mode 100644
index 000000000000..d0d94717d9c4
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/backport-dylib-command-size-limit.patch
@@ -0,0 +1,24 @@
+diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
+index acd0d61..3e83c15 100644
+--- a/compiler/main/DriverPipeline.hs
++++ b/compiler/main/DriverPipeline.hs
+@@ -1916,6 +1916,7 @@ linkBinary' staticLink dflags o_files dep_packages = do
+ ++ pkg_framework_opts
+ ++ debug_opts
+ ++ thread_opts
++ ++ (if (platformOS platform `elem` [OSDarwin]) then [ "-Wl,-dead_strip_dylibs" ] else [])
+ ))
+
+ exeFileName :: Bool -> DynFlags -> FilePath
+diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs
+index 1ab5b13..2ebbf51 100644
+--- a/compiler/main/SysTools.hs
++++ b/compiler/main/SysTools.hs
+@@ -1737,6 +1737,7 @@ linkDynLib dflags0 o_files dep_packages
+ ++ map Option pkg_lib_path_opts
+ ++ map Option pkg_link_opts
+ ++ map Option pkg_framework_opts
++ ++ [ Option "-Wl,-dead_strip_dylibs" ]
+ )
+ OSiOS -> throwGhcExceptionIO (ProgramError "dynamic libraries are not supported on iOS target")
+ _ -> do
diff --git a/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/gcc-clang-wrapper.sh b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/gcc-clang-wrapper.sh
new file mode 100755
index 000000000000..45af982c2973
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/gcc-clang-wrapper.sh
@@ -0,0 +1,46 @@
+#!@shell@
+
+inPreprocessorMode () {
+ hasE=0
+ hasU=0
+ hasT=0
+ for arg in "$@"
+ do
+ if [ 'x-E' = "x$arg" ]; then hasE=1; fi
+ if [ 'x-undef' = "x$arg" ]; then hasU=1; fi
+ if [ 'x-traditional' = "x$arg" ]; then hasT=1; fi
+ done
+ [ "$hasE$hasU$hasT" = '111' ]
+}
+
+extraClangArgs="-Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs"
+
+adjustPreprocessorLanguage () {
+ newArgs=''
+ while [ $# -gt 0 ]
+ do
+ newArgs="$newArgs $1"
+ if [ "$1" = '-x' ]
+ then
+ shift
+ if [ $# -gt 0 ]
+ then
+ if [ "$1" = 'c' ]
+ then
+ newArgs="$newArgs assembler-with-cpp"
+ else
+ newArgs="$newArgs $1"
+ fi
+ fi
+ fi
+ shift
+ done
+ echo $newArgs
+}
+
+if inPreprocessorMode "$@"
+then
+ exec clang $extraClangArgs `adjustPreprocessorLanguage "$@"`
+else
+ exec clang $extraClangArgs "${@/-nodefaultlibs/}"
+fi
diff --git a/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/head.nix b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/head.nix
new file mode 100644
index 000000000000..6f9f577743f5
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/head.nix
@@ -0,0 +1,266 @@
+{ stdenv, pkgsBuildTarget, targetPackages
+
+# build-tools
+, bootPkgs
+, autoconf, autoreconfHook, automake, coreutils, fetchgit, perl, python3, m4, sphinx
+, bash
+
+, libiconv ? null, ncurses
+
+, # GHC can be built with system libffi or a bundled one.
+ libffi ? null
+
+, enableDwarf ? !stdenv.targetPlatform.isDarwin &&
+ !stdenv.targetPlatform.isWindows
+, elfutils # for DWARF support
+
+, useLLVM ? !stdenv.targetPlatform.isx86 || stdenv.targetPlatform.isiOS
+, # LLVM is conceptually a run-time-only depedendency, but for
+ # non-x86, we need LLVM to bootstrap later stages, so it becomes a
+ # build-time dependency too.
+ buildLlvmPackages, llvmPackages
+
+, # If enabled, GHC will be built with the GPL-free but slightly slower native
+ # bignum backend instead of the faster but GPLed gmp backend.
+ enableNativeBignum ? !(stdenv.lib.any (stdenv.lib.meta.platformMatch stdenv.hostPlatform) gmp.meta.platforms)
+, gmp
+
+, # If enabled, use -fPIC when compiling static libs.
+ enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
+
+ # aarch64 outputs otherwise exceed 2GB limit
+, enableProfiledLibs ? !stdenv.targetPlatform.isAarch64
+
+, # Whether to build dynamic libs for the standard library (on the target
+ # platform). Static libs are always built.
+ enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
+
+, # Whether to build terminfo.
+ enableTerminfo ? !stdenv.targetPlatform.isWindows
+
+, version ? "8.11.20200824"
+, # What flavour to build. An empty string indicates no
+ # specific flavour and falls back to ghc default values.
+ ghcFlavour ? stdenv.lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
+ (if useLLVM then "perf-cross" else "perf-cross-ncg")
+
+, # Whether to disable the large address space allocator
+ # necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
+ disableLargeAddressSpace ? stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64
+}:
+
+assert !enableNativeBignum -> gmp != null;
+
+let
+ inherit (stdenv) buildPlatform hostPlatform targetPlatform;
+
+ inherit (bootPkgs) ghc;
+
+ # TODO(@Ericson2314) Make unconditional
+ targetPrefix = stdenv.lib.optionalString
+ (targetPlatform != hostPlatform)
+ "${targetPlatform.config}-";
+
+ buildMK = dontStrip: ''
+ BuildFlavour = ${ghcFlavour}
+ ifneq \"\$(BuildFlavour)\" \"\"
+ include mk/flavours/\$(BuildFlavour).mk
+ endif
+ DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
+ BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
+ '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
+ Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
+ CrossCompilePrefix = ${targetPrefix}
+ HADDOCK_DOCS = NO
+ BUILD_SPHINX_HTML = NO
+ BUILD_SPHINX_PDF = NO
+ '' + stdenv.lib.optionalString dontStrip ''
+ STRIP_CMD = :
+ '' + stdenv.lib.optionalString (!enableProfiledLibs) ''
+ GhcLibWays = "v dyn"
+ '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
+ GhcLibHcOpts += -fPIC
+ GhcRtsHcOpts += -fPIC
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ EXTRA_CC_OPTS += -std=gnu99
+ '';
+
+ # Splicer will pull out correct variations
+ libDeps = platform: stdenv.lib.optional enableTerminfo ncurses
+ ++ [libffi]
+ ++ stdenv.lib.optional (!enableNativeBignum) gmp
+ ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv
+ ++ stdenv.lib.optional enableDwarf elfutils;
+
+ toolsForTarget = [
+ pkgsBuildTarget.targetPackages.stdenv.cc
+ ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm;
+
+ targetCC = builtins.head toolsForTarget;
+
+ # ld.gold is disabled for musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
+ # see #84670 and #49071 for more background.
+ useLdGold = targetPlatform.isLinux && !(targetPlatform.useLLVM or false) && !targetPlatform.isMusl;
+
+in
+stdenv.mkDerivation (rec {
+ inherit version;
+ inherit (src) rev;
+ name = "${targetPrefix}ghc-${version}";
+
+ src = fetchgit {
+ url = "https://gitlab.haskell.org/ghc/ghc.git/";
+ rev = "3f50154591ada9064351ccec4adfe6df53ca2439";
+ sha256 = "1w2p5bc74aswspzvgvrhcb95hvj5ky38rgqqjvrri19z2qyiky6d";
+ };
+
+ enableParallelBuilding = true;
+
+ outputs = [ "out" "doc" ];
+
+ postPatch = "patchShebangs .";
+
+ # GHC is a bit confused on its cross terminology.
+ preConfigure = ''
+ for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
+ export "''${env#TARGET_}=''${!env}"
+ done
+ # GHC is a bit confused on its cross terminology, as these would normally be
+ # the *host* tools.
+ export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
+ export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx"
+ # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
+ # and more generally have a faster linker.
+ export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString useLdGold ".gold"}"
+ export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
+ export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
+ export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
+ export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
+ export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
+ export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
+
+ echo -n "${buildMK dontStrip}" > mk/build.mk
+ echo ${version} > VERSION
+ echo ${src.rev} > GIT_COMMIT_ID
+ ./boot
+ sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
+ '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
+ export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
+ '' + stdenv.lib.optionalString stdenv.isDarwin ''
+ export NIX_LDFLAGS+=" -no_dtrace_dof"
+ '' + stdenv.lib.optionalString targetPlatform.useAndroidPrebuilt ''
+ 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
+ '' + stdenv.lib.optionalString targetPlatform.isMusl ''
+ echo "patching llvm-targets for musl targets..."
+ echo "Cloning these existing '*-linux-gnu*' targets:"
+ grep linux-gnu llvm-targets | sed 's/^/ /'
+ echo "(go go gadget sed)"
+ sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
+ echo "llvm-targets now contains these '*-linux-musl*' targets:"
+ grep linux-musl llvm-targets | sed 's/^/ /'
+
+ echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
+ # (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
+ for x in configure aclocal.m4; do
+ substituteInPlace $x \
+ --replace '*-android*|*-gnueabi*)' \
+ '*-android*|*-gnueabi*|*-musleabi*)'
+ done
+ '';
+
+ # TODO(@Ericson2314): Always pass "--target" and always prefix.
+ configurePlatforms = [ "build" "host" ]
+ ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target";
+
+ # `--with` flags for libraries needed for RTS linker
+ configureFlags = [
+ "--datadir=$doc/share/doc/ghc"
+ "--with-curses-libraries=${ncurses.out}/lib"
+ ] ++ stdenv.lib.optionals (libffi != null) [
+ "--with-system-libffi"
+ "--with-ffi-includes=${targetPackages.libffi.dev}/include"
+ "--with-ffi-libraries=${targetPackages.libffi.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
+ "--with-gmp-includes=${targetPackages.gmp.dev}/include"
+ "--with-gmp-libraries=${targetPackages.gmp.out}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
+ "--with-iconv-includes=${libiconv}/include"
+ "--with-iconv-libraries=${libiconv}/lib"
+ ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
+ "--enable-bootstrap-with-devel-snapshot"
+ ] ++ stdenv.lib.optionals useLdGold [
+ "CFLAGS=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
+ "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
+ ] ++ stdenv.lib.optional disableLargeAddressSpace "--disable-large-address-space"
+ ++ stdenv.lib.optionals enableDwarf [
+ "--enable-dwarf-unwind"
+ "--with-libdw-includes=${stdenv.lib.getDev elfutils}/include"
+ "--with-libdw-libraries=${stdenv.lib.getLib elfutils}/lib"
+ ];
+
+ # Make sure we never relax`$PATH` and hooks support for compatibility.
+ strictDeps = true;
+
+ # Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
+ dontAddExtraLibs = true;
+
+ nativeBuildInputs = [
+ perl autoconf autoreconfHook automake m4 python3 sphinx
+ ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
+ ];
+
+ # For building runtime libs
+ depsBuildTarget = toolsForTarget;
+
+ buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
+
+ propagatedBuildInputs = [ targetPackages.stdenv.cc ]
+ ++ stdenv.lib.optional useLLVM llvmPackages.llvm;
+
+ depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform);
+ depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform);
+
+ # required, because otherwise all symbols from HSffi.o are stripped, and
+ # that in turn causes GHCi to abort
+ stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
+
+ checkTarget = "test";
+
+ hardeningDisable = [ "format" ] ++ stdenv.lib.optional stdenv.targetPlatform.isMusl "pie";
+
+ postInstall = ''
+ # Install the bash completion file.
+ install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
+
+ # Patch scripts to include "readelf" and "cat" in $PATH.
+ for i in "$out/bin/"*; do
+ test ! -h $i || continue
+ egrep --quiet '^#!' <(head -n 1 $i) || continue
+ sed -i -e '2i export PATH="$PATH:${stdenv.lib.makeBinPath [ targetPackages.stdenv.cc.bintools coreutils ]}"' $i
+ done
+ '';
+
+ passthru = {
+ inherit bootPkgs targetPrefix;
+
+ inherit llvmPackages;
+ inherit enableShared;
+
+ # Our Cabal compiler name
+ haskellCompilerName = "ghc-${version}";
+ };
+
+ meta = {
+ homepage = "http://haskell.org/ghc";
+ description = "The Glasgow Haskell Compiler";
+ maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ];
+ inherit (ghc.meta) license platforms;
+ };
+
+ dontStrip = (targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm);
+
+} // stdenv.lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
+ dontPatchELF = true;
+ noAuditTmpdir = true;
+})
diff --git a/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/issue-18549.patch b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/issue-18549.patch
new file mode 100644
index 000000000000..eb30d9d9dd4c
--- /dev/null
+++ b/infra/libkookie/nixpkgs/pkgs/development/compilers/ghc/issue-18549.patch
@@ -0,0 +1,296 @@
+From fac083e7ac8a37b61a4082bbbca2848e52fd1bb2 Mon Sep 17 00:00:00 2001
+From: Ben Gamari <ben@smart-cactus.org>
+Date: Sun, 9 Aug 2020 09:15:16 -0400
+Subject: [PATCH] Revert "[linker/rtsSymbols] More linker symbols"
+
+This reverts commit aa2e5863699306920513b216f337de09e29b5bb8.
+---
+ rts/RtsSymbols.c | 224 ++++-------------------------------------------
+ 1 file changed, 17 insertions(+), 207 deletions(-)
+
+diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
+index d10a6900db..b2f90a892d 100644
+--- a/rts/RtsSymbols.c
++++ b/rts/RtsSymbols.c
+@@ -58,6 +58,7 @@
+ SymI_HasProto(signal_handlers) \
+ SymI_HasProto(stg_sig_install) \
+ SymI_HasProto(rtsTimerSignal) \
++ SymI_HasProto(atexit) \
+ SymI_NeedsDataProto(nocldstop)
+ #endif
+
+@@ -976,213 +977,29 @@
+ RTS_USER_SIGNALS_SYMBOLS \
+ RTS_INTCHAR_SYMBOLS
+
++
+ // 64-bit support functions in libgcc.a
+-// See https://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc
+-#define RTS_LIBGCC_SYMBOLS_32 \
+- SymI_NeedsProto(__fixunsdfdi) \
+- /* 4 The GCC low-level runtime library */\
+- /* 4.1.1 Arithmetic functions */\
+- /* SymI_NeedsProto(__ashlsi3) */\
+- SymI_NeedsProto(__ashldi3) \
+- /* SymI_NeedsProto(__ashlti3) */\
+- /* These functions return the result of shifting a left by b bits. */\
+- /* SymI_NeedsProto(__ashrsi3) */\
+- SymI_NeedsProto(__ashrdi3) \
+- /* SymI_NeedsProto(__ashrti3) */\
+- /* These functions return the result of arithmetically shifting a right by b bits. */\
+- /* SymI_NeedsProto(__divsi3) */\
+- SymI_NeedsProto(__divdi3) \
+- /* SymI_NeedsProto(__divti3) */\
+- /* These functions return the quotient of the signed division of a and b. */\
+- /* SymI_NeedsProto(__lshrsi3) */ \
+- SymI_NeedsProto(__lshrdi3) \
+- /* SymI_NeedsProto(__lshrti3) */ \
+- /* These functions return the result of logically shifting a right by b bits. */\
+- /* SymI_NeedsProto(__modsi3) */ \
+- SymI_NeedsProto(__moddi3) \
+- /* SymI_NeedsProto(__modti3) */ \
+- /* These functions return the remainder of the signed division of a and b. */\
+- /* SymI_NeedsProto(__mulsi3) */ \
+- SymI_NeedsProto(__muldi3) \
+- /* SymI_NeedsProto(__multi3) */ \
+- /* These functions return the product of a and b. */\
+- SymI_NeedsProto(__negdi2) \
+- /* SymI_NeedsProto(__negti2) */ \
+- /* These functions return the negation of a. */\
+- /* SymI_NeedsProto(__udivsi3) */ \
+- SymI_NeedsProto(__udivdi3) \
+- /* SymI_NeedsProto(__udivti3) */ \
+- /* These functions return the quotient of the unsigned division of a and b. */\
+- SymI_NeedsProto(__udivmoddi4) \
+- /* SymI_NeedsProto(__udivmodti4) */ \
+- /* These functions calculate both the quotient and remainder of the unsigned division of a and b. The return value is the quotient, and the remainder is placed in variable pointed to by c. */\
+- /* SymI_NeedsProto(__umodsi3) */ \
+- SymI_NeedsProto(__umoddi3) \
+- /* SymI_NeedsProto(__umodti3) */ \
+- /* These functions return the remainder of the unsigned division of a and b. */\
+- /* 4.1.2 Comparison functions */\
+- /* The following functions implement integral comparisons. These functions implement a low-level compare, upon which the higher level comparison operators (such as less than and greater than or equal to) can be constructed. The returned values lie in the range zero to two, to allow the high-level operators to be implemented by testing the returned result using either signed or unsigned comparison. */\
+- SymI_NeedsProto(__cmpdi2) \
+- /* SymI_NeedsProto(__cmpti2) */ \
+- /* These functions perform a signed comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\
+- SymI_NeedsProto(__ucmpdi2) \
+- /* SymI_NeedsProto(__ucmpti2) */ \
+- /* These functions perform an unsigned comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\
+- /* 4.1.3 Trapping arithmetic functions */\
+- /* The following functions implement trapping arithmetic. These functions call the libc function abort upon signed arithmetic overflow. */\
+- SymI_NeedsProto(__absvsi2) \
+- SymI_NeedsProto(__absvdi2) \
+- /* These functions return the absolute value of a. */\
+- /* SymI_NeedsProto(__addvsi3) */ \
+- SymI_NeedsProto(__addvdi3) \
+- /* These functions return the sum of a and b; that is a + b. */\
+- /* SymI_NeedsProto(__mulvsi3) */ \
+- SymI_NeedsProto(__mulvdi3) \
+- /* The functions return the product of a and b; that is a * b. */\
+- SymI_NeedsProto(__negvsi2) \
+- SymI_NeedsProto(__negvdi2) \
+- /* These functions return the negation of a; that is -a. */\
+- /* SymI_NeedsProto(__subvsi3) */ \
+- SymI_NeedsProto(__subvdi3) \
+- /* These functions return the difference between b and a; that is a - b. */\
+- /* 4.1.4 Bit operations */\
+- SymI_NeedsProto(__clzsi2) \
+- SymI_NeedsProto(__clzdi2) \
+- /* SymI_NeedsProto(__clzti2) */ \
+- /* These functions return the number of leading 0-bits in a, starting at the most significant bit position. If a is zero, the result is undefined. */\
+- SymI_NeedsProto(__ctzsi2) \
+- SymI_NeedsProto(__ctzdi2) \
+- /* SymI_NeedsProto(__ctzti2) */ \
+- /* These functions return the number of trailing 0-bits in a, starting at the least significant bit position. If a is zero, the result is undefined. */\
+- SymI_NeedsProto(__ffsdi2) \
+- /* SymI_NeedsProto(__ffsti2) */ \
+- /* These functions return the index of the least significant 1-bit in a, or the value zero if a is zero. The least significant bit is index one. */\
+- SymI_NeedsProto(__paritysi2) \
+- SymI_NeedsProto(__paritydi2) \
+- /* SymI_NeedsProto(__parityti2) */\
+- /* These functions return the value zero if the number of bits set in a is even, and the value one otherwise. */\
+- SymI_NeedsProto(__popcountsi2) \
+- SymI_NeedsProto(__popcountdi2) \
+- /* SymI_NeedsProto(__popcountti2) */ \
+- /* These functions return the number of bits set in a. */\
+- SymI_NeedsProto(__bswapsi2) \
+- SymI_NeedsProto(__bswapdi2)
+-#define RTS_LIBGCC_SYMBOLS_aarch32 \
+- /* armv6l */\
+- /* TODO: should check for __ARM_EABI__ */\
+- SymI_NeedsProto(__aeabi_d2f) \
+- SymI_NeedsProto(__aeabi_d2iz) \
+- SymI_NeedsProto(__aeabi_d2lz) \
+- SymI_NeedsProto(__aeabi_d2uiz) \
+- SymI_NeedsProto(__aeabi_d2ulz) \
+- SymI_NeedsProto(__aeabi_dadd) \
+- SymI_NeedsProto(__aeabi_dcmpeq) \
+- SymI_NeedsProto(__aeabi_dcmpge) \
+- SymI_NeedsProto(__aeabi_dcmpgt) \
+- SymI_NeedsProto(__aeabi_dcmple) \
+- SymI_NeedsProto(__aeabi_dcmplt) \
+- SymI_NeedsProto(__aeabi_dcmpun) \
+- SymI_NeedsProto(__aeabi_ddiv) \
+- SymI_NeedsProto(__aeabi_dmul) \
+- SymI_NeedsProto(__aeabi_dneg) \
+- SymI_NeedsProto(__aeabi_dsub) \
+- SymI_NeedsProto(__aeabi_f2d) \
+- SymI_NeedsProto(__aeabi_f2iz) \
+- SymI_NeedsProto(__aeabi_f2lz) \
+- SymI_NeedsProto(__aeabi_f2uiz) \
+- SymI_NeedsProto(__aeabi_f2ulz) \
+- SymI_NeedsProto(__aeabi_fadd) \
+- SymI_NeedsProto(__aeabi_fcmpeq) \
+- SymI_NeedsProto(__aeabi_fcmpge) \
+- SymI_NeedsProto(__aeabi_fcmpgt) \
+- SymI_NeedsProto(__aeabi_fcmple) \
+- SymI_NeedsProto(__aeabi_fcmplt) \
+- SymI_NeedsProto(__aeabi_fcmpun) \
+- SymI_NeedsProto(__aeabi_fdiv) \
+- SymI_NeedsProto(__aeabi_fmul) \
+- SymI_NeedsProto(__aeabi_fneg) \
+- SymI_NeedsProto(__aeabi_fsub) \
+- SymI_NeedsProto(__aeabi_i2d) \
+- SymI_NeedsProto(__aeabi_i2f) \
+- SymI_NeedsProto(__aeabi_idiv) \
+- SymI_NeedsProto(__aeabi_idivmod) \
+- SymI_NeedsProto(__aeabi_l2d) \
+- SymI_NeedsProto(__aeabi_l2f) \
+- SymI_NeedsProto(__aeabi_lasr) \
+- SymI_NeedsProto(__aeabi_lcmp) \
+- SymI_NeedsProto(__aeabi_ldivmod) \
+- SymI_NeedsProto(__aeabi_llsl) \
+- SymI_NeedsProto(__aeabi_llsr) \
+- SymI_NeedsProto(__aeabi_lmul) \
+- SymI_NeedsProto(__aeabi_ui2d) \
+- SymI_NeedsProto(__aeabi_ui2f) \
+- SymI_NeedsProto(__aeabi_uidiv) \
+- SymI_NeedsProto(__aeabi_uidivmod) \
+- SymI_NeedsProto(__aeabi_ul2d) \
+- SymI_NeedsProto(__aeabi_ul2f) \
+- SymI_NeedsProto(__aeabi_ulcmp) \
+- SymI_NeedsProto(__aeabi_uldivmod)
+-#define RTS_LIBGCC_SYMBOLS_64 \
++#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32)
++#define RTS_LIBGCC_SYMBOLS \
++ SymI_NeedsProto(__divdi3) \
++ SymI_NeedsProto(__udivdi3) \
++ SymI_NeedsProto(__moddi3) \
++ SymI_NeedsProto(__umoddi3) \
++ SymI_NeedsProto(__muldi3) \
++ SymI_NeedsProto(__ashldi3) \
++ SymI_NeedsProto(__ashrdi3) \
++ SymI_NeedsProto(__lshrdi3) \
++ SymI_NeedsProto(__fixunsdfdi)
++#elif defined(__GNUC__) && SIZEOF_VOID_P == 8
++#define RTS_LIBGCC_SYMBOLS \
+ SymI_NeedsProto(__udivti3) \
+ SymI_NeedsProto(__umodti3)
+-
+-/* for aarch64 */
+-#define RTS_LIBGCC_SYMBOLS_aarch64 \
+- SymI_NeedsProto(__netf2) \
+- SymI_NeedsProto(__addtf3) \
+- SymI_NeedsProto(__subtf3) \
+- SymI_NeedsProto(__multf3) \
+- SymI_NeedsProto(__extenddftf2) \
+- SymI_NeedsProto(__fixtfsi) \
+- SymI_NeedsProto(__fixunstfsi) \
+- SymI_NeedsProto(__floatsitf) \
+- SymI_NeedsProto(__floatunsitf)
+-
+-#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && defined(arm_HOST_OS)
+-#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 RTS_LIBGCC_SYMBOLS_aarch32
+-#elif defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32)
+-#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32
+-#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 && defined(aarch64_HOST_OS)
+-#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 RTS_LIBGCC_SYMBOLS_aarch64
+-#elif defined(__GNUC__) && SIZEOF_VOID_P == 8
+-#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64
+ #else
+ #define RTS_LIBGCC_SYMBOLS
+ #endif
+
+-#if !defined(mingw32_HOST_OS) && !defined(DYNAMIC) && (defined(_FORTIFY_SOURCE) || defined(__SSP__))
+-#define RTS_SSP_SYMBOLS \
+- SymI_NeedsProto(__stack_chk_guard) \
+- SymI_NeedsProto(__stack_chk_fail)
+-#else
+-#define RTS_SSP_SYMBOLS
+-#endif
+-#if !defined(DYNAMIC) && defined(linux_HOST_OS)
+-// we need these for static musl builds. However when
+-// linking shared objects (DLLs) this will fail, hence
+-// we do not include them when building with -DDYNAMIC
+-#define RTS_LINKER_SYMBOLS \
+- SymI_NeedsProto(__fini_array_start) \
+- SymI_NeedsProto(__fini_array_end)
+-#else
+-#define RTS_LINKER_SYMBOLS
+-#endif
+-
+-#if defined(darwin_HOST_OS) && defined(powerpc_HOST_ARCH)
+- // Symbols that don't have a leading underscore
+- // on Mac OS X. They have to receive special treatment,
+- // see machoInitSymbolsWithoutUnderscore()
+-#define RTS_MACHO_NOUNDERLINE_SYMBOLS \
+- SymI_NeedsProto(saveFP) \
+- SymI_NeedsProto(restFP)
+-#endif
+-
+ /* entirely bogus claims about types of these symbols */
+-/* to prevent a bit of define expansion, SymI_NeedsProto is a variadic
+- * macro. And we'll concat vvv with the __VA_ARGS__. This prevents
+- * vvv from getting macro expanded.
+- */
+-#define SymI_NeedsProto(vvv,...) extern void vvv ## __VA_ARGS__ (void);
++#define SymI_NeedsProto(vvv) extern void vvv(void);
+ #define SymI_NeedsDataProto(vvv) extern StgWord vvv[];
+ #if defined(COMPILING_WINDOWS_DLL)
+ #define SymE_HasProto(vvv) SymE_HasProto(vvv);
+@@ -1209,8 +1026,6 @@ RTS_DARWIN_ONLY_SYMBOLS
+ RTS_OPENBSD_ONLY_SYMBOLS
+ RTS_LIBGCC_SYMBOLS
+ RTS_LIBFFI_SYMBOLS
+-RTS_SSP_SYMBOLS
+-RTS_LINKER_SYMBOLS
+ #undef SymI_NeedsProto
+ #undef SymI_NeedsDataProto
+ #undef SymI_HasProto
+@@ -1230,7 +1045,7 @@ RTS_LINKER_SYMBOLS
+ #define SymE_HasDataProto(vvv) \
+ SymE_HasProto(vvv)
+
+-#define SymI_NeedsProto(vvv,...) SymI_HasProto(vvv ## __VA_ARGS__)
++#define SymI_NeedsProto(vvv) SymI_HasProto(vvv)
+ #define SymI_NeedsDataProto(vvv) SymI_HasDataProto(vvv)
+ #define SymE_NeedsProto(vvv) SymE_HasProto(vvv)
+ #define SymE_NeedsDataProto(vvv) SymE_HasDataProto(vvv)
+@@ -1251,8 +1066,6 @@ RTS_LINKER_SYMBOLS
+ #define SymI_HasProto_deprecated(vvv) \
+ { #vvv, (void*)0xBAADF00D, true },
+
+-void *RTS_DYNAMIC = NULL;
+-
+ RtsSymbolVal rtsSyms[] = {
+ RTS_SYMBOLS
+ RTS_RET_SYMBOLS
+@@ -1264,14 +1077,11 @@ RtsSymbolVal rtsSyms[] = {
+ RTS_LIBGCC_SYMBOLS
+ RTS_LIBFFI_SYMBOLS
+ SymI_HasDataProto(nonmoving_write_barrier_enabled)
+- RTS_SSP_SYMBOLS
+- RTS_LINKER_SYMBOLS
+ #if defined(darwin_HOST_OS) && defined(i386_HOST_ARCH)
+ // dyld stub code contains references to this,
+ // but it should never be called because we treat
+ // lazy pointers as nonlazy.
+ { "dyld_stub_binding_helper", (void*)0xDEADBEEF, false },
+ #endif
+- { "_DYNAMIC", (void*)(&RTS_DYNAMIC), false },
+ { 0, 0, false } /* sentinel */
+ };
+--
+2.25.4
+