Merge pull request #26799 from obsidiansystems/cross-haskell

haskell infra: Fix cross compilation to work with new system

authored by John Ericson and committed by GitHub ec0c4802 cf3ada04

+756 -292
+5 -1
pkgs/development/compilers/ghc/6.10.2-binary.nix
··· 96 96 [ $(./main) == "yes" ] 97 97 ''; 98 98 99 - passthru = { targetPrefix = ""; }; 99 + passthru = { 100 + targetPrefix = ""; 101 + # Our Cabal compiler name 102 + haskellCompilerName = "ghc"; 103 + }; 100 104 101 105 meta = { 102 106 homepage = http://haskell.org/ghc;
+6 -1
pkgs/development/compilers/ghc/6.10.4.nix
··· 25 25 26 26 NIX_CFLAGS_COMPILE = "-fomit-frame-pointer"; 27 27 28 - passthru = { targetPrefix = ""; }; 28 + passthru = { 29 + targetPrefix = ""; 30 + 31 + # Our Cabal compiler name 32 + haskellCompilerName = "ghc"; 33 + }; 29 34 30 35 meta = { 31 36 homepage = http://haskell.org/ghc;
+7 -2
pkgs/development/compilers/ghc/6.12.3.nix
··· 23 23 ''; 24 24 25 25 preConfigure = '' 26 - echo "${buildMK}" > mk/build.mk 26 + echo -n "${buildMK}" > mk/build.mk 27 27 ''; 28 28 29 29 configureFlags = [ ··· 36 36 # that in turn causes GHCi to abort 37 37 stripDebugFlags=["-S" "--keep-file-symbols"]; 38 38 39 - passthru = { targetPrefix = ""; }; 39 + passthru = { 40 + targetPrefix = ""; 41 + 42 + # Our Cabal compiler name 43 + haskellCompilerName = "ghc"; 44 + }; 40 45 41 46 meta = { 42 47 homepage = http://haskell.org/ghc;
+6 -1
pkgs/development/compilers/ghc/7.0.4-binary.nix
··· 134 134 [ $(./main) == "yes" ] 135 135 ''; 136 136 137 - passthru = { targetPrefix = ""; }; 137 + passthru = { 138 + targetPrefix = ""; 139 + 140 + # Our Cabal compiler name 141 + haskellCompilerName = "ghc"; 142 + }; 138 143 139 144 meta.license = stdenv.lib.licenses.bsd3; 140 145 meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
+7 -2
pkgs/development/compilers/ghc/7.0.4.nix
··· 28 28 ''; 29 29 30 30 preConfigure = '' 31 - echo "${buildMK}" > mk/build.mk 31 + echo -n "${buildMK}" > mk/build.mk 32 32 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure 33 33 '' + stdenv.lib.optionalString stdenv.isDarwin '' 34 34 find . -name '*.hs' | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|' ··· 45 45 # that in turn causes GHCi to abort 46 46 stripDebugFlags=["-S" "--keep-file-symbols"]; 47 47 48 - passthru = { targetPrefix = ""; }; 48 + passthru = { 49 + targetPrefix = ""; 50 + 51 + # Our Cabal compiler name 52 + haskellCompilerName = "ghc"; 53 + }; 49 54 50 55 meta = { 51 56 homepage = http://haskell.org/ghc;
+100 -15
pkgs/development/compilers/ghc/7.10.3.nix
··· 2 2 , buildPlatform, hostPlatform, targetPlatform 3 3 4 4 # build-tools 5 - , bootPkgs, hscolour, llvm_35 5 + , bootPkgs, hscolour 6 6 , coreutils, fetchurl, fetchpatch, perl 7 7 , docbook_xsl, docbook_xml_dtd_45, docbook_xml_dtd_42, libxml2, libxslt 8 8 9 - , libiconv ? null, ncurses 9 + , libffi, libiconv ? null, ncurses 10 + 11 + , useLLVM ? !targetPlatform.isx86 12 + , # LLVM is conceptually a run-time-only depedendency, but for 13 + # non-x86, we need LLVM to bootstrap later stages, so it becomes a 14 + # build-time dependency too. 15 + buildLlvmPackages, llvmPackages 10 16 11 17 , # If enabled, GHC will be built with the GPL-free but slower integer-simple 12 18 # library instead of the faster but GPLed integer-gmp library. 13 19 enableIntegerSimple ? false, gmp ? null 20 + 21 + , # If enabled, use -fPIC when compiling static libs. 22 + enableRelocatedStaticLibs ? targetPlatform != hostPlatform 23 + 24 + , # Whether to build dynamic libs for the standard library (on the target 25 + # platform). Static libs are always built. 26 + enableShared ? true 14 27 }: 15 28 16 29 assert !enableIntegerSimple -> gmp != null; ··· 28 41 sha256 = "1j45z4kcd3w1rzm4hapap2xc16bbh942qnzzdbdjcwqznsccznf0"; 29 42 }; 30 43 44 + buildMK = '' 45 + DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} 46 + '' + stdenv.lib.optionalString enableIntegerSimple '' 47 + INTEGER_LIBRARY = integer-simple 48 + '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' 49 + BuildFlavour = perf-cross 50 + Stage1Only = YES 51 + HADDOCK_DOCS = NO 52 + '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' 53 + GhcLibHcOpts += -fPIC 54 + GhcRtsHcOpts += -fPIC 55 + ''; 56 + 57 + # Splicer will pull out correct variations 58 + libDeps = platform: [ ncurses ] 59 + ++ stdenv.lib.optional (!enableIntegerSimple) gmp 60 + ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; 61 + 62 + toolsForTarget = 63 + if hostPlatform == buildPlatform then 64 + [ targetPackages.stdenv.cc ] ++ stdenv.lib.optional useLLVM llvmPackages.llvm 65 + else assert targetPlatform == hostPlatform; # build != host == target 66 + [ stdenv.cc ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm; 67 + 68 + targetCC = builtins.head toolsForTarget; 69 + 31 70 in 32 71 33 72 stdenv.mkDerivation rec { ··· 39 78 sha256 = "1vsgmic8csczl62ciz51iv8nhrkm72lyhbz7p7id13y2w7fcx46g"; 40 79 }; 41 80 81 + enableParallelBuilding = true; 82 + 83 + outputs = [ "out" "doc" ]; 84 + 42 85 patches = [ 43 86 docFixes 44 87 ./relocation.patch 45 88 ]; 46 89 47 - buildInputs = [ ghc perl libxml2 libxslt docbook_xsl docbook_xml_dtd_45 docbook_xml_dtd_42 hscolour ] ++ stdenv.lib.optionals targetPlatform.isArm [ llvm_35 ]; 48 - 49 - enableParallelBuilding = true; 50 - 51 - outputs = [ "out" "doc" ]; 52 - 90 + # GHC is a bit confused on its cross terminology. 53 91 preConfigure = '' 92 + for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do 93 + export "''${env#TARGET_}=''${!env}" 94 + done 95 + # GHC is a bit confused on its cross terminology, as these would normally be 96 + # the *host* tools. 97 + export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" 98 + export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx" 99 + export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld" 100 + export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as" 101 + export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar" 102 + export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm" 103 + export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" 104 + export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" 105 + export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" 106 + echo -n "${buildMK}" > mk/build.mk 54 107 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure 55 108 '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' 56 - export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}" 109 + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" 57 110 '' + stdenv.lib.optionalString stdenv.isDarwin '' 58 111 export NIX_LDFLAGS+=" -no_dtrace_dof" 59 - '' + stdenv.lib.optionalString enableIntegerSimple '' 60 - echo "INTEGER_LIBRARY=integer-simple" > mk/build.mk 61 112 ''; 62 113 114 + # TODO(@Ericson2314): Always pass "--target" and always prefix. 115 + configurePlatforms = [ "build" "host" ] 116 + ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; 117 + # `--with` flags for libraries needed for RTS linker 63 118 configureFlags = [ 64 - "--with-gcc=${stdenv.cc}/bin/cc" 65 - "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" 66 119 "--datadir=$doc/share/doc/ghc" 67 - ] ++ stdenv.lib.optional (! enableIntegerSimple) [ 120 + "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" 121 + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [ 68 122 "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" 69 - ] ++ stdenv.lib.optional stdenv.isDarwin [ 123 + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [ 70 124 "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" 125 + ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ 126 + "--enable-bootstrap-with-devel-snapshot" 127 + ] ++ stdenv.lib.optionals (targetPlatform.isDarwin && targetPlatform.isAarch64) [ 128 + # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ 129 + "--disable-large-address-space" 71 130 ]; 72 131 132 + # Hack to make sure we never to the relaxation `$PATH` and hooks support for 133 + # compatability. This will be replaced with something clearer in a future 134 + # masss-rebuild. 135 + crossConfig = true; 136 + 137 + nativeBuildInputs = [ 138 + ghc perl libxml2 libxslt docbook_xsl docbook_xml_dtd_45 docbook_xml_dtd_42 hscolour 139 + ]; 140 + 141 + # For building runtime libs 142 + depsBuildTarget = toolsForTarget; 143 + 144 + buildInputs = libDeps hostPlatform; 145 + 146 + propagatedBuildInputs = [ targetPackages.stdenv.cc ] 147 + ++ stdenv.lib.optional useLLVM llvmPackages.llvm; 148 + 149 + depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform); 150 + depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform); 151 + 73 152 # required, because otherwise all symbols from HSffi.o are stripped, and 74 153 # that in turn causes GHCi to abort 75 154 stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; ··· 88 167 89 168 passthru = { 90 169 inherit bootPkgs targetPrefix; 170 + 171 + inherit llvmPackages; 172 + 173 + # Our Cabal compiler name 174 + haskellCompilerName = "ghc"; 91 175 }; 92 176 93 177 meta = { ··· 96 180 maintainers = with stdenv.lib.maintainers; [ marcweber andres peti ]; 97 181 inherit (ghc.meta) license platforms; 98 182 }; 183 + 99 184 }
+8 -3
pkgs/development/compilers/ghc/7.2.2.nix
··· 31 31 libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="${libiconv}/lib" 32 32 ''} 33 33 '' + (if enableIntegerSimple then '' 34 - INTEGER_LIBRARY=integer-simple 34 + INTEGER_LIBRARY = integer-simple 35 35 '' else '' 36 36 libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp.out}/lib" 37 37 libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="${gmp.dev}/include" 38 38 ''); 39 39 40 40 preConfigure = '' 41 - echo "${buildMK}" > mk/build.mk 41 + echo -n "${buildMK}" > mk/build.mk 42 42 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure 43 43 '' + stdenv.lib.optionalString stdenv.isDarwin '' 44 44 find . -name '*.hs' | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|' ··· 55 55 # that in turn causes GHCi to abort 56 56 stripDebugFlags=["-S" "--keep-file-symbols"]; 57 57 58 - passthru = { targetPrefix = ""; }; 58 + passthru = { 59 + targetPprefix = ""; 60 + 61 + # Our Cabal compiler name 62 + haskellCompilerName = "ghc"; 63 + }; 59 64 60 65 meta = { 61 66 homepage = http://haskell.org/ghc;
+6 -1
pkgs/development/compilers/ghc/7.4.2-binary.nix
··· 136 136 [ $(./main) == "yes" ] 137 137 ''; 138 138 139 - passthru = { targetPrefix = ""; }; 139 + passthru = { 140 + targetPrefix = ""; 141 + 142 + # Our Cabal compiler name 143 + haskellCompilerName = "ghc"; 144 + }; 140 145 141 146 meta.license = stdenv.lib.licenses.bsd3; 142 147 meta.platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
+9 -4
pkgs/development/compilers/ghc/7.4.2.nix
··· 32 32 libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="${libiconv}/lib" 33 33 ''} 34 34 '' + (if enableIntegerSimple then '' 35 - INTEGER_LIBRARY=integer-simple 35 + INTEGER_LIBRARY = integer-simple 36 36 '' else '' 37 37 libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp.out}/lib" 38 38 libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="${gmp.dev}/include" 39 39 ''); 40 40 41 41 preConfigure = '' 42 - echo "${buildMK}" > mk/build.mk 42 + echo -n "${buildMK}" > mk/build.mk 43 43 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure 44 44 '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' 45 - export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}" 45 + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" 46 46 '' + stdenv.lib.optionalString stdenv.isDarwin '' 47 47 find . -name '*.hs' | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|' 48 48 find . -name '*.lhs' | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|' ··· 56 56 # that in turn causes GHCi to abort 57 57 stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols"; 58 58 59 - passthru = { targetPrefix = ""; }; 59 + passthru = { 60 + targetPrefix = ""; 61 + 62 + # Our Cabal compiler name 63 + haskellCompilerName = "ghc"; 64 + }; 60 65 61 66 meta = { 62 67 homepage = http://haskell.org/ghc;
+9 -4
pkgs/development/compilers/ghc/7.6.3.nix
··· 43 43 SRC_HC_OPTS += ${ghcFlags} 44 44 SRC_CC_OPTS += ${cFlags} 45 45 '' + (if enableIntegerSimple then '' 46 - INTEGER_LIBRARY=integer-simple 46 + INTEGER_LIBRARY = integer-simple 47 47 '' else '' 48 48 libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp.out}/lib" 49 49 libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="${gmp.dev}/include" 50 50 ''); 51 51 52 52 preConfigure = '' 53 - echo "${buildMK}" > mk/build.mk 53 + echo -n "${buildMK}" > mk/build.mk 54 54 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure 55 55 56 56 '' + stdenv.lib.optionalString stdenv.isLinux '' ··· 58 58 sed -i -e 's|"\$topdir"|"\$topdir" ${ghcFlags}|' ghc/ghc.wrapper 59 59 60 60 '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' 61 - export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}" 61 + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" 62 62 '' + stdenv.lib.optionalString stdenv.isDarwin '' 63 63 find . -name '*.hs' | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|' 64 64 find . -name '*.lhs' | xargs sed -i -e 's|ASSERT (|ASSERT(|' -e 's|ASSERT2 (|ASSERT2(|' -e 's|WARN (|WARN(|' ··· 82 82 # that in turn causes GHCi to abort 83 83 stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols"; 84 84 85 - passthru = { targetPrefix = ""; }; 85 + passthru = { 86 + targetPrefix = ""; 87 + 88 + # Our Cabal compiler name 89 + haskellCompilerName = "ghc"; 90 + }; 86 91 87 92 meta = { 88 93 homepage = http://haskell.org/ghc;
+49 -26
pkgs/development/compilers/ghc/7.8.4.nix
··· 1 - { stdenv, fetchurl, ghc, perl, ncurses, libiconv 1 + { stdenv, targetPackages 2 + 3 + , fetchurl, ghc, perl 4 + , libffi, libiconv ? null, ncurses 2 5 3 6 , # If enabled, GHC will be built with the GPL-free but slower integer-simple 4 7 # library instead of the faster but GPLed integer-gmp library. ··· 9 12 assert stdenv.targetPlatform == stdenv.hostPlatform; 10 13 assert !enableIntegerSimple -> gmp != null; 11 14 12 - stdenv.mkDerivation (rec { 13 - version = "7.8.4"; 14 - name = "ghc-${version}"; 15 - 16 - src = fetchurl { 17 - url = "https://downloads.haskell.org/~ghc/${version}/ghc-${version}-src.tar.xz"; 18 - sha256 = "1i4254akbb4ym437rf469gc0m40bxm31blp6s1z1g15jmnacs6f3"; 19 - }; 20 - 21 - patches = [ ./relocation.patch ]; 22 - 23 - buildInputs = [ ghc perl ncurses ] 24 - ++ stdenv.lib.optional (!enableIntegerSimple) gmp; 25 - 26 - enableParallelBuilding = true; 27 - 15 + let 28 16 buildMK = '' 29 17 libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-includes="${ncurses.dev}/include" 30 18 libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-libraries="${ncurses.out}/lib" 31 19 DYNAMIC_BY_DEFAULT = NO 32 - ${stdenv.lib.optionalString stdenv.isDarwin '' 20 + ${stdenv.lib.optionalString (stdenv.hostPlatform.libc != "glibc") '' 33 21 libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-includes="${libiconv}/include" 34 22 libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries="${libiconv}/lib" 35 23 ''} 36 24 '' + (if enableIntegerSimple then '' 37 - INTEGER_LIBRARY=integer-simple 25 + INTEGER_LIBRARY = integer-simple 38 26 '' else '' 39 27 libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-libraries="${gmp.out}/lib" 40 28 libraries/integer-gmp_CONFIGURE_OPTS += --configure-option=--with-gmp-includes="${gmp.dev}/include" 41 29 ''); 42 30 31 + # Splicer will pull out correct variations 32 + libDeps = [ ncurses ] 33 + ++ stdenv.lib.optional (!enableIntegerSimple) gmp 34 + ++ stdenv.lib.optional (stdenv.hostPlatform.libc != "glibc") libiconv; 35 + 36 + in 37 + 38 + stdenv.mkDerivation rec { 39 + version = "7.8.4"; 40 + name = "ghc-${version}"; 41 + 42 + src = fetchurl { 43 + url = "http://www.haskell.org/ghc/dist/${version}/${name}-src.tar.xz"; 44 + sha256 = "1i4254akbb4ym437rf469gc0m40bxm31blp6s1z1g15jmnacs6f3"; 45 + }; 46 + 47 + enableParallelBuilding = true; 48 + 49 + patches = [ ./relocation.patch ] 50 + ++ stdenv.lib.optional stdenv.isDarwin ./hpc-7.8.4.patch; 51 + 43 52 preConfigure = '' 44 - echo "${buildMK}" > mk/build.mk 53 + echo -n "${buildMK}" > mk/build.mk 45 54 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure 46 55 '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' 47 - export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}" 56 + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" 48 57 '' + stdenv.lib.optionalString stdenv.isDarwin '' 49 58 export NIX_LDFLAGS+=" -no_dtrace_dof" 50 59 ''; 51 60 61 + # TODO(@Ericson2314): Always pass "--target" and always prefix. 62 + configurePlatforms = [ "build" "host" ]; 63 + 64 + nativeBuildInputs = [ ghc perl ]; 65 + depsBuildTarget = [ targetPackages.stdenv.cc ]; 66 + 67 + buildInputs = libDeps; 68 + propagatedBuildInputs = [ targetPackages.stdenv.cc ]; 69 + 70 + depsTargetTarget = map stdenv.lib.getDev libDeps; 71 + depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") libDeps; 72 + 52 73 # required, because otherwise all symbols from HSffi.o are stripped, and 53 74 # that in turn causes GHCi to abort 54 75 stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!stdenv.isDarwin) "--keep-file-symbols"; 55 76 56 - passthru = { targetPrefix = ""; }; 77 + passthru = { 78 + targetPrefix = ""; 79 + 80 + # Our Cabal compiler name 81 + haskellCompilerName = "ghc"; 82 + }; 57 83 58 84 meta = { 59 85 homepage = http://haskell.org/ghc; ··· 62 88 inherit (ghc.meta) license platforms; 63 89 }; 64 90 65 - } // stdenv.lib.optionalAttrs stdenv.isDarwin { 66 - # https://ghc.haskell.org/trac/ghc/ticket/9762 67 - patches = [ ./hpc-7.8.4.patch ]; 68 - }) 91 + }
+105 -16
pkgs/development/compilers/ghc/8.0.2.nix
··· 2 2 , buildPlatform, hostPlatform, targetPlatform 3 3 4 4 # build-tools 5 - , bootPkgs, hscolour, llvm_37 6 - , coreutils, fetchurl, fetchpatch, patchutils, perl, sphinx 5 + , bootPkgs, hscolour 6 + , coreutils, fetchpatch, fetchurl, perl, sphinx 7 7 8 - , libiconv ? null, ncurses 8 + , libffi, libiconv ? null, ncurses 9 + 10 + , useLLVM ? !targetPlatform.isx86 11 + , # LLVM is conceptually a run-time-only depedendency, but for 12 + # non-x86, we need LLVM to bootstrap later stages, so it becomes a 13 + # build-time dependency too. 14 + buildLlvmPackages, llvmPackages 9 15 10 16 , # If enabled, GHC will be built with the GPL-free but slower integer-simple 11 17 # library instead of the faster but GPLed integer-gmp library. 12 18 enableIntegerSimple ? false, gmp ? null 19 + 20 + , # If enabled, use -fPIC when compiling static libs. 21 + enableRelocatedStaticLibs ? targetPlatform != hostPlatform 22 + 23 + , # Whether to build dynamic libs for the standard library (on the target 24 + # platform). Static libs are always built. 25 + enableShared ? true 13 26 }: 14 27 15 28 assert !enableIntegerSimple -> gmp != null; ··· 21 34 targetPrefix = stdenv.lib.optionalString 22 35 (targetPlatform != hostPlatform) 23 36 "${targetPlatform.config}-"; 37 + 38 + buildMK = '' 39 + DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} 40 + '' + stdenv.lib.optionalString enableIntegerSimple '' 41 + INTEGER_LIBRARY = integer-simple 42 + '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' 43 + BuildFlavour = perf-cross 44 + Stage1Only = YES 45 + HADDOCK_DOCS = NO 46 + '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' 47 + GhcLibHcOpts += -fPIC 48 + GhcRtsHcOpts += -fPIC 49 + ''; 50 + 51 + # Splicer will pull out correct variations 52 + libDeps = platform: [ ncurses ] 53 + ++ stdenv.lib.optional (!enableIntegerSimple) gmp 54 + ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; 55 + 56 + toolsForTarget = 57 + if hostPlatform == buildPlatform then 58 + [ targetPackages.stdenv.cc ] ++ stdenv.lib.optional useLLVM llvmPackages.llvm 59 + else assert targetPlatform == hostPlatform; # build != host == target 60 + [ stdenv.cc ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm; 61 + 62 + targetCC = builtins.head toolsForTarget; 63 + 24 64 in 25 65 stdenv.mkDerivation rec { 26 66 version = "8.0.2"; ··· 31 71 sha256 = "1c8qc4fhkycynk4g1f9hvk53dj6a1vvqi6bklqznns6hw59m8qhi"; 32 72 }; 33 73 34 - patches = [ ./ghc-gold-linker.patch ] 35 - ++ stdenv.lib.optional stdenv.isLinux ./ghc-no-madv-free.patch 36 - ++ stdenv.lib.optional stdenv.isDarwin ./ghc-8.0.2-no-cpp-warnings.patch; 37 - 38 - buildInputs = [ ghc perl hscolour sphinx ] ++ stdenv.lib.optionals (stdenv.isArm || stdenv.isAarch64) [ llvm_37 ]; 39 - 40 74 enableParallelBuilding = true; 41 75 42 76 outputs = [ "out" "man" "doc" ]; 43 77 78 + patches = [ 79 + ./ghc-gold-linker.patch 80 + (fetchpatch { # Unreleased 1.24.x commit 81 + url = "https://github.com/haskell/cabal/commit/6394cb0b6eba91a8692a3d04b2b56935aed7cccd.patch"; 82 + sha256 = "14xxjg0nb1j1pw0riac3v385ka92qhxxblfmwyvbghz7kry6axy0"; 83 + stripLen = 1; 84 + extraPrefix = "libraries/Cabal/"; 85 + }) 86 + ] ++ stdenv.lib.optional stdenv.isLinux ./ghc-no-madv-free.patch 87 + ++ stdenv.lib.optional stdenv.isDarwin ./ghc-8.0.2-no-cpp-warnings.patch; 88 + 89 + # GHC is a bit confused on its cross terminology. 44 90 preConfigure = '' 91 + for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do 92 + export "''${env#TARGET_}=''${!env}" 93 + done 94 + # GHC is a bit confused on its cross terminology, as these would normally be 95 + # the *host* tools. 96 + export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" 97 + export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx" 98 + export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld" 99 + export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as" 100 + export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar" 101 + export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm" 102 + export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" 103 + export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" 104 + export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" 105 + echo -n "${buildMK}" > mk/build.mk 45 106 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure 46 107 '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' 47 - export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}" 108 + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" 48 109 '' + stdenv.lib.optionalString stdenv.isDarwin '' 49 110 export NIX_LDFLAGS+=" -no_dtrace_dof" 50 - '' + stdenv.lib.optionalString enableIntegerSimple '' 51 - echo "INTEGER_LIBRARY=integer-simple" > mk/build.mk 52 111 ''; 53 112 113 + # TODO(@Ericson2314): Always pass "--target" and always prefix. 114 + configurePlatforms = [ "build" "host" ] 115 + ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; 116 + # `--with` flags for libraries needed for RTS linker 54 117 configureFlags = [ 55 - "--with-gcc=${stdenv.cc}/bin/cc" 118 + "--datadir=$doc/share/doc/ghc" 56 119 "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" 57 - "--datadir=$doc/share/doc/ghc" 58 - ] ++ stdenv.lib.optional (! enableIntegerSimple) [ 120 + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [ 59 121 "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" 60 - ] ++ stdenv.lib.optional stdenv.isDarwin [ 122 + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [ 61 123 "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" 124 + ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ 125 + "--enable-bootstrap-with-devel-snapshot" 62 126 ] ++ stdenv.lib.optionals (targetPlatform.isDarwin && targetPlatform.isAarch64) [ 63 127 # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ 64 128 "--disable-large-address-space" 65 129 ]; 66 130 131 + # Hack to make sure we never to the relaxation `$PATH` and hooks support for 132 + # compatability. This will be replaced with something clearer in a future 133 + # masss-rebuild. 134 + crossConfig = true; 135 + 136 + nativeBuildInputs = [ ghc perl hscolour sphinx ]; 137 + 138 + # For building runtime libs 139 + depsBuildTarget = toolsForTarget; 140 + 141 + buildInputs = libDeps hostPlatform; 142 + 143 + propagatedBuildInputs = [ targetPackages.stdenv.cc ] 144 + ++ stdenv.lib.optional useLLVM llvmPackages.llvm; 145 + 146 + depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform); 147 + depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform); 148 + 67 149 # required, because otherwise all symbols from HSffi.o are stripped, and 68 150 # that in turn causes GHCi to abort 69 151 stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; 70 152 153 + # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't 154 + # treat that as a unary `{x,y,z,..}` repetition. 71 155 postInstall = '' 72 156 paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} 73 157 ··· 84 168 85 169 passthru = { 86 170 inherit bootPkgs targetPrefix; 171 + 172 + inherit llvmPackages; 173 + 174 + # Our Cabal compiler name 175 + haskellCompilerName = "ghc"; 87 176 }; 88 177 89 178 meta = {
+121 -48
pkgs/development/compilers/ghc/8.2.2.nix
··· 1 1 { stdenv, targetPackages 2 2 , buildPlatform, hostPlatform, targetPlatform 3 - , selfPkgs, cross ? null 4 3 5 4 # build-tools 6 - , bootPkgs, alex, happy, hscolour, llvm_39 7 - , autoconf, automake, coreutils, fetchurl, perl, python3, sphinx 5 + , bootPkgs, alex, happy, hscolour 6 + , autoconf, autoreconfHook, automake, coreutils, fetchurl, fetchpatch, perl, python3, sphinx 8 7 9 - , libiconv ? null, ncurses 8 + , libffi, libiconv ? null, ncurses 9 + 10 + , useLLVM ? !targetPlatform.isx86 11 + , # LLVM is conceptually a run-time-only depedendency, but for 12 + # non-x86, we need LLVM to bootstrap later stages, so it becomes a 13 + # build-time dependency too. 14 + buildLlvmPackages, llvmPackages 10 15 11 16 , # If enabled, GHC will be built with the GPL-free but slower integer-simple 12 17 # library instead of the faster but GPLed integer-gmp library. 13 18 enableIntegerSimple ? false, gmp ? null 19 + 20 + , # If enabled, use -fPIC when compiling static libs. 21 + enableRelocatedStaticLibs ? targetPlatform != hostPlatform 22 + 23 + , # Whether to build dynamic libs for the standard library (on the target 24 + # platform). Static libs are always built. 25 + enableShared ? 26 + !(targetPlatform.isDarwin 27 + # On iOS, dynamic linking is not supported 28 + && (targetPlatform.isAarch64 || targetPlatform.isArm)) 14 29 }: 15 30 16 31 assert !enableIntegerSimple -> gmp != null; ··· 22 37 targetPrefix = stdenv.lib.optionalString 23 38 (targetPlatform != hostPlatform) 24 39 "${targetPlatform.config}-"; 40 + 41 + buildMK = '' 42 + DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} 43 + '' + stdenv.lib.optionalString enableIntegerSimple '' 44 + INTEGER_LIBRARY = integer-simple 45 + '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' 46 + BuildFlavour = perf-cross 47 + Stage1Only = YES 48 + HADDOCK_DOCS = NO 49 + BUILD_SPHINX_HTML = NO 50 + BUILD_SPHINX_PDF = NO 51 + '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' 52 + GhcLibHcOpts += -fPIC 53 + GhcRtsHcOpts += -fPIC 54 + ''; 55 + 56 + # Splicer will pull out correct variations 57 + libDeps = platform: [ ncurses ] 58 + ++ stdenv.lib.optional (!enableIntegerSimple) gmp 59 + ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; 60 + 61 + toolsForTarget = 62 + if hostPlatform == buildPlatform then 63 + [ targetPackages.stdenv.cc ] ++ stdenv.lib.optional useLLVM llvmPackages.llvm 64 + else assert targetPlatform == hostPlatform; # build != host == target 65 + [ stdenv.cc ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm; 66 + 67 + targetCC = builtins.head toolsForTarget; 68 + 25 69 in 26 - stdenv.mkDerivation (rec { 70 + stdenv.mkDerivation rec { 27 71 version = "8.2.2"; 28 72 name = "${targetPrefix}ghc-${version}"; 29 73 ··· 32 76 sha256 = "1z05vkpaj54xdypmaml50hgsdpw29dhbs2r7magx0cm199iw73mv"; 33 77 }; 34 78 79 + enableParallelBuilding = true; 80 + 81 + outputs = [ "out" "doc" ]; 82 + 83 + patches = [ 84 + (fetchpatch { # Fix STRIP to be substituted from configure 85 + url = "https://git.haskell.org/ghc.git/commitdiff_plain/2fc8ce5f0c8c81771c26266ac0b150ca9b75c5f3"; 86 + sha256 = "03253ci40np1v6k0wmi4aypj3nmj3rdyvb1k6rwqipb30nfc719f"; 87 + }) 88 + ]; 89 + 35 90 postPatch = "patchShebangs ."; 36 91 92 + # GHC is a bit confused on its cross terminology. 37 93 preConfigure = '' 94 + for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do 95 + export "''${env#TARGET_}=''${!env}" 96 + done 97 + # GHC is a bit confused on its cross terminology, as these would normally be 98 + # the *host* tools. 99 + export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" 100 + export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx" 101 + # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177 102 + export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString targetPlatform.isArm ".gold"}" 103 + export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as" 104 + export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar" 105 + export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm" 106 + export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" 107 + export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" 108 + export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" 109 + 110 + echo -n "${buildMK}" > mk/build.mk 38 111 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure 39 112 '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' 40 - export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}" 113 + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" 41 114 '' + stdenv.lib.optionalString stdenv.isDarwin '' 42 115 export NIX_LDFLAGS+=" -no_dtrace_dof" 43 - '' + stdenv.lib.optionalString enableIntegerSimple '' 44 - echo "INTEGER_LIBRARY=integer-simple" > mk/build.mk 45 - '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' 46 - sed 's|#BuildFlavour = quick-cross|BuildFlavour = perf-cross|' mk/build.mk.sample > mk/build.mk 47 116 ''; 48 117 49 - buildInputs = [ alex autoconf automake ghc happy hscolour perl python3 sphinx ] ++ stdenv.lib.optionals (targetPlatform.isArm || targetPlatform.isAarch64) [ llvm_39 ]; 50 - 51 - enableParallelBuilding = true; 52 - 118 + # TODO(@Ericson2314): Always pass "--target" and always prefix. 119 + configurePlatforms = [ "build" "host" ] 120 + ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; 121 + # `--with` flags for libraries needed for RTS linker 53 122 configureFlags = [ 54 - "CC=${stdenv.cc}/bin/cc" 123 + "--datadir=$doc/share/doc/ghc" 55 124 "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" 56 - "--datadir=$doc/share/doc/ghc" 57 - ] ++ stdenv.lib.optional (! enableIntegerSimple) [ 125 + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [ 58 126 "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" 59 - ] ++ stdenv.lib.optional stdenv.isDarwin [ 127 + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [ 60 128 "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" 61 - ] ++ stdenv.lib.optional stdenv.isArm [ 62 - "LD=${stdenv.cc}/bin/ld.gold" 129 + ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ 130 + "--enable-bootstrap-with-devel-snapshot" 131 + ] ++ stdenv.lib.optionals (targetPlatform.isArm) [ 132 + "CFLAGS=-fuse-ld=gold" 133 + "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold" 134 + "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" 135 + ] ++ stdenv.lib.optionals (targetPlatform.isDarwin && targetPlatform.isAarch64) [ 136 + # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ 137 + "--disable-large-address-space" 63 138 ]; 64 139 140 + # Hack to make sure we never to the relaxation `$PATH` and hooks support for 141 + # compatability. This will be replaced with something clearer in a future 142 + # masss-rebuild. 143 + crossConfig = true; 144 + 145 + nativeBuildInputs = [ alex autoconf autoreconfHook automake ghc happy hscolour perl python3 sphinx ]; 146 + 147 + # For building runtime libs 148 + depsBuildTarget = toolsForTarget; 149 + 150 + buildInputs = libDeps hostPlatform; 151 + 152 + propagatedBuildInputs = [ targetPackages.stdenv.cc ] 153 + ++ stdenv.lib.optional useLLVM llvmPackages.llvm; 154 + 155 + depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform); 156 + depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform); 157 + 65 158 # required, because otherwise all symbols from HSffi.o are stripped, and 66 159 # that in turn causes GHCi to abort 67 160 stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; 68 161 69 162 checkTarget = "test"; 70 163 164 + # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't 165 + # treat that as a unary `{x,y,z,..}` repetition. 71 166 postInstall = '' 72 167 paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} 73 168 ··· 82 177 done 83 178 ''; 84 179 85 - outputs = [ "out" "doc" ]; 86 - 87 180 passthru = { 88 181 inherit bootPkgs targetPrefix; 89 - } // stdenv.lib.optionalAttrs (targetPlatform != buildPlatform) { 90 - crossCompiler = selfPkgs.ghc.override { 91 - cross = targetPlatform; 92 - bootPkgs = selfPkgs; 93 - }; 182 + 183 + inherit llvmPackages; 184 + 185 + # Our Cabal compiler name 186 + haskellCompilerName = "ghc"; 94 187 }; 95 188 96 189 meta = { ··· 100 193 inherit (ghc.meta) license platforms; 101 194 }; 102 195 103 - } // stdenv.lib.optionalAttrs (cross != null) { 104 - configureFlags = [ 105 - "CC=${stdenv.cc}/bin/${cross.config}-cc" 106 - "LD=${stdenv.cc.bintools}/bin/${cross.config}-ld" 107 - "AR=${stdenv.cc.bintools}/bin/${cross.config}-ar" 108 - "NM=${stdenv.cc.bintools}/bin/${cross.config}-nm" 109 - "RANLIB=${stdenv.cc.bintools}/bin/${cross.config}-ranlib" 110 - "--target=${cross.config}" 111 - "--enable-bootstrap-with-devel-snapshot" 112 - ] ++ 113 - # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ 114 - stdenv.lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space"; 115 - 116 - configurePlatforms = []; 117 - 118 - passthru = { 119 - inherit bootPkgs cross; 120 - cc = "${stdenv.cc}/bin/${cross.config}-cc"; 121 - ld = "${stdenv.cc}/bin/${cross.config}-ld"; 122 - }; 123 - }) 196 + }
+113 -49
pkgs/development/compilers/ghc/8.4.1.nix
··· 1 1 { stdenv, targetPackages 2 2 , buildPlatform, hostPlatform, targetPlatform 3 - , selfPkgs, cross ? null 4 3 5 4 # build-tools 6 5 , bootPkgs, alex, happy 7 6 , autoconf, automake, coreutils, fetchgit, perl, python3 8 7 9 - , libiconv ? null, ncurses 8 + , libffi, libiconv ? null, ncurses 9 + 10 + , useLLVM ? !targetPlatform.isx86 11 + , # LLVM is conceptually a run-time-only depedendency, but for 12 + # non-x86, we need LLVM to bootstrap later stages, so it becomes a 13 + # build-time dependency too. 14 + buildLlvmPackages, llvmPackages 10 15 11 16 , # If enabled, GHC will be built with the GPL-free but slower integer-simple 12 17 # library instead of the faster but GPLed integer-gmp library. 13 18 enableIntegerSimple ? false, gmp ? null 14 19 20 + , # If enabled, use -fPIC when compiling static libs. 21 + enableRelocatedStaticLibs ? targetPlatform != hostPlatform 22 + 23 + , # Whether to build dynamic libs for the standard library (on the target 24 + # platform). Static libs are always built. 25 + enableShared ? true 26 + 15 27 , version ? "8.4.20180115" 16 28 }: 17 29 ··· 20 32 let 21 33 inherit (bootPkgs) ghc; 22 34 23 - rev = "3e3a096885c0fcd0703edbeffb4e47f5cbd8f4cc"; 24 - 25 35 # TODO(@Ericson2314) Make unconditional 26 36 targetPrefix = stdenv.lib.optionalString 27 37 (targetPlatform != hostPlatform) 28 38 "${targetPlatform.config}-"; 39 + 40 + buildMK = '' 41 + DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} 42 + '' + stdenv.lib.optionalString enableIntegerSimple '' 43 + INTEGER_LIBRARY = integer-simple 44 + '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' 45 + BuildFlavour = perf-cross 46 + Stage1Only = YES 47 + HADDOCK_DOCS = NO 48 + BUILD_SPHINX_HTML = NO 49 + BUILD_SPHINX_PDF = NO 50 + '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' 51 + GhcLibHcOpts += -fPIC 52 + GhcRtsHcOpts += -fPIC 53 + ''; 54 + 55 + # Splicer will pull out correct variations 56 + libDeps = platform: [ ncurses ] 57 + ++ stdenv.lib.optional (!enableIntegerSimple) gmp 58 + ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; 59 + 60 + toolsForTarget = 61 + if hostPlatform == buildPlatform then 62 + [ targetPackages.stdenv.cc ] ++ stdenv.lib.optional useLLVM llvmPackages.llvm 63 + else assert targetPlatform == hostPlatform; # build != host == target 64 + [ stdenv.cc ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm; 65 + 66 + targetCC = builtins.head toolsForTarget; 67 + 29 68 in 30 - stdenv.mkDerivation (rec { 31 - inherit version rev; 69 + stdenv.mkDerivation rec { 70 + inherit version; 71 + inherit (src) rev; 32 72 name = "${targetPrefix}ghc-${version}"; 33 73 34 74 src = fetchgit { 35 75 url = "git://git.haskell.org/ghc.git"; 36 - inherit rev; 76 + rev = "3e3a096885c0fcd0703edbeffb4e47f5cbd8f4cc"; 37 77 sha256 = "06slymbsd7vsfp4hh40v7cxf7nmp0kvlni2wfq7ag5wlqh04slgs"; 38 78 }; 39 79 80 + enableParallelBuilding = true; 81 + 82 + outputs = [ "out" "doc" ]; 83 + 40 84 postPatch = "patchShebangs ."; 41 85 86 + # GHC is a bit confused on its cross terminology. 42 87 preConfigure = '' 88 + for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do 89 + export "''${env#TARGET_}=''${!env}" 90 + done 91 + # GHC is a bit confused on its cross terminology, as these would normally be 92 + # the *host* tools. 93 + export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" 94 + export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx" 95 + # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177 96 + export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString targetPlatform.isArm ".gold"}" 97 + export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as" 98 + export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar" 99 + export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm" 100 + export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" 101 + export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" 102 + export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" 103 + 104 + echo -n "${buildMK}" > mk/build.mk 43 105 echo ${version} >VERSION 44 - echo ${rev} >GIT_COMMIT_ID 106 + echo ${src.rev} >GIT_COMMIT_ID 45 107 ./boot 46 108 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure 47 109 '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' 48 - export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}" 110 + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" 49 111 '' + stdenv.lib.optionalString stdenv.isDarwin '' 50 112 export NIX_LDFLAGS+=" -no_dtrace_dof" 51 - '' + stdenv.lib.optionalString enableIntegerSimple '' 52 - echo "INTEGER_LIBRARY=integer-simple" > mk/build.mk 53 - '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' 54 - sed 's|#BuildFlavour = quick-cross|BuildFlavour = perf-cross|' mk/build.mk.sample > mk/build.mk 55 113 ''; 56 114 57 - buildInputs = [ ghc perl autoconf automake happy alex python3 ]; 58 - 59 - enableParallelBuilding = true; 60 - 115 + # TODO(@Ericson2314): Always pass "--target" and always prefix. 116 + configurePlatforms = [ "build" "host" ] 117 + ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; 118 + # `--with` flags for libraries needed for RTS linker 61 119 configureFlags = [ 62 - "CC=${stdenv.cc}/bin/cc" 120 + "--datadir=$doc/share/doc/ghc" 63 121 "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" 64 - "--datadir=$doc/share/doc/ghc" 65 - ] ++ stdenv.lib.optional (! enableIntegerSimple) [ 122 + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [ 66 123 "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" 67 - ] ++ stdenv.lib.optional stdenv.isDarwin [ 124 + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [ 68 125 "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" 126 + ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ 127 + "--enable-bootstrap-with-devel-snapshot" 128 + ] ++ stdenv.lib.optionals (targetPlatform.isArm) [ 129 + "CFLAGS=-fuse-ld=gold" 130 + "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold" 131 + "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" 132 + ] ++ stdenv.lib.optionals (targetPlatform.isDarwin && targetPlatform.isAarch64) [ 133 + # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ 134 + "--disable-large-address-space" 69 135 ]; 70 136 137 + # Hack to make sure we never to the relaxation `$PATH` and hooks support for 138 + # compatability. This will be replaced with something clearer in a future 139 + # masss-rebuild. 140 + crossConfig = true; 141 + 142 + nativeBuildInputs = [ ghc perl autoconf automake happy alex python3 ]; 143 + 144 + # For building runtime libs 145 + depsBuildTarget = toolsForTarget; 146 + 147 + buildInputs = libDeps hostPlatform; 148 + 149 + propagatedBuildInputs = [ targetPackages.stdenv.cc ] 150 + ++ stdenv.lib.optional useLLVM llvmPackages.llvm; 151 + 152 + depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform); 153 + depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform); 154 + 71 155 # required, because otherwise all symbols from HSffi.o are stripped, and 72 156 # that in turn causes GHCi to abort 73 157 stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; 74 158 75 159 checkTarget = "test"; 76 160 161 + # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't 162 + # treat that as a unary `{x,y,z,..}` repetition. 77 163 postInstall = '' 78 164 paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} 79 165 ··· 88 174 done 89 175 ''; 90 176 91 - outputs = [ "out" "doc" ]; 92 - 93 177 passthru = { 94 178 inherit bootPkgs targetPrefix; 95 - } // stdenv.lib.optionalAttrs (targetPlatform != buildPlatform) { 96 - crossCompiler = selfPkgs.ghc.override { 97 - cross = targetPlatform; 98 - bootPkgs = selfPkgs; 99 - }; 179 + 180 + inherit llvmPackages; 181 + 182 + # Our Cabal compiler name 183 + haskellCompilerName = "ghc"; 100 184 }; 101 185 102 186 meta = { ··· 106 190 inherit (ghc.meta) license platforms; 107 191 }; 108 192 109 - } // stdenv.lib.optionalAttrs (cross != null) { 110 - configureFlags = [ 111 - "CC=${stdenv.cc}/bin/${cross.config}-cc" 112 - "LD=${stdenv.cc.bintools}/bin/${cross.config}-ld" 113 - "AR=${stdenv.cc.bintools}/bin/${cross.config}-ar" 114 - "NM=${stdenv.cc.bintools}/bin/${cross.config}-nm" 115 - "RANLIB=${stdenv.cc.bintools}/bin/${cross.config}-ranlib" 116 - "--target=${cross.config}" 117 - "--enable-bootstrap-with-devel-snapshot" 118 - ] ++ 119 - # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ 120 - stdenv.lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space"; 121 - 122 - configurePlatforms = []; 123 - 124 - passthru = { 125 - inherit bootPkgs cross; 126 - cc = "${stdenv.cc}/bin/${cross.config}-cc"; 127 - ld = "${stdenv.cc}/bin/${cross.config}-ld"; 128 - }; 129 - }) 193 + }
+115 -51
pkgs/development/compilers/ghc/head.nix
··· 1 1 { stdenv, targetPackages 2 2 , buildPlatform, hostPlatform, targetPlatform 3 - , selfPkgs, cross ? null 4 3 5 4 # build-tools 6 5 , bootPkgs, alex, happy 7 6 , autoconf, automake, coreutils, fetchgit, perl, python3 8 7 9 - , libiconv ? null, ncurses 8 + , libffi, libiconv ? null, ncurses 9 + 10 + , useLLVM ? !targetPlatform.isx86 11 + , # LLVM is conceptually a run-time-only depedendency, but for 12 + # non-x86, we need LLVM to bootstrap later stages, so it becomes a 13 + # build-time dependency too. 14 + buildLlvmPackages, llvmPackages 10 15 11 16 , # If enabled, GHC will be built with the GPL-free but slower integer-simple 12 17 # library instead of the faster but GPLed integer-gmp library. 13 18 enableIntegerSimple ? false, gmp ? null 14 19 15 - , version ? "8.5.20171209" 20 + , # If enabled, use -fPIC when compiling static libs. 21 + enableRelocatedStaticLibs ? targetPlatform != hostPlatform 22 + 23 + , # Whether to build dynamic libs for the standard library (on the target 24 + # platform). Static libs are always built. 25 + enableShared ? true 26 + 27 + , version ? "8.5.20180118" 16 28 }: 17 29 18 30 assert !enableIntegerSimple -> gmp != null; ··· 20 32 let 21 33 inherit (bootPkgs) ghc; 22 34 23 - rev = "4335c07ca7e64624819b22644d7591853826bd75"; 24 - 25 35 # TODO(@Ericson2314) Make unconditional 26 36 targetPrefix = stdenv.lib.optionalString 27 37 (targetPlatform != hostPlatform) 28 38 "${targetPlatform.config}-"; 39 + 40 + buildMK = '' 41 + DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} 42 + '' + stdenv.lib.optionalString enableIntegerSimple '' 43 + INTEGER_LIBRARY = integer-simple 44 + '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' 45 + BuildFlavour = perf-cross 46 + Stage1Only = YES 47 + HADDOCK_DOCS = NO 48 + BUILD_SPHINX_HTML = NO 49 + BUILD_SPHINX_PDF = NO 50 + '' + stdenv.lib.optionalString enableRelocatedStaticLibs '' 51 + GhcLibHcOpts += -fPIC 52 + GhcRtsHcOpts += -fPIC 53 + ''; 54 + 55 + # Splicer will pull out correct variations 56 + libDeps = platform: [ ncurses ] 57 + ++ stdenv.lib.optional (!enableIntegerSimple) gmp 58 + ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; 59 + 60 + toolsForTarget = 61 + if hostPlatform == buildPlatform then 62 + [ targetPackages.stdenv.cc ] ++ stdenv.lib.optional useLLVM llvmPackages.llvm 63 + else assert targetPlatform == hostPlatform; # build != host == target 64 + [ stdenv.cc ] ++ stdenv.lib.optional useLLVM buildLlvmPackages.llvm; 65 + 66 + targetCC = builtins.head toolsForTarget; 67 + 29 68 in 30 - stdenv.mkDerivation (rec { 31 - inherit version rev; 69 + stdenv.mkDerivation rec { 70 + inherit version; 71 + inherit (src) rev; 32 72 name = "${targetPrefix}ghc-${version}"; 33 73 34 74 src = fetchgit { 35 75 url = "git://git.haskell.org/ghc.git"; 36 - inherit rev; 37 - sha256 = "19csad94sk0bw2nj97ppmnwh4c193jg0jmg5w2sx9rqm9ih4yg85"; 76 + rev = "e1d4140be4d2a1508015093b69e1ef53516e1eb6"; 77 + sha256 = "1gdcr10dd968d40qgljdwx9vfkva3yrvjm9a4nis7whaaac3ag58"; 38 78 }; 39 79 80 + enableParallelBuilding = true; 81 + 82 + outputs = [ "out" "doc" ]; 83 + 40 84 postPatch = "patchShebangs ."; 41 85 86 + # GHC is a bit confused on its cross terminology. 42 87 preConfigure = '' 88 + for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do 89 + export "''${env#TARGET_}=''${!env}" 90 + done 91 + # GHC is a bit confused on its cross terminology, as these would normally be 92 + # the *host* tools. 93 + export CC="${targetCC}/bin/${targetCC.targetPrefix}cc" 94 + export CXX="${targetCC}/bin/${targetCC.targetPrefix}cxx" 95 + # Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177 96 + export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${stdenv.lib.optionalString targetPlatform.isArm ".gold"}" 97 + export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as" 98 + export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar" 99 + export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm" 100 + export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" 101 + export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" 102 + export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" 103 + 104 + echo -n "${buildMK}" > mk/build.mk 43 105 echo ${version} >VERSION 44 - echo ${rev} >GIT_COMMIT_ID 106 + echo ${src.rev} >GIT_COMMIT_ID 45 107 ./boot 46 108 sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure 47 109 '' + stdenv.lib.optionalString (!stdenv.isDarwin) '' 48 - export NIX_LDFLAGS="$NIX_LDFLAGS -rpath $out/lib/ghc-${version}" 110 + export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}" 49 111 '' + stdenv.lib.optionalString stdenv.isDarwin '' 50 112 export NIX_LDFLAGS+=" -no_dtrace_dof" 51 - '' + stdenv.lib.optionalString enableIntegerSimple '' 52 - echo "INTEGER_LIBRARY=integer-simple" > mk/build.mk 53 - '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' 54 - sed 's|#BuildFlavour = quick-cross|BuildFlavour = perf-cross|' mk/build.mk.sample > mk/build.mk 55 113 ''; 56 114 57 - buildInputs = [ ghc perl autoconf automake happy alex python3 ]; 58 - 59 - enableParallelBuilding = true; 60 - 115 + # TODO(@Ericson2314): Always pass "--target" and always prefix. 116 + configurePlatforms = [ "build" "host" ] 117 + ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; 118 + # `--with` flags for libraries needed for RTS linker 61 119 configureFlags = [ 62 - "CC=${stdenv.cc}/bin/cc" 63 - "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" 64 120 "--datadir=$doc/share/doc/ghc" 65 - ] ++ stdenv.lib.optional (! enableIntegerSimple) [ 121 + "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" 122 + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [ 66 123 "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" 67 - ] ++ stdenv.lib.optional stdenv.isDarwin [ 124 + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [ 68 125 "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" 126 + ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ 127 + "--enable-bootstrap-with-devel-snapshot" 128 + ] ++ stdenv.lib.optionals (targetPlatform.isArm) [ 129 + "CFLAGS=-fuse-ld=gold" 130 + "CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold" 131 + "CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold" 132 + ] ++ stdenv.lib.optionals (targetPlatform.isDarwin && targetPlatform.isAarch64) [ 133 + # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ 134 + "--disable-large-address-space" 69 135 ]; 70 136 137 + # Hack to make sure we never to the relaxation `$PATH` and hooks support for 138 + # compatability. This will be replaced with something clearer in a future 139 + # masss-rebuild. 140 + crossConfig = true; 141 + 142 + nativeBuildInputs = [ ghc perl autoconf automake happy alex python3 ]; 143 + 144 + # For building runtime libs 145 + depsBuildTarget = toolsForTarget; 146 + 147 + buildInputs = libDeps hostPlatform; 148 + 149 + propagatedBuildInputs = [ targetPackages.stdenv.cc ] 150 + ++ stdenv.lib.optional useLLVM llvmPackages.llvm; 151 + 152 + depsTargetTarget = map stdenv.lib.getDev (libDeps targetPlatform); 153 + depsTargetTargetPropagated = map (stdenv.lib.getOutput "out") (libDeps targetPlatform); 154 + 71 155 # required, because otherwise all symbols from HSffi.o are stripped, and 72 156 # that in turn causes GHCi to abort 73 157 stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; 74 158 75 159 checkTarget = "test"; 76 160 161 + # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't 162 + # treat that as a unary `{x,y,z,..}` repetition. 77 163 postInstall = '' 78 164 paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} 79 165 ··· 88 174 done 89 175 ''; 90 176 91 - outputs = [ "out" "doc" ]; 92 - 93 177 passthru = { 94 178 inherit bootPkgs targetPrefix; 95 - } // stdenv.lib.optionalAttrs (targetPlatform != buildPlatform) { 96 - crossCompiler = selfPkgs.ghc.override { 97 - cross = targetPlatform; 98 - bootPkgs = selfPkgs; 99 - }; 179 + 180 + inherit llvmPackages; 181 + 182 + # Our Cabal compiler name 183 + haskellCompilerName = "ghc"; 100 184 }; 101 185 102 186 meta = { ··· 106 190 inherit (ghc.meta) license platforms; 107 191 }; 108 192 109 - } // stdenv.lib.optionalAttrs (cross != null) { 110 - configureFlags = [ 111 - "CC=${stdenv.cc}/bin/${cross.config}-cc" 112 - "LD=${stdenv.cc.bintools}/bin/${cross.config}-ld" 113 - "AR=${stdenv.cc.bintools}/bin/${cross.config}-ar" 114 - "NM=${stdenv.cc.bintools}/bin/${cross.config}-nm" 115 - "RANLIB=${stdenv.cc.bintools}/bin/${cross.config}-ranlib" 116 - "--target=${cross.config}" 117 - "--enable-bootstrap-with-devel-snapshot" 118 - ] ++ 119 - # fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/ 120 - stdenv.lib.optional (cross.config or null == "aarch64-apple-darwin14") "--disable-large-address-space"; 121 - 122 - configurePlatforms = []; 123 - 124 - passthru = { 125 - inherit bootPkgs cross; 126 - cc = "${stdenv.cc}/bin/${cross.config}-cc"; 127 - ld = "${stdenv.cc}/bin/${cross.config}-ld"; 128 - }; 129 - }) 193 + }
+2 -1
pkgs/development/haskell-modules/default.nix
··· 1 1 { pkgs, stdenv, lib, haskellLib, ghc, all-cabal-hashes 2 + , buildHaskellPackages 2 3 , compilerConfig ? (self: super: {}) 3 4 , packageSetConfig ? (self: super: {}) 4 5 , overrides ? (self: super: {}) ··· 14 15 15 16 haskellPackages = pkgs.callPackage makePackageSet { 16 17 package-set = initialPackages; 17 - inherit stdenv haskellLib ghc extensible-self; 18 + inherit stdenv haskellLib ghc buildHaskellPackages extensible-self; 18 19 }; 19 20 20 21 commonConfiguration = configurationCommon { inherit pkgs haskellLib; };
+15 -11
pkgs/development/haskell-modules/generic-builder.nix
··· 1 - { stdenv, buildPackages, ghc 1 + { stdenv, buildPackages, buildHaskellPackages, ghc 2 2 , jailbreak-cabal, hscolour, cpphs, nodejs 3 3 , buildPlatform, hostPlatform 4 4 }: ··· 81 81 then "package-db" 82 82 else "package-conf"; 83 83 84 - nativeGhc = if isCross || isGhcjs then ghc.bootPkgs.ghc else ghc; 84 + # GHC used for building Setup.hs 85 + # 86 + # Same as our GHC, unless we're cross, in which case it is native GHC with the 87 + # same version, or ghcjs, in which case its the ghc used to build ghcjs. 88 + nativeGhc = buildHaskellPackages.ghc; 85 89 nativePackageDbFlag = if versionOlder "7.6" nativeGhc.version 86 90 then "package-db" 87 91 else "package-conf"; ··· 147 151 ] ++ crossCabalFlags); 148 152 149 153 setupCompileFlags = [ 150 - (optionalString (!coreSetup) "-${packageDbFlag}=$packageConfDir") 151 - (optionalString isGhcjs "-build-runner") 154 + (optionalString (!coreSetup) "-${nativePackageDbFlag}=$packageConfDir") 152 155 (optionalString (isGhcjs || isHaLVM || versionOlder "7.8" ghc.version) "-j$NIX_BUILD_CORES") 153 156 # https://github.com/haskell/cabal/issues/2398 154 157 (optionalString (versionOlder "7.10" ghc.version && !isHaLVM) "-threaded") ··· 160 163 allPkgconfigDepends = pkgconfigDepends ++ libraryPkgconfigDepends ++ executablePkgconfigDepends ++ 161 164 optionals doCheck testPkgconfigDepends ++ optionals doBenchmark benchmarkPkgconfigDepends; 162 165 163 - nativeBuildInputs = optional (allPkgconfigDepends != []) pkgconfig ++ 164 - buildTools ++ libraryToolDepends ++ executableToolDepends ++ [ removeReferencesTo ]; 166 + nativeBuildInputs = [ ghc nativeGhc removeReferencesTo ] ++ optional (allPkgconfigDepends != []) pkgconfig ++ 167 + buildTools ++ libraryToolDepends ++ executableToolDepends; 165 168 propagatedBuildInputs = buildDepends ++ libraryHaskellDepends ++ executableHaskellDepends; 166 169 otherBuildInputs = setupHaskellDepends ++ extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++ 167 170 optionals (allPkgconfigDepends != []) allPkgconfigDepends ++ 168 171 optionals doCheck (testDepends ++ testHaskellDepends ++ testSystemDepends ++ testToolDepends) ++ 169 - # ghcjs's hsc2hs calls out to the native hsc2hs 170 - optional isGhcjs nativeGhc ++ 171 172 optionals doBenchmark (benchmarkDepends ++ benchmarkHaskellDepends ++ benchmarkSystemDepends ++ benchmarkToolDepends); 172 173 allBuildInputs = propagatedBuildInputs ++ otherBuildInputs; 173 174 ··· 176 177 177 178 ghcEnv = ghc.withPackages (p: haskellBuildInputs); 178 179 179 - setupBuilder = if isCross then "${nativeGhc}/bin/ghc" else ghcCommand; 180 180 setupCommand = "./Setup"; 181 + 181 182 ghcCommand' = if isGhcjs then "ghcjs" else "ghc"; 182 183 ghcCommand = "${ghc.targetPrefix}${ghcCommand'}"; 183 184 ghcCommandCaps= toUpper ghcCommand'; 184 185 186 + nativeGhcCommand = "${nativeGhc.targetPrefix}ghc"; 187 + 185 188 in 186 189 187 190 assert allPkgconfigDepends != [] -> pkgconfig != null; ··· 220 223 runHook preSetupCompilerEnvironment 221 224 222 225 echo "Build with ${ghc}." 223 - export PATH="${ghc}/bin:$PATH" 224 226 ${optionalString (hasActiveLibrary && hyperlinkSource) "export PATH=${hscolour}/bin:$PATH"} 225 227 226 228 packageConfDir="$TMPDIR/package.conf.d" ··· 271 273 done 272 274 273 275 echo setupCompileFlags: $setupCompileFlags 274 - ${setupBuilder} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i 276 + ${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i 275 277 276 278 runHook postCompileBuildDriver 277 279 ''; 278 280 281 + # Cabal takes flags like `--configure-option=--host=...` instead 282 + configurePlatforms = []; 279 283 inherit configureFlags; 280 284 281 285 configurePhase = ''
+9 -8
pkgs/development/haskell-modules/make-package-set.nix
··· 4 4 { # package-set used for build tools (all of nixpkgs) 5 5 buildPackages 6 6 7 + , # A haskell package set for Setup.hs, compiler plugins, and similar 8 + # build-time uses. 9 + buildHaskellPackages 10 + 7 11 , # package-set used for non-haskell dependencies (all of nixpkgs) 8 12 pkgs 9 13 ··· 18 22 , # compiler to use 19 23 ghc 20 24 21 - , # A function that takes `{ pkgs, stdenv, callPackage }` as the first arg and `self` 22 - # as second, and returns a set of haskell packages 25 + , # A function that takes `{ pkgs, stdenv, callPackage }` as the first arg and 26 + # `self` as second, and returns a set of haskell packages 23 27 package-set 24 28 25 29 , # The final, fully overriden package set usable with the nixpkgs fixpoint ··· 36 40 inherit (stdenv.lib) fix' extends makeOverridable; 37 41 inherit (haskellLib) overrideCabal; 38 42 39 - buildHaskellPackages = if hostPlatform != buildPlatform 40 - then self.ghc.bootPkgs 41 - else self; 42 - 43 43 mkDerivationImpl = pkgs.callPackage ./generic-builder.nix { 44 44 inherit stdenv; 45 45 nodejs = buildPackages.nodejs-slim; 46 + inherit buildHaskellPackages; 47 + inherit (self) ghc; 46 48 inherit (buildHaskellPackages) jailbreak-cabal; 47 - inherit (self) ghc; 48 49 hscolour = overrideCabal buildHaskellPackages.hscolour (drv: { 49 50 isLibrary = false; 50 51 doHaddock = false; ··· 119 120 installPhase = '' 120 121 export HOME="$TMP" 121 122 mkdir -p "$out" 122 - cabal2nix --compiler=${self.ghc.name} --system=${stdenv.system} ${sha256Arg} "${src}" > "$out/default.nix" 123 + cabal2nix --compiler=${ghc.haskellCompilerName} --system=${stdenv.system} ${sha256Arg} "${src}" > "$out/default.nix" 123 124 ''; 124 125 }; 125 126
+59 -48
pkgs/top-level/haskell-packages.nix
··· 1 - { pkgs, lib, newScope, stdenv, buildPlatform, targetPlatform, cabal-install }: 1 + { buildPackages, pkgs 2 + , newScope, stdenv 3 + , buildPlatform, targetPlatform 4 + }: 2 5 3 6 let 4 7 # These are attributes in compiler and packages that don't support integer-simple. ··· 65 68 ghc7103 = callPackage ../development/compilers/ghc/7.10.3.nix rec { 66 69 bootPkgs = packages.ghc7103Binary; 67 70 inherit (bootPkgs) hscolour; 71 + buildLlvmPackages = buildPackages.llvmPackages_35; 72 + llvmPackages = pkgs.llvmPackages_35; 68 73 }; 69 74 ghc802 = callPackage ../development/compilers/ghc/8.0.2.nix rec { 70 75 bootPkgs = packages.ghc7103Binary; 71 76 inherit (bootPkgs) hscolour; 72 77 sphinx = pkgs.python27Packages.sphinx; 78 + buildLlvmPackages = buildPackages.llvmPackages_37; 79 + llvmPackages = pkgs.llvmPackages_37; 73 80 }; 74 81 ghc822 = callPackage ../development/compilers/ghc/8.2.2.nix rec { 75 82 bootPkgs = packages.ghc821Binary; 76 83 inherit (bootPkgs) hscolour alex happy; 77 84 inherit buildPlatform targetPlatform; 78 85 sphinx = pkgs.python3Packages.sphinx; 79 - selfPkgs = packages.ghc822; 86 + buildLlvmPackages = buildPackages.llvmPackages_39; 87 + llvmPackages = pkgs.llvmPackages_39; 80 88 }; 81 89 ghc841 = callPackage ../development/compilers/ghc/8.4.1.nix rec { 82 90 bootPkgs = packages.ghc821Binary; 83 91 inherit (bootPkgs) alex happy; 84 - inherit buildPlatform targetPlatform; 85 - selfPkgs = packages.ghc841; 92 + buildLlvmPackages = buildPackages.llvmPackages_5; 93 + llvmPackages = pkgs.llvmPackages_5; 86 94 }; 87 95 ghcHEAD = callPackage ../development/compilers/ghc/head.nix rec { 88 96 bootPkgs = packages.ghc821Binary; 89 97 inherit (bootPkgs) alex happy; 90 - inherit buildPlatform targetPlatform; 91 - selfPkgs = packages.ghcHEAD; 98 + buildLlvmPackages = buildPackages.llvmPackages_5; 99 + llvmPackages = pkgs.llvmPackages_5; 92 100 }; 93 101 ghcjs = packages.ghc7103.callPackage ../development/compilers/ghcjs { 94 102 bootPkgs = packages.ghc7103; 95 - inherit cabal-install; 103 + inherit (pkgs) cabal-install; 96 104 }; 97 105 ghcjsHEAD = packages.ghc802.callPackage ../development/compilers/ghcjs/head.nix { 98 106 bootPkgs = packages.ghc802; 99 - inherit cabal-install; 107 + inherit (pkgs) cabal-install; 100 108 }; 101 109 ghcHaLVM240 = callPackage ../development/compilers/halvm/2.4.0.nix rec { 102 110 bootPkgs = packages.ghc7103Binary; ··· 110 118 111 119 # The integer-simple attribute set contains all the GHC compilers 112 120 # build with integer-simple instead of integer-gmp. 113 - integer-simple = 114 - let integerSimpleGhcNames = 115 - pkgs.lib.filter (name: ! builtins.elem name integerSimpleExcludes) 116 - (pkgs.lib.attrNames compiler); 117 - integerSimpleGhcs = pkgs.lib.genAttrs integerSimpleGhcNames 118 - (name: compiler."${name}".override { enableIntegerSimple = true; }); 119 - in pkgs.recurseIntoAttrs (integerSimpleGhcs // { 120 - ghcHEAD = integerSimpleGhcs.ghcHEAD.override { selfPkgs = packages.integer-simple.ghcHEAD; }; 121 - }); 122 - 121 + integer-simple = let 122 + integerSimpleGhcNames = pkgs.lib.filter 123 + (name: ! builtins.elem name integerSimpleExcludes) 124 + (pkgs.lib.attrNames compiler); 125 + in pkgs.recurseIntoAttrs (pkgs.lib.genAttrs 126 + integerSimpleGhcNames 127 + (name: compiler."${name}".override { enableIntegerSimple = true; })); 123 128 }; 124 129 125 - packages = { 130 + # Always get compilers from `buildPackages` 131 + packages = let bh = buildPackages.haskell; in { 126 132 127 133 ghc7103 = callPackage ../development/haskell-modules { 128 - ghc = compiler.ghc7103; 134 + buildHaskellPackages = bh.packages.ghc7103; 135 + ghc = bh.compiler.ghc7103; 129 136 compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-7.10.x.nix { }; 130 137 }; 131 138 ghc7103Binary = callPackage ../development/haskell-modules { 132 - ghc = compiler.ghc7103Binary; 139 + buildHaskellPackages = bh.packages.ghc7103Binary; 140 + ghc = bh.compiler.ghc7103Binary; 133 141 compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-7.10.x.nix { }; 134 142 }; 135 143 ghc802 = callPackage ../development/haskell-modules { 136 - ghc = compiler.ghc802; 144 + buildHaskellPackages = bh.packages.ghc802; 145 + ghc = bh.compiler.ghc802; 137 146 compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-8.0.x.nix { }; 138 147 }; 139 - ghc822 = callPackage ../development/haskell-modules { 140 - ghc = compiler.ghc822; 148 + ghc821Binary = callPackage ../development/haskell-modules { 149 + buildHaskellPackages = bh.packages.ghc821Binary; 150 + ghc = bh.compiler.ghc821Binary; 141 151 compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-8.2.x.nix { }; 142 152 }; 143 - ghc821Binary = callPackage ../development/haskell-modules { 144 - ghc = compiler.ghc821Binary; 153 + ghc822 = callPackage ../development/haskell-modules { 154 + buildHaskellPackages = bh.packages.ghc822; 155 + ghc = bh.compiler.ghc822; 145 156 compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-8.2.x.nix { }; 146 157 }; 147 158 ghc841 = callPackage ../development/haskell-modules { 148 - ghc = compiler.ghc841; 159 + buildHaskellPackages = bh.packages.ghc841; 160 + ghc = bh.compiler.ghc841; 149 161 compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-8.4.x.nix { }; 150 162 }; 151 163 ghcHEAD = callPackage ../development/haskell-modules { 152 - ghc = compiler.ghcHEAD; 164 + buildHaskellPackages = bh.packages.ghcHEAD; 165 + ghc = bh.compiler.ghcHEAD; 153 166 compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-head.nix { }; 154 167 }; 155 - # TODO Support for multiple variants here 156 - ghcCross = callPackage ../development/haskell-modules { 157 - ghc = compiler.ghcHEAD.crossCompiler; 158 - compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-head.nix { }; 159 - }; 160 - ghcjs = callPackage ../development/haskell-modules { 161 - ghc = compiler.ghcjs; 168 + ghcjs = callPackage ../development/haskell-modules rec { 169 + buildHaskellPackages = ghc.bootPkgs; 170 + ghc = bh.compiler.ghcjs; 162 171 compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-7.10.x.nix { }; 163 172 packageSetConfig = callPackage ../development/haskell-modules/configuration-ghcjs.nix { }; 164 173 }; 165 - ghcjsHEAD = callPackage ../development/haskell-modules { 166 - ghc = compiler.ghcjsHEAD; 174 + ghcjsHEAD = callPackage ../development/haskell-modules rec { 175 + buildHaskellPackages = ghc.bootPkgs; 176 + ghc = bh.compiler.ghcjsHEAD; 167 177 compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-8.0.x.nix { }; 168 178 packageSetConfig = callPackage ../development/haskell-modules/configuration-ghcjs.nix { }; 169 179 }; 170 180 ghcHaLVM240 = callPackage ../development/haskell-modules { 171 - ghc = compiler.ghcHaLVM240; 181 + buildHaskellPackages = bh.packages.ghcHaLVM240; 182 + ghc = bh.compiler.ghcHaLVM240; 172 183 compilerConfig = callPackage ../development/haskell-modules/configuration-halvm-2.4.0.nix { }; 173 184 }; 174 185 175 186 # The integer-simple attribute set contains package sets for all the GHC compilers 176 187 # using integer-simple instead of integer-gmp. 177 - integer-simple = 178 - let integerSimpleGhcNames = 179 - pkgs.lib.filter (name: ! builtins.elem name integerSimpleExcludes) 180 - (pkgs.lib.attrNames packages); 181 - in pkgs.lib.genAttrs integerSimpleGhcNames (name: packages."${name}".override { 182 - ghc = compiler.integer-simple."${name}"; 183 - overrides = _self : _super : { 184 - integer-simple = null; 185 - integer-gmp = null; 186 - }; 188 + integer-simple = let 189 + integerSimpleGhcNames = pkgs.lib.filter 190 + (name: ! builtins.elem name integerSimpleExcludes) 191 + (pkgs.lib.attrNames packages); 192 + in pkgs.lib.genAttrs integerSimpleGhcNames (name: packages."${name}".override { 193 + ghc = compiler.integer-simple."${name}"; 194 + overrides = _self : _super : { 195 + integer-simple = null; 196 + integer-gmp = null; 197 + }; 187 198 }); 188 199 189 200 };
+5
pkgs/top-level/release-cross.nix
··· 21 21 gnuCommon = lib.recursiveUpdate common { 22 22 buildPackages.gcc = nativePlatforms; 23 23 coreutils = nativePlatforms; 24 + haskell.packages.ghcHEAD.hello = nativePlatforms; 25 + haskell.packages.ghc822.hello = nativePlatforms; 24 26 }; 25 27 26 28 linuxCommon = lib.recursiveUpdate gnuCommon { ··· 119 121 mpg123 = nativePlatforms; 120 122 }); 121 123 124 + /* Linux on Aarch64 (TODO make android for real) */ 125 + android = mapTestOnCross lib.systems.examples.aarch64-multiplatform (linuxCommon // { 126 + }); 122 127 123 128 /* Cross-built bootstrap tools for every supported platform */ 124 129 bootstrapTools = let