diff --git a/pkgs/development/compilers/ghc/8.10.7.nix b/pkgs/development/compilers/ghc/8.10.7.nix index 4a770d993a678..c2dcf2bad1966 100644 --- a/pkgs/development/compilers/ghc/8.10.7.nix +++ b/pkgs/development/compilers/ghc/8.10.7.nix @@ -1,8 +1,8 @@ -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs -, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx +, autoreconfHook, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx , xattr, autoSignDarwinBinariesHook , bash @@ -44,25 +44,35 @@ , # 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 + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && 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 + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + enableUnregisterised ? false }: assert !enableIntegerSimple -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; + +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; @@ -129,7 +139,9 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -161,14 +173,11 @@ let (lib.optionalString enableIntegerSimple "-integer-simple") ]; -in + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; -# 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; +in stdenv.mkDerivation (rec { version = "8.10.7"; @@ -223,6 +232,12 @@ stdenv.mkDerivation (rec { 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 { @@ -241,6 +256,9 @@ stdenv.mkDerivation (rec { postPatch = "patchShebangs ."; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -269,6 +287,9 @@ stdenv.mkDerivation (rec { # 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" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" echo -n "${buildMK}" > mk/build.mk sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure @@ -299,18 +320,22 @@ stdenv.mkDerivation (rec { done ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || 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" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" @@ -325,6 +350,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. @@ -334,7 +361,7 @@ stdenv.mkDerivation (rec { dontAddExtraLibs = true; nativeBuildInputs = [ - perl autoconf automake m4 python3 + perl autoreconfHook autoconf automake m4 python3 ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour ] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [ autoSignDarwinBinariesHook @@ -372,6 +399,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; @@ -397,7 +432,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.0.2.nix b/pkgs/development/compilers/ghc/9.0.2.nix index 175d1fe2450b7..4080798154a79 100644 --- a/pkgs/development/compilers/ghc/9.0.2.nix +++ b/pkgs/development/compilers/ghc/9.0.2.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -46,25 +46,35 @@ , # 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 + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && 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 + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + enableUnregisterised ? false }: assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; + +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; @@ -129,7 +139,9 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -161,14 +173,11 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; -in + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; -# 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; +in stdenv.mkDerivation (rec { version = "9.0.2"; @@ -224,6 +233,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -252,6 +264,9 @@ stdenv.mkDerivation (rec { # 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" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" echo -n "${buildMK}" > mk/build.mk sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure @@ -281,18 +296,22 @@ stdenv.mkDerivation (rec { done ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || 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" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" @@ -307,6 +326,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. @@ -358,6 +379,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; @@ -383,7 +412,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.2.5.nix b/pkgs/development/compilers/ghc/9.2.5.nix index 6c86e05ebbd4c..36ede2a27aa7c 100644 --- a/pkgs/development/compilers/ghc/9.2.5.nix +++ b/pkgs/development/compilers/ghc/9.2.5.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -46,25 +46,37 @@ , # 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 + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && 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 + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; + +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; @@ -129,7 +141,9 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -161,14 +175,11 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; -in + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; -# 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; +in stdenv.mkDerivation (rec { version = "9.2.5"; @@ -223,6 +234,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -251,6 +265,10 @@ stdenv.mkDerivation (rec { # 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" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" + echo -n "${buildMK}" > mk/build.mk '' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") '' export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive" @@ -281,18 +299,22 @@ stdenv.mkDerivation (rec { done ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || 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" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" @@ -307,6 +329,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. @@ -354,6 +378,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; @@ -379,7 +411,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.2.6.nix b/pkgs/development/compilers/ghc/9.2.6.nix index 6ff58f087f8a9..af3a231baf4ab 100644 --- a/pkgs/development/compilers/ghc/9.2.6.nix +++ b/pkgs/development/compilers/ghc/9.2.6.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -46,25 +46,37 @@ , # 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 + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && 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 + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; + +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; @@ -129,7 +141,9 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -161,14 +175,11 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; -in + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; -# 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; +in stdenv.mkDerivation (rec { version = "9.2.6"; @@ -223,6 +234,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -251,6 +265,10 @@ stdenv.mkDerivation (rec { # 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" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" + echo -n "${buildMK}" > mk/build.mk '' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") '' export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive" @@ -281,18 +299,22 @@ stdenv.mkDerivation (rec { done ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || 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" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" @@ -307,6 +329,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. @@ -354,6 +378,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; @@ -379,7 +411,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.2.7.nix b/pkgs/development/compilers/ghc/9.2.7.nix index f605bfda1981f..a9f8cc4bf680d 100644 --- a/pkgs/development/compilers/ghc/9.2.7.nix +++ b/pkgs/development/compilers/ghc/9.2.7.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -46,25 +46,37 @@ , # 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 + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && 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 + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; + +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; @@ -129,7 +141,9 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -161,14 +175,11 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; -in + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; -# 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; +in stdenv.mkDerivation (rec { version = "9.2.7"; @@ -223,6 +234,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -251,6 +265,10 @@ stdenv.mkDerivation (rec { # 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" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" + echo -n "${buildMK}" > mk/build.mk '' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") '' export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive" @@ -281,18 +299,22 @@ stdenv.mkDerivation (rec { done ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || 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" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" @@ -307,6 +329,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. @@ -354,6 +378,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; @@ -379,7 +411,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.2.8.nix b/pkgs/development/compilers/ghc/9.2.8.nix index 72cfdd242f424..c8ca7f5c1d603 100644 --- a/pkgs/development/compilers/ghc/9.2.8.nix +++ b/pkgs/development/compilers/ghc/9.2.8.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -46,25 +46,37 @@ , # 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 + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && 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 + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; + +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; @@ -129,7 +141,9 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -161,14 +175,11 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; -in + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; -# 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; +in stdenv.mkDerivation (rec { version = "9.2.8"; @@ -223,6 +234,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -251,6 +265,10 @@ stdenv.mkDerivation (rec { # 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" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" + echo -n "${buildMK}" > mk/build.mk '' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") '' export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive" @@ -281,18 +299,22 @@ stdenv.mkDerivation (rec { done ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || 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" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" @@ -307,6 +329,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. @@ -354,6 +378,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; @@ -379,7 +411,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.4.5.nix b/pkgs/development/compilers/ghc/9.4.5.nix index 298af6596e713..3060a91a85c91 100644 --- a/pkgs/development/compilers/ghc/9.4.5.nix +++ b/pkgs/development/compilers/ghc/9.4.5.nix @@ -1,6 +1,6 @@ # DO NOT port this expression to hadrian. It is not possible to build a GHC # cross compiler with 9.4.* and hadrian. -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -48,25 +48,37 @@ , # 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 + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && 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 + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; + +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; @@ -131,7 +143,9 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -163,14 +177,11 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; -in + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; -# 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; +in stdenv.mkDerivation (rec { version = "9.4.5"; @@ -220,6 +231,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -248,6 +262,9 @@ stdenv.mkDerivation (rec { # 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" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" echo -n "${buildMK}" > mk/build.mk @@ -288,18 +305,22 @@ stdenv.mkDerivation (rec { 'MinBootGhcVersion="8.10"' ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || 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" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" @@ -314,6 +335,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. @@ -361,6 +384,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; @@ -386,7 +417,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.4.6.nix b/pkgs/development/compilers/ghc/9.4.6.nix index 310787e477b24..82dcbbebf2141 100644 --- a/pkgs/development/compilers/ghc/9.4.6.nix +++ b/pkgs/development/compilers/ghc/9.4.6.nix @@ -1,6 +1,6 @@ # DO NOT port this expression to hadrian. It is not possible to build a GHC # cross compiler with 9.4.* and hadrian. -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -48,25 +48,37 @@ , # 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 + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && 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 + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; + +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; @@ -131,7 +143,9 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -163,14 +177,11 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; -in + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; -# 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; +in stdenv.mkDerivation (rec { version = "9.4.6"; @@ -216,6 +227,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -244,6 +258,9 @@ stdenv.mkDerivation (rec { # 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" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" echo -n "${buildMK}" > mk/build.mk @@ -284,18 +301,22 @@ stdenv.mkDerivation (rec { 'MinBootGhcVersion="8.10"' ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || 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" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" @@ -310,6 +331,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. @@ -357,6 +380,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; @@ -382,7 +413,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.4.7.nix b/pkgs/development/compilers/ghc/9.4.7.nix index e87f8fc3a9073..0ea5eca3ce9c6 100644 --- a/pkgs/development/compilers/ghc/9.4.7.nix +++ b/pkgs/development/compilers/ghc/9.4.7.nix @@ -1,6 +1,6 @@ # DO NOT port this expression to hadrian. It is not possible to build a GHC # cross compiler with 9.4.* and hadrian. -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -48,25 +48,37 @@ , # 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 + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && 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 + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; + +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; @@ -131,7 +143,9 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -163,14 +177,11 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; -in + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; -# 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; +in stdenv.mkDerivation (rec { version = "9.4.7"; @@ -212,6 +223,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -240,6 +254,9 @@ stdenv.mkDerivation (rec { # 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" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" echo -n "${buildMK}" > mk/build.mk @@ -280,18 +297,22 @@ stdenv.mkDerivation (rec { 'MinBootGhcVersion="8.10"' ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || 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" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" @@ -306,6 +327,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. @@ -353,6 +376,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; @@ -378,7 +409,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/9.4.8.nix b/pkgs/development/compilers/ghc/9.4.8.nix index 5ac2b60b1cd75..56f41620198e7 100644 --- a/pkgs/development/compilers/ghc/9.4.8.nix +++ b/pkgs/development/compilers/ghc/9.4.8.nix @@ -1,6 +1,6 @@ # DO NOT port this expression to hadrian. It is not possible to build a GHC # cross compiler with 9.4.* and hadrian. -{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages +{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, buildPackages, targetPackages # build-tools , bootPkgs @@ -48,25 +48,37 @@ , # 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 + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !stdenv.buildPlatform.isMusl ) , enableHaddockProgram ? # Disabled for cross; see note [HADDOCK_DOCS]. - (stdenv.targetPlatform == stdenv.hostPlatform) + (stdenv.buildPlatform == stdenv.hostPlatform && 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 + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + # Registerised RV64 compiler produces programs that segfault + # See https://gitlab.haskell.org/ghc/ghc/-/issues/23957 + enableUnregisterised ? stdenv.hostPlatform.isRiscV64 || stdenv.targetPlatform.isRiscV64 }: assert !enableNativeBignum -> gmp != null; # Cross cannot currently build the `haddock` program for silly reasons, # see note [HADDOCK_DOCS]. -assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; +assert (stdenv.buildPlatform != stdenv.hostPlatform || stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram; + +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; let inherit (stdenv) buildPlatform hostPlatform targetPlatform; @@ -131,7 +143,9 @@ let pkgsBuildTarget.targetPackages.stdenv.cc ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -163,14 +177,11 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; -in + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; -# 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; +in stdenv.mkDerivation (rec { version = "9.4.8"; @@ -212,6 +223,9 @@ stdenv.mkDerivation (rec { # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # GHC is a bit confused on its cross terminology. # TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths preConfigure = '' @@ -240,6 +254,9 @@ stdenv.mkDerivation (rec { # 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" '' + '' + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" echo -n "${buildMK}" > mk/build.mk @@ -280,18 +297,22 @@ stdenv.mkDerivation (rec { 'MinBootGhcVersion="8.10"' ''; + # Although it is usually correct to pass --host, we don't do that here because + # GHC's usage of build, host, and target is non-standard. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/cross-compiling # TODO(@Ericson2314): Always pass "--target" and always prefix. - configurePlatforms = [ "build" "host" ] - ++ lib.optional (targetPlatform != hostPlatform) "target"; + configurePlatforms = [ "build" ] + ++ lib.optional (buildPlatform != hostPlatform || 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" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.ncurses.out}/lib" ] ++ lib.optionals (libffi != null) [ "--with-system-libffi" - "--with-ffi-includes=${targetPackages.libffi.dev}/include" - "--with-ffi-libraries=${targetPackages.libffi.out}/lib" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" @@ -306,6 +327,8 @@ stdenv.mkDerivation (rec { "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" ] ++ lib.optionals (disableLargeAddressSpace) [ "--disable-large-address-space" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. @@ -353,6 +376,14 @@ stdenv.mkDerivation (rec { requiredSystemFeatures = [ "big-parallel" ]; postInstall = '' + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${passthru.haskellCompilerName}/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; @@ -378,7 +409,8 @@ stdenv.mkDerivation (rec { guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; }; } // lib.optionalAttrs targetPlatform.useAndroidPrebuilt { diff --git a/pkgs/development/compilers/ghc/common-hadrian.nix b/pkgs/development/compilers/ghc/common-hadrian.nix index 465db3a252964..c5eeb10017615 100644 --- a/pkgs/development/compilers/ghc/common-hadrian.nix +++ b/pkgs/development/compilers/ghc/common-hadrian.nix @@ -12,6 +12,7 @@ , stdenv , pkgsBuildTarget , pkgsHostTarget +, buildPackages , targetPackages # build-tools @@ -164,18 +165,31 @@ , # 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 + # Docs disabled if we are building on musl or cross-building because it's a + # large task to keep all `sphinx` dependencies building in this environment. + (stdenv.buildPlatform == stdenv.hostPlatform && stdenv.targetPlatform == stdenv.hostPlatform) + && !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 + +, # Whether to build an unregisterised version of GHC. + # GHC will normally auto-detect whether it can do a registered build, but this + # option will force it to do an unregistered build when set to true. + # See https://gitlab.haskell.org/ghc/ghc/-/wikis/building/unregisterised + enableUnregisterised ? false }: assert !enableNativeBignum -> gmp != null; +# GHC does not support building when all 3 platforms are different. +assert stdenv.buildPlatform == stdenv.hostPlatform || stdenv.hostPlatform == stdenv.targetPlatform; + +# It is currently impossible to cross-compile GHC with Hadrian. +assert stdenv.buildPlatform == stdenv.hostPlatform; + let inherit (stdenv) buildPlatform hostPlatform targetPlatform; @@ -215,7 +229,9 @@ let else pkgsBuildTarget.targetPackages.stdenv.cc) ] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm; + buildCC = buildPackages.stdenv.cc; targetCC = builtins.head toolsForTarget; + installCC = pkgsHostTarget.targetPackages.stdenv.cc; # Sometimes we have to dispatch between the bintools wrapper and the unwrapped # derivation for certain tools depending on the platform. @@ -247,6 +263,13 @@ let (lib.optionalString enableNativeBignum "-native-bignum") ]; + targetLibffi = if hostPlatform != targetPlatform + then targetPackages.libffi + else pkgsHostTarget.libffi; + + # Our Cabal compiler name + haskellCompilerName = "ghc-${version}"; + in # C compiler, bintools and LLVM are used at build time, but will also leak into @@ -286,12 +309,18 @@ stdenv.mkDerivation ({ # GHC needs the locale configured during the Haddock phase. LANG = "en_US.UTF-8"; + # GHC is unable to build a cross-compiler without this set. + "NIX_CC_WRAPPER_TARGET_HOST_${buildCC.suffixSalt}" = 1; + # 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 + export CC_STAGE0="${buildCC}/bin/${buildCC.targetPrefix}cc" + export LD_STAGE0="${buildCC.bintools}/bin/${buildCC.bintools.targetPrefix}ld" + export AR_STAGE0="${buildCC.bintools.bintools}/bin/${buildCC.bintools.targetPrefix}ar" # GHC is a bit confused on its cross terminology, as these would normally be # the *host* tools. export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" @@ -379,11 +408,12 @@ stdenv.mkDerivation ({ # `--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" + "--with-curses-includes=${buildPackages.ncurses.dev}/include" + "--with-curses-libraries=${buildPackages.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" + "--with-ffi-includes=${targetLibffi.dev}/include" + "--with-ffi-libraries=${targetLibffi.out}/lib" ] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [ "--with-gmp-includes=${targetPackages.gmp.dev}/include" "--with-gmp-libraries=${targetPackages.gmp.out}/lib" @@ -408,6 +438,8 @@ stdenv.mkDerivation ({ # https://gitlab.haskell.org/ghc/ghc/-/issues/23188 # https://github.com/haskell/cabal/issues/8882 "fp_cv_prog_ar_supports_dash_l=no" + ] ++ lib.optionals enableUnregisterised [ + "--enable-unregisterised" ]; # Make sure we never relax`$PATH` and hooks support for compatibility. @@ -499,19 +531,24 @@ stdenv.mkDerivation ({ # leave bindist directory popd + # Make the installed GHC use the host platform's tools. + sed -i $out/lib/${targetPrefix}${haskellCompilerName}/lib/settings \ + -e "s!$CC!${installCC}/bin/${installCC.targetPrefix}cc!g" \ + -e "s!$CXX!${installCC}/bin/${installCC.targetPrefix}c++!g" \ + -e "s!$LD!${installCC.bintools}/bin/${installCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}!g" \ + -e "s!$AR!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ar!g" \ + -e "s!$RANLIB!${installCC.bintools.bintools}/bin/${installCC.bintools.targetPrefix}ranlib!g" + # Install the bash completion file. install -Dm 644 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc ''; passthru = { - inherit bootPkgs targetPrefix; + inherit bootPkgs targetPrefix haskellCompilerName; inherit llvmPackages; inherit enableShared; - # Our Cabal compiler name - haskellCompilerName = "ghc-${version}"; - # Expose hadrian used for bootstrapping, for debugging purposes inherit hadrian; @@ -527,7 +564,8 @@ stdenv.mkDerivation ({ guibou ] ++ lib.teams.haskell.members; timeout = 24 * 3600; - inherit (ghc.meta) license platforms; + platforms = lib.platforms.all; + inherit (ghc.meta) license; # https://github.com/NixOS/nixpkgs/issues/208959 broken = (lib.versionAtLeast version "9.6" && lib.versionOlder version "9.8") diff --git a/pkgs/test/cross/default.nix b/pkgs/test/cross/default.nix index bd233db4cd50f..7f5a777794d5c 100644 --- a/pkgs/test/cross/default.nix +++ b/pkgs/test/cross/default.nix @@ -146,6 +146,8 @@ let pkgs.pkgsCross.mips64el-linux-gnuabi64.stdenv pkgs.pkgsCross.mips64el-linux-gnuabin32.stdenv pkgs.pkgsCross.mingwW64.stdenv + # Unlike later versions, cross-compiled 8.10.7 can reliably bootstrap a native build + pkgs.pkgsCross.riscv64.haskell.compiler.integer-simple.ghc8107 ] ++ lib.optionals (with pkgs.stdenv.buildPlatform; isx86_64 && isLinux) [ # Musl-to-glibc cross on the same architecture tends to turn up diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix index ddfd8146b53d0..5568cf80bed2d 100644 --- a/pkgs/top-level/haskell-packages.nix +++ b/pkgs/top-level/haskell-packages.nix @@ -1,4 +1,4 @@ -{ buildPackages, pkgsBuildTarget, pkgs, newScope, stdenv }: +{ buildPackages, pkgsBuildBuild, pkgsBuildTarget, pkgs, newScope, stdenv }: let # These are attributes in compiler that support integer-simple. @@ -52,7 +52,8 @@ in { package-list = callPackage ../development/haskell-modules/package-list.nix {}; - compiler = { + # Always get boot compilers from `pkgsBuildBuild` + compiler = let bb = pkgsBuildBuild.haskell; in { ghc865Binary = callPackage ../development/compilers/ghc/8.6.5-binary.nix { # Should be llvmPackages_6 which has been removed from nixpkgs llvmPackages = null; @@ -73,11 +74,11 @@ in { ghc8107 = callPackage ../development/compilers/ghc/8.10.7.nix { bootPkgs = # the oldest ghc with aarch64-darwin support is 8.10.5 - if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then + if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then # to my (@a-m-joseph) knowledge there are no newer official binaries for this platform - packages.ghc865Binary + bb.packages.ghc865Binary else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -90,10 +91,10 @@ in { ghc902 = callPackage ../development/compilers/ghc/9.0.2.nix { bootPkgs = # the oldest ghc with aarch64-darwin support is 8.10.5 - if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc810 + if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc810 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; inherit (buildPackages.darwin) autoSignDarwinBinariesHook xattr; buildTargetLlvmPackages = pkgsBuildTarget.llvmPackages_12; @@ -102,10 +103,10 @@ in { ghc90 = compiler.ghc902; ghc925 = callPackage ../development/compilers/ghc/9.2.5.nix { bootPkgs = - if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc810 + if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc810 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -116,10 +117,10 @@ in { }; ghc926 = callPackage ../development/compilers/ghc/9.2.6.nix { bootPkgs = - if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc810 + if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc810 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -130,10 +131,10 @@ in { }; ghc927 = callPackage ../development/compilers/ghc/9.2.7.nix { bootPkgs = - if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc810 + if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc810 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -144,10 +145,10 @@ in { }; ghc928 = callPackage ../development/compilers/ghc/9.2.8.nix { bootPkgs = - if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc810 + if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc810 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -164,14 +165,14 @@ in { # Use 8.10 as a workaround where possible to keep bootstrap path short. # On ARM text won't build with GHC 8.10.* - if stdenv.hostPlatform.isAarch then + if stdenv.buildPlatform.isAarch then # TODO(@sternenseemann): package bindist - packages.ghc902 + bb.packages.ghc902 # No suitable bindists for powerpc64le - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc902 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc902 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -188,14 +189,14 @@ in { # Use 8.10 as a workaround where possible to keep bootstrap path short. # On ARM text won't build with GHC 8.10.* - if stdenv.hostPlatform.isAarch then + if stdenv.buildPlatform.isAarch then # TODO(@sternenseemann): package bindist - packages.ghc902 + bb.packages.ghc902 # No suitable bindists for powerpc64le - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc902 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc902 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -212,14 +213,14 @@ in { # Use 8.10 as a workaround where possible to keep bootstrap path short. # On ARM text won't build with GHC 8.10.* - if stdenv.hostPlatform.isAarch then + if stdenv.buildPlatform.isAarch then # TODO(@sternenseemann): package bindist - packages.ghc902 + bb.packages.ghc902 # No suitable bindists for powerpc64le - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc902 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc902 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -236,14 +237,14 @@ in { # Use 8.10 as a workaround where possible to keep bootstrap path short. # On ARM text won't build with GHC 8.10.* - if stdenv.hostPlatform.isAarch then + if stdenv.buildPlatform.isAarch then # TODO(@sternenseemann): package bindist - packages.ghc902 + bb.packages.ghc902 # No suitable bindists for powerpc64le - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc902 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc902 else - packages.ghc8107Binary; + bb.packages.ghc8107Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -257,12 +258,12 @@ in { ghc963 = callPackage ../development/compilers/ghc/9.6.3.nix { bootPkgs = # For GHC 9.2 no armv7l bindists are available. - if stdenv.hostPlatform.isAarch32 then - packages.ghc928 - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc928 + if stdenv.buildPlatform.isAarch32 then + bb.packages.ghc928 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc928 else - packages.ghc924Binary; + bb.packages.ghc924Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -275,12 +276,12 @@ in { ghc964 = callPackage ../development/compilers/ghc/9.6.4.nix { bootPkgs = # For GHC 9.2 no armv7l bindists are available. - if stdenv.hostPlatform.isAarch32 then - packages.ghc928 - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc928 + if stdenv.buildPlatform.isAarch32 then + bb.packages.ghc928 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc928 else - packages.ghc924Binary; + bb.packages.ghc924Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -294,19 +295,19 @@ in { ghc981 = callPackage ../development/compilers/ghc/9.8.1.nix { bootPkgs = # For GHC 9.6 no armv7l bindists are available. - if stdenv.hostPlatform.isAarch32 then - packages.ghc963 - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc963 - else if stdenv.hostPlatform.isDarwin then + if stdenv.buildPlatform.isAarch32 then + bb.packages.ghc963 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc963 + else if stdenv.buildPlatform.isDarwin then # it seems like the GHC 9.6.* bindists are built with a different # toolchain than we are using (which I'm guessing from the fact # that 9.6.4 bindists pass linker flags our ld doesn't support). # With both 9.6.3 and 9.6.4 binary it is impossible to link against # the clock package (probably a hsc2hs problem). - packages.ghc963 + bb.packages.ghc963 else - packages.ghc963Binary; + bb.packages.ghc963Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -319,19 +320,19 @@ in { ghc982 = callPackage ../development/compilers/ghc/9.8.2.nix { bootPkgs = # For GHC 9.6 no armv7l bindists are available. - if stdenv.hostPlatform.isAarch32 then - packages.ghc963 - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc963 - else if stdenv.hostPlatform.isDarwin then + if stdenv.buildPlatform.isAarch32 then + bb.packages.ghc963 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc963 + else if stdenv.buildPlatform.isDarwin then # it seems like the GHC 9.6.* bindists are built with a different # toolchain than we are using (which I'm guessing from the fact # that 9.6.4 bindists pass linker flags our ld doesn't support). # With both 9.6.3 and 9.6.4 binary it is impossible to link against # the clock package (probably a hsc2hs problem). - packages.ghc963 + bb.packages.ghc963 else - packages.ghc963Binary; + bb.packages.ghc963Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -345,19 +346,19 @@ in { ghcHEAD = callPackage ../development/compilers/ghc/head.nix { bootPkgs = # For GHC 9.6 no armv7l bindists are available. - if stdenv.hostPlatform.isAarch32 then - packages.ghc963 - else if stdenv.hostPlatform.isPower64 && stdenv.hostPlatform.isLittleEndian then - packages.ghc963 - else if stdenv.hostPlatform.isDarwin then + if stdenv.buildPlatform.isAarch32 then + bb.packages.ghc963 + else if stdenv.buildPlatform.isPower64 && stdenv.buildPlatform.isLittleEndian then + bb.packages.ghc963 + else if stdenv.buildPlatform.isDarwin then # it seems like the GHC 9.6.* bindists are built with a different # toolchain than we are using (which I'm guessing from the fact # that 9.6.4 bindists pass linker flags our ld doesn't support). # With both 9.6.3 and 9.6.4 binary it is impossible to link against # the clock package (probably a hsc2hs problem). - packages.ghc963 + bb.packages.ghc963 else - packages.ghc963Binary; + bb.packages.ghc963Binary; inherit (buildPackages.python3Packages) sphinx; # Need to use apple's patched xattr until # https://github.com/xattr/xattr/issues/44 and @@ -370,7 +371,7 @@ in { ghcjs = compiler.ghcjs810; ghcjs810 = callPackage ../development/compilers/ghcjs/8.10 { - bootPkgs = packages.ghc810; + bootPkgs = bb.packages.ghc810; ghcjsSrcJson = ../development/compilers/ghcjs/8.10/git.json; stage0 = ../development/compilers/ghcjs/8.10/stage0.nix; };