diff options
Diffstat (limited to 'pkgs/development/compilers/ghc')
31 files changed, 0 insertions, 4499 deletions
diff --git a/pkgs/development/compilers/ghc/8.10.7-binary.nix b/pkgs/development/compilers/ghc/8.10.7-binary.nix deleted file mode 100644 index c29b3c89f4b8..000000000000 --- a/pkgs/development/compilers/ghc/8.10.7-binary.nix +++ /dev/null @@ -1,454 +0,0 @@ -{ lib, stdenv -, fetchurl, perl, gcc -, ncurses5 -, ncurses6, gmp, libiconv, numactl -, llvmPackages -, coreutils -, targetPackages - - # 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 - downloadsUrl = "https://downloads.haskell.org/ghc"; - - # Copy sha256 from https://downloads.haskell.org/~ghc/8.10.7/SHA256SUMS - version = "8.10.7"; - - # Information about available bindists that we use in the build. - # - # # Bindist library checking - # - # The field `archSpecificLibraries` also provides a way for us get notified - # early when the upstream bindist changes its dependencies (e.g. because a - # newer Debian version is used that uses a new `ncurses` version). - # - # Usage: - # - # * You can find the `fileToCheckFor` of libraries by running `readelf -d` - # on the compiler binary (`exePathForLibraryCheck`). - # * To skip library checking for an architecture, - # set `exePathForLibraryCheck = null`. - # * To skip file checking for a specific arch specfic library, - # set `fileToCheckFor = null`. - ghcBinDists = { - # Binary distributions for the default libc (e.g. glibc, or libSystem on Darwin) - # nixpkgs uses for the respective system. - defaultLibc = { - i686-linux = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz"; - sha256 = "fbfc1ef194f4e7a4c0da8c11cc69b17458a4b928b609b3622c97acc4acd5c5ab"; - }; - exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - # The i686-linux bindist provided by GHC HQ is currently built on Debian 9, - # which link it against `libtinfo.so.5` (ncurses 5). - # Other bindists are linked `libtinfo.so.6` (ncurses 6). - { nixPackage = ncurses5; fileToCheckFor = "libtinfo.so.5"; } - ]; - }; - x86_64-linux = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb10-linux.tar.xz"; - sha256 = "a13719bca87a0d3ac0c7d4157a4e60887009a7f1a8dbe95c4759ec413e086d30"; - }; - exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; } - ]; - }; - armv7l-linux = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-armv7-deb10-linux.tar.xz"; - sha256 = "3949c31bdf7d3b4afb765ea8246bca4ca9707c5d988d9961a244f0da100956a2"; - }; - exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; } - ]; - }; - aarch64-linux = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz"; - sha256 = "fad2417f9b295233bf8ade79c0e6140896359e87be46cb61cd1d35863d9d0e55"; - }; - exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; } - { nixPackage = numactl; fileToCheckFor = null; } - ]; - }; - x86_64-darwin = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz"; - sha256 = "287db0f9c338c9f53123bfa8731b0996803ee50f6ee847fe388092e5e5132047"; - }; - exePathForLibraryCheck = null; # we don't have a library check for darwin yet - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - { nixPackage = ncurses6; fileToCheckFor = null; } - { nixPackage = libiconv; fileToCheckFor = null; } - ]; - }; - aarch64-darwin = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz"; - sha256 = "dc469fc3c35fd2a33a5a575ffce87f13de7b98c2d349a41002e200a56d9bba1c"; - }; - exePathForLibraryCheck = null; # we don't have a library check for darwin yet - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - { nixPackage = ncurses6; fileToCheckFor = null; } - { nixPackage = libiconv; fileToCheckFor = null; } - ]; - }; - }; - # Binary distributions for the musl libc for the respective system. - musl = { - x86_64-linux = { - variantSuffix = "-musl-integer-simple"; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-alpine3.10-linux-integer-simple.tar.xz"; - sha256 = "16903df850ef73d5246f2ff169cbf57ecab76c2ac5acfa9928934282cfad575c"; - }; - exePathForLibraryCheck = "bin/ghc"; - archSpecificLibraries = [ - # No `gmp` here, since this is an `integer-simple` bindist. - - # In contrast to glibc builds, the musl-bindist uses `libncursesw.so.*` - # instead of `libtinfo.so.*.` - { nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; } - ]; - isHadrian = true; - }; - }; - }; - - distSetName = if stdenv.hostPlatform.isMusl then "musl" else "defaultLibc"; - - binDistUsed = ghcBinDists.${distSetName}.${stdenv.hostPlatform.system} - or (throw "cannot bootstrap GHC on this platform ('${stdenv.hostPlatform.system}' with libc '${distSetName}')"); - - useLLVM = !stdenv.targetPlatform.isx86; - - libPath = - lib.makeLibraryPath ( - # Add arch-specific libraries. - map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries - ); - - libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY" - + "LD_LIBRARY_PATH"; - - runtimeDeps = [ - targetPackages.stdenv.cc - targetPackages.stdenv.cc.bintools - coreutils # for cat - ] - ++ lib.optionals useLLVM [ - (lib.getBin llvmPackages.llvm) - ] - # On darwin, we need unwrapped bintools as well (for otool) - ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ - targetPackages.stdenv.cc.bintools.bintools - ]; - -in - -stdenv.mkDerivation rec { - inherit version; - pname = "ghc-binary${binDistUsed.variantSuffix}"; - - src = fetchurl binDistUsed.src; - - # Note that for GHC 8.10 versions >= 8.10.6, the GHC HQ musl bindist - # uses `integer-simple` and has no `gmp` dependency: - # https://gitlab.haskell.org/ghc/ghc/-/commit/8306501020cd66f683ad9c215fa8e16c2d62357d - # Related nixpkgs issues: - # * https://github.com/NixOS/nixpkgs/pull/130441#issuecomment-922452843 - # TODO: When this file is copied to `ghc-9.*-binary.nix`, determine whether - # the GHC 9 branch also switched from `gmp` to `integer-simple` via the - # currently-open issue: - # https://gitlab.haskell.org/ghc/ghc/-/issues/20059 - # and update this comment accordingly. - - nativeBuildInputs = [ perl ]; - - # Set LD_LIBRARY_PATH or equivalent so that the programs running as part - # of the bindist installer can find the libraries they expect. - # Cannot patchelf beforehand due to relative RPATHs that anticipate - # the final install location. - ${libEnvVar} = libPath; - - postUnpack = - # Verify our assumptions of which `libtinfo.so` (ncurses) version is used, - # so that we know when ghc bindists upgrade that and we need to update the - # version used in `libPath`. - lib.optionalString - (binDistUsed.exePathForLibraryCheck != null) - # Note the `*` glob because some GHCs have a suffix when unpacked, e.g. - # the musl bindist has dir `ghc-VERSION-x86_64-unknown-linux/`. - # As a result, don't shell-quote this glob when splicing the string. - (let buildExeGlob = ''ghc-${version}*/"${binDistUsed.exePathForLibraryCheck}"''; in - lib.concatStringsSep "\n" [ - ('' - shopt -u nullglob - echo "Checking that ghc binary exists in bindist at ${buildExeGlob}" - if ! test -e ${buildExeGlob}; then - echo >&2 "GHC binary ${binDistUsed.exePathForLibraryCheck} could not be found in the bindist build directory (at ${buildExeGlob}) for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1; - fi - '') - (lib.concatMapStringsSep - "\n" - ({ fileToCheckFor, nixPackage }: - lib.optionalString (fileToCheckFor != null) '' - echo "Checking bindist for ${fileToCheckFor} to ensure that is still used" - if ! readelf -d ${buildExeGlob} | grep "${fileToCheckFor}"; then - echo >&2 "File ${fileToCheckFor} could not be found in ${binDistUsed.exePathForLibraryCheck} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1; - fi - - echo "Checking that the nix package ${nixPackage} contains ${fileToCheckFor}" - if ! test -e "${lib.getLib nixPackage}/lib/${fileToCheckFor}"; then - echo >&2 "Nix package ${nixPackage} did not contain ${fileToCheckFor} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1; - fi - '' - ) - binDistUsed.archSpecificLibraries - ) - ]) - # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib - # during linking - + 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 - test -d ghc-${version}/inplace/bin && \ - patchShebangs ghc-${version}/inplace/bin - '' + - # We have to patch the GMP paths for the integer-gmp package. - # Note that musl bindists do not contain them, - # see: https://gitlab.haskell.org/ghc/ghc/-/issues/20073#note_363231 - # However, musl bindists >= 8.10.6 use `integer-simple`, not `gmp`. - '' - find . -name integer-gmp.buildinfo \ - -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \; - '' + 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. - lib.optionalString (stdenv.hostPlatform.isLinux && 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 - lib.optionalString stdenv.isLinux '' - find . -type f -executable -exec patchelf \ - --interpreter ${stdenv.cc.bintools.dynamicLinker} {} \; - '' + - # The hadrian install Makefile uses 'xxx' as a temporary placeholder in path - # substitution. Which can break the build if the store path / prefix happens - # to contain this string. This will be fixed with 9.4 bindists. - # https://gitlab.haskell.org/ghc/ghc/-/issues/21402 - '' - # Detect hadrian Makefile by checking for the target that has the problem - if grep '^update_package_db' ghc-${version}*/Makefile > /dev/null; then - echo Hadrian bindist, applying workaround for xxx path substitution. - # based on https://gitlab.haskell.org/ghc/ghc/-/commit/dd5fecb0e2990b192d92f4dfd7519ecb33164fad.patch - substituteInPlace ghc-${version}*/Makefile --replace 'xxx' '\0xxx\0' - else - echo Not a hadrian bindist, not applying xxx path workaround. - fi - ''; - - # fix for `configure: error: Your linker is affected by binutils #16177` - preConfigure = lib.optionalString - stdenv.targetPlatform.isAarch32 - "LD=ld.gold"; - - configurePlatforms = [ ]; - configureFlags = [ - "--with-gmp-includes=${lib.getDev gmp}/include" - # Note `--with-gmp-libraries` does nothing for GHC bindists: - # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6124 - ] ++ lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}" - # From: https://github.com/NixOS/nixpkgs/pull/43369/commits - ++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override"; - - # No building is necessary, but calling make without flags ironically - # calls install-strip ... - dontBuild = true; - - # Patch scripts to include runtime dependencies in $PATH. - postInstall = '' - for i in "$out/bin/"*; do - test ! -h "$i" || continue - isScript "$i" || continue - sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i" - done - ''; - - # Apparently necessary for the ghc Alpine (musl) bindist: - # When we strip, and then run the - # patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p - # below, running ghc (e.g. during `installCheckPhase)` gives some apparently - # corrupted rpath or whatever makes the loader work on nonsensical strings: - # running install tests - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: : symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: ir6zf6c9f86pfx8sr30n2vjy-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: y/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: �: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: �?: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found - # This is extremely bogus and should be investigated. - dontStrip = if stdenv.hostPlatform.isMusl then true else false; # `if` for explicitness - - # On Linux, use patchelf to modify the executables so that they can - # find editline/gmp. - postFixup = 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 - '') + 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 - '' + - 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 - # `-f` because e.g. musl bindist does not have this file. - rm -f $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}. - ''; - - # In nixpkgs, musl based builds currently enable `pie` hardening by default - # (see `defaultHardeningFlags` in `make-derivation.nix`). - # But GHC cannot currently produce outputs that are ready for `-pie` linking. - # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear. - # See: - # * https://github.com/NixOS/nixpkgs/issues/129247 - # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580 - hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie"; - - doInstallCheck = true; - installCheckPhase = '' - # 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 - env -i $out/bin/ghc --make main.hs || exit 1 - echo compilation ok - [ $(./main) == "yes" ] - ''; - - passthru = { - targetPrefix = ""; - enableShared = true; - - inherit llvmPackages; - - # Our Cabal compiler name - haskellCompilerName = "ghc-${version}"; - } - # We duplicate binDistUsed here since we have a sensible default even if no bindist is avaible, - # this makes sure that getting the `meta` attribute doesn't throw even on unsupported platforms. - // lib.optionalAttrs (ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}.isHadrian or false) { - # Normal GHC derivations expose the hadrian derivation used to build them - # here. In the case of bindists we just make sure that the attribute exists, - # as it is used for checking if a GHC derivation has been built with hadrian. - # The isHadrian mechanism will become obsolete with GHCs that use hadrian - # exclusively, i.e. 9.6 (and 9.4?). - hadrian = null; - }; - - meta = rec { - homepage = "http://haskell.org/ghc"; - description = "Glasgow Haskell Compiler"; - license = lib.licenses.bsd3; - # HACK: since we can't encode the libc / abi in platforms, we need - # to make the platform list dependent on the evaluation platform - # in order to avoid eval errors with musl which supports less - # platforms than the default libcs (i. e. glibc / libSystem). - # This is done for the benefit of Hydra, so `packagePlatforms` - # won't return any platforms that would cause an evaluation - # failure for `pkgsMusl.haskell.compiler.ghc8107Binary`, as - # long as the evaluator runs on a platform that supports - # `pkgsMusl`. - platforms = builtins.attrNames ghcBinDists.${distSetName}; - maintainers = with lib.maintainers; [ - prusnak - domenkozar - ] ++ lib.teams.haskell.members; - }; -} diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix deleted file mode 100644 index c8669a2761f8..000000000000 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ /dev/null @@ -1,434 +0,0 @@ -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages - -# build-tools -, bootPkgs -, autoreconfHook, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx -, xattr, autoSignDarwinBinariesHook -, bash - -, libiconv ? null, ncurses - -, # GHC can be built with system libffi or a bundled one. - libffi ? null - -, useLLVM ? !(stdenv.targetPlatform.isx86 - || stdenv.targetPlatform.isPower - || stdenv.targetPlatform.isSparc) -, # LLVM is conceptually a run-time-only dependency, but for - # non-x86, we need LLVM to bootstrap later stages, so it becomes a - # build-time dependency too. - buildTargetLlvmPackages, 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 ? !(lib.meta.availableOn stdenv.hostPlatform gmp - && lib.meta.availableOn stdenv.targetPlatform gmp) -, gmp - -, # If enabled, use -fPIC when compiling static libs. - enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform - -, enableProfiledLibs ? true - -, # 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 ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) - (if useLLVM then "perf-cross" else "perf-cross-ncg") - -, # Whether to build sphinx documentation. - enableDocs ? ( - # Docs disabled if we are building on musl because it's a large task to keep - # all `sphinx` dependencies building in this environment. - !stdenv.buildPlatform.isMusl - ) - -, enableHaddockProgram ? - # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) - -, # 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.isiOS -}: - -assert !enableIntegerSimple -> gmp != null; - -# Cross cannot currently build the `haddock` program for silly reasons, -# see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; - -let - inherit (stdenv) buildPlatform hostPlatform targetPlatform; - - inherit (bootPkgs) ghc; - - # TODO(@Ericson2314) Make unconditional - targetPrefix = lib.optionalString - (targetPlatform != hostPlatform) - "${targetPlatform.config}-"; - - buildMK = '' - BuildFlavour = ${ghcFlavour} - ifneq \"\$(BuildFlavour)\" \"\" - include mk/flavours/\$(BuildFlavour).mk - endif - BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"} - BUILD_SPHINX_PDF = NO - '' + - # Note [HADDOCK_DOCS]: - # Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock` - # program is built (which we generally always want to have a complete GHC install) - # and whether it is run on the GHC sources to generate hyperlinked source code - # (which is impossible for cross-compilation); see: - # https://gitlab.haskell.org/ghc/ghc/-/issues/20077 - # This implies that currently a cross-compiled GHC will never have a `haddock` - # program, so it can never generate haddocks for any packages. - # If this is solved in the future, we'd like to unconditionally - # build the haddock program (removing the `enableHaddockProgram` option). - '' - HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"} - # Build haddocks for boot packages with hyperlinking - EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump - - DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} - INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"} - '' + lib.optionalString (targetPlatform != hostPlatform) '' - Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"} - CrossCompilePrefix = ${targetPrefix} - '' + lib.optionalString (!enableProfiledLibs) '' - BUILD_PROF_LIBS = NO - '' + lib.optionalString enableRelocatedStaticLibs '' - GhcLibHcOpts += -fPIC - GhcRtsHcOpts += -fPIC - '' + lib.optionalString targetPlatform.useAndroidPrebuilt '' - EXTRA_CC_OPTS += -std=gnu99 - '' - # While split sections are now enabled by default in ghc 8.8 for windows, - # they seem to lead to `too many sections` errors when building base for - # profiling. - + lib.optionalString targetPlatform.isWindows '' - SplitSections = NO - ''; - - # Splicer will pull out correct variations - libDeps = platform: lib.optional enableTerminfo ncurses - ++ [libffi] - ++ lib.optional (!enableIntegerSimple) gmp - ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; - - # TODO(@sternenseemann): is buildTarget LLVM unnecessary? - # GHC doesn't seem to have {LLC,OPT}_HOST - toolsForTarget = [ - pkgsBuildTarget.targetPackages.stdenv.cc - ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; - - targetCC = builtins.head toolsForTarget; - - # toolPath calculates the absolute path to the name tool associated with a - # given `stdenv.cc` derivation, i.e. it picks the correct derivation to take - # the tool from (cc, cc.bintools, cc.bintools.bintools) and adds the correct - # subpath of the tool. - toolPath = name: cc: - let - tools = { - "cc" = cc; - "c++" = cc; - as = cc.bintools.bintools; - - ar = cc.bintools.bintools; - ranlib = cc.bintools.bintools; - nm = cc.bintools.bintools; - readelf = cc.bintools.bintools; - - ld = cc.bintools; - "ld.gold" = cc.bintools; - - otool = cc.bintools.bintools; - - # GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is - # part of the bintools wrapper (due to codesigning requirements), but not on - # x86_64-darwin. We decide based on target platform to have consistent tools - # across all GHC stages. - install_name_tool = - if stdenv.targetPlatform.isAarch64 - then cc.bintools - else cc.bintools.bintools; - # Same goes for strip. - strip = - # TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold" - if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin - then cc.bintools - else cc.bintools.bintools; - }.${name}; - in - "${tools}/bin/${tools.targetPrefix}${name}"; - - # Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues. - # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856 - # see #84670 and #49071 for more background. - useLdGold = targetPlatform.linker == "gold" || - (targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); - - # Makes debugging easier to see which variant is at play in `nix-store -q --tree`. - variantSuffix = lib.concatStrings [ - (lib.optionalString stdenv.hostPlatform.isMusl "-musl") - (lib.optionalString enableIntegerSimple "-integer-simple") - ]; - -in - -# C compiler, bintools and LLVM are used at build time, but will also leak into -# the resulting GHC's settings file and used at runtime. This means that we are -# currently only able to build GHC if hostPlatform == buildPlatform. -assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc; -assert buildTargetLlvmPackages.llvm == llvmPackages.llvm; -assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang; - -stdenv.mkDerivation (rec { - version = "8.10.7"; - pname = "${targetPrefix}ghc${variantSuffix}"; - - src = fetchurl { - url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz"; - sha256 = "e3eef6229ce9908dfe1ea41436befb0455fefb1932559e860ad4c606b0d03c9d"; - }; - - enableParallelBuilding = true; - - outputs = [ "out" "doc" ]; - - patches = [ - # Fix docs build with sphinx >= 6.0 - # https://gitlab.haskell.org/ghc/ghc/-/issues/22766 - (fetchpatch { - name = "ghc-docs-sphinx-6.0.patch"; - url = "https://gitlab.haskell.org/ghc/ghc/-/commit/10e94a556b4f90769b7fd718b9790d58ae566600.patch"; - sha256 = "0kmhfamr16w8gch0lgln2912r8aryjky1hfcda3jkcwa5cdzgjdv"; - }) - - # See upstream patch at - # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4885. Since we build - # from source distributions, the auto-generated configure script needs to be - # patched as well, therefore we use an in-tree patch instead of pulling the - # upstream patch. Don't forget to check backport status of the upstream patch - # when adding new GHC releases in nixpkgs. - ./respect-ar-path.patch - - # fix hyperlinked haddock sources: https://github.com/haskell/haddock/pull/1482 - (fetchpatch { - url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/1482.patch"; - sha256 = "sha256-8w8QUCsODaTvknCDGgTfFNZa8ZmvIKaKS+2ZJZ9foYk="; - extraPrefix = "utils/haddock/"; - stripLen = 1; - }) - - # cabal passes incorrect --host= when cross-compiling - # https://github.com/haskell/cabal/issues/5887 - (fetchpatch { - url = "https://raw.githubusercontent.com/input-output-hk/haskell.nix/122bd81150386867da07fdc9ad5096db6719545a/overlays/patches/ghc/cabal-host.patch"; - sha256 = "sha256:0yd0sajgi24sc1w5m55lkg2lp6kfkgpp3lgija2c8y3cmkwfpdc1"; - }) - - # In order to build ghcjs packages, the Cabal of the ghc used for the ghcjs - # needs to be patched. Ref https://github.com/haskell/cabal/pull/7575 - (fetchpatch { - url = "https://github.com/haskell/cabal/commit/369c4a0a54ad08a9e6b0d3bd303fedd7b5e5a336.patch"; - sha256 = "120f11hwyaqa0pq9g5l1300crqij49jg0rh83hnp9sa49zfdwx1n"; - stripLen = 3; - extraPrefix = "libraries/Cabal/Cabal/"; - }) - - # We need to be able to set AR_STAGE0 and LD_STAGE0 when cross-compiling - (fetchpatch { - url = "https://gitlab.haskell.org/ghc/ghc/-/commit/8f7dd5710b80906ea7a3e15b7bb56a883a49fed8.patch"; - hash = "sha256-C636Nq2U8YOG/av7XQmG3L1rU0bmC9/7m7Hty5pm5+s="; - }) - ] ++ 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"; - }) - ] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [ - # Prevent the paths module from emitting symbols that we don't use - # when building with separate outputs. - # - # These cause problems as they're not eliminated by GHC's dead code - # elimination on aarch64-darwin. (see - # https://github.com/NixOS/nixpkgs/issues/140774 for details). - ./Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch - ]; - - postPatch = "patchShebangs ."; - - # GHC is a bit confused on its cross terminology. - # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths - 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="${toolPath "cc" targetCC}" - export CXX="${toolPath "c++" targetCC}" - # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177 - export LD="${toolPath "ld${lib.optionalString useLdGold ".gold"}" targetCC}" - export AS="${toolPath "as" targetCC}" - export AR="${toolPath "ar" targetCC}" - export NM="${toolPath "nm" targetCC}" - export RANLIB="${toolPath "ranlib" targetCC}" - export READELF="${toolPath "readelf" targetCC}" - export STRIP="${toolPath "strip" targetCC}" - '' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") '' - export OTOOL="${toolPath "otool" targetCC}" - export INSTALL_NAME_TOOL="${toolPath "install_name_tool" targetCC}" - '' + lib.optionalString useLLVM '' - export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc" - export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt" - '' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) '' - # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm - export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang" - '' + '' - - echo -n "${buildMK}" > mk/build.mk - sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure - '' + lib.optionalString (!stdenv.isDarwin) '' - export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" - '' + lib.optionalString stdenv.isDarwin '' - export NIX_LDFLAGS+=" -no_dtrace_dof" - - # GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7 - export XATTR=${lib.getBin xattr}/bin/xattr - '' + 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 - '' + 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" ] - ++ 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" - ] ++ lib.optionals (libffi != null) [ - "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" - ] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [ - "--with-gmp-includes=${targetPackages.gmp.dev}/include" - "--with-gmp-libraries=${targetPackages.gmp.out}/lib" - ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ - "--with-iconv-includes=${libiconv}/include" - "--with-iconv-libraries=${libiconv}/lib" - ] ++ lib.optionals (targetPlatform != hostPlatform) [ - "--enable-bootstrap-with-devel-snapshot" - ] ++ lib.optionals useLdGold [ - "CFLAGS=-fuse-ld=gold" - "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold" - "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" - ] ++ 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 autoreconfHook autoconf automake m4 python3 - ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour - ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ - autoSignDarwinBinariesHook - ] ++ lib.optionals enableDocs [ - sphinx - ]; - - # For building runtime libs - depsBuildTarget = toolsForTarget; - - buildInputs = [ perl bash ] ++ (libDeps hostPlatform); - - depsTargetTarget = map lib.getDev (libDeps targetPlatform); - depsTargetTargetPropagated = map (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" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; - - checkTarget = "test"; - - hardeningDisable = - [ "format" ] - # In nixpkgs, musl based builds currently enable `pie` hardening by default - # (see `defaultHardeningFlags` in `make-derivation.nix`). - # But GHC cannot currently produce outputs that are ready for `-pie` linking. - # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear. - # See: - # * https://github.com/NixOS/nixpkgs/issues/129247 - # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580 - ++ lib.optional stdenv.targetPlatform.isMusl "pie"; - - # big-parallel allows us to build with more than 2 cores on - # Hydra which already warrants a significant speedup - requiredSystemFeatures = [ "big-parallel" ]; - - postInstall = '' - # Install the bash completion file. - install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc - ''; - - passthru = { - inherit bootPkgs targetPrefix; - - inherit llvmPackages; - inherit enableShared; - - # This is used by the haskell builder to query - # the presence of the haddock program. - hasHaddock = enableHaddockProgram; - - # Our Cabal compiler name - haskellCompilerName = "ghc-${version}"; - }; - - meta = { - homepage = "http://haskell.org/ghc"; - description = "Glasgow Haskell Compiler"; - maintainers = with lib.maintainers; [ - guibou - ] ++ lib.teams.haskell.members; - timeout = 24 * 3600; - inherit (ghc.meta) license platforms; - }; - -} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { - dontStrip = true; - dontPatchELF = true; - noAuditTmpdir = true; -}) diff --git a/pkgs/development/compilers/ghc/8.6.5-binary.nix b/pkgs/development/compilers/ghc/8.6.5-binary.nix deleted file mode 100644 index d66f47b661a5..000000000000 --- a/pkgs/development/compilers/ghc/8.6.5-binary.nix +++ /dev/null @@ -1,231 +0,0 @@ -{ lib, stdenv -, fetchurl, perl, gcc -, ncurses5, ncurses6, gmp, glibc, libiconv -, llvmPackages -, coreutils -, targetPackages -}: - -# Prebuilt only does native -assert stdenv.targetPlatform == stdenv.hostPlatform; - -let - useLLVM = !(stdenv.targetPlatform.isx86 - || stdenv.targetPlatform.isPower - || stdenv.targetPlatform.isSparc); - - useNcurses6 = stdenv.hostPlatform.system == "x86_64-linux" - || (with stdenv.hostPlatform; isPower64 && isLittleEndian); - - ourNcurses = if useNcurses6 then ncurses6 else ncurses5; - - libPath = lib.makeLibraryPath ([ - ourNcurses gmp - ] ++ lib.optional (stdenv.hostPlatform.isDarwin) libiconv); - - libEnvVar = 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 - "${lib.getLib glibc}/lib/ld-linux*"; - - downloadsUrl = "https://downloads.haskell.org/ghc"; - - runtimeDeps = [ - targetPackages.stdenv.cc - targetPackages.stdenv.cc.bintools - coreutils # for cat - ] - ++ lib.optionals (assert useLLVM -> !(llvmPackages == null); useLLVM) [ - (lib.getBin llvmPackages.llvm) - ] - # On darwin, we need unwrapped bintools as well (for otool) - ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ - targetPackages.stdenv.cc.bintools.bintools - ]; - -in - -stdenv.mkDerivation rec { - version = "8.6.5"; - pname = "ghc-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 = "${downloadsUrl}/${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 = "${downloadsUrl}/${version}/ghc-${version}-x86_64-fedora27-linux.tar.xz"; - sha256 = "18dlqm5d028fqh6ghzn7pgjspr5smw030jjzl3kq6q1kmwzbay6g"; - }; - x86_64-darwin = { - url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz"; - sha256 = "0s9188vhhgf23q3rjarwhbr524z6h2qga5xaaa2pma03sfqvvhfz"; - }; - powerpc64le-linux = { - url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-powerpc64le-fedora29-linux.tar.xz"; - sha256 = "sha256-tWSsJdPVrCiqDyIKzpBt5DaXb3b6j951tCya584kWs4="; - }; - }.${stdenv.hostPlatform.system} - or (throw "cannot bootstrap GHC on this platform")); - - nativeBuildInputs = [ perl ]; - - # 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 - 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 - test -d ghc-${version}/inplace/bin && \ - patchShebangs ghc-${version}/inplace/bin - '' + - - # 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@" {} \; - '' + 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 - lib.optionalString stdenv.isLinux '' - find . -type f -perm -0100 \ - -exec patchelf \ - --replace-needed libncurses${lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \ - ${ # This isn't required for x86_64-linux where we use ncurses6 - 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: - lib.optionalString stdenv.hostPlatform.isMusl '' - find ./ghc-${version}/rts -name "libHSrts*.a" -exec ''${OBJCOPY:-objcopy} --redefine-sym __strdup=strdup {} \; - ''; - - configurePlatforms = [ ]; - configureFlags = [ - "--with-gmp-includes=${lib.getDev gmp}/include" - # Note `--with-gmp-libraries` does nothing for GHC bindists: - # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6124 - ] ++ lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}" - ++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override"; - - # No building is necessary, but calling make without flags ironically - # calls install-strip ... - dontBuild = true; - - # Patch scripts to include runtime dependencies in $PATH. - postInstall = '' - for i in "$out/bin/"*; do - test ! -h "$i" || continue - isScript "$i" || continue - sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i" - done - ''; - - # On Linux, use patchelf to modify the executables so that they can - # find editline/gmp. - postFixup = 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 - '' + 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 - ''; - - # In nixpkgs, musl based builds currently enable `pie` hardening by default - # (see `defaultHardeningFlags` in `make-derivation.nix`). - # But GHC cannot currently produce outputs that are ready for `-pie` linking. - # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear. - # See: - # * https://github.com/NixOS/nixpkgs/issues/129247 - # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580 - hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie"; - - doInstallCheck = true; - installCheckPhase = '' - # 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 - env -i $out/bin/ghc --make main.hs || exit 1 - echo compilation ok - [ $(./main) == "yes" ] - ''; - - passthru = { - targetPrefix = ""; - enableShared = true; - - inherit llvmPackages; - - # Our Cabal compiler name - haskellCompilerName = "ghc-${version}"; - }; - - meta = rec { - license = lib.licenses.bsd3; - platforms = [ - "x86_64-linux" - "i686-linux" - "x86_64-darwin" - "powerpc64le-linux" - ]; - # build segfaults, use ghc8107Binary which has proper musl support instead - broken = stdenv.hostPlatform.isMusl; - maintainers = with lib.maintainers; [ - guibou - ] ++ lib.teams.haskell.members; - }; -} diff --git a/pkgs/development/compilers/ghc/9.0.2.nix b/pkgs/development/compilers/ghc/9.0.2.nix deleted file mode 100644 index 987821830504..000000000000 --- a/pkgs/development/compilers/ghc/9.0.2.nix +++ /dev/null @@ -1,4 +0,0 @@ -import ./common-make-native-bignum.nix { - version = "9.0.2"; - sha256 = "140e42b96346322d1a39eb17602bcdc76e292028ad4a69286b230bab188a9197"; -} diff --git a/pkgs/development/compilers/ghc/9.10.1.nix b/pkgs/development/compilers/ghc/9.10.1.nix deleted file mode 100644 index 7955661f50e1..000000000000 --- a/pkgs/development/compilers/ghc/9.10.1.nix +++ /dev/null @@ -1,4 +0,0 @@ -import ./common-hadrian.nix rec { - version = "9.10.1"; - sha256 = "bf386a302d4ee054791ffd51748900f15d71760fd199157922d120cc1f89e2f7"; -} diff --git a/pkgs/development/compilers/ghc/9.2.4-binary.nix b/pkgs/development/compilers/ghc/9.2.4-binary.nix deleted file mode 100644 index 920b63ce4eab..000000000000 --- a/pkgs/development/compilers/ghc/9.2.4-binary.nix +++ /dev/null @@ -1,439 +0,0 @@ -{ lib, stdenv -, fetchurl, perl, gcc -, ncurses5 -, ncurses6, gmp, libiconv, numactl, libffi -, llvmPackages -, coreutils -, targetPackages - - # 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 - downloadsUrl = "https://downloads.haskell.org/ghc"; - - # Copy sha256 from https://downloads.haskell.org/~ghc/9.2.4/SHA256SUMS - version = "9.2.4"; - - # Information about available bindists that we use in the build. - # - # # Bindist library checking - # - # The field `archSpecificLibraries` also provides a way for us get notified - # early when the upstream bindist changes its dependencies (e.g. because a - # newer Debian version is used that uses a new `ncurses` version). - # - # Usage: - # - # * You can find the `fileToCheckFor` of libraries by running `readelf -d` - # on the compiler binary (`exePathForLibraryCheck`). - # * To skip library checking for an architecture, - # set `exePathForLibraryCheck = null`. - # * To skip file checking for a specific arch specfic library, - # set `fileToCheckFor = null`. - ghcBinDists = { - # Binary distributions for the default libc (e.g. glibc, or libSystem on Darwin) - # nixpkgs uses for the respective system. - defaultLibc = { - i686-linux = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz"; - sha256 = "5dc1eb9c65f01b1e5c5693af72af07a4e9e75c6920e620fd598daeefa804487a"; - }; - exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - # The i686-linux bindist provided by GHC HQ is currently built on Debian 9, - # which link it against `libtinfo.so.5` (ncurses 5). - # Other bindists are linked `libtinfo.so.6` (ncurses 6). - { nixPackage = ncurses5; fileToCheckFor = "libtinfo.so.5"; } - ]; - }; - x86_64-linux = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb10-linux.tar.xz"; - sha256 = "a77a91a39d9b0167124b7e97648b2b52973ae0978cb259e0d44f0752a75037cb"; - }; - exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; } - ]; - }; - aarch64-linux = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz"; - sha256 = "fc7dbc6bae36ea5ac30b7e9a263b7e5be3b45b0eb3e893ad0bc2c950a61f14ec"; - }; - exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2"; - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; } - { nixPackage = numactl; fileToCheckFor = null; } - ]; - }; - x86_64-darwin = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz"; - sha256 = "f2e8366fd3754dd9388510792aba2d2abecb1c2f7f1e5555f6065c3c5e2ffec4"; - }; - exePathForLibraryCheck = null; # we don't have a library check for darwin yet - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - { nixPackage = ncurses6; fileToCheckFor = null; } - { nixPackage = libiconv; fileToCheckFor = null; } - ]; - isHadrian = true; - }; - aarch64-darwin = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz"; - sha256 = "8cf8408544a1a43adf1bbbb0dd6b074efadffc68bfa1a792947c52e825171224"; - }; - exePathForLibraryCheck = null; # we don't have a library check for darwin yet - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - { nixPackage = ncurses6; fileToCheckFor = null; } - { nixPackage = libiconv; fileToCheckFor = null; } - ]; - isHadrian = true; - }; - }; - # Binary distributions for the musl libc for the respective system. - musl = { - x86_64-linux = { - variantSuffix = "-musl"; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-alpine3.12-linux-gmp.tar.xz"; - sha256 = "026348947d30a156b84de5d6afeaa48fdcb2795b47954cd8341db00d3263a481"; - }; - isStatic = true; - isHadrian = true; - # We can't check the RPATH for statically linked executable - exePathForLibraryCheck = null; - archSpecificLibraries = [ - { nixPackage = gmp.override { withStatic = true; }; fileToCheckFor = null; } - ]; - }; - }; - }; - - distSetName = if stdenv.hostPlatform.isMusl then "musl" else "defaultLibc"; - - binDistUsed = ghcBinDists.${distSetName}.${stdenv.hostPlatform.system} - or (throw "cannot bootstrap GHC on this platform ('${stdenv.hostPlatform.system}' with libc '${distSetName}')"); - - gmpUsed = (builtins.head ( - builtins.filter ( - drv: lib.hasPrefix "gmp" (drv.nixPackage.name or "") - ) binDistUsed.archSpecificLibraries - )).nixPackage; - - # GHC has other native backends (like PowerPC), but here only the ones - # we ship bindists for matter. - useLLVM = !(stdenv.targetPlatform.isx86 - || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin)); - - libPath = - lib.makeLibraryPath ( - # Add arch-specific libraries. - map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries - ); - - libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY" - + "LD_LIBRARY_PATH"; - - runtimeDeps = [ - targetPackages.stdenv.cc - targetPackages.stdenv.cc.bintools - coreutils # for cat - ] - ++ lib.optionals useLLVM [ - (lib.getBin llvmPackages.llvm) - ] - # On darwin, we need unwrapped bintools as well (for otool) - ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ - targetPackages.stdenv.cc.bintools.bintools - ]; - -in - -stdenv.mkDerivation rec { - inherit version; - pname = "ghc-binary${binDistUsed.variantSuffix}"; - - src = fetchurl binDistUsed.src; - - nativeBuildInputs = [ perl ]; - - # Set LD_LIBRARY_PATH or equivalent so that the programs running as part - # of the bindist installer can find the libraries they expect. - # Cannot patchelf beforehand due to relative RPATHs that anticipate - # the final install location. - ${libEnvVar} = libPath; - - postUnpack = - # Verify our assumptions of which `libtinfo.so` (ncurses) version is used, - # so that we know when ghc bindists upgrade that and we need to update the - # version used in `libPath`. - lib.optionalString - (binDistUsed.exePathForLibraryCheck != null) - # Note the `*` glob because some GHCs have a suffix when unpacked, e.g. - # the musl bindist has dir `ghc-VERSION-x86_64-unknown-linux/`. - # As a result, don't shell-quote this glob when splicing the string. - (let buildExeGlob = ''ghc-${version}*/"${binDistUsed.exePathForLibraryCheck}"''; in - lib.concatStringsSep "\n" [ - ('' - shopt -u nullglob - echo "Checking that ghc binary exists in bindist at ${buildExeGlob}" - if ! test -e ${buildExeGlob}; then - echo >&2 "GHC binary ${binDistUsed.exePathForLibraryCheck} could not be found in the bindist build directory (at ${buildExeGlob}) for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1; - fi - '') - (lib.concatMapStringsSep - "\n" - ({ fileToCheckFor, nixPackage }: - lib.optionalString (fileToCheckFor != null) '' - echo "Checking bindist for ${fileToCheckFor} to ensure that is still used" - if ! readelf -d ${buildExeGlob} | grep "${fileToCheckFor}"; then - echo >&2 "File ${fileToCheckFor} could not be found in ${binDistUsed.exePathForLibraryCheck} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1; - fi - - echo "Checking that the nix package ${nixPackage} contains ${fileToCheckFor}" - if ! test -e "${lib.getLib nixPackage}/lib/${fileToCheckFor}"; then - echo >&2 "Nix package ${nixPackage} did not contain ${fileToCheckFor} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1; - fi - '' - ) - binDistUsed.archSpecificLibraries - ) - ]) - # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib - # during linking - + 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 - test -d ghc-${version}/inplace/bin && \ - patchShebangs ghc-${version}/inplace/bin - '' + - # We have to patch the GMP paths for the integer-gmp package. - '' - find . -name ghc-bignum.buildinfo \ - -exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${lib.getLib gmpUsed}/lib@" {} \; - - # we need to modify the package db directly for hadrian bindists - find . -name 'ghc-bignum*.conf' \ - -exec sed -e '/^[a-z-]*library-dirs/a \ ${lib.getLib gmpUsed}/lib' -i {} \; - '' + lib.optionalString stdenv.isDarwin '' - # we need to modify the package db directly for hadrian bindists - # (all darwin bindists are hadrian-based for 9.2.2) - find . -name 'base*.conf' \ - -exec sed -e '/^[a-z-]*library-dirs/a \ ${lib.getLib libiconv}/lib' -i {} \; - - # To link RTS in the end we also need libffi now - find . -name 'rts*.conf' \ - -exec sed -e '/^[a-z-]*library-dirs/a \ ${lib.getLib libffi}/lib' \ - -e 's@/Library/Developer/.*/usr/include/ffi@${lib.getDev libffi}/include@' \ - -i {} \; - '' + - # 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. - lib.optionalString (stdenv.hostPlatform.isLinux && 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 - lib.optionalString stdenv.isLinux '' - find . -type f -executable -exec patchelf \ - --interpreter ${stdenv.cc.bintools.dynamicLinker} {} \; - ''; - - # fix for `configure: error: Your linker is affected by binutils #16177` - preConfigure = lib.optionalString - stdenv.targetPlatform.isAarch32 - "LD=ld.gold"; - - configurePlatforms = [ ]; - configureFlags = [ - "--with-gmp-includes=${lib.getDev gmpUsed}/include" - # Note `--with-gmp-libraries` does nothing for GHC bindists: - # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6124 - ] ++ lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}" - # From: https://github.com/NixOS/nixpkgs/pull/43369/commits - ++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override"; - - # No building is necessary, but calling make without flags ironically - # calls install-strip ... - dontBuild = true; - - # Patch scripts to include runtime dependencies in $PATH. - postInstall = '' - for i in "$out/bin/"*; do - test ! -h "$i" || continue - isScript "$i" || continue - sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i" - done - ''; - - # Apparently necessary for the ghc Alpine (musl) bindist: - # When we strip, and then run the - # patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p - # below, running ghc (e.g. during `installCheckPhase)` gives some apparently - # corrupted rpath or whatever makes the loader work on nonsensical strings: - # running install tests - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: : symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: ir6zf6c9f86pfx8sr30n2vjy-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: y/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: �: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: �?: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found - # This is extremely bogus and should be investigated. - dontStrip = if stdenv.hostPlatform.isMusl then true else false; # `if` for explicitness - - # On Linux, use patchelf to modify the executables so that they can - # find editline/gmp. - postFixup = lib.optionalString (stdenv.isLinux && !(binDistUsed.isStatic or false)) - (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 ${lib.getLib gmpUsed}/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 - '') + 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 - '' + - 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 - # `-f` because e.g. musl bindist does not have this file. - rm -f $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}. - '' - # Recache package db which needs to happen for Hadrian bindists - # where we modify the package db before installing - + '' - shopt -s nullglob - package_db=("$out"/lib/ghc-*/lib/package.conf.d "$out"/lib/ghc-*/package.conf.d) - "$out/bin/ghc-pkg" --package-db="$package_db" recache - ''; - - # In nixpkgs, musl based builds currently enable `pie` hardening by default - # (see `defaultHardeningFlags` in `make-derivation.nix`). - # But GHC cannot currently produce outputs that are ready for `-pie` linking. - # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear. - # See: - # * https://github.com/NixOS/nixpkgs/issues/129247 - # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580 - hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie"; - - doInstallCheck = true; - installCheckPhase = '' - # 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 - env -i $out/bin/ghc --make main.hs || exit 1 - echo compilation ok - [ $(./main) == "yes" ] - ''; - - passthru = { - targetPrefix = ""; - enableShared = true; - - inherit llvmPackages; - - # Our Cabal compiler name - haskellCompilerName = "ghc-${version}"; - } - # We duplicate binDistUsed here since we have a sensible default even if no bindist is avaible, - # this makes sure that getting the `meta` attribute doesn't throw even on unsupported platforms. - // lib.optionalAttrs (ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}.isHadrian or false) { - # Normal GHC derivations expose the hadrian derivation used to build them - # here. In the case of bindists we just make sure that the attribute exists, - # as it is used for checking if a GHC derivation has been built with hadrian. - # The isHadrian mechanism will become obsolete with GHCs that use hadrian - # exclusively, i.e. 9.6 (and 9.4?). - hadrian = null; - }; - - meta = rec { - homepage = "http://haskell.org/ghc"; - description = "Glasgow Haskell Compiler"; - license = lib.licenses.bsd3; - # HACK: since we can't encode the libc / abi in platforms, we need - # to make the platform list dependent on the evaluation platform - # in order to avoid eval errors with musl which supports less - # platforms than the default libcs (i. e. glibc / libSystem). - # This is done for the benefit of Hydra, so `packagePlatforms` - # won't return any platforms that would cause an evaluation - # failure for `pkgsMusl.haskell.compiler.ghc922Binary`, as - # long as the evaluator runs on a platform that supports - # `pkgsMusl`. - platforms = builtins.attrNames ghcBinDists.${distSetName}; - maintainers = lib.teams.haskell.members; - }; -} diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix deleted file mode 100644 index 366b25441bbb..000000000000 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ /dev/null @@ -1,4 +0,0 @@ -import ./common-make-native-bignum.nix { - version = "9.2.5"; - sha256 = "0606797d1b38e2d88ee2243f38ec6b9a1aa93e9b578e95f0de9a9c0a4144021c"; -} diff --git a/pkgs/development/compilers/ghc/9.2.6.nix b/pkgs/development/compilers/ghc/9.2.6.nix deleted file mode 100644 index 4490cd6f5b31..000000000000 --- a/pkgs/development/compilers/ghc/9.2.6.nix +++ /dev/null @@ -1,4 +0,0 @@ -import ./common-make-native-bignum.nix { - version = "9.2.6"; - sha256 = "7a54cf0398ad488b4ed219e15d1d1e64c0b6876c43a0564550dd11f0540d7305"; -} diff --git a/pkgs/development/compilers/ghc/9.2.7.nix b/pkgs/development/compilers/ghc/9.2.7.nix deleted file mode 100644 index ad840dd0a32f..000000000000 --- a/pkgs/development/compilers/ghc/9.2.7.nix +++ /dev/null @@ -1,4 +0,0 @@ -import ./common-make-native-bignum.nix { - version = "9.2.7"; - sha256 = "a253567a17b734a4c0dd0ffa296d33c2a5b5a54a77df988806a2a1e1ca7e88b8"; -} diff --git a/pkgs/development/compilers/ghc/9.2.8.nix b/pkgs/development/compilers/ghc/9.2.8.nix deleted file mode 100644 index dc2bd89b3174..000000000000 --- a/pkgs/development/compilers/ghc/9.2.8.nix +++ /dev/null @@ -1,4 +0,0 @@ -import ./common-make-native-bignum.nix { - version = "9.2.8"; - sha256 = "sha256-XxPReGv0/RL0tF+qN6vttbs/NtXlj32lMH6L/oilZ6E="; -} diff --git a/pkgs/development/compilers/ghc/9.4.5.nix b/pkgs/development/compilers/ghc/9.4.5.nix deleted file mode 100644 index cffbfef1524e..000000000000 --- a/pkgs/development/compilers/ghc/9.4.5.nix +++ /dev/null @@ -1,6 +0,0 @@ -# DO NOT port this expression to hadrian. It is not possible to build a GHC -# cross compiler with 9.4.* and hadrian. -import ./common-make-native-bignum.nix { - version = "9.4.5"; - sha256 = "6256cf9caf6d6dc7b611dcfbb247df2d528e85aa39d22a698e870e5a590e8601"; -} diff --git a/pkgs/development/compilers/ghc/9.4.6-bytestring-posix-source.patch b/pkgs/development/compilers/ghc/9.4.6-bytestring-posix-source.patch deleted file mode 100644 index 644ab295191f..000000000000 --- a/pkgs/development/compilers/ghc/9.4.6-bytestring-posix-source.patch +++ /dev/null @@ -1,15 +0,0 @@ -Make sure that the appropriate feature flags are set when -Rts.h is included, so that clockid_t is defined. - -diff --git a/cbits/is-valid-utf8.c b/cbits/is-valid-utf8.c -index 01b3b41..c69596a 100644 ---- a/libraries/bytestring/cbits/is-valid-utf8.c -+++ b/libraries/bytestring/cbits/is-valid-utf8.c -@@ -29,6 +29,7 @@ SUCH DAMAGE. - */ - #pragma GCC push_options - #pragma GCC optimize("-O2") -+#include "rts/PosixSource.h" - #include <stdbool.h> - #include <stddef.h> - #include <stdint.h> diff --git a/pkgs/development/compilers/ghc/9.4.6.nix b/pkgs/development/compilers/ghc/9.4.6.nix deleted file mode 100644 index 0d37ba97fdb6..000000000000 --- a/pkgs/development/compilers/ghc/9.4.6.nix +++ /dev/null @@ -1,6 +0,0 @@ -# DO NOT port this expression to hadrian. It is not possible to build a GHC -# cross compiler with 9.4.* and hadrian. -import ./common-make-native-bignum.nix { - version = "9.4.6"; - sha256 = "1b705cf52692f9d4d6707cdf8e761590f5f56ec8ea6a65e36610db392d3d24b9"; -} diff --git a/pkgs/development/compilers/ghc/9.4.7.nix b/pkgs/development/compilers/ghc/9.4.7.nix deleted file mode 100644 index 2be8c9f092fb..000000000000 --- a/pkgs/development/compilers/ghc/9.4.7.nix +++ /dev/null @@ -1,6 +0,0 @@ -# DO NOT port this expression to hadrian. It is not possible to build a GHC -# cross compiler with 9.4.* and hadrian. -import ./common-make-native-bignum.nix { - version = "9.4.7"; - sha256 = "06775a52b4d13ac09edc6dabc299fd11e59d8886bbcae450af367baee2684c8f"; -} diff --git a/pkgs/development/compilers/ghc/9.4.8.nix b/pkgs/development/compilers/ghc/9.4.8.nix deleted file mode 100644 index a98d7404b7ac..000000000000 --- a/pkgs/development/compilers/ghc/9.4.8.nix +++ /dev/null @@ -1,6 +0,0 @@ -# DO NOT port this expression to hadrian. It is not possible to build a GHC -# cross compiler with 9.4.* and hadrian. -import ./common-make-native-bignum.nix { - version = "9.4.8"; - sha256 = "0bf407eb67fe3e3c24b0f4c8dea8cb63e07f63ca0f76cf2058565143507ab85e"; -} diff --git a/pkgs/development/compilers/ghc/9.6.3-binary.nix b/pkgs/development/compilers/ghc/9.6.3-binary.nix deleted file mode 100644 index 65ed655e5797..000000000000 --- a/pkgs/development/compilers/ghc/9.6.3-binary.nix +++ /dev/null @@ -1,410 +0,0 @@ -{ lib, stdenv -, fetchurl, perl, gcc -, ncurses5 -, ncurses6, gmp, libiconv, numactl, libffi -, llvmPackages -, coreutils -, targetPackages - - # 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 - downloadsUrl = "https://downloads.haskell.org/ghc"; - - # Copy sha256 from https://downloads.haskell.org/~ghc/9.6.3/SHA256SUMS - version = "9.6.3"; - - # Information about available bindists that we use in the build. - # - # # Bindist library checking - # - # The field `archSpecificLibraries` also provides a way for us get notified - # early when the upstream bindist changes its dependencies (e.g. because a - # newer Debian version is used that uses a new `ncurses` version). - # - # Usage: - # - # * You can find the `fileToCheckFor` of libraries by running `readelf -d` - # on the compiler binary (`exePathForLibraryCheck`). - # * To skip library checking for an architecture, - # set `exePathForLibraryCheck = null`. - # * To skip file checking for a specific arch specfic library, - # set `fileToCheckFor = null`. - ghcBinDists = { - # Binary distributions for the default libc (e.g. glibc, or libSystem on Darwin) - # nixpkgs uses for the respective system. - defaultLibc = { - i686-linux = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz"; - sha256 = "58be26f8b8f6b5bd8baf5c32abb03e2c4621646b2142fab10e5c7de5af5c50f8"; - }; - exePathForLibraryCheck = "bin/ghc"; - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - # The i686-linux bindist provided by GHC HQ is currently built on Debian 9, - # which link it against `libtinfo.so.5` (ncurses 5). - # Other bindists are linked `libtinfo.so.6` (ncurses 6). - { nixPackage = ncurses5; fileToCheckFor = "libtinfo.so.5"; } - ]; - }; - x86_64-linux = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb11-linux.tar.xz"; - sha256 = "c4c0124857265926f1cf22a09d950d7ba989ff94053a4ddf3dcdab5359f4cab7"; - }; - exePathForLibraryCheck = "bin/ghc"; - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; } - ]; - }; - aarch64-linux = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz"; - sha256 = "03c389859319f09452081310fc13af7525063ea8930830ef76be2a14b312271e"; - }; - exePathForLibraryCheck = "bin/ghc"; - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - { nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; } - { nixPackage = numactl; fileToCheckFor = null; } - ]; - }; - x86_64-darwin = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz"; - sha256 = "dde46118ab8388fb1066312c097123e93b1dcf6ae366e3370f88ea456382c9db"; - }; - exePathForLibraryCheck = null; # we don't have a library check for darwin yet - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - { nixPackage = ncurses6; fileToCheckFor = null; } - { nixPackage = libiconv; fileToCheckFor = null; } - ]; - }; - aarch64-darwin = { - variantSuffix = ""; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz"; - sha256 = "e1cdf458926b2eaf52d2a8287d99a965040ff9051171f5c3b7467049cf0eb213"; - }; - exePathForLibraryCheck = null; # we don't have a library check for darwin yet - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - { nixPackage = ncurses6; fileToCheckFor = null; } - { nixPackage = libiconv; fileToCheckFor = null; } - ]; - }; - }; - # Binary distributions for the musl libc for the respective system. - musl = { - x86_64-linux = { - variantSuffix = "-musl"; - src = { - url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-alpine3_12-linux.tar.xz"; - sha256 = "8f457af0aa40127049c11134c8793f64351a446e87da1f8ec256e1279b5ab61f"; - }; - exePathForLibraryCheck = "bin/ghc"; - archSpecificLibraries = [ - { nixPackage = gmp; fileToCheckFor = null; } - { nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; } - ]; - }; - }; - }; - - distSetName = if stdenv.hostPlatform.isMusl then "musl" else "defaultLibc"; - - binDistUsed = ghcBinDists.${distSetName}.${stdenv.hostPlatform.system} - or (throw "cannot bootstrap GHC on this platform ('${stdenv.hostPlatform.system}' with libc '${distSetName}')"); - - gmpUsed = (builtins.head ( - builtins.filter ( - drv: lib.hasPrefix "gmp" (drv.nixPackage.name or "") - ) binDistUsed.archSpecificLibraries - )).nixPackage; - - # GHC has other native backends (like PowerPC), but here only the ones - # we ship bindists for matter. - useLLVM = !(stdenv.targetPlatform.isx86 - || (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin)); - - libPath = - lib.makeLibraryPath ( - # Add arch-specific libraries. - map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries - ); - - libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY" - + "LD_LIBRARY_PATH"; - - runtimeDeps = [ - targetPackages.stdenv.cc - targetPackages.stdenv.cc.bintools - coreutils # for cat - ] - ++ lib.optionals useLLVM [ - (lib.getBin llvmPackages.llvm) - ] - # On darwin, we need unwrapped bintools as well (for otool) - ++ lib.optionals (stdenv.targetPlatform.linker == "cctools") [ - targetPackages.stdenv.cc.bintools.bintools - ]; - -in - -stdenv.mkDerivation rec { - inherit version; - pname = "ghc-binary${binDistUsed.variantSuffix}"; - - src = fetchurl binDistUsed.src; - - nativeBuildInputs = [ perl ]; - - # Set LD_LIBRARY_PATH or equivalent so that the programs running as part - # of the bindist installer can find the libraries they expect. - # Cannot patchelf beforehand due to relative RPATHs that anticipate - # the final install location. - ${libEnvVar} = libPath; - - postUnpack = - # Verify our assumptions of which `libtinfo.so` (ncurses) version is used, - # so that we know when ghc bindists upgrade that and we need to update the - # version used in `libPath`. - lib.optionalString - (binDistUsed.exePathForLibraryCheck != null) - # Note the `*` glob because some GHCs have a suffix when unpacked, e.g. - # the musl bindist has dir `ghc-VERSION-x86_64-unknown-linux/`. - # As a result, don't shell-quote this glob when splicing the string. - (let buildExeGlob = ''ghc-${version}*/"${binDistUsed.exePathForLibraryCheck}"''; in - lib.concatStringsSep "\n" [ - ('' - shopt -u nullglob - echo "Checking that ghc binary exists in bindist at ${buildExeGlob}" - if ! test -e ${buildExeGlob}; then - echo >&2 "GHC binary ${binDistUsed.exePathForLibraryCheck} could not be found in the bindist build directory (at ${buildExeGlob}) for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1; - fi - '') - (lib.concatMapStringsSep - "\n" - ({ fileToCheckFor, nixPackage }: - lib.optionalString (fileToCheckFor != null) '' - echo "Checking bindist for ${fileToCheckFor} to ensure that is still used" - if ! readelf -d ${buildExeGlob} | grep "${fileToCheckFor}"; then - echo >&2 "File ${fileToCheckFor} could not be found in ${binDistUsed.exePathForLibraryCheck} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1; - fi - - echo "Checking that the nix package ${nixPackage} contains ${fileToCheckFor}" - if ! test -e "${lib.getLib nixPackage}/lib/${fileToCheckFor}"; then - echo >&2 "Nix package ${nixPackage} did not contain ${fileToCheckFor} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1; - fi - '' - ) - binDistUsed.archSpecificLibraries - ) - ]) - # GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib - # during linking - + 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 - isMachO $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 - '' - - # We have to patch the GMP paths for the ghc-bignum package, for hadrian by - # modifying the package-db directly - + '' - find . -name 'ghc-bignum*.conf' \ - -exec sed -e '/^[a-z-]*library-dirs/a \ ${lib.getLib gmpUsed}/lib' -i {} \; - '' - # Similar for iconv and libffi on darwin - + lib.optionalString stdenv.isDarwin '' - find . -name 'base*.conf' \ - -exec sed -e '/^[a-z-]*library-dirs/a \ ${lib.getLib libiconv}/lib' -i {} \; - - # To link RTS in the end we also need libffi now - find . -name 'rts*.conf' \ - -exec sed -e '/^[a-z-]*library-dirs/a \ ${lib.getLib libffi}/lib' \ - -e 's@/Library/Developer/.*/usr/include/ffi@${lib.getDev libffi}/include@' \ - -i {} \; - '' + - # 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. - lib.optionalString (stdenv.hostPlatform.isLinux && 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 - lib.optionalString stdenv.isLinux '' - find . -type f -executable -exec patchelf \ - --interpreter ${stdenv.cc.bintools.dynamicLinker} {} \; - ''; - - # fix for `configure: error: Your linker is affected by binutils #16177` - preConfigure = lib.optionalString - stdenv.targetPlatform.isAarch32 - "LD=ld.gold"; - - # GHC has a patched config.sub and bindists' platforms should always work - dontUpdateAutotoolsGnuConfigScripts = true; - - configurePlatforms = [ ]; - configureFlags = - lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}" - # From: https://github.com/NixOS/nixpkgs/pull/43369/commits - ++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override"; - - # No building is necessary, but calling make without flags ironically - # calls install-strip ... - dontBuild = true; - - # Patch scripts to include runtime dependencies in $PATH. - postInstall = '' - for i in "$out/bin/"*; do - test ! -h "$i" || continue - isScript "$i" || continue - sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i" - done - ''; - - # Apparently necessary for the ghc Alpine (musl) bindist: - # When we strip, and then run the - # patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p - # below, running ghc (e.g. during `installCheckPhase)` gives some apparently - # corrupted rpath or whatever makes the loader work on nonsensical strings: - # running install tests - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: : symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: ir6zf6c9f86pfx8sr30n2vjy-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: y/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: �: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: �?: symbol not found - # Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found - # This is extremely bogus and should be investigated. - dontStrip = if stdenv.hostPlatform.isMusl then true else false; # `if` for explicitness - - # On Linux, use patchelf to modify the executables so that they can - # find editline/gmp. - postFixup = lib.optionalString (stdenv.isLinux && !(binDistUsed.isStatic or false)) - (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 ${lib.getLib gmpUsed}/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 - '') + 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 - isMachO $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 - '' - # Recache package db which needs to happen for Hadrian bindists - # where we modify the package db before installing - + '' - package_db=("$out"/lib/ghc-*/lib/package.conf.d) - "$out/bin/ghc-pkg" --package-db="$package_db" recache - ''; - - # In nixpkgs, musl based builds currently enable `pie` hardening by default - # (see `defaultHardeningFlags` in `make-derivation.nix`). - # But GHC cannot currently produce outputs that are ready for `-pie` linking. - # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear. - # See: - # * https://github.com/NixOS/nixpkgs/issues/129247 - # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580 - hardeningDisable = lib.optional stdenv.targetPlatform.isMusl "pie"; - - doInstallCheck = true; - installCheckPhase = '' - # 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 - env -i $out/bin/ghc --make main.hs || exit 1 - echo compilation ok - [ $(./main) == "yes" ] - ''; - - passthru = { - targetPrefix = ""; - enableShared = true; - - inherit llvmPackages; - - # Our Cabal compiler name - haskellCompilerName = "ghc-${version}"; - - # Normal GHC derivations expose the hadrian derivation used to build them - # here. In the case of bindists we just make sure that the attribute exists, - # as it is used for checking if a GHC derivation has been built with hadrian. - hadrian = null; - }; - - meta = rec { - homepage = "http://haskell.org/ghc"; - description = "Glasgow Haskell Compiler"; - license = lib.licenses.bsd3; - # HACK: since we can't encode the libc / abi in platforms, we need - # to make the platform list dependent on the evaluation platform - # in order to avoid eval errors with musl which supports less - # platforms than the default libcs (i. e. glibc / libSystem). - # This is done for the benefit of Hydra, so `packagePlatforms` - # won't return any platforms that would cause an evaluation - # failure for `pkgsMusl.haskell.compiler.ghc922Binary`, as - # long as the evaluator runs on a platform that supports - # `pkgsMusl`. - platforms = builtins.attrNames ghcBinDists.${distSetName}; - maintainers = lib.teams.haskell.members; - # packages involving hsc2hs (clock) produce libraries our - # ld can't link against - broken = stdenv.hostPlatform.isDarwin; - }; -} diff --git a/pkgs/development/compilers/ghc/9.6.3.nix b/pkgs/development/compilers/ghc/9.6.3.nix deleted file mode 100644 index 35bbf020acbf..000000000000 --- a/pkgs/development/compilers/ghc/9.6.3.nix +++ /dev/null @@ -1,4 +0,0 @@ -import ./common-hadrian.nix rec { - version = "9.6.3"; - sha256 = "1xbpxchmvm9gswrwwz1rsvx9kjaxhc2q3fx9l6wa0l5599xydkfz"; -} diff --git a/pkgs/development/compilers/ghc/9.6.4.nix b/pkgs/development/compilers/ghc/9.6.4.nix deleted file mode 100644 index 40a2261180e2..000000000000 --- a/pkgs/development/compilers/ghc/9.6.4.nix +++ /dev/null @@ -1,4 +0,0 @@ -import ./common-hadrian.nix { - version = "9.6.4"; - sha256 = "10bf25b8b07174fdd9868b5c0c56c17c0ef1edcb6247b4b864be933651bfd4c0"; -} diff --git a/pkgs/development/compilers/ghc/9.6.5.nix b/pkgs/development/compilers/ghc/9.6.5.nix deleted file mode 100644 index 0f1ac5022f8b..000000000000 --- a/pkgs/development/compilers/ghc/9.6.5.nix +++ /dev/null @@ -1,4 +0,0 @@ -import ./common-hadrian.nix { - version = "9.6.5"; - sha256 = "87b389924f98c1a26c205122757338c8dab33ad1fcf670faa22622742432b93c"; -} diff --git a/pkgs/development/compilers/ghc/9.8.1.nix b/pkgs/development/compilers/ghc/9.8.1.nix deleted file mode 100644 index 7c8c476c5b1a..000000000000 --- a/pkgs/development/compilers/ghc/9.8.1.nix +++ /dev/null @@ -1,4 +0,0 @@ -import ./common-hadrian.nix rec { - version = "9.8.1"; - sha256 = "b2f8ed6b7f733797a92436f4ff6e088a520913149c9a9be90465b40ad1f20751"; -} diff --git a/pkgs/development/compilers/ghc/9.8.2.nix b/pkgs/development/compilers/ghc/9.8.2.nix deleted file mode 100644 index 0a7b109013bf..000000000000 --- a/pkgs/development/compilers/ghc/9.8.2.nix +++ /dev/null @@ -1,4 +0,0 @@ -import ./common-hadrian.nix rec { - version = "9.8.2"; - sha256 = "4vt6fddGEjfSLoNlqD7dnhp30uFdBF85RTloRah3gck="; -} diff --git a/pkgs/development/compilers/ghc/Cabal-3.12-paths-fix-cycle-aarch64-darwin.patch b/pkgs/development/compilers/ghc/Cabal-3.12-paths-fix-cycle-aarch64-darwin.patch deleted file mode 100644 index f094790088c2..000000000000 --- a/pkgs/development/compilers/ghc/Cabal-3.12-paths-fix-cycle-aarch64-darwin.patch +++ /dev/null @@ -1,596 +0,0 @@ -This patch is based on https://github.com/sternenseemann/cabal/compare/Cabal-v3.12.0.0..e836ef53c1f80bf99a70f9c4ee5976e9f3830215 -and has been postprocessed with `filterdiff --strip=1 --addoldprefix=a/libraries/Cabal/ --addnewprefix=b/libraries/Cabal/`. - -Reasoning and explanation of the patch can be found in the comment in the diff for PathsModule.hs below. - -diffCabal/src/Distribution/Simple/Build/PathsModule.hs b/Cabal/src/Distribution/Simple/Build/PathsModule.hs -index 892e5bd38..391f5b130 100644 ---- a/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule.hs -+++ b/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule.hs -@@ -51,6 +51,7 @@ generatePathsModule pkg_descr lbi clbi = - , Z.zIsWindows = isWindows - , Z.zIsI386 = buildArch == I386 - , Z.zIsX8664 = buildArch == X86_64 -+ , Z.zOr = (||) - , Z.zNot = not - , Z.zManglePkgName = showPkgName - , Z.zPrefix = show flat_prefix -@@ -60,8 +61,110 @@ generatePathsModule pkg_descr lbi clbi = - , Z.zDatadir = zDatadir - , Z.zLibexecdir = zLibexecdir - , Z.zSysconfdir = zSysconfdir -+ , -- Sadly we can't be cleverer about this – we can't have literals in the template -+ Z.zShouldEmitDataDir = shouldEmit "DataDir" -+ , Z.zShouldEmitLibDir = shouldEmit "LibDir" -+ , Z.zShouldEmitDynLibDir = shouldEmit "DynLibDir" -+ , Z.zShouldEmitLibexecDir = shouldEmit "LibexecDir" -+ , Z.zShouldEmitSysconfDir = shouldEmit "SysconfDir" -+ , Z.zWarning = zWarning -+ , Z.zShouldEmitWarning = zShouldEmitWarning - } - where -+ -- GHC's NCG backend for aarch64-darwin does not support link-time dead code -+ -- elimination to the extent that NCG does for other targets. Consequently, -+ -- we struggle with unnecessarily retained store path references due to the -+ -- use of `Paths_*` modules – even if `getLibDir` is not used, it'll end up -+ -- in the final library or executables we build. -+ -- -+ -- When using a different output for the executables and library, this -+ -- becomes more sinister: The library will contain a reference to the bin -+ -- output and itself due to `getLibDir` and `getBinDir`, but the executables -+ -- will do so, too. Either due to linking dynamically or because the library -+ -- is linked statically into the executable and retains those references. -+ -- Since Nix disallows cyclical references between two outputs, it becomes -+ -- impossible to use the `Paths_*` module and a separate `bin` output for -+ -- aarch64-darwin. -+ -- -+ -- The solution we have resorted to for now, is to trim the `Paths_*` module -+ -- dynamically depending on what references *could* be used without causing -+ -- a cyclical reference. That has the effect that any code that would not -+ -- cause a cyclical reference with dead code elimination will compile and -+ -- work for aarch64-darwin. If the code would use a `get*Dir` function that -+ -- has been omitted, this would indicate that the code would have caused a -+ -- cyclical reference anyways. -+ -- -+ -- The logic for this makes some pretty big assumptions about installation -+ -- prefixes that probably only hold fully in nixpkgs with -+ -- `haskellPackages.mkDerivation`. Simple uses outside nixpkgs that have -+ -- everything below the same prefix should continue to work as expected, -+ -- though. -+ -- -+ -- We assume the following: -+ -- -+ -- - flat_prefix is `$out`. -+ -- - flat_libdir etc. are always below `$out`. -+ -- -+ -- Since in the normal case due to static linking `$bin` and `$out` will -+ -- have the same references in libraries/executables, we need to either -+ -- prevent usage of `getBinDir` or `getLibDir` to break the cycle in case -+ -- `flat_bindir` is not below `$out`. We have decided to always allow usage -+ -- of `getBinDir`, so `getLibDir` gets dropped if a separate `bin` output is -+ -- used. This has the simple reason that `$out` which contains `flat_libdir` -+ -- tends to be quite big – we would like to have a `bin` output that doesn't -+ -- require keeping that around. -+ pathEmittable :: FilePath -> Bool -+ pathEmittable p -+ -- If the executable installation target is below `$out` the reference -+ -- cycle is within a single output (since libs are installed to `$out`) -+ -- and thus unproblematic. We can use any and all `get*Dir` functions. -+ | flat_prefix `isPrefixOf` flat_bindir = True -+ -- Otherwise, we need to disallow all `get*Dir` functions that would cause -+ -- a reference to `$out` which contains the libraries that would in turn -+ -- reference `$bin`. This always include `flat_libdir` and friends, but -+ -- can also include `flat_datadir` if no separate output for data files is -+ -- used. -+ | otherwise = not (flat_prefix `isPrefixOf` p) -+ -+ -- This list maps the "name" of the directory to whether we want to include -+ -- it in the `Paths_*` module or not. `shouldEmit` performs a lookup in this. -+ dirs :: [(String, Bool)] -+ dirs = -+ map -+ (\(name, path) -> (name, pathEmittable path)) -+ [ ("LibDir", flat_libdir) -+ , ("DynLibDir", flat_dynlibdir) -+ , ("DataDir", flat_datadir) -+ , ("LibexecDir", flat_libexecdir) -+ , ("SysconfDir", flat_sysconfdir) -+ ] -+ -+ shouldEmit :: String -> Bool -+ shouldEmit name = -+ case lookup name dirs of -+ Just b -> b -+ Nothing -> error "panic! BUG in Cabal Paths_ patch for aarch64-darwin, report this at https://github.com/nixos/nixpkgs/issues" -+ -+ -- This is a comma separated list of all functions that have been emitted. -+ -- This is included in a GHC warning which will be attached to the `Paths_*` -+ -- module in case we are dropping any `get*Dir` functions that would -+ -- normally exist. -+ -- -+ -- TODO: getDataFileName is not accounted for at the moment. -+ omittedFunctions :: String -+ omittedFunctions = -+ intercalate ", " $ -+ map (("get" ++) . fst) $ -+ filter (not . snd) dirs -+ -+ zWarning :: String -+ zWarning = -+ show $ -+ "The following functions have been omitted by a nixpkgs-specific patch to Cabal: " -+ ++ omittedFunctions -+ zShouldEmitWarning :: Bool -+ zShouldEmitWarning = any (not . snd) dirs -+ - supports_cpp = supports_language_pragma - supports_rebindable_syntax = ghc_newer_than (mkVersion [7, 0, 1]) - supports_language_pragma = ghc_newer_than (mkVersion [6, 6, 1]) -diffCabal/src/Distribution/Simple/Build/PathsModule/Z.hs b/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs -index 25c924720..a8278675e 100644 ---- a/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs -+++ b/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs -@@ -19,6 +19,14 @@ data Z - zDatadir :: FilePath, - zLibexecdir :: FilePath, - zSysconfdir :: FilePath, -+ zShouldEmitLibDir :: Bool, -+ zShouldEmitDynLibDir :: Bool, -+ zShouldEmitLibexecDir :: Bool, -+ zShouldEmitDataDir :: Bool, -+ zShouldEmitSysconfDir :: Bool, -+ zShouldEmitWarning :: Bool, -+ zWarning :: String, -+ zOr :: (Bool -> Bool -> Bool), - zNot :: (Bool -> Bool), - zManglePkgName :: (PackageName -> String)} - deriving Generic -@@ -54,10 +62,51 @@ render z_root = execWriter $ do - tell "{-# OPTIONS_GHC -w #-}\n" - tell "module Paths_" - tell (zManglePkgName z_root (zPackageName z_root)) -- tell " (\n" -+ tell "\n" -+ tell " " -+ if (zShouldEmitWarning z_root) -+ then do -+ tell "{-# WARNING " -+ tell (zWarning z_root) -+ tell " #-}" -+ return () -+ else do -+ return () -+ tell "\n" -+ tell " (\n" - tell " version,\n" -- tell " getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,\n" -- tell " getDataFileName, getSysconfDir\n" -+ tell " getBinDir,\n" -+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitLibDir z_root)) -+ then do -+ tell " getLibDir,\n" -+ return () -+ else do -+ return () -+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitDynLibDir z_root)) -+ then do -+ tell " getDynLibDir,\n" -+ return () -+ else do -+ return () -+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitLibexecDir z_root)) -+ then do -+ tell " getLibexecDir,\n" -+ return () -+ else do -+ return () -+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitDataDir z_root)) -+ then do -+ tell " getDataFileName,\n" -+ tell " getDataDir,\n" -+ return () -+ else do -+ return () -+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitSysconfDir z_root)) -+ then do -+ tell " getSysconfDir\n" -+ return () -+ else do -+ return () - tell " ) where\n" - tell "\n" - if (zNot z_root (zAbsolute z_root)) -@@ -106,12 +155,15 @@ render z_root = execWriter $ do - tell (zVersionDigits z_root) - tell " []\n" - tell "\n" -- tell "getDataFileName :: FilePath -> IO FilePath\n" -- tell "getDataFileName name = do\n" -- tell " dir <- getDataDir\n" -- tell " return (dir `joinFileName` name)\n" -- tell "\n" -- tell "getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n" -+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitDataDir z_root)) -+ then do -+ tell "getDataFileName :: FilePath -> IO FilePath\n" -+ tell "getDataFileName name = do\n" -+ tell " dir <- getDataDir\n" -+ tell " return (dir `joinFileName` name)\n" -+ return () -+ else do -+ return () - tell "\n" - let - z_var0_function_defs = do -@@ -139,6 +191,7 @@ render z_root = execWriter $ do - tell "\n" - if (zRelocatable z_root) - then do -+ tell "\n" - tell "\n" - tell "getPrefixDirReloc :: FilePath -> IO FilePath\n" - tell "getPrefixDirReloc dirRel = do\n" -@@ -148,31 +201,37 @@ render z_root = execWriter $ do - tell (zBindir z_root) - tell ") `joinFileName` dirRel)\n" - tell "\n" -+ tell "getBinDir :: IO FilePath\n" - tell "getBinDir = catchIO (getEnv \"" - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_bindir\") (\\_ -> getPrefixDirReloc $ " - tell (zBindir z_root) - tell ")\n" -+ tell "getLibDir :: IO FilePath\n" - tell "getLibDir = catchIO (getEnv \"" - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_libdir\") (\\_ -> getPrefixDirReloc $ " - tell (zLibdir z_root) - tell ")\n" -+ tell "getDynLibDir :: IO FilePath\n" - tell "getDynLibDir = catchIO (getEnv \"" - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_dynlibdir\") (\\_ -> getPrefixDirReloc $ " - tell (zDynlibdir z_root) - tell ")\n" -+ tell "getDataDir :: IO FilePath\n" - tell "getDataDir = catchIO (getEnv \"" - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_datadir\") (\\_ -> getPrefixDirReloc $ " - tell (zDatadir z_root) - tell ")\n" -+ tell "getLibexecDir :: IO FilePath\n" - tell "getLibexecDir = catchIO (getEnv \"" - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_libexecdir\") (\\_ -> getPrefixDirReloc $ " - tell (zLibexecdir z_root) - tell ")\n" -+ tell "getSysconfDir :: IO FilePath\n" - tell "getSysconfDir = catchIO (getEnv \"" - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_sysconfdir\") (\\_ -> getPrefixDirReloc $ " -@@ -186,72 +245,119 @@ render z_root = execWriter $ do - if (zAbsolute z_root) - then do - tell "\n" -- tell "bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath\n" -+ tell "bindir :: FilePath\n" - tell "bindir = " - tell (zBindir z_root) - tell "\n" -- tell "libdir = " -- tell (zLibdir z_root) -- tell "\n" -- tell "dynlibdir = " -- tell (zDynlibdir z_root) -+ tell "getBinDir :: IO FilePath\n" -+ tell "getBinDir = catchIO (getEnv \"" -+ tell (zManglePkgName z_root (zPackageName z_root)) -+ tell "_bindir\") (\\_ -> return bindir)\n" - tell "\n" -- tell "datadir = " -- tell (zDatadir z_root) -+ if (zShouldEmitLibDir z_root) -+ then do -+ tell "libdir :: FilePath\n" -+ tell "libdir = " -+ tell (zLibdir z_root) -+ tell "\n" -+ tell "getLibDir :: IO FilePath\n" -+ tell "getLibDir = catchIO (getEnv \"" -+ tell (zManglePkgName z_root (zPackageName z_root)) -+ tell "_libdir\") (\\_ -> return libdir)\n" -+ return () -+ else do -+ return () - tell "\n" -- tell "libexecdir = " -- tell (zLibexecdir z_root) -+ if (zShouldEmitDynLibDir z_root) -+ then do -+ tell "dynlibdir :: FilePath\n" -+ tell "dynlibdir = " -+ tell (zDynlibdir z_root) -+ tell "\n" -+ tell "getDynLibDir :: IO FilePath\n" -+ tell "getDynLibDir = catchIO (getEnv \"" -+ tell (zManglePkgName z_root (zPackageName z_root)) -+ tell "_dynlibdir\") (\\_ -> return dynlibdir)\n" -+ return () -+ else do -+ return () - tell "\n" -- tell "sysconfdir = " -- tell (zSysconfdir z_root) -+ if (zShouldEmitDataDir z_root) -+ then do -+ tell "datadir :: FilePath\n" -+ tell "datadir = " -+ tell (zDatadir z_root) -+ tell "\n" -+ tell "getDataDir :: IO FilePath\n" -+ tell "getDataDir = catchIO (getEnv \"" -+ tell (zManglePkgName z_root (zPackageName z_root)) -+ tell "_datadir\") (\\_ -> return datadir)\n" -+ return () -+ else do -+ return () - tell "\n" -+ if (zShouldEmitLibexecDir z_root) -+ then do -+ tell "libexecdir :: FilePath\n" -+ tell "libexecdir = " -+ tell (zLibexecdir z_root) -+ tell "\n" -+ tell "getLibexecDir :: IO FilePath\n" -+ tell "getLibexecDir = catchIO (getEnv \"" -+ tell (zManglePkgName z_root (zPackageName z_root)) -+ tell "_libexecdir\") (\\_ -> return libexecdir)\n" -+ return () -+ else do -+ return () - tell "\n" -- tell "getBinDir = catchIO (getEnv \"" -- tell (zManglePkgName z_root (zPackageName z_root)) -- tell "_bindir\") (\\_ -> return bindir)\n" -- tell "getLibDir = catchIO (getEnv \"" -- tell (zManglePkgName z_root (zPackageName z_root)) -- tell "_libdir\") (\\_ -> return libdir)\n" -- tell "getDynLibDir = catchIO (getEnv \"" -- tell (zManglePkgName z_root (zPackageName z_root)) -- tell "_dynlibdir\") (\\_ -> return dynlibdir)\n" -- tell "getDataDir = catchIO (getEnv \"" -- tell (zManglePkgName z_root (zPackageName z_root)) -- tell "_datadir\") (\\_ -> return datadir)\n" -- tell "getLibexecDir = catchIO (getEnv \"" -- tell (zManglePkgName z_root (zPackageName z_root)) -- tell "_libexecdir\") (\\_ -> return libexecdir)\n" -- tell "getSysconfDir = catchIO (getEnv \"" -- tell (zManglePkgName z_root (zPackageName z_root)) -- tell "_sysconfdir\") (\\_ -> return sysconfdir)\n" -+ if (zShouldEmitSysconfDir z_root) -+ then do -+ tell "sysconfdir :: FilePath\n" -+ tell "sysconfdir = " -+ tell (zSysconfdir z_root) -+ tell "\n" -+ tell "getSysconfDir :: IO FilePath\n" -+ tell "getSysconfDir = catchIO (getEnv \"" -+ tell (zManglePkgName z_root (zPackageName z_root)) -+ tell "_sysconfdir\") (\\_ -> return sysconfdir)\n" -+ return () -+ else do -+ return () - tell "\n" - return () - else do - if (zIsWindows z_root) - then do -+ tell "\n" - tell "\n" - tell "prefix :: FilePath\n" - tell "prefix = " - tell (zPrefix z_root) - tell "\n" - tell "\n" -+ tell "getBinDir :: IO FilePath\n" - tell "getBinDir = getPrefixDirRel $ " - tell (zBindir z_root) - tell "\n" -+ tell "getLibDir :: IO FilePath\n" - tell "getLibDir = " - tell (zLibdir z_root) - tell "\n" -+ tell "getDynLibDir :: IO FilePath\n" - tell "getDynLibDir = " - tell (zDynlibdir z_root) - tell "\n" -+ tell "getDataDir :: IO FilePath\n" - tell "getDataDir = catchIO (getEnv \"" - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_datadir\") (\\_ -> " - tell (zDatadir z_root) - tell ")\n" -+ tell "getLibexecDir :: IO FilePath\n" - tell "getLibexecDir = " - tell (zLibexecdir z_root) - tell "\n" -+ tell "getSysconfDir :: IO FilePath\n" - tell "getSysconfDir = " - tell (zSysconfdir z_root) - tell "\n" -diffcabal-dev-scripts/src/GenPathsModule.hs b/cabal-dev-scripts/src/GenPathsModule.hs -index 46ef779e2..e9f5e099f 100644 ---- a/libraries/Cabal/cabal-dev-scripts/src/GenPathsModule.hs -+++ b/libraries/Cabal/cabal-dev-scripts/src/GenPathsModule.hs -@@ -41,6 +41,16 @@ $(capture "decls" [d| - , zLibexecdir :: FilePath - , zSysconfdir :: FilePath - -+ , zShouldEmitLibDir :: Bool -+ , zShouldEmitDynLibDir :: Bool -+ , zShouldEmitLibexecDir :: Bool -+ , zShouldEmitDataDir :: Bool -+ , zShouldEmitSysconfDir :: Bool -+ -+ , zShouldEmitWarning :: Bool -+ , zWarning :: String -+ -+ , zOr :: Bool -> Bool -> Bool - , zNot :: Bool -> Bool - , zManglePkgName :: PackageName -> String - } -difftemplates/Paths_pkg.template.hs b/templates/Paths_pkg.template.hs -index 8e1e03d27..cc5c86701 100644 ---- a/libraries/Cabal/templates/Paths_pkg.template.hs -+++ b/libraries/Cabal/templates/Paths_pkg.template.hs -@@ -14,10 +14,31 @@ - {% endif %} - {-# OPTIONS_GHC -fno-warn-missing-import-lists #-} - {-# OPTIONS_GHC -w #-} --module Paths_{{ manglePkgName packageName }} ( -+module Paths_{{ manglePkgName packageName }} -+ {% if shouldEmitWarning %}{-# WARNING {{ warning }} #-}{% endif %} -+ ( - version, -- getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, -- getDataFileName, getSysconfDir -+ getBinDir, -+{# We only care about the absolute case for our emit logic, since only in this -+ case references are incurred. We are not going to hit isWindows and relocatable -+ has no absolute references to begin with. -+#} -+{% if or (not absolute) shouldEmitLibDir %} -+ getLibDir, -+{% endif %} -+{% if or (not absolute) shouldEmitDynLibDir %} -+ getDynLibDir, -+{% endif %} -+{% if or (not absolute) shouldEmitLibexecDir %} -+ getLibexecDir, -+{% endif %} -+{% if or (not absolute) shouldEmitDataDir %} -+ getDataFileName, -+ getDataDir, -+{% endif %} -+{% if or (not absolute) shouldEmitSysconfDir %} -+ getSysconfDir -+{% endif %} - ) where - - {% if not absolute %} -@@ -56,12 +77,12 @@ catchIO = Exception.catch - version :: Version - version = Version {{ versionDigits }} [] - -+{% if or (not absolute) shouldEmitDataDir %} - getDataFileName :: FilePath -> IO FilePath - getDataFileName name = do - dir <- getDataDir - return (dir `joinFileName` name) -- --getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath -+{% endif %} - - {% defblock function_defs %} - minusFileName :: FilePath -> String -> FilePath -@@ -90,48 +111,93 @@ splitFileName p = (reverse (path2++drive), reverse fname) - - {% if relocatable %} - -+{# Relocatable can not incur any absolute references, so we can ignore it. -+ Additionally, --enable-relocatable is virtually useless in Nix builds -+#} -+ - getPrefixDirReloc :: FilePath -> IO FilePath - getPrefixDirReloc dirRel = do - exePath <- getExecutablePath - let (dir,_) = splitFileName exePath - return ((dir `minusFileName` {{ bindir }}) `joinFileName` dirRel) - -+getBinDir :: IO FilePath - getBinDir = catchIO (getEnv "{{ manglePkgName packageName }}_bindir") (\_ -> getPrefixDirReloc $ {{ bindir }}) -+getLibDir :: IO FilePath - getLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_libdir") (\_ -> getPrefixDirReloc $ {{ libdir }}) -+getDynLibDir :: IO FilePath - getDynLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_dynlibdir") (\_ -> getPrefixDirReloc $ {{ dynlibdir }}) -+getDataDir :: IO FilePath - getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> getPrefixDirReloc $ {{ datadir }}) -+getLibexecDir :: IO FilePath - getLibexecDir = catchIO (getEnv "{{ manglePkgName packageName }}_libexecdir") (\_ -> getPrefixDirReloc $ {{ libexecdir }}) -+getSysconfDir :: IO FilePath - getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\_ -> getPrefixDirReloc $ {{ sysconfdir }}) - - {% useblock function_defs %} - - {% elif absolute %} - --bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath -+bindir :: FilePath - bindir = {{ bindir }} --libdir = {{ libdir }} --dynlibdir = {{ dynlibdir }} --datadir = {{ datadir }} --libexecdir = {{ libexecdir }} --sysconfdir = {{ sysconfdir }} -- -+getBinDir :: IO FilePath - getBinDir = catchIO (getEnv "{{ manglePkgName packageName }}_bindir") (\_ -> return bindir) -+ -+{% if shouldEmitLibDir %} -+libdir :: FilePath -+libdir = {{ libdir }} -+getLibDir :: IO FilePath - getLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_libdir") (\_ -> return libdir) -+{% endif %} -+ -+{% if shouldEmitDynLibDir %} -+dynlibdir :: FilePath -+dynlibdir = {{ dynlibdir }} -+getDynLibDir :: IO FilePath - getDynLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_dynlibdir") (\_ -> return dynlibdir) -+{% endif %} -+ -+{% if shouldEmitDataDir %} -+datadir :: FilePath -+datadir = {{ datadir }} -+getDataDir :: IO FilePath - getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> return datadir) -+{% endif %} -+ -+{% if shouldEmitLibexecDir %} -+libexecdir :: FilePath -+libexecdir = {{ libexecdir }} -+getLibexecDir :: IO FilePath - getLibexecDir = catchIO (getEnv "{{ manglePkgName packageName }}_libexecdir") (\_ -> return libexecdir) -+{% endif %} -+ -+{% if shouldEmitSysconfDir %} -+sysconfdir :: FilePath -+sysconfdir = {{ sysconfdir }} -+getSysconfDir :: IO FilePath - getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\_ -> return sysconfdir) -+{% endif %} - - {% elif isWindows %} - -+{# We are only trying to fix the problem for aarch64-darwin with this patch, -+ so let's ignore Windows which we can reach via pkgsCross, for example. -+#} -+ - prefix :: FilePath - prefix = {{ prefix }} - -+getBinDir :: IO FilePath - getBinDir = getPrefixDirRel $ {{ bindir }} -+getLibDir :: IO FilePath - getLibDir = {{ libdir }} -+getDynLibDir :: IO FilePath - getDynLibDir = {{ dynlibdir }} -+getDataDir :: IO FilePath - getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> {{ datadir }}) -+getLibexecDir :: IO FilePath - getLibexecDir = {{ libexecdir }} -+getSysconfDir :: IO FilePath - getSysconfDir = {{ sysconfdir }} - - getPrefixDirRel :: FilePath -> IO FilePath diff --git a/pkgs/development/compilers/ghc/Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch b/pkgs/development/compilers/ghc/Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch deleted file mode 100644 index 19adcf5388bb..000000000000 --- a/pkgs/development/compilers/ghc/Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch +++ /dev/null @@ -1,99 +0,0 @@ -diff --git a/Cabal/Distribution/Simple/Build/PathsModule.hs b/Cabal/Distribution/Simple/Build/PathsModule.hs -index 5e660e8d6..1ae603c94 100644 ---- a/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs -+++ b/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs -@@ -37,6 +37,9 @@ import System.FilePath ( pathSeparator ) - -- * Building Paths_<pkg>.hs - -- ------------------------------------------------------------ - -+splitPath :: FilePath -> [ String ] -+splitPath = unintersperse pathSeparator -+ - generatePathsModule :: PackageDescription -> LocalBuildInfo -> ComponentLocalBuildInfo -> String - generatePathsModule pkg_descr lbi clbi = - let pragmas = -@@ -78,12 +81,44 @@ generatePathsModule pkg_descr lbi clbi = - "import System.Environment (getExecutablePath)\n" - | otherwise = "" - -+ dirs = [ (flat_libdir, "LibDir") -+ , (flat_dynlibdir, "DynLibDir") -+ , (flat_datadir, "DataDir") -+ , (flat_libexecdir, "LibexecDir") -+ , (flat_sysconfdir, "SysconfDir") ]; -+ -+ shouldEmitPath p -+ | (splitPath flat_prefix) `isPrefixOf` (splitPath flat_bindir) = True -+ | (splitPath flat_prefix) `isPrefixOf` (splitPath p) = False -+ | otherwise = True -+ -+ shouldEmitDataDir = shouldEmitPath flat_datadir -+ -+ nixEmitPathFn (path, name) = let -+ varName = toLower <$> name -+ fnName = "get"++name -+ in if shouldEmitPath path then -+ varName ++ " :: FilePath\n"++ -+ varName ++ " = " ++ show path ++ -+ "\n" ++ fnName ++ " :: IO FilePath" ++ -+ "\n" ++ fnName ++ " = " ++ mkGetEnvOr varName ("return " ++ varName)++"\n" -+ else "" -+ -+ absBody = intercalate "\n" $ nixEmitPathFn <$> dirs -+ -+ warnPragma = case filter (not . shouldEmitPath . fst) dirs of -+ [] -> "" -+ omittedDirs -> "{-# WARNING \"The functions: "++omittedFns++" Have been omitted by the Nix build system.\" #-}" -+ where omittedFns = intercalate ", " $ map snd omittedDirs -+ -+ importList = intercalate ", " $ ("get" ++) . snd <$> filter (shouldEmitPath . fst) dirs -+ - header = - pragmas++ -- "module " ++ prettyShow paths_modulename ++ " (\n"++ -- " version,\n"++ -- " getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,\n"++ -- " getDataFileName, getSysconfDir\n"++ -+ "module " ++ prettyShow paths_modulename ++ " " ++ warnPragma ++ " (\n"++ -+ " version, getBinDir,\n"++ -+ (if shouldEmitDataDir then " getDataFileName, \n" else "\n")++ -+ " " ++ importList ++"\n"++ - " ) where\n"++ - "\n"++ - foreign_imports++ -@@ -136,26 +171,18 @@ generatePathsModule pkg_descr lbi clbi = - "\n"++ - filename_stuff - | absolute = -- "\nbindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath\n"++ -+ "\nbindir :: FilePath\n"++ - "\nbindir = " ++ show flat_bindir ++ -- "\nlibdir = " ++ show flat_libdir ++ -- "\ndynlibdir = " ++ show flat_dynlibdir ++ -- "\ndatadir = " ++ show flat_datadir ++ -- "\nlibexecdir = " ++ show flat_libexecdir ++ -- "\nsysconfdir = " ++ show flat_sysconfdir ++ - "\n"++ -- "\ngetBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n"++ -+ "\ngetBinDir :: IO FilePath\n"++ - "getBinDir = "++mkGetEnvOr "bindir" "return bindir"++"\n"++ -- "getLibDir = "++mkGetEnvOr "libdir" "return libdir"++"\n"++ -- "getDynLibDir = "++mkGetEnvOr "dynlibdir" "return dynlibdir"++"\n"++ -- "getDataDir = "++mkGetEnvOr "datadir" "return datadir"++"\n"++ -- "getLibexecDir = "++mkGetEnvOr "libexecdir" "return libexecdir"++"\n"++ -- "getSysconfDir = "++mkGetEnvOr "sysconfdir" "return sysconfdir"++"\n"++ -- "\n"++ -- "getDataFileName :: FilePath -> IO FilePath\n"++ -- "getDataFileName name = do\n"++ -- " dir <- getDataDir\n"++ -- " return (dir ++ "++path_sep++" ++ name)\n" -+ absBody ++ "\n"++ -+ (if shouldEmitDataDir then -+ "getDataFileName :: FilePath -> IO FilePath\n"++ -+ "getDataFileName name = do\n"++ -+ " dir <- getDataDir\n"++ -+ " return (dir ++ "++path_sep++" ++ name)\n" -+ else "\n") - | otherwise = - "\nprefix, bindirrel :: FilePath" ++ - "\nprefix = " ++ show flat_prefix ++ diff --git a/pkgs/development/compilers/ghc/Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch b/pkgs/development/compilers/ghc/Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch deleted file mode 100644 index 1f7a79cc6885..000000000000 --- a/pkgs/development/compilers/ghc/Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch +++ /dev/null @@ -1,602 +0,0 @@ -This patch is based on https://github.com/sternenseemann/cabal/compare/982646d67b95b32813b89ab5d2d2f4d4dc03fb2b..7c49047f253e1f128e2df356400ec5da6f11066b -and has been postprocessed with `filterdiff --strip=1 --addoldprefix=a/libraries/Cabal/ --addnewprefix=b/libraries/Cabal/`. -Note that the base for the diff is not the Cabal 3.6.3.0 release tag, but -982646d67b95b32813b89ab5d2d2f4d4dc03fb2b which is obtained by applying -https://github.com/haskell/cabal/commit/6c796218c92f93c95e94d5ec2d077f6956f68e98 -on top of said release tag. That patch is applied to all our GHCs in the 9.2 series. - -Reasoning and explanation of the patch can be found in the comment in the diff for PathsModule.hs below. - -diffCabal/src/Distribution/Simple/Build/PathsModule.hs b/Cabal/src/Distribution/Simple/Build/PathsModule.hs -index b2be7e1a8..9b63e9850 100644 ---- a/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule.hs -+++ b/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule.hs -@@ -46,6 +46,7 @@ generatePathsModule pkg_descr lbi clbi = Z.render Z.Z - , Z.zIsWindows = isWindows - , Z.zIsI386 = buildArch == I386 - , Z.zIsX8664 = buildArch == X86_64 -+ , Z.zOr = (||) - , Z.zNot = not - , Z.zManglePkgName = showPkgName - -@@ -56,8 +57,112 @@ generatePathsModule pkg_descr lbi clbi = Z.render Z.Z - , Z.zDatadir = zDatadir - , Z.zLibexecdir = zLibexecdir - , Z.zSysconfdir = zSysconfdir -+ -+ -- Sadly we can't be cleverer about this – we can't have literals in the template -+ , Z.zShouldEmitDataDir = shouldEmit "DataDir" -+ , Z.zShouldEmitLibDir = shouldEmit "LibDir" -+ , Z.zShouldEmitDynLibDir = shouldEmit "DynLibDir" -+ , Z.zShouldEmitLibexecDir = shouldEmit "LibexecDir" -+ , Z.zShouldEmitSysconfDir = shouldEmit "SysconfDir" -+ -+ , Z.zWarning = zWarning -+ , Z.zShouldEmitWarning = zShouldEmitWarning - } - where -+ -- GHC's NCG backend for aarch64-darwin does not support link-time dead code -+ -- elimination to the extent that NCG does for other targets. Consequently, -+ -- we struggle with unnecessarily retained store path references due to the -+ -- use of `Paths_*` modules – even if `getLibDir` is not used, it'll end up -+ -- in the final library or executables we build. -+ -- -+ -- When using a different output for the executables and library, this -+ -- becomes more sinister: The library will contain a reference to the bin -+ -- output and itself due to `getLibDir` and `getBinDir`, but the executables -+ -- will do so, too. Either due to linking dynamically or because the library -+ -- is linked statically into the executable and retains those references. -+ -- Since Nix disallows cyclical references between two outputs, it becomes -+ -- impossible to use the `Paths_*` module and a separate `bin` output for -+ -- aarch64-darwin. -+ -- -+ -- The solution we have resorted to for now, is to trim the `Paths_*` module -+ -- dynamically depending on what references *could* be used without causing -+ -- a cyclical reference. That has the effect that any code that would not -+ -- cause a cyclical reference with dead code elimination will compile and -+ -- work for aarch64-darwin. If the code would use a `get*Dir` function that -+ -- has been omitted, this would indicate that the code would have caused a -+ -- cyclical reference anyways. -+ -- -+ -- The logic for this makes some pretty big assumptions about installation -+ -- prefixes that probably only hold fully in nixpkgs with -+ -- `haskellPackages.mkDerivation`. Simple uses outside nixpkgs that have -+ -- everything below the same prefix should continue to work as expected, -+ -- though. -+ -- -+ -- We assume the following: -+ -- -+ -- - flat_prefix is `$out`. -+ -- - flat_libdir etc. are always below `$out`. -+ -- -+ -- Since in the normal case due to static linking `$bin` and `$out` will -+ -- have the same references in libraries/executables, we need to either -+ -- prevent usage of `getBinDir` or `getLibDir` to break the cycle in case -+ -- `flat_bindir` is not below `$out`. We have decided to always allow usage -+ -- of `getBinDir`, so `getLibDir` gets dropped if a separate `bin` output is -+ -- used. This has the simple reason that `$out` which contains `flat_libdir` -+ -- tends to be quite big – we would like to have a `bin` output that doesn't -+ -- require keeping that around. -+ pathEmittable :: FilePath -> Bool -+ pathEmittable p -+ -- If the executable installation target is below `$out` the reference -+ -- cycle is within a single output (since libs are installed to `$out`) -+ -- and thus unproblematic. We can use any and all `get*Dir` functions. -+ | flat_prefix `isPrefixOf` flat_bindir = True -+ -- Otherwise, we need to disallow all `get*Dir` functions that would cause -+ -- a reference to `$out` which contains the libraries that would in turn -+ -- reference `$bin`. This always include `flat_libdir` and friends, but -+ -- can also include `flat_datadir` if no separate output for data files is -+ -- used. -+ | otherwise = not (flat_prefix `isPrefixOf` p) -+ -+ -- This list maps the "name" of the directory to whether we want to include -+ -- it in the `Paths_*` module or not. `shouldEmit` performs a lookup in this. -+ dirs :: [(String, Bool)] -+ dirs = -+ map -+ (\(name, path) -> (name, pathEmittable path)) -+ [ ("LibDir", flat_libdir) -+ , ("DynLibDir", flat_dynlibdir) -+ , ("DataDir", flat_datadir) -+ , ("LibexecDir", flat_libexecdir) -+ , ("SysconfDir", flat_sysconfdir) -+ ] -+ -+ shouldEmit :: String -> Bool -+ shouldEmit name = -+ case lookup name dirs of -+ Just b -> b -+ Nothing -> error "panic! BUG in Cabal Paths_ patch for aarch64-darwin, report this at https://github.com/nixos/nixpkgs/issues" -+ -+ -- This is a comma separated list of all functions that have been omitted. -+ -- This is included in a GHC warning which will be attached to the `Paths_*` -+ -- module in case we are dropping any `get*Dir` functions that would -+ -- normally exist. -+ -- -+ -- TODO: getDataFileName is not accounted for at the moment. -+ omittedFunctions :: String -+ omittedFunctions = -+ intercalate ", " -+ $ map (("get" ++) . fst) -+ $ filter (not . snd) dirs -+ -+ zWarning :: String -+ zWarning = -+ show $ -+ "The following functions have been omitted by a nixpkgs-specific patch to Cabal: " -+ ++ omittedFunctions -+ zShouldEmitWarning :: Bool -+ zShouldEmitWarning = any (not . snd) dirs -+ - supports_cpp = supports_language_pragma - supports_rebindable_syntax = ghc_newer_than (mkVersion [7,0,1]) - supports_language_pragma = ghc_newer_than (mkVersion [6,6,1]) -diffCabal/src/Distribution/Simple/Build/PathsModule/Z.hs b/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs -index 6488ea061..a6cdc8e31 100644 ---- a/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs -+++ b/libraries/Cabal/Cabal/src/Distribution/Simple/Build/PathsModule/Z.hs -@@ -18,6 +18,14 @@ data Z - zDatadir :: FilePath, - zLibexecdir :: FilePath, - zSysconfdir :: FilePath, -+ zShouldEmitLibDir :: Bool, -+ zShouldEmitDynLibDir :: Bool, -+ zShouldEmitLibexecDir :: Bool, -+ zShouldEmitDataDir :: Bool, -+ zShouldEmitSysconfDir :: Bool, -+ zShouldEmitWarning :: Bool, -+ zWarning :: String, -+ zOr :: (Bool -> Bool -> Bool), - zNot :: (Bool -> Bool), - zManglePkgName :: (PackageName -> String)} - deriving Generic -@@ -45,10 +53,51 @@ render z_root = execWriter $ do - tell "{-# OPTIONS_GHC -w #-}\n" - tell "module Paths_" - tell (zManglePkgName z_root (zPackageName z_root)) -- tell " (\n" -+ tell "\n" -+ tell " " -+ if (zShouldEmitWarning z_root) -+ then do -+ tell "{-# WARNING " -+ tell (zWarning z_root) -+ tell " #-}" -+ return () -+ else do -+ return () -+ tell "\n" -+ tell " (\n" - tell " version,\n" -- tell " getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,\n" -- tell " getDataFileName, getSysconfDir\n" -+ tell " getBinDir,\n" -+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitLibDir z_root)) -+ then do -+ tell " getLibDir,\n" -+ return () -+ else do -+ return () -+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitDynLibDir z_root)) -+ then do -+ tell " getDynLibDir,\n" -+ return () -+ else do -+ return () -+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitLibexecDir z_root)) -+ then do -+ tell " getLibexecDir,\n" -+ return () -+ else do -+ return () -+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitDataDir z_root)) -+ then do -+ tell " getDataFileName,\n" -+ tell " getDataDir,\n" -+ return () -+ else do -+ return () -+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitSysconfDir z_root)) -+ then do -+ tell " getSysconfDir\n" -+ return () -+ else do -+ return () - tell " ) where\n" - tell "\n" - if (zNot z_root (zAbsolute z_root)) -@@ -97,12 +146,15 @@ render z_root = execWriter $ do - tell (zVersionDigits z_root) - tell " []\n" - tell "\n" -- tell "getDataFileName :: FilePath -> IO FilePath\n" -- tell "getDataFileName name = do\n" -- tell " dir <- getDataDir\n" -- tell " return (dir `joinFileName` name)\n" -- tell "\n" -- tell "getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n" -+ if (zOr z_root (zNot z_root (zAbsolute z_root)) (zShouldEmitDataDir z_root)) -+ then do -+ tell "getDataFileName :: FilePath -> IO FilePath\n" -+ tell "getDataFileName name = do\n" -+ tell " dir <- getDataDir\n" -+ tell " return (dir `joinFileName` name)\n" -+ return () -+ else do -+ return () - tell "\n" - let - z_var0_function_defs = do -@@ -130,6 +182,7 @@ render z_root = execWriter $ do - tell "\n" - if (zRelocatable z_root) - then do -+ tell "\n" - tell "\n" - tell "getPrefixDirReloc :: FilePath -> IO FilePath\n" - tell "getPrefixDirReloc dirRel = do\n" -@@ -139,31 +192,37 @@ render z_root = execWriter $ do - tell (zBindir z_root) - tell ") `joinFileName` dirRel)\n" - tell "\n" -+ tell "getBinDir :: IO FilePath\n" - tell "getBinDir = catchIO (getEnv \"" - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_bindir\") (\\_ -> getPrefixDirReloc $ " - tell (zBindir z_root) - tell ")\n" -+ tell "getLibDir :: IO FilePath\n" - tell "getLibDir = catchIO (getEnv \"" - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_libdir\") (\\_ -> getPrefixDirReloc $ " - tell (zLibdir z_root) - tell ")\n" -+ tell "getDynLibDir :: IO FilePath\n" - tell "getDynLibDir = catchIO (getEnv \"" - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_dynlibdir\") (\\_ -> getPrefixDirReloc $ " - tell (zDynlibdir z_root) - tell ")\n" -+ tell "getDataDir :: IO FilePath\n" - tell "getDataDir = catchIO (getEnv \"" - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_datadir\") (\\_ -> getPrefixDirReloc $ " - tell (zDatadir z_root) - tell ")\n" -+ tell "getLibexecDir :: IO FilePath\n" - tell "getLibexecDir = catchIO (getEnv \"" - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_libexecdir\") (\\_ -> getPrefixDirReloc $ " - tell (zLibexecdir z_root) - tell ")\n" -+ tell "getSysconfDir :: IO FilePath\n" - tell "getSysconfDir = catchIO (getEnv \"" - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_sysconfdir\") (\\_ -> getPrefixDirReloc $ " -@@ -177,72 +236,119 @@ render z_root = execWriter $ do - if (zAbsolute z_root) - then do - tell "\n" -- tell "bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath\n" -+ tell "bindir :: FilePath\n" - tell "bindir = " - tell (zBindir z_root) - tell "\n" -- tell "libdir = " -- tell (zLibdir z_root) -- tell "\n" -- tell "dynlibdir = " -- tell (zDynlibdir z_root) -+ tell "getBinDir :: IO FilePath\n" -+ tell "getBinDir = catchIO (getEnv \"" -+ tell (zManglePkgName z_root (zPackageName z_root)) -+ tell "_bindir\") (\\_ -> return bindir)\n" - tell "\n" -- tell "datadir = " -- tell (zDatadir z_root) -+ if (zShouldEmitLibDir z_root) -+ then do -+ tell "libdir :: FilePath\n" -+ tell "libdir = " -+ tell (zLibdir z_root) -+ tell "\n" -+ tell "getLibDir :: IO FilePath\n" -+ tell "getLibDir = catchIO (getEnv \"" -+ tell (zManglePkgName z_root (zPackageName z_root)) -+ tell "_libdir\") (\\_ -> return libdir)\n" -+ return () -+ else do -+ return () - tell "\n" -- tell "libexecdir = " -- tell (zLibexecdir z_root) -+ if (zShouldEmitDynLibDir z_root) -+ then do -+ tell "dynlibdir :: FilePath\n" -+ tell "dynlibdir = " -+ tell (zDynlibdir z_root) -+ tell "\n" -+ tell "getDynLibDir :: IO FilePath\n" -+ tell "getDynLibDir = catchIO (getEnv \"" -+ tell (zManglePkgName z_root (zPackageName z_root)) -+ tell "_dynlibdir\") (\\_ -> return dynlibdir)\n" -+ return () -+ else do -+ return () - tell "\n" -- tell "sysconfdir = " -- tell (zSysconfdir z_root) -+ if (zShouldEmitDataDir z_root) -+ then do -+ tell "datadir :: FilePath\n" -+ tell "datadir = " -+ tell (zDatadir z_root) -+ tell "\n" -+ tell "getDataDir :: IO FilePath\n" -+ tell "getDataDir = catchIO (getEnv \"" -+ tell (zManglePkgName z_root (zPackageName z_root)) -+ tell "_datadir\") (\\_ -> return datadir)\n" -+ return () -+ else do -+ return () - tell "\n" -+ if (zShouldEmitLibexecDir z_root) -+ then do -+ tell "libexecdir :: FilePath\n" -+ tell "libexecdir = " -+ tell (zLibexecdir z_root) -+ tell "\n" -+ tell "getLibexecDir :: IO FilePath\n" -+ tell "getLibexecDir = catchIO (getEnv \"" -+ tell (zManglePkgName z_root (zPackageName z_root)) -+ tell "_libexecdir\") (\\_ -> return libexecdir)\n" -+ return () -+ else do -+ return () - tell "\n" -- tell "getBinDir = catchIO (getEnv \"" -- tell (zManglePkgName z_root (zPackageName z_root)) -- tell "_bindir\") (\\_ -> return bindir)\n" -- tell "getLibDir = catchIO (getEnv \"" -- tell (zManglePkgName z_root (zPackageName z_root)) -- tell "_libdir\") (\\_ -> return libdir)\n" -- tell "getDynLibDir = catchIO (getEnv \"" -- tell (zManglePkgName z_root (zPackageName z_root)) -- tell "_dynlibdir\") (\\_ -> return dynlibdir)\n" -- tell "getDataDir = catchIO (getEnv \"" -- tell (zManglePkgName z_root (zPackageName z_root)) -- tell "_datadir\") (\\_ -> return datadir)\n" -- tell "getLibexecDir = catchIO (getEnv \"" -- tell (zManglePkgName z_root (zPackageName z_root)) -- tell "_libexecdir\") (\\_ -> return libexecdir)\n" -- tell "getSysconfDir = catchIO (getEnv \"" -- tell (zManglePkgName z_root (zPackageName z_root)) -- tell "_sysconfdir\") (\\_ -> return sysconfdir)\n" -+ if (zShouldEmitSysconfDir z_root) -+ then do -+ tell "sysconfdir :: FilePath\n" -+ tell "sysconfdir = " -+ tell (zSysconfdir z_root) -+ tell "\n" -+ tell "getSysconfDir :: IO FilePath\n" -+ tell "getSysconfDir = catchIO (getEnv \"" -+ tell (zManglePkgName z_root (zPackageName z_root)) -+ tell "_sysconfdir\") (\\_ -> return sysconfdir)\n" -+ return () -+ else do -+ return () - tell "\n" - return () - else do - if (zIsWindows z_root) - then do -+ tell "\n" - tell "\n" - tell "prefix :: FilePath\n" - tell "prefix = " - tell (zPrefix z_root) - tell "\n" - tell "\n" -+ tell "getBinDir :: IO FilePath\n" - tell "getBinDir = getPrefixDirRel $ " - tell (zBindir z_root) - tell "\n" -+ tell "getLibDir :: IO FilePath\n" - tell "getLibDir = " - tell (zLibdir z_root) - tell "\n" -+ tell "getDynLibDir :: IO FilePath\n" - tell "getDynLibDir = " - tell (zDynlibdir z_root) - tell "\n" -+ tell "getDataDir :: IO FilePath\n" - tell "getDataDir = catchIO (getEnv \"" - tell (zManglePkgName z_root (zPackageName z_root)) - tell "_datadir\") (\\_ -> " - tell (zDatadir z_root) - tell ")\n" -+ tell "getLibexecDir :: IO FilePath\n" - tell "getLibexecDir = " - tell (zLibexecdir z_root) - tell "\n" -+ tell "getSysconfDir :: IO FilePath\n" - tell "getSysconfDir = " - tell (zSysconfdir z_root) - tell "\n" -diffcabal-dev-scripts/src/GenPathsModule.hs b/cabal-dev-scripts/src/GenPathsModule.hs -index e4b930635..9b978f284 100644 ---- a/libraries/Cabal/cabal-dev-scripts/src/GenPathsModule.hs -+++ b/libraries/Cabal/cabal-dev-scripts/src/GenPathsModule.hs -@@ -41,6 +41,16 @@ $(capture "decls" [d| - , zLibexecdir :: FilePath - , zSysconfdir :: FilePath - -+ , zShouldEmitLibDir :: Bool -+ , zShouldEmitDynLibDir :: Bool -+ , zShouldEmitLibexecDir :: Bool -+ , zShouldEmitDataDir :: Bool -+ , zShouldEmitSysconfDir :: Bool -+ -+ , zShouldEmitWarning :: Bool -+ , zWarning :: String -+ -+ , zOr :: Bool -> Bool -> Bool - , zNot :: Bool -> Bool - , zManglePkgName :: PackageName -> String - } -difftemplates/Paths_pkg.template.hs b/templates/Paths_pkg.template.hs -index 6bc6b7875..aa90a9382 100644 ---- a/libraries/Cabal/templates/Paths_pkg.template.hs -+++ b/libraries/Cabal/templates/Paths_pkg.template.hs -@@ -9,10 +9,31 @@ - {% endif %} - {-# OPTIONS_GHC -fno-warn-missing-import-lists #-} - {-# OPTIONS_GHC -w #-} --module Paths_{{ manglePkgName packageName }} ( -+module Paths_{{ manglePkgName packageName }} -+ {% if shouldEmitWarning %}{-# WARNING {{ warning }} #-}{% endif %} -+ ( - version, -- getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, -- getDataFileName, getSysconfDir -+ getBinDir, -+{# We only care about the absolute case for our emit logic, since only in this -+ case references are incurred. We are not going to hit isWindows and relocatable -+ has no absolute references to begin with. -+#} -+{% if or (not absolute) shouldEmitLibDir %} -+ getLibDir, -+{% endif %} -+{% if or (not absolute) shouldEmitDynLibDir %} -+ getDynLibDir, -+{% endif %} -+{% if or (not absolute) shouldEmitLibexecDir %} -+ getLibexecDir, -+{% endif %} -+{% if or (not absolute) shouldEmitDataDir %} -+ getDataFileName, -+ getDataDir, -+{% endif %} -+{% if or (not absolute) shouldEmitSysconfDir %} -+ getSysconfDir -+{% endif %} - ) where - - {% if not absolute %} -@@ -51,12 +72,12 @@ catchIO = Exception.catch - version :: Version - version = Version {{ versionDigits }} [] - -+{% if or (not absolute) shouldEmitDataDir %} - getDataFileName :: FilePath -> IO FilePath - getDataFileName name = do - dir <- getDataDir - return (dir `joinFileName` name) -- --getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath -+{% endif %} - - {% defblock function_defs %} - minusFileName :: FilePath -> String -> FilePath -@@ -85,48 +106,93 @@ splitFileName p = (reverse (path2++drive), reverse fname) - - {% if relocatable %} - -+{# Relocatable can not incur any absolute references, so we can ignore it. -+ Additionally, --enable-relocatable is virtually useless in Nix builds -+#} -+ - getPrefixDirReloc :: FilePath -> IO FilePath - getPrefixDirReloc dirRel = do - exePath <- getExecutablePath - let (dir,_) = splitFileName exePath - return ((dir `minusFileName` {{ bindir }}) `joinFileName` dirRel) - -+getBinDir :: IO FilePath - getBinDir = catchIO (getEnv "{{ manglePkgName packageName }}_bindir") (\_ -> getPrefixDirReloc $ {{ bindir }}) -+getLibDir :: IO FilePath - getLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_libdir") (\_ -> getPrefixDirReloc $ {{ libdir }}) -+getDynLibDir :: IO FilePath - getDynLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_dynlibdir") (\_ -> getPrefixDirReloc $ {{ dynlibdir }}) -+getDataDir :: IO FilePath - getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> getPrefixDirReloc $ {{ datadir }}) -+getLibexecDir :: IO FilePath - getLibexecDir = catchIO (getEnv "{{ manglePkgName packageName }}_libexecdir") (\_ -> getPrefixDirReloc $ {{ libexecdir }}) -+getSysconfDir :: IO FilePath - getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\_ -> getPrefixDirReloc $ {{ sysconfdir }}) - - {% useblock function_defs %} - - {% elif absolute %} - --bindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath -+bindir :: FilePath - bindir = {{ bindir }} --libdir = {{ libdir }} --dynlibdir = {{ dynlibdir }} --datadir = {{ datadir }} --libexecdir = {{ libexecdir }} --sysconfdir = {{ sysconfdir }} -- -+getBinDir :: IO FilePath - getBinDir = catchIO (getEnv "{{ manglePkgName packageName }}_bindir") (\_ -> return bindir) -+ -+{% if shouldEmitLibDir %} -+libdir :: FilePath -+libdir = {{ libdir }} -+getLibDir :: IO FilePath - getLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_libdir") (\_ -> return libdir) -+{% endif %} -+ -+{% if shouldEmitDynLibDir %} -+dynlibdir :: FilePath -+dynlibdir = {{ dynlibdir }} -+getDynLibDir :: IO FilePath - getDynLibDir = catchIO (getEnv "{{ manglePkgName packageName }}_dynlibdir") (\_ -> return dynlibdir) -+{% endif %} -+ -+{% if shouldEmitDataDir %} -+datadir :: FilePath -+datadir = {{ datadir }} -+getDataDir :: IO FilePath - getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> return datadir) -+{% endif %} -+ -+{% if shouldEmitLibexecDir %} -+libexecdir :: FilePath -+libexecdir = {{ libexecdir }} -+getLibexecDir :: IO FilePath - getLibexecDir = catchIO (getEnv "{{ manglePkgName packageName }}_libexecdir") (\_ -> return libexecdir) -+{% endif %} -+ -+{% if shouldEmitSysconfDir %} -+sysconfdir :: FilePath -+sysconfdir = {{ sysconfdir }} -+getSysconfDir :: IO FilePath - getSysconfDir = catchIO (getEnv "{{ manglePkgName packageName }}_sysconfdir") (\_ -> return sysconfdir) -+{% endif %} - - {% elif isWindows %} - -+{# We are only trying to fix the problem for aarch64-darwin with this patch, -+ so let's ignore Windows which we can reach via pkgsCross, for example. -+#} -+ - prefix :: FilePath - prefix = {{ prefix }} - -+getBinDir :: IO FilePath - getBinDir = getPrefixDirRel $ {{ bindir }} -+getLibDir :: IO FilePath - getLibDir = {{ libdir }} -+getDynLibDir :: IO FilePath - getDynLibDir = {{ dynlibdir }} -+getDataDir :: IO FilePath - getDataDir = catchIO (getEnv "{{ manglePkgName packageName }}_datadir") (\_ -> {{ datadir }}) -+getLibexecDir :: IO FilePath - getLibexecDir = {{ libexecdir }} -+getSysconfDir :: IO FilePath - getSysconfDir = {{ sysconfdir }} - - getPrefixDirRel :: FilePath -> IO FilePath diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix deleted file mode 100644 index b5fef30332f7..000000000000 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ /dev/null @@ -1,593 +0,0 @@ -{ version -, rev ? null -, sha256 -, url ? - if rev != null - then "https://gitlab.haskell.org/ghc/ghc.git" - else "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz" -, postFetch ? null -}: - -{ lib -, stdenv -, pkgsBuildTarget -, pkgsHostTarget -, targetPackages -, fetchpatch - -# build-tools -, bootPkgs -, autoconf -, automake -, coreutils -, fetchurl -, fetchgit -, perl -, python3 -, m4 -, sphinx -, xattr -, autoSignDarwinBinariesHook -, bash -, srcOnly - -, libiconv ? null, ncurses -, glibcLocales ? null - -, # GHC can be built with system libffi or a bundled one. - libffi ? null - -, useLLVM ? !(stdenv.targetPlatform.isx86 - || stdenv.targetPlatform.isPower - || stdenv.targetPlatform.isSparc - || stdenv.targetPlatform.isAarch64 - || stdenv.targetPlatform.isGhcjs) -, # LLVM is conceptually a run-time-only dependency, but for - # non-x86, we need LLVM to bootstrap later stages, so it becomes a - # build-time dependency too. - buildTargetLlvmPackages -, 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 ? !(lib.meta.availableOn stdenv.hostPlatform gmp - && lib.meta.availableOn stdenv.targetPlatform gmp) - || stdenv.targetPlatform.isGhcjs -, gmp - -, # If enabled, use -fPIC when compiling static libs. - enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform - -, enableProfiledLibs ? true - -, # Whether to build dynamic libs for the standard library (on the target - # platform). Static libs are always built. - enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic && !isGhcjs - -, # Whether to build terminfo. - enableTerminfo ? !(stdenv.targetPlatform.isWindows - || stdenv.targetPlatform.isGhcjs) - -, # Libdw.c only supports x86_64, i686 and s390x as of 2022-08-04 - enableDwarf ? (stdenv.targetPlatform.isx86 || - (stdenv.targetPlatform.isS390 && stdenv.targetPlatform.is64bit)) && - lib.meta.availableOn stdenv.hostPlatform elfutils && - lib.meta.availableOn stdenv.targetPlatform elfutils && - # HACK: elfutils is marked as broken on static platforms - # which availableOn can't tell. - !stdenv.targetPlatform.isStatic && - !stdenv.hostPlatform.isStatic -, elfutils - -, # What flavour to build. Flavour string may contain a flavour and flavour - # transformers as accepted by hadrian. - ghcFlavour ? - let - # TODO(@sternenseemann): does using the static flavour make sense? - baseFlavour = "release"; - # Note: in case hadrian's flavour transformers cease being expressive - # enough for us, we'll need to resort to defining a "nixpkgs" flavour - # in hadrianUserSettings and using that instead. - transformers = - lib.optionals useLLVM [ "llvm" ] - ++ lib.optionals (!enableShared) [ - "no_dynamic_libs" - "no_dynamic_ghc" - ] - ++ lib.optionals (!enableProfiledLibs) [ "no_profiled_libs" ] - # While split sections are now enabled by default in ghc 8.8 for windows, - # they seem to lead to `too many sections` errors when building base for - # profiling. - ++ lib.optionals (!stdenv.targetPlatform.isWindows) [ "split_sections" ] - ; - in - baseFlavour + lib.concatMapStrings (t: "+${t}") transformers - -, # Contents of the UserSettings.hs file to use when compiling hadrian. - hadrianUserSettings ? '' - module UserSettings ( - userFlavours, userPackages, userDefaultFlavour, - verboseCommand, buildProgressColour, successColour, finalStage - ) where - - import Flavour.Type - import Expression - import {-# SOURCE #-} Settings.Default - - -- no way to set this via the command line - finalStage :: Stage - finalStage = ${ - # Always build the stage 2 compiler if possible. Note we can currently - # assume hostPlatform == buildPlatform. - # TODO(@sternenseemann): improve this condition when we can cross-compile GHC - if stdenv.hostPlatform.canExecute stdenv.targetPlatform - then "Stage2" # native compiler or “native” cross e.g. pkgsStatic - else "Stage1" # cross compiler - } - - userDefaultFlavour :: String - userDefaultFlavour = "release" - - userFlavours :: [Flavour] - userFlavours = [] - - -- Disable Colours - buildProgressColour :: BuildProgressColour - buildProgressColour = mkBuildProgressColour (Dull Reset) - successColour :: SuccessColour - successColour = mkSuccessColour (Dull Reset) - - -- taken from src/UserSettings.hs unchanged, need to be there - userPackages :: [Package] - userPackages = [] - verboseCommand :: Predicate - verboseCommand = do - verbosity <- expr getVerbosity - return $ verbosity >= Verbose - '' - -, ghcSrc ? - srcOnly { - name = "ghc-${version}"; # -source appended by srcOnly - src = - (if rev != null then fetchgit else fetchurl) ({ - inherit url sha256; - } // lib.optionalAttrs (rev != null) { - inherit rev; - } // lib.optionalAttrs (postFetch != null) { - inherit postFetch; - }); - - patches = - let - # Disable haddock generating pretty source listings to stay under 3GB on aarch64-linux - enableHyperlinkedSource = - lib.versionAtLeast version "9.8" || - !(stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux); - in - [ - # Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129 - (if lib.versionAtLeast version "9.8" - then ./docs-sphinx-7-ghc98.patch - else ./docs-sphinx-7.patch ) - ] - ++ lib.optionals (lib.versionAtLeast version "9.6" && lib.versionOlder version "9.8") [ - (fetchpatch { - name = "fix-fully_static.patch"; - url = "https://gitlab.haskell.org/ghc/ghc/-/commit/1bb24432ff77e11a0340a7d8586e151e15bba2a1.diff"; - hash = "sha256-MpvTmFFsNiPDoOp9BhZyWeapeibQ77zgEV+xzZ1UAXs="; - }) - ] - ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [ - # Prevent the paths module from emitting symbols that we don't use - # when building with separate outputs. - # - # These cause problems as they're not eliminated by GHC's dead code - # elimination on aarch64-darwin. (see - # https://github.com/NixOS/nixpkgs/issues/140774 for details). - (if lib.versionOlder version "9.10" - then ./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch - else ./Cabal-3.12-paths-fix-cycle-aarch64-darwin.patch) - ] - # Prevents passing --hyperlinked-source to haddock. This is a custom - # workaround as we wait for this to be configurable via userSettings or - # similar. https://gitlab.haskell.org/ghc/ghc/-/issues/23625 - ++ lib.optionals (!enableHyperlinkedSource) [ - # TODO(@sternenseemann): Doesn't apply for GHC >= 9.8 - ../../tools/haskell/hadrian/disable-hyperlinked-source.patch - ] - # Incorrect bounds on Cabal in hadrian - # https://gitlab.haskell.org/ghc/ghc/-/issues/24100 - ++ lib.optionals (lib.elem version [ "9.8.1" "9.8.2" ]) [ - ../../tools/haskell/hadrian/hadrian-9.8.1-allow-Cabal-3.10.patch - ]; - } - - # GHC's build system hadrian built from the GHC-to-build's source tree - # using our bootstrap GHC. -, hadrian ? import ../../tools/haskell/hadrian/make-hadrian.nix { inherit bootPkgs lib; } { - inherit ghcSrc; - ghcVersion = version; - userSettings = hadrianUserSettings; - } - -, # Whether to build sphinx documentation. - # TODO(@sternenseemann): Hadrian ignores the --docs flag if finalStage = Stage1 - enableDocs ? ( - # Docs disabled if we are building on musl because it's a large task to keep - # all `sphinx` dependencies building in this environment. - !stdenv.buildPlatform.isMusl - ) - -, # 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.isiOS -}: - -assert !enableNativeBignum -> gmp != null; - -let - inherit (stdenv) buildPlatform hostPlatform targetPlatform; - - inherit (bootPkgs) ghc; - - # TODO(@Ericson2314) Make unconditional - targetPrefix = lib.optionalString - (targetPlatform != hostPlatform) - "${targetPlatform.config}-"; - - hadrianSettings = - # -fexternal-dynamic-refs apparently (because it's not clear from the - # documentation) makes the GHC RTS able to load static libraries, which may - # be needed for TemplateHaskell. This solution was described in - # https://www.tweag.io/blog/2020-09-30-bazel-static-haskell - lib.optionals enableRelocatedStaticLibs [ - "*.*.ghc.*.opts += -fPIC -fexternal-dynamic-refs" - ] - ++ lib.optionals targetPlatform.useAndroidPrebuilt [ - "*.*.ghc.c.opts += -optc-std=gnu99" - ]; - - # Splicer will pull out correct variations - libDeps = platform: lib.optional enableTerminfo ncurses - ++ lib.optionals (!targetPlatform.isGhcjs) [libffi] - # Bindist configure script fails w/o elfutils in linker search path - # https://gitlab.haskell.org/ghc/ghc/-/issues/22081 - ++ lib.optional enableDwarf elfutils - ++ lib.optional (!enableNativeBignum) gmp - ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows && !targetPlatform.isGhcjs) libiconv; - - # TODO(@sternenseemann): is buildTarget LLVM unnecessary? - # GHC doesn't seem to have {LLC,OPT}_HOST - toolsForTarget = [ - (if targetPlatform.isGhcjs - then pkgsBuildTarget.emscripten - else pkgsBuildTarget.targetPackages.stdenv.cc) - ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; - - targetCC = builtins.head toolsForTarget; - - # toolPath calculates the absolute path to the name tool associated with a - # given `stdenv.cc` derivation, i.e. it picks the correct derivation to take - # the tool from (cc, cc.bintools, cc.bintools.bintools) and adds the correct - # subpath of the tool. - toolPath = name: cc: - let - tools = { - "cc" = cc; - "c++" = cc; - as = cc.bintools.bintools; - - ar = cc.bintools.bintools; - ranlib = cc.bintools.bintools; - nm = cc.bintools.bintools; - readelf = cc.bintools.bintools; - - ld = cc.bintools; - "ld.gold" = cc.bintools; - - otool = cc.bintools.bintools; - - # GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is - # part of the bintools wrapper (due to codesigning requirements), but not on - # x86_64-darwin. We decide based on target platform to have consistent tools - # across all GHC stages. - install_name_tool = - if stdenv.targetPlatform.isAarch64 - then cc.bintools - else cc.bintools.bintools; - # Same goes for strip. - strip = - # TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold" - if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin - then cc.bintools - else cc.bintools.bintools; - }.${name}; - in - "${tools}/bin/${tools.targetPrefix}${name}"; - - # Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues. - # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856 - # see #84670 and #49071 for more background. - useLdGold = targetPlatform.linker == "gold" || - (targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); - - # Makes debugging easier to see which variant is at play in `nix-store -q --tree`. - variantSuffix = lib.concatStrings [ - (lib.optionalString stdenv.hostPlatform.isMusl "-musl") - (lib.optionalString enableNativeBignum "-native-bignum") - ]; - -in - -# C compiler, bintools and LLVM are used at build time, but will also leak into -# the resulting GHC's settings file and used at runtime. This means that we are -# currently only able to build GHC if hostPlatform == buildPlatform. -assert !targetPlatform.isGhcjs -> targetCC == pkgsHostTarget.targetPackages.stdenv.cc; -assert buildTargetLlvmPackages.llvm == llvmPackages.llvm; -assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang; - -stdenv.mkDerivation ({ - pname = "${targetPrefix}ghc${variantSuffix}"; - inherit version; - - src = ghcSrc; - - enableParallelBuilding = true; - - postPatch = '' - patchShebangs --build . - ''; - - # GHC needs the locale configured during the Haddock phase. - LANG = "en_US.UTF-8"; - - # GHC is a bit confused on its cross terminology. - # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths - 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="${toolPath "cc" targetCC}" - export CXX="${toolPath "c++" targetCC}" - # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177 - export LD="${toolPath "ld${lib.optionalString useLdGold ".gold"}" targetCC}" - export AS="${toolPath "as" targetCC}" - export AR="${toolPath "ar" targetCC}" - export NM="${toolPath "nm" targetCC}" - export RANLIB="${toolPath "ranlib" targetCC}" - export READELF="${toolPath "readelf" targetCC}" - export STRIP="${toolPath "strip" targetCC}" - '' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") '' - export OTOOL="${toolPath "otool" targetCC}" - export INSTALL_NAME_TOOL="${toolPath "install_name_tool" targetCC}" - '' + lib.optionalString useLLVM '' - export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc" - export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt" - '' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) '' - # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm - export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang" - '' + - lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") '' - export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive" - '' + lib.optionalString (!stdenv.isDarwin) '' - export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" - '' + lib.optionalString stdenv.isDarwin '' - export NIX_LDFLAGS+=" -no_dtrace_dof" - - # GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7 - export XATTR=${lib.getBin xattr}/bin/xattr - '' - # If we are not using release tarballs, some files need to be generated using - # the boot script. - + lib.optionalString (rev != null) '' - echo ${version} > VERSION - echo ${rev} > GIT_COMMIT_ID - ./boot - '' - + 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 - '' + 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 - '' - # Need to make writable EM_CACHE for emscripten. The path in EM_CACHE must be absolute. - # https://gitlab.haskell.org/ghc/ghc/-/wikis/javascript-backend#configure-fails-with-sub-word-sized-atomic-operations-not-available - + lib.optionalString targetPlatform.isGhcjs '' - export EM_CACHE="$(realpath $(mktemp -d emcache.XXXXXXXXXX))" - cp -Lr ${targetCC /* == emscripten */}/share/emscripten/cache/* "$EM_CACHE/" - chmod u+rwX -R "$EM_CACHE" - '' - # Create bash array hadrianFlagsArray for use in buildPhase. Do it in - # preConfigure, so overrideAttrs can be used to modify it effectively. - # hadrianSettings are passed via the command line so they are more visible - # in the build log. - + '' - hadrianFlagsArray=( - "-j$NIX_BUILD_CORES" - ${lib.escapeShellArgs hadrianSettings} - ) - ''; - - ${if targetPlatform.isGhcjs then "configureScript" else null} = "emconfigure ./configure"; - # GHC currently ships an edited config.sub so ghcjs is accepted which we can not rollback - ${if targetPlatform.isGhcjs then "dontUpdateAutotoolsGnuConfigScripts" else null} = true; - - # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ 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" - ] ++ lib.optionals (libffi != null && !targetPlatform.isGhcjs) [ - "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" - ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ - "--with-gmp-includes=${targetPackages.gmp.dev}/include" - "--with-gmp-libraries=${targetPackages.gmp.out}/lib" - ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ - "--with-iconv-includes=${libiconv}/include" - "--with-iconv-libraries=${libiconv}/lib" - ] ++ lib.optionals (targetPlatform != hostPlatform) [ - "--enable-bootstrap-with-devel-snapshot" - ] ++ lib.optionals useLdGold [ - "CFLAGS=-fuse-ld=gold" - "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold" - "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" - ] ++ lib.optionals (disableLargeAddressSpace) [ - "--disable-large-address-space" - ] ++ lib.optionals enableDwarf [ - "--enable-dwarf-unwind" - "--with-libdw-includes=${lib.getDev targetPackages.elfutils}/include" - "--with-libdw-libraries=${lib.getLib targetPackages.elfutils}/lib" - ] ++ lib.optionals targetPlatform.isDarwin [ - # Darwin uses llvm-ar. GHC will try to use `-L` with `ar` when it is `llvm-ar` - # but it doesn’t currently work because Cabal never uses `-L` on Darwin. See: - # https://gitlab.haskell.org/ghc/ghc/-/issues/23188 - # https://github.com/haskell/cabal/issues/8882 - "fp_cv_prog_ar_supports_dash_l=no" - ]; - - # 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 ghc hadrian bootPkgs.alex bootPkgs.happy bootPkgs.hscolour - # autoconf and friends are necessary for hadrian to create the bindist - autoconf automake m4 - # Python is used in a few scripts invoked by hadrian to generate e.g. rts headers. - python3 - ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ - autoSignDarwinBinariesHook - ] ++ lib.optionals enableDocs [ - sphinx - ]; - - # For building runtime libs - depsBuildTarget = toolsForTarget; - - buildInputs = [ perl bash ] ++ (libDeps hostPlatform); - - depsTargetTarget = map lib.getDev (libDeps targetPlatform); - depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform); - - hadrianFlags = [ - "--flavour=${ghcFlavour}" - "--bignum=${if enableNativeBignum then "native" else "gmp"}" - "--docs=${if enableDocs then "no-sphinx-pdfs" else "no-sphinx"}" - ]; - - buildPhase = '' - runHook preBuild - - # hadrianFlagsArray is created in preConfigure - echo "hadrianFlags: $hadrianFlags ''${hadrianFlagsArray[@]}" - - # We need to go via the bindist for installing - hadrian $hadrianFlags "''${hadrianFlagsArray[@]}" binary-dist-dir - - runHook postBuild - ''; - - # required, because otherwise all symbols from HSffi.o are stripped, and - # that in turn causes GHCi to abort - stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; - - checkTarget = "test"; - - hardeningDisable = - [ "format" ] - # In nixpkgs, musl based builds currently enable `pie` hardening by default - # (see `defaultHardeningFlags` in `make-derivation.nix`). - # But GHC cannot currently produce outputs that are ready for `-pie` linking. - # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear. - # See: - # * https://github.com/NixOS/nixpkgs/issues/129247 - # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580 - ++ lib.optional stdenv.targetPlatform.isMusl "pie"; - - # big-parallel allows us to build with more than 2 cores on - # Hydra which already warrants a significant speedup - requiredSystemFeatures = [ "big-parallel" ]; - - outputs = [ "out" "doc" ]; - - # We need to configure the bindist *again* before installing - # https://gitlab.haskell.org/ghc/ghc/-/issues/22058 - # TODO(@sternenseemann): it would be nice if the bindist could be an intermediate - # derivation, but since it is > 2GB even on x86_64-linux, not a good idea? - preInstall = '' - pushd _build/bindist/* - - '' - # the bindist configure script uses different env variables than the GHC configure script - # see https://github.com/NixOS/nixpkgs/issues/267250 and https://gitlab.haskell.org/ghc/ghc/-/issues/24211 - + lib.optionalString (stdenv.targetPlatform.linker == "cctools") '' - export InstallNameToolCmd=$INSTALL_NAME_TOOL - export OtoolCmd=$OTOOL - '' - + '' - $configureScript $configureFlags "''${configureFlagsArray[@]}" - ''; - - postInstall = '' - # leave bindist directory - popd - - # Install the bash completion file. - install -Dm 644 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc - ''; - - passthru = { - inherit bootPkgs targetPrefix; - - inherit llvmPackages; - inherit enableShared; - - # Our Cabal compiler name - haskellCompilerName = "ghc-${version}"; - - # Expose hadrian used for bootstrapping, for debugging purposes - inherit hadrian; - - # TODO(@sternenseemann): there's no stage0:exe:haddock target by default, - # so haddock isn't available for GHC cross-compilers. Can we fix that? - hasHaddock = stdenv.hostPlatform == stdenv.targetPlatform; - }; - - meta = { - homepage = "http://haskell.org/ghc"; - description = "Glasgow Haskell Compiler"; - maintainers = with lib.maintainers; [ - guibou - ] ++ lib.teams.haskell.members; - timeout = 24 * 3600; - inherit (ghc.meta) license platforms; - }; - - dontStrip = targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm; -} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { - dontPatchELF = true; - noAuditTmpdir = true; -}) diff --git a/pkgs/development/compilers/ghc/common-make-native-bignum.nix b/pkgs/development/compilers/ghc/common-make-native-bignum.nix deleted file mode 100644 index 79fced444f56..000000000000 --- a/pkgs/development/compilers/ghc/common-make-native-bignum.nix +++ /dev/null @@ -1,460 +0,0 @@ -{ version -, sha256 -, url ? "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz" -}: - -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages - -# build-tools -, bootPkgs -, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx -, xattr, autoSignDarwinBinariesHook -, bash - -, libiconv ? null, ncurses -, glibcLocales ? null - -, # GHC can be built with system libffi or a bundled one. - libffi ? null - -, useLLVM ? !(stdenv.targetPlatform.isx86 - || stdenv.targetPlatform.isPower - || stdenv.targetPlatform.isSparc - || (lib.versionAtLeast version "9.2" && stdenv.targetPlatform.isAarch64)) -, # LLVM is conceptually a run-time-only dependency, but for - # non-x86, we need LLVM to bootstrap later stages, so it becomes a - # build-time dependency too. - buildTargetLlvmPackages, 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 ? !(lib.meta.availableOn stdenv.hostPlatform gmp - && lib.meta.availableOn stdenv.targetPlatform gmp) -, gmp - -, # If enabled, use -fPIC when compiling static libs. - enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform - -, enableProfiledLibs ? true - -, # Whether to build dynamic libs for the standard library (on the target - # platform). Static libs are always built. - enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic - -, # 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 ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform) - (if useLLVM then "perf-cross" else "perf-cross-ncg") - -, # Whether to build sphinx documentation. - enableDocs ? ( - # Docs disabled if we are building on musl because it's a large task to keep - # all `sphinx` dependencies building in this environment. - !stdenv.buildPlatform.isMusl - ) - -, enableHaddockProgram ? - # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) - -, # 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.isiOS -}: - -assert !enableNativeBignum -> gmp != null; - -# Cross cannot currently build the `haddock` program for silly reasons, -# see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; - -let - inherit (stdenv) buildPlatform hostPlatform targetPlatform; - - inherit (bootPkgs) ghc; - - # TODO(@Ericson2314) Make unconditional - targetPrefix = lib.optionalString - (targetPlatform != hostPlatform) - "${targetPlatform.config}-"; - - buildMK = '' - BuildFlavour = ${ghcFlavour} - ifneq \"\$(BuildFlavour)\" \"\" - include mk/flavours/\$(BuildFlavour).mk - endif - BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"} - BUILD_SPHINX_PDF = NO - '' + - # Note [HADDOCK_DOCS]: - # Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock` - # program is built (which we generally always want to have a complete GHC install) - # and whether it is run on the GHC sources to generate hyperlinked source code - # (which is impossible for cross-compilation); see: - # https://gitlab.haskell.org/ghc/ghc/-/issues/20077 - # This implies that currently a cross-compiled GHC will never have a `haddock` - # program, so it can never generate haddocks for any packages. - # If this is solved in the future, we'd like to unconditionally - # build the haddock program (removing the `enableHaddockProgram` option). - '' - HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"} - # Build haddocks for boot packages with hyperlinking - EXTRA_HADDOCK_OPTS += --hyperlinked-source --quickjump - - DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} - BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"} - '' + lib.optionalString (targetPlatform != hostPlatform) '' - Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"} - CrossCompilePrefix = ${targetPrefix} - '' + lib.optionalString (!enableProfiledLibs) '' - BUILD_PROF_LIBS = NO - '' + - # -fexternal-dynamic-refs apparently (because it's not clear from the documentation) - # makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell. - # This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell - lib.optionalString enableRelocatedStaticLibs '' - GhcLibHcOpts += -fPIC -fexternal-dynamic-refs - GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs - '' + lib.optionalString targetPlatform.useAndroidPrebuilt '' - EXTRA_CC_OPTS += -std=gnu99 - ''; - - # Splicer will pull out correct variations - libDeps = platform: lib.optional enableTerminfo ncurses - ++ [libffi] - ++ lib.optional (!enableNativeBignum) gmp - ++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; - - # TODO(@sternenseemann): is buildTarget LLVM unnecessary? - # GHC doesn't seem to have {LLC,OPT}_HOST - toolsForTarget = [ - pkgsBuildTarget.targetPackages.stdenv.cc - ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; - - targetCC = builtins.head toolsForTarget; - - # toolPath calculates the absolute path to the name tool associated with a - # given `stdenv.cc` derivation, i.e. it picks the correct derivation to take - # the tool from (cc, cc.bintools, cc.bintools.bintools) and adds the correct - # subpath of the tool. - toolPath = name: cc: - let - tools = { - "cc" = cc; - "c++" = cc; - as = cc.bintools.bintools; - - ar = cc.bintools.bintools; - ranlib = cc.bintools.bintools; - nm = cc.bintools.bintools; - readelf = cc.bintools.bintools; - - ld = cc.bintools; - "ld.gold" = cc.bintools; - - otool = cc.bintools.bintools; - - # GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is - # part of the bintools wrapper (due to codesigning requirements), but not on - # x86_64-darwin. We decide based on target platform to have consistent tools - # across all GHC stages. - install_name_tool = - if stdenv.targetPlatform.isAarch64 - then cc.bintools - else cc.bintools.bintools; - # Same goes for strip. - strip = - # TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold" - if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin - then cc.bintools - else cc.bintools.bintools; - }.${name}; - in - "${tools}/bin/${tools.targetPrefix}${name}"; - - # Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues. - # But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856 - # see #84670 and #49071 for more background. - useLdGold = targetPlatform.linker == "gold" || - (targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl); - - # Makes debugging easier to see which variant is at play in `nix-store -q --tree`. - variantSuffix = lib.concatStrings [ - (lib.optionalString stdenv.hostPlatform.isMusl "-musl") - (lib.optionalString enableNativeBignum "-native-bignum") - ]; - -in - -# C compiler, bintools and LLVM are used at build time, but will also leak into -# the resulting GHC's settings file and used at runtime. This means that we are -# currently only able to build GHC if hostPlatform == buildPlatform. -assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc; -assert buildTargetLlvmPackages.llvm == llvmPackages.llvm; -assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang; - -stdenv.mkDerivation (rec { - pname = "${targetPrefix}ghc${variantSuffix}"; - inherit version; - - src = fetchurl { - inherit url sha256; - }; - - enableParallelBuilding = true; - - outputs = [ "out" "doc" ]; - - patches = lib.optionals (lib.versionOlder version "9.4") [ - # fix hyperlinked haddock sources: https://github.com/haskell/haddock/pull/1482 - (fetchpatch { - url = "https://patch-diff.githubusercontent.com/raw/haskell/haddock/pull/1482.patch"; - sha256 = "sha256-8w8QUCsODaTvknCDGgTfFNZa8ZmvIKaKS+2ZJZ9foYk="; - extraPrefix = "utils/haddock/"; - stripLen = 1; - }) - ] - - ++ lib.optionals (lib.versionOlder version "9.4.6") [ - # Fix docs build with sphinx >= 6.0 - # https://gitlab.haskell.org/ghc/ghc/-/issues/22766 - (fetchpatch { - name = "ghc-docs-sphinx-6.0.patch"; - url = "https://gitlab.haskell.org/ghc/ghc/-/commit/10e94a556b4f90769b7fd718b9790d58ae566600.patch"; - sha256 = "0kmhfamr16w8gch0lgln2912r8aryjky1hfcda3jkcwa5cdzgjdv"; - }) - ] - - ++ [ - # Fix docs build with Sphinx >= 7 https://gitlab.haskell.org/ghc/ghc/-/issues/24129 - ./docs-sphinx-7.patch - ] - - ++ lib.optionals (lib.versionOlder version "9.2.2") [ - # Add flag that fixes C++ exception handling; opt-in. Merged in 9.4 and 9.2.2. - # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7423 - (fetchpatch { - name = "ghc-9.0.2-fcompact-unwind.patch"; - # Note that the test suite is not packaged. - url = "https://gitlab.haskell.org/ghc/ghc/-/commit/c6132c782d974a7701e7f6447bdcd2bf6db4299a.patch?merge_request_iid=7423"; - sha256 = "sha256-b4feGZIaKDj/UKjWTNY6/jH4s2iate0wAgMxG3rAbZI="; - }) - ] - - ++ lib.optionals (lib.versionAtLeast version "9.2") [ - # Don't generate code that doesn't compile when --enable-relocatable is passed to Setup.hs - # Can be removed if the Cabal library included with ghc backports the linked fix - (fetchpatch { - url = "https://github.com/haskell/cabal/commit/6c796218c92f93c95e94d5ec2d077f6956f68e98.patch"; - stripLen = 1; - extraPrefix = "libraries/Cabal/"; - sha256 = "sha256-yRQ6YmMiwBwiYseC5BsrEtDgFbWvst+maGgDtdD0vAY="; - }) - ] - - ++ lib.optionals (version == "9.4.6") [ - # Work around a type not being defined when including Rts.h in bytestring's cbits - # due to missing feature macros. See https://gitlab.haskell.org/ghc/ghc/-/issues/23810. - ./9.4.6-bytestring-posix-source.patch - ] - - ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [ - # Prevent the paths module from emitting symbols that we don't use - # when building with separate outputs. - # - # These cause problems as they're not eliminated by GHC's dead code - # elimination on aarch64-darwin. (see - # https://github.com/NixOS/nixpkgs/issues/140774 for details). - (if lib.versionAtLeast version "9.2" - then ./Cabal-at-least-3.6-paths-fix-cycle-aarch64-darwin.patch - else ./Cabal-3.2-3.4-paths-fix-cycle-aarch64-darwin.patch) - ]; - - postPatch = "patchShebangs ."; - - # GHC needs the locale configured during the Haddock phase. - LANG = "en_US.UTF-8"; - - # GHC is a bit confused on its cross terminology. - # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths - 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="${toolPath "cc" targetCC}" - export CXX="${toolPath "c++" targetCC}" - # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177 - export LD="${toolPath "ld${lib.optionalString useLdGold ".gold"}" targetCC}" - export AS="${toolPath "as" targetCC}" - export AR="${toolPath "ar" targetCC}" - export NM="${toolPath "nm" targetCC}" - export RANLIB="${toolPath "ranlib" targetCC}" - export READELF="${toolPath "readelf" targetCC}" - export STRIP="${toolPath "strip" targetCC}" - '' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") '' - export OTOOL="${toolPath "otool" targetCC}" - export INSTALL_NAME_TOOL="${toolPath "install_name_tool" targetCC}" - '' + lib.optionalString useLLVM '' - export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc" - export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt" - '' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) '' - # LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm - export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang" - '' - + '' - echo -n "${buildMK}" > mk/build.mk - '' - + lib.optionalString (lib.versionOlder version "9.2" || lib.versionAtLeast version "9.4") '' - sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure - '' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") '' - export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive" - '' + lib.optionalString (!stdenv.isDarwin) '' - export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" - '' + lib.optionalString stdenv.isDarwin '' - export NIX_LDFLAGS+=" -no_dtrace_dof" - '' + lib.optionalString (stdenv.isDarwin && lib.versionAtLeast version "9.2") '' - - # GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7 - export XATTR=${lib.getBin xattr}/bin/xattr - '' + 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 - '' + 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 - '' - # HACK: allow bootstrapping with GHC 8.10 which works fine, as we don't have - # binary 9.0 packaged. Bootstrapping with 9.2 is broken without hadrian. - + lib.optionalString (lib.versions.majorMinor version == "9.4") '' - substituteInPlace configure --replace \ - 'MinBootGhcVersion="9.0"' \ - 'MinBootGhcVersion="8.10"' - ''; - - # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ 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" - ] ++ lib.optionals (libffi != null) [ - "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" - ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ - "--with-gmp-includes=${targetPackages.gmp.dev}/include" - "--with-gmp-libraries=${targetPackages.gmp.out}/lib" - ] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ - "--with-iconv-includes=${libiconv}/include" - "--with-iconv-libraries=${libiconv}/lib" - ] ++ lib.optionals (targetPlatform != hostPlatform) [ - "--enable-bootstrap-with-devel-snapshot" - ] ++ lib.optionals useLdGold [ - "CFLAGS=-fuse-ld=gold" - "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold" - "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" - ] ++ 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 - ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour - ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ - autoSignDarwinBinariesHook - ] ++ lib.optionals enableDocs [ - sphinx - ] ++ lib.optionals (stdenv.isDarwin && lib.versions.majorMinor version == "9.0") [ - # TODO(@sternenseemann): backport addition of XATTR env var like - # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6447 - xattr - ]; - - # For building runtime libs - depsBuildTarget = toolsForTarget; - - buildInputs = [ perl bash ] ++ (libDeps hostPlatform); - - depsTargetTarget = map lib.getDev (libDeps targetPlatform); - depsTargetTargetPropagated = map (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" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; - - checkTarget = "test"; - - hardeningDisable = - [ "format" ] - # In nixpkgs, musl based builds currently enable `pie` hardening by default - # (see `defaultHardeningFlags` in `make-derivation.nix`). - # But GHC cannot currently produce outputs that are ready for `-pie` linking. - # Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear. - # See: - # * https://github.com/NixOS/nixpkgs/issues/129247 - # * https://gitlab.haskell.org/ghc/ghc/-/issues/19580 - ++ lib.optional stdenv.targetPlatform.isMusl "pie"; - - # big-parallel allows us to build with more than 2 cores on - # Hydra which already warrants a significant speedup - requiredSystemFeatures = [ "big-parallel" ]; - - postInstall = '' - # Install the bash completion file. - install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc - ''; - - passthru = { - inherit bootPkgs targetPrefix; - - inherit llvmPackages; - inherit enableShared; - - # This is used by the haskell builder to query - # the presence of the haddock program. - hasHaddock = enableHaddockProgram; - - # Our Cabal compiler name - haskellCompilerName = "ghc-${version}"; - }; - - meta = { - homepage = "http://haskell.org/ghc"; - description = "Glasgow Haskell Compiler"; - maintainers = with lib.maintainers; [ - guibou - ] ++ lib.teams.haskell.members; - timeout = 24 * 3600; - inherit (ghc.meta) license platforms; - }; - -} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { - dontStrip = true; - dontPatchELF = true; - noAuditTmpdir = true; -}) diff --git a/pkgs/development/compilers/ghc/docs-sphinx-7-ghc98.patch b/pkgs/development/compilers/ghc/docs-sphinx-7-ghc98.patch deleted file mode 100644 index 3fc1a0f21561..000000000000 --- a/pkgs/development/compilers/ghc/docs-sphinx-7-ghc98.patch +++ /dev/null @@ -1,8 +0,0 @@ -Fix build of docs after sphinx update. -https://github.com/sphinx-doc/sphinx/pull/11381 -https://gitlab.haskell.org/ghc/ghc/-/issues/24129 ---- a/docs/users_guide/rtd-theme/layout.html -+++ b/docs/users_guide/rtd-theme/layout.html -@@ -28 +28 @@ -- <link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" /> -+ <link rel="stylesheet" href="{{ pathto('_static/' + styles[-1], 1) }}" type="text/css" /> diff --git a/pkgs/development/compilers/ghc/docs-sphinx-7.patch b/pkgs/development/compilers/ghc/docs-sphinx-7.patch deleted file mode 100644 index 49fa45d1b9a2..000000000000 --- a/pkgs/development/compilers/ghc/docs-sphinx-7.patch +++ /dev/null @@ -1,8 +0,0 @@ -Fix build of docs after sphinx update. -https://github.com/sphinx-doc/sphinx/pull/11381 -https://gitlab.haskell.org/ghc/ghc/-/issues/24129 ---- a/docs/users_guide/rtd-theme/layout.html -+++ b/docs/users_guide/rtd-theme/layout.html -@@ -67 +67 @@ -- <link rel="stylesheet" href="{{ pathto('_static/' + style, 1) }}" type="text/css" /> -+ <link rel="stylesheet" href="{{ pathto('_static/' + styles[-1], 1) }}" type="text/css" /> diff --git a/pkgs/development/compilers/ghc/gcc-clang-wrapper.sh b/pkgs/development/compilers/ghc/gcc-clang-wrapper.sh deleted file mode 100755 index 45af982c2973..000000000000 --- a/pkgs/development/compilers/ghc/gcc-clang-wrapper.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!@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/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix deleted file mode 100644 index 73808dc431a9..000000000000 --- a/pkgs/development/compilers/ghc/head.nix +++ /dev/null @@ -1,11 +0,0 @@ -import ./common-hadrian.nix { - version = "9.11.20240410"; - rev = "1b1a92bd25c3f7249cf922c5dbf4415d2de44a36"; - sha256 = "sha256-2HdhxhVrKn8c/ZOGYoYThqXpod2OPiGXgH+mAV69Ip0="; - # The STM benchmark contains chanbench.hs and ChanBench.hs causing a hash - # mismatch on case insensitive filesystems. See also - # https://gitlab.haskell.org/ghc/packages/stm/-/issues/2 - postFetch = '' - rm -rf "$out/libraries/stm/bench" - ''; -} diff --git a/pkgs/development/compilers/ghc/respect-ar-path.patch b/pkgs/development/compilers/ghc/respect-ar-path.patch deleted file mode 100644 index a08a802c18a0..000000000000 --- a/pkgs/development/compilers/ghc/respect-ar-path.patch +++ /dev/null @@ -1,25 +0,0 @@ -diff -urd a/aclocal.m4 b/aclocal.m4 ---- a/aclocal.m4 -+++ b/aclocal.m4 -@@ -1199,7 +1199,8 @@ - # thinks that target == host so it never checks the unqualified - # tools for Windows. See #14274. - AC_DEFUN([FP_PROG_AR], --[if test -z "$fp_prog_ar"; then -+[AC_SUBST(fp_prog_ar,$AR) -+if test -z "$fp_prog_ar"; then - if test "$HostOS" = "mingw32" - then - AC_PATH_PROG([fp_prog_ar], [ar]) -diff -urd a/configure b/configure ---- a/configure -+++ b/configure -@@ -10744,6 +10744,8 @@ - test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' - - -+fp_prog_ar=$AR -+ - if test -z "$fp_prog_ar"; then - if test "$HostOS" = "mingw32" - then |