diff --git a/builder/hspkg-builder.nix b/builder/hspkg-builder.nix index ffa1a9da52..d8d5ced2fb 100644 --- a/builder/hspkg-builder.nix +++ b/builder/hspkg-builder.nix @@ -23,7 +23,14 @@ assert (if ghc.isHaskellNixCompiler or false then true + pkgs.lib.optionalString (name != null) (" for " + name))); let - cabalFile = if revision == null || revision == 0 then null else + # Some packages bundled with GHC are not the same as they are in hackage. + bundledSrc = { + # These are problematic because the hackage versions will not install and are part of LTS. + "ghc902/stm-2.5.0.0" = "/libraries/stm"; + "ghc902/filepath-1.4.2.1" = "/libraries/filepath"; + }."${compiler-nix-name}/${name}" or null; + src = if bundledSrc == null then pkg.src else ghc.configured-src + bundledSrc; + cabalFile = if revision == null || revision == 0 || bundledSrc != null then null else fetchurl { name = "${name}-${toString revision}.cabal"; url = "https://hackage.haskell.org/package/${name}/revision/${toString revision}.cabal"; @@ -94,7 +101,8 @@ let synopsis = null; license = "MIT"; }; - src = null; cleanSrc = buildPackages.runCommand "default-Setup-src" {} '' + src = null; + cleanSrc = buildPackages.runCommand "default-Setup-src" {} '' mkdir $out cat ${defaultSetupSrc} > $out/Setup.hs ''; diff --git a/builder/make-config-files.nix b/builder/make-config-files.nix index 94650bffa9..928f91722b 100644 --- a/builder/make-config-files.nix +++ b/builder/make-config-files.nix @@ -3,6 +3,10 @@ { identifier, component, fullName, flags ? {}, needsProfiling ? false, enableDWARF ? false, chooseDrv ? drv: drv, nonReinstallablePkgs ? defaults.nonReinstallablePkgs }: let + # Sort and remove duplicates from nonReinstallablePkgs. + # That way changes to the order of nonReinstallablePkgs does not require rebuilds. + nonReinstallablePkgs' = __attrNames (lib.genAttrs nonReinstallablePkgs (x: x)); + ghc = if enableDWARF then defaults.ghc.dwarf else defaults.ghc; flagsAndConfig = field: xs: lib.optionalString (xs != []) '' @@ -93,7 +97,7 @@ let ghc=${ghc} ${ # Copy over the nonReinstallablePkgs from the global package db. '' - for p in ${lib.concatStringsSep " " nonReinstallablePkgs}; do + for p in ${lib.concatStringsSep " " nonReinstallablePkgs'}; do find $ghc/lib/${ghc.name}/package.conf.d -name $p'*.conf' -exec cp -f {} $out/${packageCfgDir} \; done ''} @@ -152,13 +156,13 @@ let cat $p/exactDep/cabal.config >> $out/cabal.config ''} done - for p in ${lib.concatStringsSep " " (lib.remove "ghc" nonReinstallablePkgs)}; do + for p in ${lib.concatStringsSep " " (lib.remove "ghc" nonReinstallablePkgs')}; do if [ -e $ghc/envDeps/$p ]; then cat $ghc/envDeps/$p >> $out/ghc-environment fi done '' + lib.optionalString component.doExactConfig '' - for p in ${lib.concatStringsSep " " nonReinstallablePkgs}; do + for p in ${lib.concatStringsSep " " nonReinstallablePkgs'}; do if [ -e $ghc/exactDeps/$p ]; then cat $ghc/exactDeps/$p/configure-flags >> $out/configure-flags cat $ghc/exactDeps/$p/cabal.config >> $out/cabal.config diff --git a/ci.nix b/ci.nix index dff87df1c9..8283772409 100644 --- a/ci.nix +++ b/ci.nix @@ -44,10 +44,16 @@ ghc810420210212 = false; }); systems = nixpkgsName: nixpkgs: compiler-nix-name: nixpkgs.lib.genAttrs ( - nixpkgs.lib.filter (v: v != "aarch64-darwin" || ( - # aarch64-darwin requires ghc 8.10.7 and does not work on older nixpkgs - !__elem compiler-nix-name ["ghc865" "ghc884" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901"] - && !__elem nixpkgsName ["R2105"])) supportedSystems) (v: v); + nixpkgs.lib.filter (v: + # We have less x86_64-darwin build capacity so build fewer GhC versions and no R2105 + (v != "x86_64-darwin" || ( + !__elem compiler-nix-name ["ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921"] + && !__elem nixpkgsName ["R2105"])) + && + # aarch64-darwin requires ghc 8.10.7 and does not work on older nixpkgs + (v != "aarch64-darwin" || ( + !__elem compiler-nix-name ["ghc865" "ghc884" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921"] + && !__elem nixpkgsName ["R2105"]))) supportedSystems) (v: v); crossSystems = nixpkgsName: nixpkgs: compiler-nix-name: system: # We need to use the actual nixpkgs version we're working with here, since the values # of 'lib.systems.examples' are not understood between all versions diff --git a/compiler/ghc/default.nix b/compiler/ghc/default.nix index e18a88a487..7c15b51eb6 100644 --- a/compiler/ghc/default.nix +++ b/compiler/ghc/default.nix @@ -288,7 +288,7 @@ stdenv.mkDerivation (rec { $i done - # Save generated files for needed when building ghcjs + # Save generated files for needed when building ghc and ghcjs mkdir -p $generated/includes/dist-derivedconstants/header cp includes/dist-derivedconstants/header/GHCConstantsHaskell*.hs \ $generated/includes/dist-derivedconstants/header @@ -299,6 +299,15 @@ stdenv.mkDerivation (rec { fi mkdir -p $generated/compiler/stage2/build cp compiler/stage2/build/Config.hs $generated/compiler/stage2/build || true + if [[ -f compiler/stage2/build/GHC/Platform/Constants.hs ]]; then + mkdir -p $generated/compiler/stage2/build/GHC/Platform + cp compiler/stage2/build/GHC/Platform/Constants.hs $generated/compiler/stage2/build/GHC/Platform + fi + if [[ -f compiler/stage2/build/GHC/Settings/Config.hs ]]; then + mkdir -p $generated/compiler/stage2/build/GHC/Settings + cp compiler/stage2/build/GHC/Settings/Config.hs $generated/compiler/stage2/build/GHC/Settings + fi + cp compiler/stage2/build/*.hs-incl $generated/compiler/stage2/build || true mkdir -p $generated/rts/build cp rts/build/config.hs-incl $generated/rts/build || true diff --git a/modules/component-driver.nix b/modules/component-driver.nix index 90a257b3f8..34af70a98e 100644 --- a/modules/component-driver.nix +++ b/modules/component-driver.nix @@ -54,7 +54,7 @@ in # without reinstallable-lib:ghc, this is significantly larger. config.nonReinstallablePkgs = - [ "rts" "ghc-heap" "ghc-prim" "integer-gmp" "integer-simple" "base" + [ "rts" "ghc-prim" "integer-gmp" "integer-simple" "base" "deepseq" "array" "ghc-boot-th" "pretty" "template-haskell" # ghcjs custom packages "ghcjs-prim" "ghcjs-th" @@ -72,6 +72,9 @@ in "mtl" "parsec" "process" "text" "time" "transformers" "unix" "xhtml" "terminfo" # "stm" + ] + ++ lib.optionals (!config.reinstallableLibGhc || __elem config.compiler.nix-name ["ghc865"]) [ + "ghc-heap" ]; options.bootPkgs = lib.mkOption { @@ -80,7 +83,6 @@ in config.bootPkgs = [ "rts" "ghc-boot-th" - "ghc-heap" # since ghc 8.6. "ghcjs-prim" ] ++ lib.optional (!config.reinstallableLibGhc) "ghc" ++ lib.optionals ( diff --git a/overlays/ghc-packages.nix b/overlays/ghc-packages.nix index 20bc3bf61c..94ac2f2a98 100644 --- a/overlays/ghc-packages.nix +++ b/overlays/ghc-packages.nix @@ -106,24 +106,42 @@ let in rec { ghc-boot-packages-src-and-nix = builtins.mapAttrs (ghcName: ghc: builtins.mapAttrs - (pkgName: dir: rec { + (pkgName: subDir: rec { src = # Add in the generated files needed by ghc-boot - if dir == "libraries/ghc-boot" - then final.evalPackages.runCommand "ghc-boot-src" {} '' - cp -Lr ${ghc.passthru.configured-src}/${dir} $out - chmod -R +w $out - cp -Lr ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/* $out/GHC + if subDir == "libraries/ghc-boot" + then final.evalPackages.runCommand "ghc-boot-src" { nativeBuildInputs = [final.evalPackages.xorg.lndir]; } '' + mkdir $out + lndir -silent ${ghc.passthru.configured-src}/${subDir} $out + lndir -silent ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC $out/GHC '' - else if dir == "compiler" - then final.evalPackages.runCommand "ghc-src" {} '' - cp -Lr ${ghc.passthru.configured-src}/${dir} $out - chmod -R +w $out - if [[ -f ${ghc.generated}/compiler/stage2/build/Config.hs ]]; then - cp -Lr ${ghc.generated}/compiler/stage2/build/Config.hs $out - fi - '' - else "${ghc.passthru.configured-src}/${dir}"; + else if subDir == "compiler" + then final.haskell-nix.haskellLib.cleanSourceWith { + src = final.evalPackages.runCommand "ghc-src" { nativeBuildInputs = [final.evalPackages.xorg.lndir]; } '' + mkdir $out + lndir -silent ${ghc.passthru.configured-src} $out + if [[ -f ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Version.hs ]]; then + ln -s ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Version.hs $out/libraries/ghc-boot/GHC + fi + if [[ -f ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs ]]; then + ln -s ${ghc.generated}/libraries/ghc-boot/dist-install/build/GHC/Platform/Host.hs $out/libraries/ghc-boot/GHC/Platform + fi + if [[ -f ${ghc.generated}/compiler/stage2/build/Config.hs ]]; then + ln -s ${ghc.generated}/compiler/stage2/build/Config.hs $out/compiler + fi + if [[ -f ${ghc.generated}/compiler/stage2/build/GHC/Platform/Constants.hs ]]; then + ln -s ${ghc.generated}/compiler/stage2/build/GHC/Platform/Constants.hs $out/compiler/GHC/Platform + fi + if [[ -f ${ghc.generated}/compiler/stage2/build/GHC/Settings/Config.hs ]]; then + ln -s ${ghc.generated}/compiler/stage2/build/GHC/Settings/Config.hs $out/compiler/GHC/Settings + fi + ln -s ${ghc.generated}/includes/dist-derivedconstants/header/* $out/compiler + ln -s ${ghc.generated}/compiler/stage2/build/*.hs-incl $out/compiler + ''; + inherit subDir; + includeSiblings = true; + } + else "${ghc.passthru.configured-src}/${subDir}"; nix = callCabal2Nix ghcName "${ghcName}-${pkgName}" src; }) (ghc-extra-pkgs ghc.version)) final.buildPackages.haskell-nix.compiler; diff --git a/test/setup-deps/default.nix b/test/setup-deps/default.nix index 3d23cd0a65..c2f0be5f5b 100644 --- a/test/setup-deps/default.nix +++ b/test/setup-deps/default.nix @@ -17,15 +17,13 @@ let meta = { platforms = platforms.unix; - # Building reinstallable lib GHC is broken on 8.10, and we require lib ghc so this won't work with cross-compiling. + # We require lib ghc so this won't work with cross-compiling. # Moreover, even building the plan doesn't seem to work in these circumstances. - disabled = stdenv.buildPlatform != stdenv.hostPlatform || stdenv.hostPlatform.isMusl || __elem compiler-nix-name ["ghc8101" "ghc8102" "ghc8103" "ghc8104" "ghc8105" "ghc8106" "ghc8107" "ghc810420210212"]; + disabled = stdenv.buildPlatform != stdenv.hostPlatform || stdenv.hostPlatform.isMusl; }; in recurseIntoAttrs ({ - meta.disabled = __elem compiler-nix-name ["ghc901" "ghc902" "ghc921" "ghc922"]; - ifdInputs = { plan-nix = addMetaAttrs meta project.plan-nix; }; diff --git a/test/setup-deps/pkg/Setup.hs b/test/setup-deps/pkg/Setup.hs index 81aebe61a8..69c4f08c20 100644 --- a/test/setup-deps/pkg/Setup.hs +++ b/test/setup-deps/pkg/Setup.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} import Distribution.Simple -- https://github.com/snoyberg/conduit#readme @@ -7,7 +8,11 @@ import System.Directory (removeFile) -- Make sure Cabal and ghc were included import Distribution.Package () +#if MIN_VERSION_ghc(9,0,0) +import GHC.SysTools.Ar () +#else import Ar () +#endif example = do -- Pure operations: summing numbers.