From 86ca043152ed4324bd313a0fa64efcd84914f595 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Tue, 27 Feb 2018 09:46:47 +0800 Subject: [PATCH 01/44] check if stdenv isDarwin, not if targetPlatform isDarwin this will break when cross compiling where targetPlatform might be something that's not darwin, however the build host is actually darwin. --- pkgs/os-specific/darwin/cctools/port.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/os-specific/darwin/cctools/port.nix b/pkgs/os-specific/darwin/cctools/port.nix index d8abdc2c6f843..6c2c24e9311c5 100644 --- a/pkgs/os-specific/darwin/cctools/port.nix +++ b/pkgs/os-specific/darwin/cctools/port.nix @@ -21,6 +21,8 @@ let "${targetPlatform.config}-"; in +assert stdenv.isDarwin; + # Non-Darwin alternatives assert (!hostPlatform.isDarwin) -> (maloader != null && xctoolchain != null); From 6bed1f6edafd39c89328ec7423fdf96a470a9ece Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Tue, 27 Feb 2018 09:47:41 +0800 Subject: [PATCH 02/44] Drop targetPlatform == hostPlatform assert This is triggered during the check validity phase when cross compiling. When it is perfectly fine to use the binary package on the build machine. --- pkgs/development/compilers/ghc/8.2.1-binary.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/ghc/8.2.1-binary.nix b/pkgs/development/compilers/ghc/8.2.1-binary.nix index c88d2a8685a6b..d912fcf0096ff 100644 --- a/pkgs/development/compilers/ghc/8.2.1-binary.nix +++ b/pkgs/development/compilers/ghc/8.2.1-binary.nix @@ -4,7 +4,7 @@ }: # Prebuilt only does native -assert stdenv.targetPlatform == stdenv.hostPlatform; +# assert stdenv.targetPlatform == stdenv.hostPlatform; let libPath = stdenv.lib.makeLibraryPath ([ From 9919e6a1bec9e34320fd7d55c5b1270d6b9888d8 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Thu, 1 Mar 2018 13:35:48 +0800 Subject: [PATCH 03/44] use custom package database Adapted from https://github.com/obsidiansystems/nixpkgs/commit/b69f420121120433220c568e4b35ade539ef60f2 by @Ericson2314 --- .../haskell-modules/generic-builder.nix | 33 +++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 3ab77c42cbbad..7ffa21d60ed19 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -232,7 +232,10 @@ stdenv.mkDerivation ({ packageConfDir="$TMPDIR/package.conf.d" mkdir -p $packageConfDir - + '' + (optionalString (isCross && setupHaskellDepends != []) '' + setupPackageConfDir="$TMPDIR/setup-package.conf.d" + mkdir -p $setupPackageConfDir + '') + '' setupCompileFlags="${concatStringsSep " " setupCompileFlags}" configureFlags="${concatStringsSep " " defaultConfigureFlags} $configureFlags" @@ -268,6 +271,28 @@ stdenv.mkDerivation ({ for f in "$packageConfDir/"*.conf; do sed -i "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," $f done + '') + (optionalString (isCross && setupHaskellDepends != []) '' + # Note: We'll iterate only over pkgsHostTarget, as pkgsHostHost contain + # packages that are not build-host specific. I (@angerman) see + # for example in pkgsHostHost: libiconv-x86_64-pc-mingw32 and libiconv-osx-10.11.6 + # at the same time. + # + # We build the Setup.hs on the *build* machine, and as such should only add + # dependencies for the build machine. + # + for p in "''${pkgsHostTarget[@]}"; do + if [ -d "$p/lib/${nativeGhc.name}/package.conf.d" ]; then + cp -f "$p/lib/${nativeGhc.name}/package.conf.d/"*.conf $setupPackageConfDir/ + continue + fi + if [ -d "$p/include" ]; then + setupConfigureFlags+=" --extra-include-dirs=$p/include" + fi + if [ -d "$p/lib" ]; then + setupConfigureFlags+=" --extra-lib-dirs=$p/lib" + fi + done + ${nativeGhcCommand}-pkg --${packageDbFlag}="$setupPackageConfDir" recache '') + '' ${ghcCommand}-pkg --${packageDbFlag}="$packageConfDir" recache @@ -282,7 +307,11 @@ stdenv.mkDerivation ({ done echo setupCompileFlags: $setupCompileFlags - ${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i + ${optionalString (isCross && setupHaskellDepends != []) + '' + echo GHC_PACKAGE_PATH="$setupPackageConfDir:" + GHC_PACKAGE_PATH="$setupPackageConfDir:" '' + }${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i runHook postCompileBuildDriver ''; From df2bbe0461695aa9adfc2f84964f60df601d7403 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Thu, 1 Mar 2018 13:57:17 +0800 Subject: [PATCH 04/44] parameterize buildMK; allow ghcFlavour to be overridden. --- pkgs/development/compilers/ghc/head.nix | 26 +++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index 7e1c73d166a23..c069e6eeeb6de 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -15,16 +15,26 @@ , # If enabled, GHC will be built with the GPL-free but slower integer-simple # library instead of the faster but GPLed integer-gmp library. - enableIntegerSimple ? false, gmp ? null + enableIntegerSimple ? targetPlatform != hostPlatform, gmp ? null , # If enabled, use -fPIC when compiling static libs. enableRelocatedStaticLibs ? targetPlatform != hostPlatform , # Whether to build dynamic libs for the standard library (on the target # platform). Static libs are always built. - enableShared ? !targetPlatform.useAndroidPrebuilt + # + # We don't do this by default if target != host, or if we target windows. + enableShared ? (targetPlatform == hostPlatform && !targetPlatform.isWindows && !targetPlatform.useAndroidPrebuilt) + +, # Whetherto build terminfo. + enableTerminfo ? !targetPlatform.isWindows , version ? "8.5.20180118" +, ghcRevision ? "e1d4140be4d2a1508015093b69e1ef53516e1eb6" +, ghcSha256 ? "1gdcr10dd968d40qgljdwx9vfkva3yrvjm9a4nis7whaaac3ag58" +, ghcFlavour ? "" +, ghcCrossFlavour ? "perf-cross" +, ghcDiffs ? [] }: assert !enableIntegerSimple -> gmp != null; @@ -38,11 +48,14 @@ let "${targetPlatform.config}-"; buildMK = '' + BuildFlavour = ${if targetPlatform != hostPlatform then ghcCrossFlavour else ghcFlavour} + ifneq \"\$(BuildFlavour)\" \"\" + include mk/flavours/\$(BuildFlavour).mk + endif DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} '' + stdenv.lib.optionalString enableIntegerSimple '' INTEGER_LIBRARY = integer-simple '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' - BuildFlavour = perf-cross Stage1Only = YES HADDOCK_DOCS = NO BUILD_SPHINX_HTML = NO @@ -54,8 +67,9 @@ let EXTRA_CC_OPTS += -std=gnu99 ''; + # Splicer will pull out correct variations - libDeps = platform: [ ncurses ] + libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] ++ stdenv.lib.optional (!enableIntegerSimple) gmp ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; @@ -75,8 +89,8 @@ stdenv.mkDerivation rec { src = fetchgit { url = "git://git.haskell.org/ghc.git"; - rev = "e1d4140be4d2a1508015093b69e1ef53516e1eb6"; - sha256 = "1gdcr10dd968d40qgljdwx9vfkva3yrvjm9a4nis7whaaac3ag58"; + rev = "${ghcRevision}"; + sha256 = "${ghcSha256}"; }; enableParallelBuilding = true; From 9351258e3fcbc0484f9585a45e63401396dd438d Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sat, 3 Mar 2018 20:37:28 +0800 Subject: [PATCH 05/44] Hardcode the sourceforge mirror, while sourceforge is down. --- pkgs/os-specific/windows/mingw-w64/common.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/os-specific/windows/mingw-w64/common.nix b/pkgs/os-specific/windows/mingw-w64/common.nix index 102d9489fe9ff..2e6e3834b0462 100644 --- a/pkgs/os-specific/windows/mingw-w64/common.nix +++ b/pkgs/os-specific/windows/mingw-w64/common.nix @@ -5,7 +5,7 @@ rec { name = "mingw-w64-${version}"; src = fetchurl { - url = "mirror://sourceforge/mingw-w64/mingw-w64-v${version}.tar.bz2"; + url = "http://cfhcable.dl.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v${version}.tar.bz2"; sha256 = "1d4wrjfdlq5xqpv9zg6ssw4lm8jnv6522xf7d6zbjygmkswisq1a"; }; From bd294f25febeffbf0759538b481d68b77baf9ffa Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Mon, 5 Mar 2018 21:34:31 +0800 Subject: [PATCH 06/44] Fix /bin/haddock not found. Only paxmark `haddock` if it was built (not all configuration build haddock). --- pkgs/development/compilers/ghc/head.nix | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index c069e6eeeb6de..50cb6258df230 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -155,7 +155,7 @@ stdenv.mkDerivation rec { # masss-rebuild. crossConfig = true; - nativeBuildInputs = [ ghc perl autoconf automake happy alex python3 ]; + nativeBuildInputs = [ ghc perl autoconf automake happy alex python3 m4 ]; # For building runtime libs depsBuildTarget = toolsForTarget; @@ -177,7 +177,11 @@ stdenv.mkDerivation rec { # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't # treat that as a unary `{x,y,z,..}` repetition. postInstall = '' - paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} + for f in $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"}; do + if [ -f $f ]; then + paxmark m $f + fi + done # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc From 8ab98a09bb9b42d0c71c3e5347d6f73688392d3d Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Mon, 5 Mar 2018 21:40:49 +0800 Subject: [PATCH 07/44] import m4 --- pkgs/development/compilers/ghc/head.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index 50cb6258df230..feb48601f1348 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -3,7 +3,7 @@ # build-tools , bootPkgs, alex, happy -, autoconf, automake, coreutils, fetchgit, perl, python3 +, autoconf, automake, coreutils, fetchgit, perl, python3, m4 , libffi, libiconv ? null, ncurses From 8b8a23837debb3ed7438548c8a2708b1eff598da Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sun, 11 Mar 2018 17:13:25 +0800 Subject: [PATCH 08/44] Adds `doVerbose` to the generic haskell builder --- pkgs/development/haskell-modules/generic-builder.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 7ffa21d60ed19..f88b55e0ac9b5 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -22,6 +22,7 @@ in , description ? "" , doCheck ? !isCross && (stdenv.lib.versionOlder "7.4" ghc.version) , doBenchmark ? false +, doVerbose ? false , doHoogle ? true , editedCabalFile ? null , enableLibraryProfiling ? true @@ -339,7 +340,7 @@ stdenv.mkDerivation ({ buildPhase = '' runHook preBuild - ${setupCommand} build ${buildTarget}${crossCabalFlagsString} + ${setupCommand} build ${buildTarget}${crossCabalFlagsString}${optionalString doVerbose " -v3"} runHook postBuild ''; From 5ddaf0c858b6cda44dd0b556bc11b30e50b8e3e8 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sat, 17 Mar 2018 14:42:28 +0800 Subject: [PATCH 09/44] Doe the `links` dance only if shared is enabled. --- pkgs/development/haskell-modules/generic-builder.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index f88b55e0ac9b5..248d7638a6647 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -257,7 +257,7 @@ stdenv.mkDerivation ({ # only use the links hack if we're actually building dylibs. otherwise, the # "dynamic-library-dirs" point to nonexistent paths, and the ln command becomes # "ln -s $out/lib/links", which tries to recreate the links dir and fails - + (optionalString (stdenv.isDarwin && enableSharedLibraries) '' + + (optionalString (stdenv.isDarwin && (enableSharedLibraries || enableSharedExecutables)) '' # Work around a limit in the macOS Sierra linker on the number of paths # referenced by any one dynamic library: # From 91db81cb5e4bbcf74bfee5a8103d5cda9a2cad80 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sat, 17 Mar 2018 16:55:39 +0800 Subject: [PATCH 10/44] Adds buildFlags logic --- pkgs/development/haskell-modules/generic-builder.nix | 5 ++++- pkgs/development/haskell-modules/lib.nix | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 248d7638a6647..cb9726e789b47 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -19,6 +19,7 @@ in , buildTarget ? "" , buildTools ? [], libraryToolDepends ? [], executableToolDepends ? [], testToolDepends ? [], benchmarkToolDepends ? [] , configureFlags ? [] +, buildFlags ? [] , description ? "" , doCheck ? !isCross && (stdenv.lib.versionOlder "7.4" ghc.version) , doBenchmark ? false @@ -127,6 +128,8 @@ let crossCabalFlagsString = stdenv.lib.optionalString isCross (" " + stdenv.lib.concatStringsSep " " crossCabalFlags); + buildFlagsString = optionalString (buildFlags != []) (" " + concatStringsSep " " buildFlags); + defaultConfigureFlags = [ "--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid" (optionalString enableSeparateDataOutput "--datadir=$data/share/${ghc.name}") @@ -340,7 +343,7 @@ stdenv.mkDerivation ({ buildPhase = '' runHook preBuild - ${setupCommand} build ${buildTarget}${crossCabalFlagsString}${optionalString doVerbose " -v3"} + ${setupCommand} build ${buildTarget}${crossCabalFlagsString}${buildFlagsString}${optionalString doVerbose " -v3"} runHook postBuild ''; diff --git a/pkgs/development/haskell-modules/lib.nix b/pkgs/development/haskell-modules/lib.nix index ff86e06979c1d..fedb0fa8de836 100644 --- a/pkgs/development/haskell-modules/lib.nix +++ b/pkgs/development/haskell-modules/lib.nix @@ -131,6 +131,8 @@ rec { */ appendConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = (drv.configureFlags or []) ++ [x]; }); + appendBuildFlag = drv: x: overrideCabal drv (drv: { buildFlags = (drv.buildFlags or []) ++ [x]; }); + appendBuildFlags = drv: xs: overrideCabal drv (drv: { buildFlags = (drv.buildFlags or []) ++ xs; }); /* removeConfigureFlag drv x is a Haskell package like drv, but with all cabal configure arguments that are equal to x removed. From be83b84956e97b7f4bd1b888c694b1815659e234 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Mon, 19 Mar 2018 10:23:23 +0800 Subject: [PATCH 11/44] cleanup --- pkgs/os-specific/windows/pthread-w32/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/os-specific/windows/pthread-w32/default.nix b/pkgs/os-specific/windows/pthread-w32/default.nix index ef42dadc2973a..1813afad3be63 100644 --- a/pkgs/os-specific/windows/pthread-w32/default.nix +++ b/pkgs/os-specific/windows/pthread-w32/default.nix @@ -1,7 +1,7 @@ { fetchurl, stdenv, mingw_header, hostPlatform, buildPlatform }: # This file is tweaked for cross-compilation only. -assert hostPlatform != buildPlatform; +assert stdenv.hostPlatform != stdenv.buildPlatform; stdenv.mkDerivation { name = "pthread-w32-1.10.0"; From 7fd694acdd8a2cbec2f92a2280e4dd887c1b2067 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Mon, 19 Mar 2018 10:24:11 +0800 Subject: [PATCH 12/44] Revert "[cctools] check if stdenv isDarwin, not if targetPlatform isDarwin" This reverts commit 4b6c9232b6e6b8fcfc27bf601bbeb9e3aea91818. --- pkgs/os-specific/darwin/cctools/port.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/os-specific/darwin/cctools/port.nix b/pkgs/os-specific/darwin/cctools/port.nix index 6c2c24e9311c5..4637a74187cf5 100644 --- a/pkgs/os-specific/darwin/cctools/port.nix +++ b/pkgs/os-specific/darwin/cctools/port.nix @@ -21,7 +21,7 @@ let "${targetPlatform.config}-"; in -assert stdenv.isDarwin; +assert targetPlatform.isDarwin; # Non-Darwin alternatives assert (!hostPlatform.isDarwin) -> (maloader != null && xctoolchain != null); From 84017d054e5f657c4f666976dee8e4baf13886c6 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Mon, 19 Mar 2018 10:24:12 +0800 Subject: [PATCH 13/44] Revert "[ghc] Drop targetPlatform == hostPlatform assert" This reverts commit 4dac9189b82fefe0176df9b8bc98f549474e1136. --- pkgs/development/compilers/ghc/8.2.1-binary.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/ghc/8.2.1-binary.nix b/pkgs/development/compilers/ghc/8.2.1-binary.nix index d912fcf0096ff..c88d2a8685a6b 100644 --- a/pkgs/development/compilers/ghc/8.2.1-binary.nix +++ b/pkgs/development/compilers/ghc/8.2.1-binary.nix @@ -4,7 +4,7 @@ }: # Prebuilt only does native -# assert stdenv.targetPlatform == stdenv.hostPlatform; +assert stdenv.targetPlatform == stdenv.hostPlatform; let libPath = stdenv.lib.makeLibraryPath ([ From f932e96bb5bc373077a9e9606c48df642af46652 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Thu, 22 Mar 2018 07:30:19 +0800 Subject: [PATCH 14/44] more verbose logic. --- pkgs/development/haskell-modules/generic-builder.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index cb9726e789b47..8744123de1219 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -228,7 +228,10 @@ stdenv.mkDerivation ({ ${jailbreak-cabal}/bin/jailbreak-cabal ${pname}.cabal '' + postPatch; - setupCompilerEnvironmentPhase = '' + setupCompilerEnvironmentPhase = + (optionalString doVerbose '' + set -x + '') + '' runHook preSetupCompilerEnvironment echo "Build with ${ghc}." @@ -315,7 +318,7 @@ stdenv.mkDerivation ({ '' echo GHC_PACKAGE_PATH="$setupPackageConfDir:" GHC_PACKAGE_PATH="$setupPackageConfDir:" '' - }${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i + }${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i${optionalString doVerbose " -v3"} runHook postCompileBuildDriver ''; From 224392f36328dedb1c304f12a35784745e32e101 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Thu, 22 Mar 2018 07:31:01 +0800 Subject: [PATCH 15/44] stdenv.isDarwin -> hostplatform.isDarwin --- pkgs/development/interpreters/python/cpython/2.7/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/interpreters/python/cpython/2.7/default.nix b/pkgs/development/interpreters/python/cpython/2.7/default.nix index 98e5b4b1da0e7..7f116e3230cb9 100644 --- a/pkgs/development/interpreters/python/cpython/2.7/default.nix +++ b/pkgs/development/interpreters/python/cpython/2.7/default.nix @@ -153,7 +153,7 @@ let ++ optional hostPlatform.isCygwin expat ++ [ db gdbm ncurses sqlite readline ] ++ optionals x11Support [ tcl tk xlibsWrapper libX11 ] - ++ optionals stdenv.isDarwin ([ CF ] ++ optional (configd != null) configd); + ++ optionals hostPlatform.isDarwin ([ CF ] ++ optional (configd != null) configd); nativeBuildInputs = optionals (hostPlatform != buildPlatform) [ buildPackages.stdenv.cc buildPackages.python ]; From 3992ea9ae5eb69e2eeb3a8ed9df1e4aeab1ae4bf Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sun, 25 Mar 2018 11:43:18 +0800 Subject: [PATCH 16/44] Do not enable stm without enabling haskeline Otherwise we'll end up with inconsistent dependencies. - haskeline -> stm (1), as shipped with GHC. - ... -> stm (2), as built with nix. (1) /= (2) => cabal complains. --- pkgs/development/haskell-modules/configuration-ghc-head.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/configuration-ghc-head.nix b/pkgs/development/haskell-modules/configuration-ghc-head.nix index 99003102ec584..1fa4b6b2344fa 100644 --- a/pkgs/development/haskell-modules/configuration-ghc-head.nix +++ b/pkgs/development/haskell-modules/configuration-ghc-head.nix @@ -24,6 +24,8 @@ self: super: { ghc-prim = null; ghci = null; haskeline = null; + stm = null; + hoopl = null; hpc = null; integer-gmp = null; @@ -92,5 +94,6 @@ self: super: { test-framework = doJailbreak super.test-framework; atomic-primops = doJailbreak (appendPatch super.atomic-primops ./patches/atomic-primops-Cabal-1.25.patch); hashable = doJailbreak super.hashable; - stm = doJailbreak super.stm; +# haskeline = doJailbreak super.haskeline; +# stm = doJailbreak super.stm; } From 1f1de5b189c8325c3c27f05332c8b13429b2e46e Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sun, 25 Mar 2018 11:43:29 +0800 Subject: [PATCH 17/44] allow all platforms. --- pkgs/development/libraries/libyaml/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/libyaml/default.nix b/pkgs/development/libraries/libyaml/default.nix index e441d1e6b6150..20053190e3bc9 100644 --- a/pkgs/development/libraries/libyaml/default.nix +++ b/pkgs/development/libraries/libyaml/default.nix @@ -14,7 +14,7 @@ stdenv.mkDerivation { homepage = http://pyyaml.org/; description = "A YAML 1.1 parser and emitter written in C"; license = licenses.mit; - platforms = platforms.unix; + platforms = platforms.all; maintainers = with maintainers; [ wkennington ]; }; } From 6c7fb304c7c426f8e36a7e0001b25df1537e8f88 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sun, 25 Mar 2018 11:43:46 +0800 Subject: [PATCH 18/44] Adds custom Setup derivation. --- pkgs/development/haskell-modules/setup.nix | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 pkgs/development/haskell-modules/setup.nix diff --git a/pkgs/development/haskell-modules/setup.nix b/pkgs/development/haskell-modules/setup.nix new file mode 100644 index 0000000000000..ec7cf17acf0a1 --- /dev/null +++ b/pkgs/development/haskell-modules/setup.nix @@ -0,0 +1,42 @@ +# This is the generic `Setup` installer for haskell packages. +# +# For now we just build the `Setup.hs` against the +{ stdenv, ghc, lib }: +{ setupHaskellDepends ? [] +, setupHs ? '' + import Distribution.Simple + main = defaultMain +'' +} @ args: +stdenv.mkDerivation (rec { + name = "Setup"; + + phases = [ "buildPhase" ]; + + buildInputs = [ ghc ] ++ setupHaskellDepends; + LANG = "en_US.UTF-8"; + + # build up the package database, with the additional dependencies + preBuild = '' + setupPackageConfDir="$TMPDIR/setup-package.conf.d" + mkdir -p "$setupPackageConfDir" + + # Add the setupHaskellDepends to a custom package-db, + # which ghc will be provided with. + + for p in ${lib.escapeShellArgs setupHaskellDepends}; do + if [ -d "$p/lib/${ghc.name}/package.conf.d" ]; then + cp -f "$p/lib/${ghc.name}/package.conf.d/"*.conf $setupPackageConfDir/ + fi + done + ${ghc.targetPrefix}ghc-pkg --package-db="$setupPackageConfDir" recache + ''; + + buildPhase = '' + runHook preBuild + echo "$setupPackageConfDir" + mkdir -p $out + GHC_PACKAGE_PATH="$setupPackageConfDir:" ghc --make -o $out/Setup -odir $TMPDIR -hidir $TMPDIR ${builtins.toFile "Setup.hs" setupHs} + runHook postBuild + ''; +}) From 2a8ded3620ad057456756cd315284638a91e2ab0 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sun, 25 Mar 2018 11:44:09 +0800 Subject: [PATCH 19/44] use/provide setup in package sets. --- pkgs/development/haskell-modules/make-package-set.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/make-package-set.nix b/pkgs/development/haskell-modules/make-package-set.nix index bde4f85f67846..1d5d57767a8a7 100644 --- a/pkgs/development/haskell-modules/make-package-set.nix +++ b/pkgs/development/haskell-modules/make-package-set.nix @@ -40,6 +40,11 @@ let inherit (stdenv.lib) fix' extends makeOverridable; inherit (haskellLib) overrideCabal; + setupImpl = pkgs.callPackage ./setup.nix { + inherit stdenv; + inherit (self) ghc; + }; + mkDerivationImpl = pkgs.callPackage ./generic-builder.nix { inherit stdenv; nodejs = buildPackages.nodejs-slim; @@ -66,6 +71,8 @@ let }; mkDerivation = makeOverridable mkDerivationImpl; + setup = makeOverridable setupImpl; + # manualArgs are the arguments that were explictly passed to `callPackage`, like: # @@ -151,7 +158,7 @@ let in package-set { inherit pkgs stdenv callPackage; } self // { - inherit mkDerivation callPackage haskellSrc2nix hackage2nix; + inherit mkDerivation setup callPackage haskellSrc2nix hackage2nix; inherit (haskellLib) packageSourceOverrides; From 56d28ed9c6f3f057c56badb2ba3a8813fdba847d Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sun, 25 Mar 2018 11:48:33 +0800 Subject: [PATCH 20/44] use Setup derivation when cross compiling. --- .../haskell-modules/generic-builder.nix | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 8744123de1219..0e3192ae38fe2 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -186,7 +186,21 @@ let ghcEnv = ghc.withPackages (p: haskellBuildInputs); - setupCommand = "./Setup"; + simpleSetup = buildHaskellPackages.setup {}; + configureSetup = buildHaskellPackages.setup { setupHs = '' + import Distribution.Simple + main = defaultMainWithHooks autoconfUserHooks +''; +}; + + setupCommand = if isCross then '' + if [ -f configure ]; then + HS_SETUP=${configureSetup} + else + HS_SETUP=${simpleSetup} + fi + $HS_SETUP/Setup'' + else "./Setup"; ghcCommand' = if isGhcjs then "ghcjs" else "ghc"; ghcCommand = "${ghc.targetPrefix}${ghcCommand'}"; @@ -207,7 +221,11 @@ stdenv.mkDerivation ({ pos = builtins.unsafeGetAttrPos "pname" args; prePhases = ["setupCompilerEnvironmentPhase"]; - preConfigurePhases = ["compileBuildDriverPhase"]; + + # when cross compiling, we only support Simple or Configure build-types. + # Custom build-types are silently ignored! Hence we use the Setup + # derivations and don't need the compileBuildDriverPhase. + preConfigurePhases = optionals (!isCross) ["compileBuildDriverPhase"]; preInstallPhases = ["haddockPhase"]; inherit src; @@ -278,28 +296,6 @@ stdenv.mkDerivation ({ for f in "$packageConfDir/"*.conf; do sed -i "s,dynamic-library-dirs: .*,dynamic-library-dirs: $dynamicLinksDir," $f done - '') + (optionalString (isCross && setupHaskellDepends != []) '' - # Note: We'll iterate only over pkgsHostTarget, as pkgsHostHost contain - # packages that are not build-host specific. I (@angerman) see - # for example in pkgsHostHost: libiconv-x86_64-pc-mingw32 and libiconv-osx-10.11.6 - # at the same time. - # - # We build the Setup.hs on the *build* machine, and as such should only add - # dependencies for the build machine. - # - for p in "''${pkgsHostTarget[@]}"; do - if [ -d "$p/lib/${nativeGhc.name}/package.conf.d" ]; then - cp -f "$p/lib/${nativeGhc.name}/package.conf.d/"*.conf $setupPackageConfDir/ - continue - fi - if [ -d "$p/include" ]; then - setupConfigureFlags+=" --extra-include-dirs=$p/include" - fi - if [ -d "$p/lib" ]; then - setupConfigureFlags+=" --extra-lib-dirs=$p/lib" - fi - done - ${nativeGhcCommand}-pkg --${packageDbFlag}="$setupPackageConfDir" recache '') + '' ${ghcCommand}-pkg --${packageDbFlag}="$packageConfDir" recache From dcb0cb83957a97cb2edaeca044cd3606c4cc7703 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sun, 25 Mar 2018 11:49:43 +0800 Subject: [PATCH 21/44] do not add nativeGhc to the buildInputs For cross compilation, we don't need it, it's deferred to the Setup derivation. When ghc is th enativeGhc, we don't need to add it to the buildInputs either. --- pkgs/development/haskell-modules/generic-builder.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 0e3192ae38fe2..4d60cd09b3613 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -172,7 +172,8 @@ let allPkgconfigDepends = pkgconfigDepends ++ libraryPkgconfigDepends ++ executablePkgconfigDepends ++ optionals doCheck testPkgconfigDepends ++ optionals doBenchmark benchmarkPkgconfigDepends; - nativeBuildInputs = [ ghc nativeGhc removeReferencesTo ] ++ optional (allPkgconfigDepends != []) pkgconfig ++ + nativeBuildInputs = [ ghc removeReferencesTo ] ++ optional (!isCross && ghc != nativeGhc) nativeGhc + ++ optional (allPkgconfigDepends != []) pkgconfig ++ buildTools ++ libraryToolDepends ++ executableToolDepends; propagatedBuildInputs = buildDepends ++ libraryHaskellDepends ++ executableHaskellDepends; otherBuildInputs = setupHaskellDepends ++ extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++ From fcb8be545da943f00489226e210ec94910331a73 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sun, 25 Mar 2018 13:25:02 +0800 Subject: [PATCH 22/44] no -staticlib for windows. --- pkgs/development/haskell-modules/generic-builder.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 4d60cd09b3613..d52a02b88d9d1 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -146,7 +146,9 @@ let (enableFeature enableExecutableProfiling (if versionOlder ghc.version "8" then "executable-profiling" else "profiling")) (enableFeature enableSharedLibraries "shared") (optionalString (versionAtLeast ghc.version "7.10") (enableFeature doCoverage "coverage")) - (optionalString (versionOlder "8.4" ghc.version) (enableFeature enableStaticLibraries "static")) + # --enable-static does not work on windows. This is a bug in GHC. + # --enable-static will pass -staticlib to ghc, which only works for mach-o and elf. + (optionalString (!hostPlatform.isWindows && versionOlder "8.4" ghc.version) (enableFeature enableStaticLibraries "static")) (optionalString (isGhcjs || versionOlder "7.4" ghc.version) (enableFeature enableSharedExecutables "executable-dynamic")) (optionalString (isGhcjs || versionOlder "7" ghc.version) (enableFeature doCheck "tests")) "--enable-library-vanilla" # TODO: Should this be configurable? From cd793491c2746d0e80106fe6cb78e2cdf13b7361 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Mon, 26 Mar 2018 14:44:57 +0800 Subject: [PATCH 23/44] Adds more asserts --- .../package-management/nix-prefetch-scripts/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/tools/package-management/nix-prefetch-scripts/default.nix b/pkgs/tools/package-management/nix-prefetch-scripts/default.nix index a2ff38ab3004e..f63640d683db7 100644 --- a/pkgs/tools/package-management/nix-prefetch-scripts/default.nix +++ b/pkgs/tools/package-management/nix-prefetch-scripts/default.nix @@ -2,6 +2,13 @@ git, subversion, mercurial, bazaar, cvs, unzip, curl, gnused, coreutils, nix }: +# these scripts should only be run on the build machine +# and as such the target and host for these scripts should +# be identical. +assert stdenv.targetPlatform == stdenv.hostPlatform; +# these scripts are also only supported on Linux and Darwin +assert stdenv.targetPlatform.isUnix; + let mkPrefetchScript = tool: src: deps: stdenv.mkDerivation { name = "nix-prefetch-${tool}"; From 2276ff8ab36c6fcd445a8418d214e6bbefd7636d Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Mon, 26 Mar 2018 14:45:11 +0800 Subject: [PATCH 24/44] more logging. --- pkgs/development/haskell-modules/generic-builder.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index d52a02b88d9d1..a781a2d2fca3e 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -269,8 +269,10 @@ stdenv.mkDerivation ({ # host.*Pkgs defined in stdenv/setup.hs for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do - if [ -d "$p/lib/${ghc.name}/package.conf.d" ]; then - cp -f "$p/lib/${ghc.name}/package.conf.d/"*.conf $packageConfDir/ + ${optionalString doVerbose '' + echo $p + ''}if [ -d "$p/lib/${ghc.targetPrefix}${ghc.name}/package.conf.d" ]; then + cp -f "$p/lib/${ghc.targetPrefix}${ghc.name}/package.conf.d/"*.conf $packageConfDir/ continue fi if [ -d "$p/include" ]; then From 55f320f0632174678d084121eee6e8c21c5516fc Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Mon, 26 Mar 2018 14:57:15 +0800 Subject: [PATCH 25/44] Revert incorrect naming. --- pkgs/development/haskell-modules/generic-builder.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index a781a2d2fca3e..2d966af47adeb 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -271,8 +271,9 @@ stdenv.mkDerivation ({ for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do ${optionalString doVerbose '' echo $p - ''}if [ -d "$p/lib/${ghc.targetPrefix}${ghc.name}/package.conf.d" ]; then - cp -f "$p/lib/${ghc.targetPrefix}${ghc.name}/package.conf.d/"*.conf $packageConfDir/ + echo $p/lib/${ghc.name}/package.conf.d + ''}if [ -d "$p/lib/${ghc.name}/package.conf.d" ]; then + cp -f "$p/lib/${ghc.name}/package.conf.d/"*.conf $packageConfDir/ continue fi if [ -d "$p/include" ]; then From 5666ec858ebe4bc806de40912b91d21a3aba73c0 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Mon, 26 Mar 2018 14:57:30 +0800 Subject: [PATCH 26/44] Use buildpackages for nix and nix-prefetch-scripts --- pkgs/top-level/all-packages.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 66bdda119d0be..7cdb5bdcf41d5 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -940,8 +940,8 @@ with pkgs; install -D $out/bin/${drv.pname} $exe rm -rf $out/{bin,lib,share} makeWrapper $exe $out/bin/${drv.pname} \ - --prefix PATH ":" "${nix}/bin" \ - --prefix PATH ":" "${nix-prefetch-scripts}/bin" + --prefix PATH ":" "${buildPackages.nix}/bin" \ + --prefix PATH ":" "${buildPackages.nix-prefetch-scripts}/bin" mkdir -p $out/share/{bash-completion/completions,zsh/vendor-completions,fish/completions} $exe --bash-completion-script $exe >$out/share/bash-completion/completions/${drv.pname} $exe --zsh-completion-script $exe >$out/share/zsh/vendor-completions/_${drv.pname} From a30250552d38ef8172c003d7a45d77d10ef40062 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Mon, 26 Mar 2018 14:57:56 +0800 Subject: [PATCH 27/44] used stdenv.targetPlatform.isDarwin and not stdenv.isDarwin. --- pkgs/development/haskell-modules/configuration-nix.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/haskell-modules/configuration-nix.nix b/pkgs/development/haskell-modules/configuration-nix.nix index 469b249010fa6..2f1eb1ad97a86 100644 --- a/pkgs/development/haskell-modules/configuration-nix.nix +++ b/pkgs/development/haskell-modules/configuration-nix.nix @@ -128,7 +128,7 @@ self: super: builtins.intersectAttrs super { # Prevents needing to add security_tool as a build tool to all of x509-system's # dependencies. - x509-system = if pkgs.stdenv.isDarwin && !pkgs.stdenv.cc.nativeLibc + x509-system = if pkgs.stdenv.targetPlatform.isDarwin && !pkgs.stdenv.cc.nativeLibc then let inherit (pkgs.darwin) security_tool; in pkgs.lib.overrideDerivation (addBuildDepend super.x509-system security_tool) (drv: { postPatch = (drv.postPatch or "") + '' From 093afd83b25cdd7af6e7f2fddcbab70373d255ac Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Wed, 28 Mar 2018 07:51:50 +0800 Subject: [PATCH 28/44] fix python27 --- pkgs/top-level/all-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7cdb5bdcf41d5..ddad8a19a7386 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7294,7 +7294,7 @@ with pkgs; python27 = callPackage ../development/interpreters/python/cpython/2.7 { self = python27; - inherit (darwin) CF configd; + inherit (buildPackages.darwin) CF configd; }; python34 = callPackage ../development/interpreters/python/cpython/3.4 { inherit (darwin) CF configd; From d050c020e3f460f281f9af453f5817f9b93e6392 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Thu, 3 May 2018 13:54:00 +0800 Subject: [PATCH 29/44] Drop `libiconv` on windows. nixpkgs#37012 and nixpkgs#37707 introduces the setup-hooks for libiconv, which inject `-liconv` into the `NIX_LDFLAGS`. This breaks horribly on windows where the linker end up having no idea how to linke `-liconv`. The configure.ac file specifically ignores libiconv on windows. --- pkgs/development/compilers/ghc/head.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index feb48601f1348..b6f6bac1ce704 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -71,7 +71,7 @@ let # Splicer will pull out correct variations libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] ++ stdenv.lib.optional (!enableIntegerSimple) gmp - ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; + ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; toolsForTarget = if hostPlatform == buildPlatform then @@ -137,7 +137,7 @@ stdenv.mkDerivation rec { "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [ "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" - ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [ + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ "--enable-bootstrap-with-devel-snapshot" From ca6cf4a6375d44ba817218e9e7687eace907ca9d Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Wed, 9 May 2018 12:06:39 +0800 Subject: [PATCH 30/44] WIP --- pkgs/development/compilers/ghc/8.4.2.nix | 24 ++++++++++++++----- pkgs/development/compilers/ghc/head.nix | 6 ++--- .../development/libraries/rocksdb/default.nix | 4 ++-- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/pkgs/development/compilers/ghc/8.4.2.nix b/pkgs/development/compilers/ghc/8.4.2.nix index 94555482d28be..46723448c8618 100644 --- a/pkgs/development/compilers/ghc/8.4.2.nix +++ b/pkgs/development/compilers/ghc/8.4.2.nix @@ -15,7 +15,7 @@ , # If enabled, GHC will be built with the GPL-free but slower integer-simple # library instead of the faster but GPLed integer-gmp library. - enableIntegerSimple ? false, gmp ? null, m4 + enableIntegerSimple ? targetPlatform != hostPlatform, gmp ? null, m4 , # If enabled, use -fPIC when compiling static libs. enableRelocatedStaticLibs ? targetPlatform != hostPlatform @@ -24,7 +24,12 @@ # platform). Static libs are always built. enableShared ? !targetPlatform.useAndroidPrebuilt +, # Whetherto build terminfo. + enableTerminfo ? !targetPlatform.isWindows + , version ? "8.4.2" +, ghcFlavour ? "" +, ghcCrossFlavour ? "perf-cross" }: assert !enableIntegerSimple -> gmp != null; @@ -38,11 +43,14 @@ let "${targetPlatform.config}-"; buildMK = '' + BuildFlavour = ${if targetPlatform != hostPlatform then ghcCrossFlavour else ghcFlavour} + ifneq \"\$(BuildFlavour)\" \"\" + include mk/flavours/\$(BuildFlavour).mk + endif DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} '' + stdenv.lib.optionalString enableIntegerSimple '' INTEGER_LIBRARY = integer-simple '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' - BuildFlavour = perf-cross Stage1Only = YES HADDOCK_DOCS = NO BUILD_SPHINX_HTML = NO @@ -55,9 +63,9 @@ let ''; # Splicer will pull out correct variations - libDeps = platform: [ ncurses ] + libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ] ++ stdenv.lib.optional (!enableIntegerSimple) gmp - ++ stdenv.lib.optional (platform.libc != "glibc") libiconv; + ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv; toolsForTarget = if hostPlatform == buildPlatform then @@ -125,7 +133,7 @@ stdenv.mkDerivation rec { "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [ "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" - ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [ + ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [ "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ "--enable-bootstrap-with-devel-snapshot" @@ -165,7 +173,11 @@ stdenv.mkDerivation rec { # zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't # treat that as a unary `{x,y,z,..}` repetition. postInstall = '' - paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} + for f in $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"}; do + if [ -f $f ]; then + paxmark m $f + fi + done # Install the bash completion file. install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc diff --git a/pkgs/development/compilers/ghc/head.nix b/pkgs/development/compilers/ghc/head.nix index b6f6bac1ce704..d1739e0585cbc 100644 --- a/pkgs/development/compilers/ghc/head.nix +++ b/pkgs/development/compilers/ghc/head.nix @@ -3,7 +3,7 @@ # build-tools , bootPkgs, alex, happy -, autoconf, automake, coreutils, fetchgit, perl, python3, m4 +, autoconf, automake, coreutils, fetchgit, perl, python3 , libffi, libiconv ? null, ncurses @@ -15,7 +15,7 @@ , # If enabled, GHC will be built with the GPL-free but slower integer-simple # library instead of the faster but GPLed integer-gmp library. - enableIntegerSimple ? targetPlatform != hostPlatform, gmp ? null + enableIntegerSimple ? targetPlatform != hostPlatform, gmp ? null, m4 , # If enabled, use -fPIC when compiling static libs. enableRelocatedStaticLibs ? targetPlatform != hostPlatform @@ -155,7 +155,7 @@ stdenv.mkDerivation rec { # masss-rebuild. crossConfig = true; - nativeBuildInputs = [ ghc perl autoconf automake happy alex python3 m4 ]; + nativeBuildInputs = [ ghc perl autoconf automake m4 happy alex python3 ]; # For building runtime libs depsBuildTarget = toolsForTarget; diff --git a/pkgs/development/libraries/rocksdb/default.nix b/pkgs/development/libraries/rocksdb/default.nix index bb36d942a69b8..8c7a99760d973 100644 --- a/pkgs/development/libraries/rocksdb/default.nix +++ b/pkgs/development/libraries/rocksdb/default.nix @@ -30,8 +30,8 @@ stdenv.mkDerivation rec { sha256 = "15x2r7aib1xinwcchl32wghs8g96k4q5xgv6z97mxgp35475x01p"; }; - nativeBuildInputs = [ which perl ]; - buildInputs = [ snappy google-gflags zlib bzip2 lz4 malloc fixDarwinDylibNames ]; + nativeBuildInputs = [ which perl snappy google-gflags ]; + buildInputs = [ zlib bzip2 lz4 malloc fixDarwinDylibNames ]; postPatch = '' # Hack to fix typos From a7f951740058dd619cf4d13bb64ec5db6dd8084b Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Wed, 9 May 2018 03:14:38 -0300 Subject: [PATCH 31/44] fix lz4 cross-build --- pkgs/tools/compression/lz4/default.nix | 2 +- pkgs/tools/compression/lz4/windows.patch | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 pkgs/tools/compression/lz4/windows.patch diff --git a/pkgs/tools/compression/lz4/default.nix b/pkgs/tools/compression/lz4/default.nix index 04c83fa03fcf9..19c54de876ca7 100644 --- a/pkgs/tools/compression/lz4/default.nix +++ b/pkgs/tools/compression/lz4/default.nix @@ -22,7 +22,7 @@ stdenv.mkDerivation rec { doCheck = false; # tests take a very long time checkTarget = "test"; - patches = [ ./install-on-freebsd.patch ] ; + patches = [ ./install-on-freebsd.patch ./windows.patch ] ; postInstall = "rm $out/lib/*.a"; diff --git a/pkgs/tools/compression/lz4/windows.patch b/pkgs/tools/compression/lz4/windows.patch new file mode 100644 index 0000000000000..8d67ded90766b --- /dev/null +++ b/pkgs/tools/compression/lz4/windows.patch @@ -0,0 +1,12 @@ +diff -u -r source-orig/programs/lz4io.c source/programs/lz4io.c +--- source-orig/programs/lz4io.c 2018-05-09 03:06:04.447422696 -0300 ++++ source/programs/lz4io.c 2018-05-09 03:06:21.383557382 -0300 +@@ -66,7 +66,7 @@ + # include /* _setmode, _fileno, _get_osfhandle */ + # if !defined(__DJGPP__) + # define SET_BINARY_MODE(file) { int unused=_setmode(_fileno(file), _O_BINARY); (void)unused; } +-# include /* DeviceIoControl, HANDLE, FSCTL_SET_SPARSE */ ++# include /* DeviceIoControl, HANDLE, FSCTL_SET_SPARSE */ + # define SET_SPARSE_FILE_MODE(file) { DWORD dw; DeviceIoControl((HANDLE) _get_osfhandle(_fileno(file)), FSCTL_SET_SPARSE, 0, 0, 0, 0, &dw, 0); } + # if defined(_MSC_VER) && (_MSC_VER >= 1400) /* Avoid MSVC fseek()'s 2GiB barrier */ + # define fseek _fseeki64 From 3443dd3c7e1a083854f4df5b6ee4c5c307a0634a Mon Sep 17 00:00:00 2001 From: Michael Bishop Date: Wed, 9 May 2018 03:20:35 -0300 Subject: [PATCH 32/44] make rocksdb use cmake (doesnt work) --- pkgs/development/libraries/rocksdb/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/rocksdb/default.nix b/pkgs/development/libraries/rocksdb/default.nix index 8c7a99760d973..1783c51ad32ba 100644 --- a/pkgs/development/libraries/rocksdb/default.nix +++ b/pkgs/development/libraries/rocksdb/default.nix @@ -1,7 +1,7 @@ { stdenv , fetchFromGitHub , fixDarwinDylibNames -, which, perl +, which, perl, cmake # Optional Arguments , snappy ? null, google-gflags ? null, zlib ? null, bzip2 ? null, lz4 ? null @@ -33,6 +33,10 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ which perl snappy google-gflags ]; buildInputs = [ zlib bzip2 lz4 malloc fixDarwinDylibNames ]; + crossAttrs = { + nativeBuildInputs = [ which perl snappy google-gflags cmake ]; + }; + postPatch = '' # Hack to fix typos sed -i 's,#inlcude,#include,g' build_tools/build_detect_platform From 45e425826632eeab7c16970781657609cc78c833 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Wed, 9 May 2018 17:17:07 +0800 Subject: [PATCH 33/44] fix libuv --- pkgs/top-level/all-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index ddad8a19a7386..3cf810f87c988 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -10489,7 +10489,7 @@ with pkgs; else callPackage ../development/libraries/libunwind { }; libuv = callPackage ../development/libraries/libuv { - inherit (darwin.apple_sdk.frameworks) ApplicationServices CoreServices; + inherit (buildPackages.darwin.apple_sdk.frameworks) ApplicationServices CoreServices; }; libv4l = lowPrio (v4l_utils.override { From f4f044fd60556da50c6b9ece7df64d39f2b0fc91 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Wed, 16 May 2018 10:02:14 +0800 Subject: [PATCH 34/44] rocksdb (don't fully work yet...) --- .../development/libraries/rocksdb/default.nix | 86 ++++++++++--------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/pkgs/development/libraries/rocksdb/default.nix b/pkgs/development/libraries/rocksdb/default.nix index 1783c51ad32ba..71b3442409eb1 100644 --- a/pkgs/development/libraries/rocksdb/default.nix +++ b/pkgs/development/libraries/rocksdb/default.nix @@ -1,6 +1,7 @@ { stdenv , fetchFromGitHub , fixDarwinDylibNames +, hostPlatform, lib , which, perl, cmake # Optional Arguments @@ -11,6 +12,7 @@ , jemalloc ? null, gperftools ? null , enableLite ? false +, windows }: let @@ -31,53 +33,57 @@ stdenv.mkDerivation rec { }; nativeBuildInputs = [ which perl snappy google-gflags ]; - buildInputs = [ zlib bzip2 lz4 malloc fixDarwinDylibNames ]; - + buildInputs = [ zlib bzip2 malloc fixDarwinDylibNames ] # lz4 ]; + ++ lib.optional (hostPlatform.libc == "msvcrt") [ windows.mingw_w64_pthreads windows.mingw_w64_headers ]; crossAttrs = { nativeBuildInputs = [ which perl snappy google-gflags cmake ]; }; - postPatch = '' - # Hack to fix typos - sed -i 's,#inlcude,#include,g' build_tools/build_detect_platform - ''; +# cmakeFlags = "-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ "; + cmakeFlags = "-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CXX_FLAGS=-std=c++11 -DCMAKE_CXX_FLAGS=-pthread"; + buildFlags = "rocksdb VERBOSE=1 -j1"; + + # postPatch = '' + # # Hack to fix typos + # sed -i 's,#inlcude,#include,g' build_tools/build_detect_platform + # ''; - # Environment vars used for building certain configurations + # # Environment vars used for building certain configurations PORTABLE = "1"; USE_SSE = "1"; - CMAKE_CXX_FLAGS = "-std=gnu++11"; - JEMALLOC_LIB = stdenv.lib.optionalString (malloc == jemalloc) "-ljemalloc"; - - LIBNAME = "librocksdb${stdenv.lib.optionalString enableLite "_lite"}"; - ${if enableLite then "CXXFLAGS" else null} = "-DROCKSDB_LITE=1"; - - buildAndInstallFlags = [ - "USE_RTTI=1" - "DEBUG_LEVEL=0" - "DISABLE_WARNING_AS_ERROR=1" - ]; - - buildFlags = buildAndInstallFlags ++ [ - "shared_lib" - "static_lib" - ] ++ tools ; - - installFlags = buildAndInstallFlags ++ [ - "INSTALL_PATH=\${out}" - "install-shared" - "install-static" - ]; - - postInstall = '' - # Might eventually remove this when we are confident in the build process - echo "BUILD CONFIGURATION FOR SANITY CHECKING" - cat make_config.mk - mkdir -pv $static/lib/ - mv -vi $out/lib/${LIBNAME}.a $static/lib/ - - install -d ''${!outputBin}/bin - install -D ${stdenv.lib.concatStringsSep " " tools} ''${!outputBin}/bin - ''; + #CMAKE_CXX_FLAGS = "-std=c++11 -pthread -pthreads"; + # JEMALLOC_LIB = stdenv.lib.optionalString (malloc == jemalloc) "-ljemalloc"; + + # LIBNAME = "librocksdb${stdenv.lib.optionalString enableLite "_lite"}"; + # ${if enableLite then "CXXFLAGS" else null} = "-DROCKSDB_LITE=1"; + + # buildAndInstallFlags = [ + # "USE_RTTI=1" + # "DEBUG_LEVEL=0" + # "DISABLE_WARNING_AS_ERROR=1" + # ]; + + # buildFlags = buildAndInstallFlags ++ [ + # "shared_lib" + # "static_lib" + # ] ++ tools ; + + # installFlags = buildAndInstallFlags ++ [ + # "INSTALL_PATH=\${out}" + # "install-shared" + # "install-static" + # ]; + + # postInstall = '' + # # Might eventually remove this when we are confident in the build process + # echo "BUILD CONFIGURATION FOR SANITY CHECKING" + # cat make_config.mk + # mkdir -pv $static/lib/ + # mv -vi $out/lib/${LIBNAME}.a $static/lib/ + + # install -d ''${!outputBin}/bin + # install -D ${stdenv.lib.concatStringsSep " " tools} ''${!outputBin}/bin + # ''; enableParallelBuilding = true; From 3c032a164ff849bf75600ed8d11086990bb5f3bc Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Wed, 16 May 2018 15:55:29 +0800 Subject: [PATCH 35/44] proper mingw names --- lib/systems/examples.nix | 4 ++-- lib/systems/parse.nix | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/systems/examples.nix b/lib/systems/examples.nix index 9c43d9b1bbc78..0542e504eee92 100644 --- a/lib/systems/examples.nix +++ b/lib/systems/examples.nix @@ -133,7 +133,7 @@ rec { # 32 bit mingw-w64 mingw32 = { - config = "i686-pc-mingw32"; + config = "i686-w64-mingw32"; libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain platform = {}; }; @@ -141,7 +141,7 @@ rec { # 64 bit mingw-w64 mingwW64 = { # That's the triplet they use in the mingw-w64 docs. - config = "x86_64-pc-mingw32"; + config = "x86_64-w64-mingw32"; libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain platform = {}; }; diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index d79947ad3dea3..41311a1100926 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -110,6 +110,7 @@ rec { vendors = setTypes types.openVendor { apple = {}; pc = {}; + w64 = {}; # mingw-w64 unknown = {}; }; From 7f864704d698483122baf8b82934c0f032ec9af2 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Wed, 16 May 2018 15:55:54 +0800 Subject: [PATCH 36/44] revert rocksdb --- .../development/libraries/rocksdb/default.nix | 92 +++++++++---------- 1 file changed, 41 insertions(+), 51 deletions(-) diff --git a/pkgs/development/libraries/rocksdb/default.nix b/pkgs/development/libraries/rocksdb/default.nix index 71b3442409eb1..bb36d942a69b8 100644 --- a/pkgs/development/libraries/rocksdb/default.nix +++ b/pkgs/development/libraries/rocksdb/default.nix @@ -1,8 +1,7 @@ { stdenv , fetchFromGitHub , fixDarwinDylibNames -, hostPlatform, lib -, which, perl, cmake +, which, perl # Optional Arguments , snappy ? null, google-gflags ? null, zlib ? null, bzip2 ? null, lz4 ? null @@ -12,7 +11,6 @@ , jemalloc ? null, gperftools ? null , enableLite ? false -, windows }: let @@ -32,58 +30,50 @@ stdenv.mkDerivation rec { sha256 = "15x2r7aib1xinwcchl32wghs8g96k4q5xgv6z97mxgp35475x01p"; }; - nativeBuildInputs = [ which perl snappy google-gflags ]; - buildInputs = [ zlib bzip2 malloc fixDarwinDylibNames ] # lz4 ]; - ++ lib.optional (hostPlatform.libc == "msvcrt") [ windows.mingw_w64_pthreads windows.mingw_w64_headers ]; - crossAttrs = { - nativeBuildInputs = [ which perl snappy google-gflags cmake ]; - }; - -# cmakeFlags = "-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ "; - cmakeFlags = "-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CXX_FLAGS=-std=c++11 -DCMAKE_CXX_FLAGS=-pthread"; - buildFlags = "rocksdb VERBOSE=1 -j1"; + nativeBuildInputs = [ which perl ]; + buildInputs = [ snappy google-gflags zlib bzip2 lz4 malloc fixDarwinDylibNames ]; - # postPatch = '' - # # Hack to fix typos - # sed -i 's,#inlcude,#include,g' build_tools/build_detect_platform - # ''; + postPatch = '' + # Hack to fix typos + sed -i 's,#inlcude,#include,g' build_tools/build_detect_platform + ''; - # # Environment vars used for building certain configurations + # Environment vars used for building certain configurations PORTABLE = "1"; USE_SSE = "1"; - #CMAKE_CXX_FLAGS = "-std=c++11 -pthread -pthreads"; - # JEMALLOC_LIB = stdenv.lib.optionalString (malloc == jemalloc) "-ljemalloc"; - - # LIBNAME = "librocksdb${stdenv.lib.optionalString enableLite "_lite"}"; - # ${if enableLite then "CXXFLAGS" else null} = "-DROCKSDB_LITE=1"; - - # buildAndInstallFlags = [ - # "USE_RTTI=1" - # "DEBUG_LEVEL=0" - # "DISABLE_WARNING_AS_ERROR=1" - # ]; - - # buildFlags = buildAndInstallFlags ++ [ - # "shared_lib" - # "static_lib" - # ] ++ tools ; - - # installFlags = buildAndInstallFlags ++ [ - # "INSTALL_PATH=\${out}" - # "install-shared" - # "install-static" - # ]; - - # postInstall = '' - # # Might eventually remove this when we are confident in the build process - # echo "BUILD CONFIGURATION FOR SANITY CHECKING" - # cat make_config.mk - # mkdir -pv $static/lib/ - # mv -vi $out/lib/${LIBNAME}.a $static/lib/ - - # install -d ''${!outputBin}/bin - # install -D ${stdenv.lib.concatStringsSep " " tools} ''${!outputBin}/bin - # ''; + CMAKE_CXX_FLAGS = "-std=gnu++11"; + JEMALLOC_LIB = stdenv.lib.optionalString (malloc == jemalloc) "-ljemalloc"; + + LIBNAME = "librocksdb${stdenv.lib.optionalString enableLite "_lite"}"; + ${if enableLite then "CXXFLAGS" else null} = "-DROCKSDB_LITE=1"; + + buildAndInstallFlags = [ + "USE_RTTI=1" + "DEBUG_LEVEL=0" + "DISABLE_WARNING_AS_ERROR=1" + ]; + + buildFlags = buildAndInstallFlags ++ [ + "shared_lib" + "static_lib" + ] ++ tools ; + + installFlags = buildAndInstallFlags ++ [ + "INSTALL_PATH=\${out}" + "install-shared" + "install-static" + ]; + + postInstall = '' + # Might eventually remove this when we are confident in the build process + echo "BUILD CONFIGURATION FOR SANITY CHECKING" + cat make_config.mk + mkdir -pv $static/lib/ + mv -vi $out/lib/${LIBNAME}.a $static/lib/ + + install -d ''${!outputBin}/bin + install -D ${stdenv.lib.concatStringsSep " " tools} ''${!outputBin}/bin + ''; enableParallelBuilding = true; From 2cce00ab4ddff395249ae85051e93a1aec8cd003 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Wed, 16 May 2018 15:56:27 +0800 Subject: [PATCH 37/44] cleanup mingw --- pkgs/os-specific/windows/mingw-w64/common.nix | 5 ----- .../os-specific/windows/mingw-w64/default.nix | 21 +++++++++++++++---- .../os-specific/windows/mingw-w64/headers.nix | 8 +++++-- .../windows/mingw-w64/pthreads.nix | 8 +++---- 4 files changed, 27 insertions(+), 15 deletions(-) diff --git a/pkgs/os-specific/windows/mingw-w64/common.nix b/pkgs/os-specific/windows/mingw-w64/common.nix index 2e6e3834b0462..4ba874615a09b 100644 --- a/pkgs/os-specific/windows/mingw-w64/common.nix +++ b/pkgs/os-specific/windows/mingw-w64/common.nix @@ -8,9 +8,4 @@ rec { url = "http://cfhcable.dl.sourceforge.net/project/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v${version}.tar.bz2"; sha256 = "1d4wrjfdlq5xqpv9zg6ssw4lm8jnv6522xf7d6zbjygmkswisq1a"; }; - - configureFlags = [ - "--enable-idl" - "--enable-secure-api" - ]; } diff --git a/pkgs/os-specific/windows/mingw-w64/default.nix b/pkgs/os-specific/windows/mingw-w64/default.nix index 53050435256fb..13b6d0cd8ef3d 100644 --- a/pkgs/os-specific/windows/mingw-w64/default.nix +++ b/pkgs/os-specific/windows/mingw-w64/default.nix @@ -1,8 +1,21 @@ -{ stdenv, callPackage, windows }: +{ stdenv, callPackage, targetPlatform }: +with stdenv.lib; +let inherit (callPackage ./common.nix {}) name src; +in stdenv.mkDerivation { +# buildInputs = [ windows.mingw_w64_headers ]; + + name = name + "-msvcrt"; + inherit src; -stdenv.mkDerivation { - inherit (callPackage ./common.nix {}) name src; - buildInputs = [ windows.mingw_w64_headers ]; dontStrip = true; hardeningDisable = [ "stackprotector" "fortify" ]; + + # https://sourceforge.net/p/mingw-w64/wiki2/Cross%20Win32%20and%20Win64%20compiler/ + # specifies that the headers should be in + prefix = "\${out}/${targetPlatform.config}"; + + configureFlags = [ + "--enable-idl" + "--enable-secure-api" + ]; } diff --git a/pkgs/os-specific/windows/mingw-w64/headers.nix b/pkgs/os-specific/windows/mingw-w64/headers.nix index 03dbf712e2e51..47b72007bb124 100644 --- a/pkgs/os-specific/windows/mingw-w64/headers.nix +++ b/pkgs/os-specific/windows/mingw-w64/headers.nix @@ -1,12 +1,16 @@ -{ stdenvNoCC, callPackage }: +{ stdenvNoCC, callPackage, hostPlatform, targetPlatform }: let inherit (callPackage ./common.nix {}) name src; in stdenvNoCC.mkDerivation { - name = name + "-headers"; + name = name + "-headers" + stdenvNoCC.lib.optionalString (targetPlatform != hostPlatform) "-${targetPlatform.config}"; inherit src; + # https://sourceforge.net/p/mingw-w64/wiki2/Cross%20Win32%20and%20Win64%20compiler/ + # specifies that the headers should be in + prefix = "\${out}/${targetPlatform.config}"; + preConfigure = '' cd mingw-w64-headers ''; diff --git a/pkgs/os-specific/windows/mingw-w64/pthreads.nix b/pkgs/os-specific/windows/mingw-w64/pthreads.nix index 1a33e8db07e81..60baaf1e6c1f5 100644 --- a/pkgs/os-specific/windows/mingw-w64/pthreads.nix +++ b/pkgs/os-specific/windows/mingw-w64/pthreads.nix @@ -1,8 +1,6 @@ { stdenv, callPackage }: - -let - inherit (callPackage ./common.nix {}) name src; - +with stdenv.lib; +let inherit (callPackage ./common.nix {}) name src; in stdenv.mkDerivation { name = name + "-pthreads"; inherit src; @@ -10,4 +8,6 @@ in stdenv.mkDerivation { preConfigure = '' cd mingw-w64-libraries/winpthreads ''; + + hardeningDisable = [ "stackprotector" ]; } From 728ada5c6862a05d17165ed0522ab6ae0610d0dc Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Wed, 16 May 2018 15:57:14 +0800 Subject: [PATCH 38/44] Adds preliminary gcc-ng infra. --- .../compilers/gcc/7/default-ng-prebuilt.nix | 70 +++++++++++++++++++ .../compilers/gcc/7/default-ng.nix | 44 ++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 pkgs/development/compilers/gcc/7/default-ng-prebuilt.nix create mode 100644 pkgs/development/compilers/gcc/7/default-ng.nix diff --git a/pkgs/development/compilers/gcc/7/default-ng-prebuilt.nix b/pkgs/development/compilers/gcc/7/default-ng-prebuilt.nix new file mode 100644 index 0000000000000..ee7e278d3b2a0 --- /dev/null +++ b/pkgs/development/compilers/gcc/7/default-ng-prebuilt.nix @@ -0,0 +1,70 @@ +{ stdenv, targetPackages, fetchurl, targetPlatform, hostPlatform +, langC ? true, langCC ? true, langFortran ? false +, langObjC ? targetPlatform.isDarwin +, langObjCpp ? targetPlatform.isDarwin +, langJava ? false +, langGo ? false +# build deps +, gmp, mpfr, libmpc +, extraBuildInputs ? [] +, extraConfigureFlags ? [] +, ... }: + +with stdenv.lib; + +let version = "7.3.0"; +in stdenv.mkDerivation ({ + + name = "gcc-${version}-prebuilt" + optionalString (targetPlatform != hostPlatform) "-${targetPlatform.config}"; + + src = fetchurl { + url = "mirror://gcc/releases/gcc-${version}/gcc-${version}.tar.xz"; + sha256 = "0p71bij6bfhzyrs8676a8jmpjsfz392s2rg862sdnsk30jpacb43"; + }; + + buildInputs = [ + gmp mpfr libmpc #libelf + stdenv.cc.bintools # For linking code at run-time + ] ++ extraBuildInputs; + + configurePlatforms = [ "build" "host" ] ++ optional (targetPlatform != hostPlatform) "target"; + + configureFlags = [ + "--enable-languages=${ + concatStrings (intersperse "," + ( optional langC "c" + ++ optional langCC "c++" + ++ optional langFortran "fortran" + ++ optional langJava "java" + ++ optional langGo "go" + ++ optional langObjC "objc" + ++ optional langObjCpp "obj-c++" + ) + ) + }" + "--disable-multilib" + "--with-bugurl=https://github.com/nixos/nixpkgs/issues" + "--with-gmp-include=${gmp.dev}/include" + "--with-gmp-lib=${gmp.out}/lib" + "--with-mpfr-include=${mpfr.dev}/include" + "--with-mpfr-lib=${mpfr.out}/lib" + "--with-mpc=${libmpc}" + + "--with-threads=posix" + + # we need to ensure that we set the proper assembler and linker. If we don't + # we can't change this at runtime anymore -- m( + "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" + "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" + ] ++ extraConfigureFlags; + + # don't fail with: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security] + hardeningDisable = [ "format" ]; + enableParallelBuilding = true; + + makeFlags = [ "all-gcc" ]; + # installTargets = "install-${component}"; + installPhase = "mkdir -p $out && tar -czf $out/prebuilt.tar.gz ."; + fixpuPhase = ""; + dontPatchShebangs = true; +}) diff --git a/pkgs/development/compilers/gcc/7/default-ng.nix b/pkgs/development/compilers/gcc/7/default-ng.nix new file mode 100644 index 0000000000000..5298ba2ab8037 --- /dev/null +++ b/pkgs/development/compilers/gcc/7/default-ng.nix @@ -0,0 +1,44 @@ +{ stdenv, targetPackages, gcc-prebuilt, component, hostPlatform, targetPlatform +, gmp, mpfr, libmpc, gcc, extraBuildInputs ? [] }: + +with stdenv.lib; + +let version = "7.3.0"; +in stdenv.mkDerivation ({ + + name = "gcc-${version}-${component}" + optionalString (targetPlatform != hostPlatform) "-${targetPlatform.config}"; + + buildInputs = extraBuildInputs ++ [ + gcc-prebuilt + gmp mpfr libmpc + targetPackages.stdenv.cc.bintools + ] ++ optional (component != "gcc") gcc; + + src = "${gcc-prebuilt}/prebuilt.tar.gz"; + # prebuilt doesn't have a root directory. + setSourceRoot = "sourceRoot=`pwd`"; + + postPatch = '' + echo "rewriting prefix from ${gcc-prebuilt} -> $out" + find . \( -name mkheaders\* -o -name Makefile \) -exec \ + sed -i -e "s|${gcc-prebuilt}|$out|g" {} \; + ''; + + # don't fail with: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security] + hardeningDisable = [ "format" ]; + enableParallelBuilding = true; # (component == "gcc"); #true; + + # We've already done the treewide configure + # in the gcc-prebuilt. + configurePhase = '' + echo "configure disabled" + ''; + dontStrip = true; + +# outputs = [ "out" "lib" "man" "info" ]; + makeFlags = [ "all-${component}" ]; + installTargets = "install-${component}"; +# postInstall = '' +# ls -lah $out/ +# ''; +} // optionalAttrs (component == "gcc") { buildPhase = ""; }) From cd3b3deae250958e7aed3b8b0156e513ad200d5b Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Wed, 28 Mar 2018 07:51:27 +0800 Subject: [PATCH 39/44] Adds wine (darwin) --- pkgs/misc/emulators/wine/base.nix | 18 +++++++++++++----- pkgs/misc/emulators/wine/packages.nix | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pkgs/misc/emulators/wine/base.nix b/pkgs/misc/emulators/wine/base.nix index e064609941500..f5d1dee770a17 100644 --- a/pkgs/misc/emulators/wine/base.nix +++ b/pkgs/misc/emulators/wine/base.nix @@ -6,7 +6,8 @@ buildScript ? null, configureFlags ? "" }: -assert stdenv.cc.cc.isGNU or false; +assert stdenv.isLinux || stdenv.isDarwin; +# assert stdenv.cc.cc.isGNU or false; with import ./util.nix { inherit lib; }; @@ -54,9 +55,14 @@ stdenv.mkDerivation ((lib.optionalAttrs (! isNull buildScript) { ++ lib.optionals xmlSupport [ pkgs.libxml2 pkgs.libxslt ] ++ lib.optionals tlsSupport [ pkgs.openssl pkgs.gnutls ] ++ lib.optionals openglSupport [ pkgs.libGLU_combined pkgs.mesa_noglu.osmesa pkgs.libdrm ] - ++ (with pkgs.xorg; [ - libX11 libXi libXcursor libXrandr libXrender libXxf86vm libXcomposite libXext - ]))); + ++ lib.optionals stdenv.isDarwin (with pkgs.buildPackages.darwin.apple_sdk.frameworks; [ + CoreServices Foundation ForceFeedback AppKit OpenGL IOKit DiskArbitration Security + ApplicationServices AudioToolbox CoreAudio AudioUnit CoreMIDI OpenAL OpenCL Cocoa Carbon + ]) + ++ lib.optionals stdenv.isLinux (with pkgs.xorg; [ + libXi libXcursor libXrandr libXrender libXxf86vm libXcomposite libXext + ]) + ++ [ pkgs.xorg.libX11 ])); # Wine locates a lot of libraries dynamically through dlopen(). Add # them to the RPATH so that the user doesn't have to set them in @@ -115,4 +121,6 @@ stdenv.mkDerivation ((lib.optionalAttrs (! isNull buildScript) { description = "An Open Source implementation of the Windows API on top of X, OpenGL, and Unix"; maintainers = with stdenv.lib.maintainers; [ avnik raskin bendlas ]; }; -}) + } // lib.optionalAttrs stdenv.isDarwin { + hardeningDisable = [ "fortify" ]; + }) diff --git a/pkgs/misc/emulators/wine/packages.nix b/pkgs/misc/emulators/wine/packages.nix index a786babc79de9..d2305aa37ba6b 100644 --- a/pkgs/misc/emulators/wine/packages.nix +++ b/pkgs/misc/emulators/wine/packages.nix @@ -20,7 +20,7 @@ in with src; { geckos = [ gecko64 ]; monos = [ mono ]; configureFlags = [ "--enable-win64" ]; - platforms = [ "x86_64-linux" ]; + platforms = [ "x86_64-linux" "x86_64-darwin" ]; }; wineWow = callPackage ./base.nix { name = "wine-wow-${version}"; From 1353a6eb25688e9b7301bf01ddb0899793797186 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Thu, 17 May 2018 14:06:44 +0800 Subject: [PATCH 40/44] make bulding libgcc work. --- .../compilers/gcc/7/default-ng-prebuilt.nix | 26 ++++++-- .../compilers/gcc/7/default-ng.nix | 44 +++++++++++--- pkgs/os-specific/windows/mingw-w64/common.nix | 19 ++++++ .../os-specific/windows/mingw-w64/default.nix | 18 +++--- .../os-specific/windows/mingw-w64/headers.nix | 10 ++-- .../windows/mingw-w64/pthreads.nix | 4 +- pkgs/top-level/all-packages.nix | 59 +++++++++++++++++-- 7 files changed, 148 insertions(+), 32 deletions(-) diff --git a/pkgs/development/compilers/gcc/7/default-ng-prebuilt.nix b/pkgs/development/compilers/gcc/7/default-ng-prebuilt.nix index ee7e278d3b2a0..9ccdabd13d605 100644 --- a/pkgs/development/compilers/gcc/7/default-ng-prebuilt.nix +++ b/pkgs/development/compilers/gcc/7/default-ng-prebuilt.nix @@ -6,8 +6,10 @@ , langGo ? false # build deps , gmp, mpfr, libmpc +, binutils , extraBuildInputs ? [] , extraConfigureFlags ? [] +, threadModel ? "posix" , ... }: with stdenv.lib; @@ -24,9 +26,20 @@ in stdenv.mkDerivation ({ buildInputs = [ gmp mpfr libmpc #libelf - stdenv.cc.bintools # For linking code at run-time + binutils ] ++ extraBuildInputs; + # bould out of tree. We don't use `pwd` in the `configureScript` so + # that we do not hardcode the build location. We are going to re-use + # the build folder in a different derivation again when actually + # installing `gcc`, `libgcc`, ... + preConfigure = '' + mkdir ../build + cd ../build + + configureScript="../$sourceRoot/configure" + ''; + configurePlatforms = [ "build" "host" ] ++ optional (targetPlatform != hostPlatform) "target"; configureFlags = [ @@ -50,12 +63,12 @@ in stdenv.mkDerivation ({ "--with-mpfr-lib=${mpfr.out}/lib" "--with-mpc=${libmpc}" - "--with-threads=posix" + "--enable-threads=posix" # we need to ensure that we set the proper assembler and linker. If we don't # we can't change this at runtime anymore -- m( - "--with-as=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-as" - "--with-ld=${targetPackages.stdenv.cc.bintools}/bin/${targetPlatform.config}-ld" + "--with-as=${binutils}/bin/${targetPlatform.config}-as" + "--with-ld=${binutils}/bin/${targetPlatform.config}-ld" ] ++ extraConfigureFlags; # don't fail with: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security] @@ -64,7 +77,10 @@ in stdenv.mkDerivation ({ makeFlags = [ "all-gcc" ]; # installTargets = "install-${component}"; - installPhase = "mkdir -p $out && tar -czf $out/prebuilt.tar.gz ."; + installPhase = '' + cd .. + mkdir -p $out && tar -czf $out/prebuilt.tar.gz "$sourceRoot" build + ''; fixpuPhase = ""; dontPatchShebangs = true; }) diff --git a/pkgs/development/compilers/gcc/7/default-ng.nix b/pkgs/development/compilers/gcc/7/default-ng.nix index 5298ba2ab8037..07ca83bb514e4 100644 --- a/pkgs/development/compilers/gcc/7/default-ng.nix +++ b/pkgs/development/compilers/gcc/7/default-ng.nix @@ -1,4 +1,4 @@ -{ stdenv, targetPackages, gcc-prebuilt, component, hostPlatform, targetPlatform +{ stdenv, targetPackages, windows, gcc-prebuilt, component, hostPlatform, targetPlatform , gmp, mpfr, libmpc, gcc, extraBuildInputs ? [] }: with stdenv.lib; @@ -11,22 +11,38 @@ in stdenv.mkDerivation ({ buildInputs = extraBuildInputs ++ [ gcc-prebuilt gmp mpfr libmpc - targetPackages.stdenv.cc.bintools - ] ++ optional (component != "gcc") gcc; + ]; src = "${gcc-prebuilt}/prebuilt.tar.gz"; # prebuilt doesn't have a root directory. setSourceRoot = "sourceRoot=`pwd`"; + # We'll need to replace all the paths to the prebuilt version + # with the current $out as the prefix. We also need to injet + # -B to the mingw_w64/lib folder so we find libcrt2.o and + # the other windows libraires (libmvcrt, ...). Adding -L + # would not help gcc find libcrt2.o. + # + # For pthread support also need to inject the include and lib + # dirs. Ideally this would be handled by the cc-wrapper. But + # we still use the build cc here. + # + # TODO: the linking of the mingw_w64_headers into $out/mingw + # is rather annoying but gcc currently expect them there. + # Ideally I'd like to link them into `mingw` in the + # libc (windows.mingw_w64). postPatch = '' echo "rewriting prefix from ${gcc-prebuilt} -> $out" find . \( -name mkheaders\* -o -name Makefile \) -exec \ sed -i -e "s|${gcc-prebuilt}|$out|g" {} \; + '' + optionalString (component != "gcc") '' + sed -i -e 's|SYSROOT_CFLAGS_FOR_TARGET = |SYSROOT_CFLAGS_FOR_TARGET = -B${windows.mingw_w64}/lib -I${windows.mingw_w64_pthreads}/include -L${windows.mingw_w64_pthreads}/lib|g' build/Makefile + mkdir -p $out && ln -s ${windows.mingw_w64_headers} $out/mingw ''; # don't fail with: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security] hardeningDisable = [ "format" ]; - enableParallelBuilding = true; # (component == "gcc"); #true; + enableParallelBuilding = true; #(component == "gcc"); #true; # We've already done the treewide configure # in the gcc-prebuilt. @@ -35,10 +51,20 @@ in stdenv.mkDerivation ({ ''; dontStrip = true; -# outputs = [ "out" "lib" "man" "info" ]; + # the -prebuilt tarball contains `gcc-X.Y` and `build` + # which is the out of tree build directory for gcc. + # So we'll change into it prior to buildinging/installing. + preBuild = '' + cd build + ''; + makeFlags = [ "all-${component}" ]; installTargets = "install-${component}"; -# postInstall = '' -# ls -lah $out/ -# ''; -} // optionalAttrs (component == "gcc") { buildPhase = ""; }) +} // optionalAttrs (component == "gcc") { + # gcc has already been built by the -prebuilt step. + # as such, we don't need to rebuild it here. + # Maybe we can skip this hack, and just run make + # it should be a no-op mostly anyway, and would + # simplify the expression. + buildPhase = ""; +}) diff --git a/pkgs/os-specific/windows/mingw-w64/common.nix b/pkgs/os-specific/windows/mingw-w64/common.nix index 4ba874615a09b..6a9d714da88e8 100644 --- a/pkgs/os-specific/windows/mingw-w64/common.nix +++ b/pkgs/os-specific/windows/mingw-w64/common.nix @@ -1,3 +1,22 @@ +# The Mingw-w64 toolchain +# ======================= +# +# The mingw-w64 toolchain provides whas is essentially the msvcrt (libc for windows). +# It comes in the following components: +# - headers. These proivde the basic headers needed to build against the msvcrt. +# - msvcrt. The libc itself (headers + lirbary) +# - winpthreads. A pthreads implementation for windows. This is notably required +# to allow GCC to use the posix thread-model, which is an essential requirement +# for c++11 support in GCC. +# +# Installation instructions can be found at +# https://sourceforge.net/p/mingw-w64/wiki2/Cross%20Win32%20and%20Win64%20compiler/ +# +# Note: while the installation instruction explicitly state that we need to place +# the headers and crt into as of v3. This does not seem to be acurate +# anymore. As nix CC wrapper picks up the ~include~ folder from ~$out~, we will +# use just ~$out~ instead of ~$out/x86_64-w64-mingw~. +# { fetchurl }: rec { diff --git a/pkgs/os-specific/windows/mingw-w64/default.nix b/pkgs/os-specific/windows/mingw-w64/default.nix index 13b6d0cd8ef3d..234a6899ad279 100644 --- a/pkgs/os-specific/windows/mingw-w64/default.nix +++ b/pkgs/os-specific/windows/mingw-w64/default.nix @@ -1,21 +1,21 @@ -{ stdenv, callPackage, targetPlatform }: +{ stdenv, callPackage, targetPlatform, windows }: with stdenv.lib; let inherit (callPackage ./common.nix {}) name src; in stdenv.mkDerivation { -# buildInputs = [ windows.mingw_w64_headers ]; name = name + "-msvcrt"; inherit src; + buildInputs = [ windows.mingw_w64_headers ]; + dontStrip = true; hardeningDisable = [ "stackprotector" "fortify" ]; - # https://sourceforge.net/p/mingw-w64/wiki2/Cross%20Win32%20and%20Win64%20compiler/ - # specifies that the headers should be in - prefix = "\${out}/${targetPlatform.config}"; + preConfigure = '' + cd mingw-w64-crt + ''; - configureFlags = [ - "--enable-idl" - "--enable-secure-api" - ]; + postInstall = '' + ln -s ${windows.mingw_w64_headers} $out/mingw + ''; } diff --git a/pkgs/os-specific/windows/mingw-w64/headers.nix b/pkgs/os-specific/windows/mingw-w64/headers.nix index 47b72007bb124..76f7973a17491 100644 --- a/pkgs/os-specific/windows/mingw-w64/headers.nix +++ b/pkgs/os-specific/windows/mingw-w64/headers.nix @@ -7,11 +7,13 @@ in stdenvNoCC.mkDerivation { name = name + "-headers" + stdenvNoCC.lib.optionalString (targetPlatform != hostPlatform) "-${targetPlatform.config}"; inherit src; - # https://sourceforge.net/p/mingw-w64/wiki2/Cross%20Win32%20and%20Win64%20compiler/ - # specifies that the headers should be in - prefix = "\${out}/${targetPlatform.config}"; - preConfigure = '' cd mingw-w64-headers ''; + + configureFlags = [ + "--enable-idl" + "--enable-secure-api" + # "--with-default-win32-winnt=0x600" + ]; } diff --git a/pkgs/os-specific/windows/mingw-w64/pthreads.nix b/pkgs/os-specific/windows/mingw-w64/pthreads.nix index 60baaf1e6c1f5..02471b107f32b 100644 --- a/pkgs/os-specific/windows/mingw-w64/pthreads.nix +++ b/pkgs/os-specific/windows/mingw-w64/pthreads.nix @@ -1,10 +1,12 @@ -{ stdenv, callPackage }: +{ stdenv, callPackage, windows }: with stdenv.lib; let inherit (callPackage ./common.nix {}) name src; in stdenv.mkDerivation { name = name + "-pthreads"; inherit src; + buildInputs = [ windows.mingw_w64_headers windows.mingw_w64 ]; + preConfigure = '' cd mingw-w64-libraries/winpthreads ''; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3cf810f87c988..b9cc528937ea4 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6160,7 +6160,12 @@ with pkgs; crossLibcStdenv = buildPackages.makeStdenvCross { inherit (buildPackages.buildPackages) stdenv; inherit buildPlatform hostPlatform targetPlatform; - cc = buildPackages.gccCrossStageStatic; + cc = buildPackages.gcc7-ng-msvcrt; #gccCrossStageStatic; + }; + crossLibcStdenvNolibc = buildPackages.makeStdenvCross { + inherit (buildPackages.buildPackages) stdenv; + inherit buildPlatform hostPlatform targetPlatform; + cc = buildPackages.gcc7-ng-nolibc; #gccCrossStageStatic; }; # The GCC used to build libc for the target platform. Normal gccs will be @@ -6262,6 +6267,50 @@ with pkgs; isl = if !stdenv.isDarwin then isl_0_17 else null; })); + # the idea is the following: + # - build binutils with the build-cc, and build-libc + # - prebuild gcc with the build-cc, and build-libc + # == Now we have a gcc that targets the target + # - install gcc from the prebuilt-gcc. + # - build libc (msvcrt) with the gcc we just built + # - link the mingw-headers into a mingw symlink + # into the msvcrt result. + # == Now we also have a libc that targets the target. + # - using the msvcrt we just built, set --sysroot + # and build winpthreads + # - finish building the rest of gcc. (libgcc, ...) + + gcc7-ng-prebuilt = + let libc = targetPackages.windows.mingw_w64_headers; + bintools = wrapBintoolsWith { bintools = binutils-unwrapped; libc = libc; }; + in callPackage ../development/compilers/gcc/7/default-ng-prebuilt.nix { binutils = bintools; }; + + gcc7-ng-nolibc = + let libc = targetPackages.windows.mingw_w64_headers; + bintools = wrapBintoolsWith { bintools = binutils-unwrapped; libc = libc; }; + in wrapCCWith { + cc = callPackage ../development/compilers/gcc/7/default-ng.nix { gcc-prebuilt = gcc7-ng-prebuilt; component = "gcc"; }; + libc = libc; + bintools = bintools; + }; + + gcc7-ng-msvcrt = + let libc = targetPackages.windows.mingw_w64; + bintools = wrapBintoolsWith { bintools = binutils-unwrapped; libc = libc; }; + in wrapCCWith { + cc = callPackage ../development/compilers/gcc/7/default-ng.nix { gcc-prebuilt = gcc7-ng-prebuilt; component = "gcc"; }; + libc = libc; + bintools = bintools; + }; + + # this is a rather convoluted setup to achive the following: + # still use the build machiens CC, yet build a target library. + gcc7-ng-libgcc = callPackage ../development/compilers/gcc/7/default-ng.nix { gcc-prebuilt = buildPackages.gcc7-ng-prebuilt; component = "target-libgcc"; + stdenv = buildPackages.stdenv; #crossLibcStdenv; + extraBuildInputs = [ windows.mingw_w64 buildPackages.binutils-unwrapped windows.mingw_w64_pthreads ]; + inherit (buildPackages) gmp mpfr libmpc; + }; + gcc8 = lowPrio (wrapCC (callPackage ../development/compilers/gcc/8 { inherit noSysDirs; @@ -11433,7 +11482,7 @@ with pkgs; rlog = callPackage ../development/libraries/rlog { }; - rocksdb = callPackage ../development/libraries/rocksdb { jemalloc = jemalloc450; }; + rocksdb = callPackage ../development/libraries/rocksdb { stdenv = overrideCC stdenv gcc7-ng-msvcrt; jemalloc = jemalloc450; }; rocksdb_lite = rocksdb.override { enableLite = true; }; @@ -14227,12 +14276,14 @@ with pkgs; }; mingw_w64 = callPackage ../os-specific/windows/mingw-w64 { - stdenv = crossLibcStdenv; + stdenv = crossLibcStdenvNolibc; }; mingw_w64_headers = callPackage ../os-specific/windows/mingw-w64/headers.nix { }; - mingw_w64_pthreads = callPackage ../os-specific/windows/mingw-w64/pthreads.nix { }; + mingw_w64_pthreads = callPackage ../os-specific/windows/mingw-w64/pthreads.nix { + stdenv = crossLibcStdenv; + }; pthreads = callPackage ../os-specific/windows/pthread-w32 { mingw_headers = mingw_headers3; From b1adfd19e93b88a91a706c284c5ed08752dd735a Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Thu, 17 May 2018 14:07:22 +0800 Subject: [PATCH 41/44] Revert "revert rocksdb" This reverts commit 7f864704d698483122baf8b82934c0f032ec9af2. --- .../development/libraries/rocksdb/default.nix | 92 ++++++++++--------- 1 file changed, 51 insertions(+), 41 deletions(-) diff --git a/pkgs/development/libraries/rocksdb/default.nix b/pkgs/development/libraries/rocksdb/default.nix index bb36d942a69b8..71b3442409eb1 100644 --- a/pkgs/development/libraries/rocksdb/default.nix +++ b/pkgs/development/libraries/rocksdb/default.nix @@ -1,7 +1,8 @@ { stdenv , fetchFromGitHub , fixDarwinDylibNames -, which, perl +, hostPlatform, lib +, which, perl, cmake # Optional Arguments , snappy ? null, google-gflags ? null, zlib ? null, bzip2 ? null, lz4 ? null @@ -11,6 +12,7 @@ , jemalloc ? null, gperftools ? null , enableLite ? false +, windows }: let @@ -30,50 +32,58 @@ stdenv.mkDerivation rec { sha256 = "15x2r7aib1xinwcchl32wghs8g96k4q5xgv6z97mxgp35475x01p"; }; - nativeBuildInputs = [ which perl ]; - buildInputs = [ snappy google-gflags zlib bzip2 lz4 malloc fixDarwinDylibNames ]; + nativeBuildInputs = [ which perl snappy google-gflags ]; + buildInputs = [ zlib bzip2 malloc fixDarwinDylibNames ] # lz4 ]; + ++ lib.optional (hostPlatform.libc == "msvcrt") [ windows.mingw_w64_pthreads windows.mingw_w64_headers ]; + crossAttrs = { + nativeBuildInputs = [ which perl snappy google-gflags cmake ]; + }; + +# cmakeFlags = "-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ "; + cmakeFlags = "-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CXX_FLAGS=-std=c++11 -DCMAKE_CXX_FLAGS=-pthread"; + buildFlags = "rocksdb VERBOSE=1 -j1"; - postPatch = '' - # Hack to fix typos - sed -i 's,#inlcude,#include,g' build_tools/build_detect_platform - ''; + # postPatch = '' + # # Hack to fix typos + # sed -i 's,#inlcude,#include,g' build_tools/build_detect_platform + # ''; - # Environment vars used for building certain configurations + # # Environment vars used for building certain configurations PORTABLE = "1"; USE_SSE = "1"; - CMAKE_CXX_FLAGS = "-std=gnu++11"; - JEMALLOC_LIB = stdenv.lib.optionalString (malloc == jemalloc) "-ljemalloc"; - - LIBNAME = "librocksdb${stdenv.lib.optionalString enableLite "_lite"}"; - ${if enableLite then "CXXFLAGS" else null} = "-DROCKSDB_LITE=1"; - - buildAndInstallFlags = [ - "USE_RTTI=1" - "DEBUG_LEVEL=0" - "DISABLE_WARNING_AS_ERROR=1" - ]; - - buildFlags = buildAndInstallFlags ++ [ - "shared_lib" - "static_lib" - ] ++ tools ; - - installFlags = buildAndInstallFlags ++ [ - "INSTALL_PATH=\${out}" - "install-shared" - "install-static" - ]; - - postInstall = '' - # Might eventually remove this when we are confident in the build process - echo "BUILD CONFIGURATION FOR SANITY CHECKING" - cat make_config.mk - mkdir -pv $static/lib/ - mv -vi $out/lib/${LIBNAME}.a $static/lib/ - - install -d ''${!outputBin}/bin - install -D ${stdenv.lib.concatStringsSep " " tools} ''${!outputBin}/bin - ''; + #CMAKE_CXX_FLAGS = "-std=c++11 -pthread -pthreads"; + # JEMALLOC_LIB = stdenv.lib.optionalString (malloc == jemalloc) "-ljemalloc"; + + # LIBNAME = "librocksdb${stdenv.lib.optionalString enableLite "_lite"}"; + # ${if enableLite then "CXXFLAGS" else null} = "-DROCKSDB_LITE=1"; + + # buildAndInstallFlags = [ + # "USE_RTTI=1" + # "DEBUG_LEVEL=0" + # "DISABLE_WARNING_AS_ERROR=1" + # ]; + + # buildFlags = buildAndInstallFlags ++ [ + # "shared_lib" + # "static_lib" + # ] ++ tools ; + + # installFlags = buildAndInstallFlags ++ [ + # "INSTALL_PATH=\${out}" + # "install-shared" + # "install-static" + # ]; + + # postInstall = '' + # # Might eventually remove this when we are confident in the build process + # echo "BUILD CONFIGURATION FOR SANITY CHECKING" + # cat make_config.mk + # mkdir -pv $static/lib/ + # mv -vi $out/lib/${LIBNAME}.a $static/lib/ + + # install -d ''${!outputBin}/bin + # install -D ${stdenv.lib.concatStringsSep " " tools} ''${!outputBin}/bin + # ''; enableParallelBuilding = true; From 3c044d22e757419d1ec2d2fc37b05e4c192a4e6e Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Thu, 17 May 2018 14:42:05 +0800 Subject: [PATCH 42/44] use gcc7-ng-msvcrt by default. --- pkgs/top-level/all-packages.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index b9cc528937ea4..9ef8dc5fec627 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6092,7 +6092,7 @@ with pkgs; gerbil-unstable = callPackage ../development/compilers/gerbil/unstable.nix { }; gccFun = callPackage ../development/compilers/gcc/7; - gcc = gcc7; + gcc = gcc7-ng-msvcrt; gcc-unwrapped = gcc.cc; gccStdenv = if stdenv.cc.isGNU then stdenv else stdenv.override { From 68d2d15f0017f780f13944c35e3cf5d49f3904e8 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Fri, 8 Jun 2018 23:44:52 +0800 Subject: [PATCH 43/44] bump --- .../compilers/gcc/7/default-ng.nix | 28 +++++++++ .../compilers/ghc/8.2.1-binary.nix | 4 +- pkgs/development/compilers/ghc/8.4.2.nix | 3 +- pkgs/development/libraries/gmp/6.x.nix | 15 ++++- .../development/libraries/openssl/default.nix | 8 ++- .../development/libraries/rocksdb/default.nix | 45 +++++++++++--- pkgs/top-level/all-packages.nix | 60 ++++++++++++++++--- 7 files changed, 139 insertions(+), 24 deletions(-) diff --git a/pkgs/development/compilers/gcc/7/default-ng.nix b/pkgs/development/compilers/gcc/7/default-ng.nix index 07ca83bb514e4..58da50deb12c6 100644 --- a/pkgs/development/compilers/gcc/7/default-ng.nix +++ b/pkgs/development/compilers/gcc/7/default-ng.nix @@ -67,4 +67,32 @@ in stdenv.mkDerivation ({ # it should be a no-op mostly anyway, and would # simplify the expression. buildPhase = ""; +} // optionalAttrs (component != "gcc") { + # alright, so if we do build the components + # separately, they still end up in + # $out/lib/gcc// + # that's also where the include folder ends + # up in. As we'll only push $out/lib and + # $out/include into the NIX_CFLAGS and NIX_LDFLAGS + # we need to move them into place. + postInstall = '' + set -v + mv $out/lib $out/lib.old + mv $(ls -d $out/lib.old/gcc/*/*) $out/lib + mv $out/lib/include $out/include + mkdir -p $out/include + mv $out/*/lib/* $out/lib + mkdir -p $out/lib + ls $out + targetDir=$(find $out -name "*-*-*" -mindepth 1 -maxdepth 1 -type d) + if [[ -d "$targetDir/include" ]]; then + mv $targetDir/include/*/*/* $out/include + fi + targetDir2=$(find $out/include -name "*-*-*" -mindepth 1 -maxdepth 1 -type d) + if [[ -d "$targetDir2" ]]; then + cp -r $targetDir2/* $out/include + fi + rm -fR $out/lib.old + set +v + ''; }) diff --git a/pkgs/development/compilers/ghc/8.2.1-binary.nix b/pkgs/development/compilers/ghc/8.2.1-binary.nix index c88d2a8685a6b..0a53433089acd 100644 --- a/pkgs/development/compilers/ghc/8.2.1-binary.nix +++ b/pkgs/development/compilers/ghc/8.2.1-binary.nix @@ -61,7 +61,7 @@ stdenv.mkDerivation rec { for exe in $(find . -type f -executable); do isScript $exe && continue ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib - install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe + install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe done '' + @@ -131,7 +131,7 @@ stdenv.mkDerivation rec { for exe in $(find "$out" -type f -executable); do isScript $exe && continue ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib - install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe + install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib $exe done for file in $(find "$out" -name setup-config); do diff --git a/pkgs/development/compilers/ghc/8.4.2.nix b/pkgs/development/compilers/ghc/8.4.2.nix index 46723448c8618..ed05e494187b0 100644 --- a/pkgs/development/compilers/ghc/8.4.2.nix +++ b/pkgs/development/compilers/ghc/8.4.2.nix @@ -48,8 +48,7 @@ let include mk/flavours/\$(BuildFlavour).mk endif DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} - '' + stdenv.lib.optionalString enableIntegerSimple '' - INTEGER_LIBRARY = integer-simple + INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"} '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' Stage1Only = YES HADDOCK_DOCS = NO diff --git a/pkgs/development/libraries/gmp/6.x.nix b/pkgs/development/libraries/gmp/6.x.nix index 551e7e5e1f6b9..1cac1a45b1344 100644 --- a/pkgs/development/libraries/gmp/6.x.nix +++ b/pkgs/development/libraries/gmp/6.x.nix @@ -1,10 +1,11 @@ { stdenv, fetchurl, m4, cxx ? true +, targetPlatform , buildPackages , withStatic ? false }: let inherit (stdenv.lib) optional optionalString; in -let self = stdenv.mkDerivation rec { +let self = stdenv.mkDerivation (rec { name = "gmp-6.1.2"; src = fetchurl { # we need to use bz2, others aren't in bootstrapping stdenv @@ -78,5 +79,15 @@ let self = stdenv.mkDerivation rec { platforms = platforms.all; maintainers = [ maintainers.peti maintainers.vrthra ]; }; -}; +} // stdenv.lib.optionalAttrs targetPlatform.isWindows { + # NOTE: can not use stdenv.cc.isGNU / isClang, as that results in + # an infinite recursion at the gmp = gmp6 line in all-packages. + # + # do *not* pass CXXSTDLIB when cc is not clang, gcc doesn't understand + # -stdlib=libc++. If the buildPackages compiler is clang, we will + # inject this, and certainly do not want it for the cc compiler. + preConfigure = '' + export NIX_CXXSTDLIB_LINK="" + ''; +}); in self diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix index 1eac225387d21..a12f95f61ca5f 100644 --- a/pkgs/development/libraries/openssl/default.nix +++ b/pkgs/development/libraries/openssl/default.nix @@ -76,7 +76,11 @@ let # Parallel building is broken in OpenSSL. enableParallelBuilding = false; - postInstall = '' + postInstall = (stdenv.lib.optionalString hostPlatform.isWindows '' + echo $out/* + echo $out/lib/* + echo $out/bin/* + '') + '' # If we're building dynamic libraries, then don't install static # libraries. if [ -n "$(echo $out/lib/*.so $out/lib/*.dylib $out/lib/*.dll)" ]; then @@ -93,6 +97,8 @@ let rm -r $out/etc/ssl/misc rmdir $out/etc/ssl/{certs,private} + '' + stdenv.lib.optionalString hostPlatform.isWindows '' + cp $bin/bin/*.dll $out/lib/ ''; postFixup = '' diff --git a/pkgs/development/libraries/rocksdb/default.nix b/pkgs/development/libraries/rocksdb/default.nix index 71b3442409eb1..3043a91a7dc1e 100644 --- a/pkgs/development/libraries/rocksdb/default.nix +++ b/pkgs/development/libraries/rocksdb/default.nix @@ -23,7 +23,7 @@ stdenv.mkDerivation rec { name = "rocksdb-${version}"; version = "5.11.3"; - outputs = [ "dev" "out" "static" "bin" ]; +# outputs = [ "dev" "out" "static" "bin" ]; src = fetchFromGitHub { owner = "facebook"; @@ -40,17 +40,44 @@ stdenv.mkDerivation rec { }; # cmakeFlags = "-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ "; - cmakeFlags = "-DCMAKE_SYSTEM_NAME=Windows -DCMAKE_CXX_FLAGS=-std=c++11 -DCMAKE_CXX_FLAGS=-pthread"; - buildFlags = "rocksdb VERBOSE=1 -j1"; + cmakeFlags = "-DJNI=0 -DWITH_GFLAGS=0 -DCMAKE_SYSTEM_NAME=Windows"; + buildFlags = "rocksdb-shared rocksdb"; + +# preInstall = '' +# mv librocksdb.a .. +# cd .. +# ''; + + installPhase = '' + install -d $out/lib + cd .. + for header_dir in `find "include/rocksdb" -type d`; do \ + install -d $out/$header_dir; \ + done + for header in `find "include/rocksdb" -type f -name "*.h"`; do \ + install -C -m 644 $header $out/$header; \ + done + cd build + for lib in `find . -type f -name "*rocksdb*.a"`; do \ + install -C -m 755 $lib $out/lib + done + for lib in `find . -type f -name "*rocksdb*.dll"`; do \ + install -C -m 755 $lib $out/lib + done + ''; + + NIX_CFLAGS_COMPILE = [ "-Wno-unused-but-set-variable" "-D_POSIX_C_SOURCE" "-static-libstdc++" ]; # postPatch = '' # # Hack to fix typos # sed -i 's,#inlcude,#include,g' build_tools/build_detect_platform # ''; - + hardeningDisable = [ "format" "stackprotector" ]; # # Environment vars used for building certain configurations PORTABLE = "1"; USE_SSE = "1"; +# CMAKE_CXX_FLAGS = "-static-libstdc++"; +# CXXFLAGS = "-static-libstdc++"; #CMAKE_CXX_FLAGS = "-std=c++11 -pthread -pthreads"; # JEMALLOC_LIB = stdenv.lib.optionalString (malloc == jemalloc) "-ljemalloc"; @@ -68,11 +95,11 @@ stdenv.mkDerivation rec { # "static_lib" # ] ++ tools ; - # installFlags = buildAndInstallFlags ++ [ - # "INSTALL_PATH=\${out}" - # "install-shared" - # "install-static" - # ]; +# installFlags = [ +# "INSTALL_PATH=\${out}" +# "install-shared" +# "install-headers" +# ]; # postInstall = '' # # Might eventually remove this when we are confident in the build process diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9ef8dc5fec627..d9953cf93013e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6092,7 +6092,7 @@ with pkgs; gerbil-unstable = callPackage ../development/compilers/gerbil/unstable.nix { }; gccFun = callPackage ../development/compilers/gcc/7; - gcc = gcc7-ng-msvcrt; + gcc = gcc7-ng; gcc-unwrapped = gcc.cc; gccStdenv = if stdenv.cc.isGNU then stdenv else stdenv.override { @@ -6160,7 +6160,12 @@ with pkgs; crossLibcStdenv = buildPackages.makeStdenvCross { inherit (buildPackages.buildPackages) stdenv; inherit buildPlatform hostPlatform targetPlatform; - cc = buildPackages.gcc7-ng-msvcrt; #gccCrossStageStatic; + cc = buildPackages.gcc7-ng;#-msvcrt; #gccCrossStageStatic; + }; + crossLibcStdenvNoLibgcc = buildPackages.makeStdenvCross { + inherit (buildPackages.buildPackages) stdenv; + inherit buildPlatform hostPlatform targetPlatform; + cc = buildPackages.gcc7-ng-msvcrt;#-msvcrt; #gccCrossStageStatic; }; crossLibcStdenvNolibc = buildPackages.makeStdenvCross { inherit (buildPackages.buildPackages) stdenv; @@ -6280,6 +6285,18 @@ with pkgs; # and build winpthreads # - finish building the rest of gcc. (libgcc, ...) + # Dependencies: + # + # + # gcc7 + # - gcc7-ng-msvcrt + # - mingw_w64 + # - mingw_w64_headers + # - gcc7-ng-libgcc + # - bintools + # - mingw_w64 + # - mingw_w64_pthreads + gcc7-ng-prebuilt = let libc = targetPackages.windows.mingw_w64_headers; bintools = wrapBintoolsWith { bintools = binutils-unwrapped; libc = libc; }; @@ -6298,6 +6315,19 @@ with pkgs; let libc = targetPackages.windows.mingw_w64; bintools = wrapBintoolsWith { bintools = binutils-unwrapped; libc = libc; }; in wrapCCWith { + extraPackages = [ libc targetPackages.windows.mingw_w64_headers ]; + cc = callPackage ../development/compilers/gcc/7/default-ng.nix { gcc-prebuilt = gcc7-ng-prebuilt; component = "gcc"; }; + libc = libc; + bintools = bintools; + }; + + gcc7-ng = + let libc = targetPackages.windows.mingw_w64; + bintools = wrapBintoolsWith { bintools = binutils-unwrapped; libc = libc; }; + in wrapCCWith { + extraPackages = [ targetPackages.gcc7-ng-libgcc targetPackages.gcc7-ng-libssp targetPackages.gcc7-ng-libstdcpp-v3 + libc targetPackages.windows.mingw_w64_headers targetPackages.windows.mingw_w64_pthreads + ]; cc = callPackage ../development/compilers/gcc/7/default-ng.nix { gcc-prebuilt = gcc7-ng-prebuilt; component = "gcc"; }; libc = libc; bintools = bintools; @@ -6306,7 +6336,21 @@ with pkgs; # this is a rather convoluted setup to achive the following: # still use the build machiens CC, yet build a target library. gcc7-ng-libgcc = callPackage ../development/compilers/gcc/7/default-ng.nix { gcc-prebuilt = buildPackages.gcc7-ng-prebuilt; component = "target-libgcc"; - stdenv = buildPackages.stdenv; #crossLibcStdenv; + stdenv = buildPackages.stdenv; + extraBuildInputs = [ windows.mingw_w64 buildPackages.binutils-unwrapped windows.mingw_w64_pthreads ]; + inherit (buildPackages) gmp mpfr libmpc; + }; + + # this is a rather convoluted setup to achive the following: + # still use the build machiens CC, yet build a target library. + gcc7-ng-libssp = callPackage ../development/compilers/gcc/7/default-ng.nix { gcc-prebuilt = buildPackages.gcc7-ng-prebuilt; component = "target-libssp"; + stdenv = buildPackages.stdenv; + extraBuildInputs = [ windows.mingw_w64 buildPackages.binutils-unwrapped windows.mingw_w64_pthreads ]; + inherit (buildPackages) gmp mpfr libmpc; + }; + + gcc7-ng-libstdcpp-v3 = callPackage ../development/compilers/gcc/7/default-ng.nix { gcc-prebuilt = buildPackages.gcc7-ng-prebuilt; component = "target-libstdc++-v3"; + stdenv = buildPackages.stdenv; extraBuildInputs = [ windows.mingw_w64 buildPackages.binutils-unwrapped windows.mingw_w64_pthreads ]; inherit (buildPackages) gmp mpfr libmpc; }; @@ -6324,7 +6368,7 @@ with pkgs; gcc-snapshot = lowPrio (wrapCC (callPackage ../development/compilers/gcc/snapshot { inherit noSysDirs; - + # PGO seems to speed up compilation by gcc by ~10%, see #445 discussion profiledCompiler = with stdenv; (!isDarwin && (isi686 || isx86_64)); @@ -7025,7 +7069,7 @@ with pkgs; wla-dx = callPackage ../development/compilers/wla-dx { }; - wrapCCWith = { name ? "", cc, bintools, libc, extraBuildCommands ? "" }: + wrapCCWith = { name ? "", cc, bintools, libc, extraBuildCommands ? "", extraPackages ? [] }: ccWrapperFun rec { nativeTools = targetPlatform == hostPlatform && stdenv.cc.nativeTools or false; nativeLibc = targetPlatform == hostPlatform && stdenv.cc.nativeLibc or false; @@ -7035,7 +7079,7 @@ with pkgs; isGNU = cc.isGNU or false; isClang = cc.isClang or false; - inherit name cc bintools libc extraBuildCommands; + inherit name cc bintools libc extraBuildCommands extraPackages; }; ccWrapperFun = callPackage ../build-support/cc-wrapper; @@ -11482,7 +11526,7 @@ with pkgs; rlog = callPackage ../development/libraries/rlog { }; - rocksdb = callPackage ../development/libraries/rocksdb { stdenv = overrideCC stdenv gcc7-ng-msvcrt; jemalloc = jemalloc450; }; + rocksdb = callPackage ../development/libraries/rocksdb { jemalloc = jemalloc450; }; rocksdb_lite = rocksdb.override { enableLite = true; }; @@ -14282,7 +14326,7 @@ with pkgs; mingw_w64_headers = callPackage ../os-specific/windows/mingw-w64/headers.nix { }; mingw_w64_pthreads = callPackage ../os-specific/windows/mingw-w64/pthreads.nix { - stdenv = crossLibcStdenv; + stdenv = crossLibcStdenvNoLibgcc; }; pthreads = callPackage ../os-specific/windows/pthread-w32 { From 461b7bb9813a50a43b434f1cfa6f50abf133fba8 Mon Sep 17 00:00:00 2001 From: Moritz Angermann Date: Sun, 10 Jun 2018 08:11:55 +0800 Subject: [PATCH 44/44] Stop haskell from generating $out/lib. Nix cc logic relies on passing /lib for each dependency as a library search path. This makes little sense for haskell packages, as their libs are nested deeply in the /lib tree. Also GHC will generate the right library serach paths on its own from the package database entries. The larger issue though is that with one search path entry for each library, and a similar one generated by GHC for each dependency will eventually overflow the command line argument limits. As such we do *not* put haskell libraries into $out anymore. --- .../haskell-modules/generic-builder.nix | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkgs/development/haskell-modules/generic-builder.nix b/pkgs/development/haskell-modules/generic-builder.nix index 2d966af47adeb..f00c0197af3b3 100644 --- a/pkgs/development/haskell-modules/generic-builder.nix +++ b/pkgs/development/haskell-modules/generic-builder.nix @@ -131,12 +131,12 @@ let buildFlagsString = optionalString (buildFlags != []) (" " + concatStringsSep " " buildFlags); defaultConfigureFlags = [ - "--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid" + "--verbose" "--prefix=$out" "--libdir=\\$prefix/\\$compiler" "--libsubdir=\\$pkgid" (optionalString enableSeparateDataOutput "--datadir=$data/share/${ghc.name}") (optionalString enableSeparateDocOutput "--docdir=${docdir "$doc"}") "--with-gcc=$CC" # Clang won't work without that extra information. "--package-db=$packageConfDir" - (optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/lib/${ghc.name}/${pname}-${version}") + (optionalString (enableSharedExecutables && stdenv.isLinux) "--ghc-option=-optl=-Wl,-rpath=$out/${ghc.name}/${pname}-${version}") (optionalString (enableSharedExecutables && stdenv.isDarwin) "--ghc-option=-optl=-Wl,-headerpad_max_install_names") (optionalString enableParallelBuilding "--ghc-option=-j$NIX_BUILD_CORES") (optionalString useCpphs "--with-cpphs=${cpphs}/bin/cpphs --ghc-options=-cpp --ghc-options=-pgmP${cpphs}/bin/cpphs --ghc-options=-optP--cpp") @@ -251,7 +251,7 @@ stdenv.mkDerivation ({ setupCompilerEnvironmentPhase = (optionalString doVerbose '' - set -x + # set -x '') + '' runHook preSetupCompilerEnvironment @@ -271,9 +271,9 @@ stdenv.mkDerivation ({ for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do ${optionalString doVerbose '' echo $p - echo $p/lib/${ghc.name}/package.conf.d - ''}if [ -d "$p/lib/${ghc.name}/package.conf.d" ]; then - cp -f "$p/lib/${ghc.name}/package.conf.d/"*.conf $packageConfDir/ + echo $p/${ghc.name}/package.conf.d + ''}if [ -d "$p/${ghc.name}/package.conf.d" ]; then + cp -f "$p/${ghc.name}/package.conf.d/"*.conf $packageConfDir/ continue fi if [ -d "$p/include" ]; then @@ -348,7 +348,7 @@ stdenv.mkDerivation ({ buildPhase = '' runHook preBuild - ${setupCommand} build ${buildTarget}${crossCabalFlagsString}${buildFlagsString}${optionalString doVerbose " -v3"} + ${setupCommand} build ${buildTarget}${crossCabalFlagsString}${buildFlagsString}${optionalString doVerbose ""} runHook postBuild ''; @@ -373,7 +373,7 @@ stdenv.mkDerivation ({ ${if !hasActiveLibrary then "${setupCommand} install" else '' ${setupCommand} copy - local packageConfDir="$out/lib/${ghc.name}/package.conf.d" + local packageConfDir="$out/${ghc.name}/package.conf.d" local packageConfFile="$packageConfDir/${pname}-${version}.conf" mkdir -p "$packageConfDir" ${setupCommand} register --gen-pkg-config=$packageConfFile @@ -398,7 +398,7 @@ stdenv.mkDerivation ({ ${optionalString doCoverage "mkdir -p $out/share && cp -r dist/hpc $out/share"} ${optionalString (enableSharedExecutables && isExecutable && !isGhcjs && stdenv.isDarwin && stdenv.lib.versionOlder ghc.version "7.10") '' for exe in "$out/bin/"* ; do - install_name_tool -add_rpath "$out/lib/ghc-${ghc.version}/${pname}-${version}" "$exe" + install_name_tool -add_rpath "$out/ghc-${ghc.version}/${pname}-${version}" "$exe" done ''} @@ -479,4 +479,5 @@ stdenv.mkDerivation ({ // optionalAttrs (dontStrip) { inherit dontStrip; } // optionalAttrs (hardeningDisable != []) { inherit hardeningDisable; } // optionalAttrs (buildPlatform.libc == "glibc"){ LOCALE_ARCHIVE = "${glibcLocales}/lib/locale/locale-archive"; } + // optionalAttrs doVerbose { NIX_DEBUG = 1; } )