From a78c6490d70d7b7ebb0b2ba593dcbba2af7ab631 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sun, 23 Feb 2014 23:44:11 +0100 Subject: [PATCH 01/37] mingw-w64: Update to new upstream version 3.1.0. Signed-off-by: aszlig --- pkgs/os-specific/windows/mingw-w64/default.nix | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/pkgs/os-specific/windows/mingw-w64/default.nix b/pkgs/os-specific/windows/mingw-w64/default.nix index c358565c4551..0d7beb532fe7 100644 --- a/pkgs/os-specific/windows/mingw-w64/default.nix +++ b/pkgs/os-specific/windows/mingw-w64/default.nix @@ -1,23 +1,15 @@ {stdenv, fetchurl, binutilsCross ? null, gccCross ? null, onlyHeaders ? false}: let - name = "mingw-w64-2.0.3"; + name = "mingw-w64-3.1.0"; in stdenv.mkDerivation (rec { inherit name; src = fetchurl { - url = "mirror://sourceforge/mingw-w64/mingw-w64-v2.0.3.tar.gz"; - sha256 = "043jk6z90f9pxs9kfn6ckh2vlnbgcv6yfbp5ybahrj3z58dcijp5"; + url = "mirror://sourceforge/mingw-w64/mingw-w64-v3.1.0.tar.bz2"; + sha256 = "1lhpw381gc59w8b1r9zzdwa9cdi2wx6qx7s6rvajapmbw7ksgrzc"; }; - - # I don't know what's that $host directory about, I put the - # files inside include as usual. - postInstall = '' - rmdir $out/include - mv $out/x86_64-w64-mingw32/* $out - rm -R $out/x86_64-w64-mingw32 - ''; } // (if onlyHeaders then { name = name + "-headers"; From ba8b0e8af9e0ced255cd974101c349ca9d787b89 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 24 Feb 2014 00:28:46 +0100 Subject: [PATCH 02/37] binutils-cross: Remove unreferenced package. This package wasn't imported by anything in the package tree and also isn't used for cross-builds. So in order to avoid confusion, it's better to remove it as it is outdated as well. Signed-off-by: aszlig --- .../tools/misc/binutils-cross/builder.sh | 26 ------------------- .../tools/misc/binutils-cross/default.nix | 13 ---------- 2 files changed, 39 deletions(-) delete mode 100644 pkgs/development/tools/misc/binutils-cross/builder.sh delete mode 100644 pkgs/development/tools/misc/binutils-cross/default.nix diff --git a/pkgs/development/tools/misc/binutils-cross/builder.sh b/pkgs/development/tools/misc/binutils-cross/builder.sh deleted file mode 100644 index 29d3b3779b6a..000000000000 --- a/pkgs/development/tools/misc/binutils-cross/builder.sh +++ /dev/null @@ -1,26 +0,0 @@ -source $stdenv/setup - -if test $cross = "arm-linux" ; then - configureFlags="--target=arm-linux" -elif test $cross = "mips-linux" ; then - configureFlags="--target=mips-linux" -elif test $cross = "mipsel-linux" ; then - configureFlags="--target=mipsel-linux" -elif test $cross = "sparc-linux" ; then - configureFlags="--target=sparc-linux" -elif test $cross = "powerpc-linux" ; then - configureFlags="--target=powerpc-linux" -elif test $cross = "ppc-linux" ; then - configureFlags="--target=powerpc-linux" -fi - -patchConfigure() { - # Clear the default library search path. - if test "$noSysDirs" = "1"; then - echo 'NATIVE_LIB_DIRS=' >> ld/configure.tgt - fi -} - -preConfigure=patchConfigure - -genericBuild diff --git a/pkgs/development/tools/misc/binutils-cross/default.nix b/pkgs/development/tools/misc/binutils-cross/default.nix deleted file mode 100644 index 7d77baced373..000000000000 --- a/pkgs/development/tools/misc/binutils-cross/default.nix +++ /dev/null @@ -1,13 +0,0 @@ -{stdenv, fetchurl, noSysDirs, cross}: - -stdenv.mkDerivation { - name = "binutils-2.16.1"; - builder = ./builder.sh; - src = fetchurl { - url = http://ftp.nluug.nl/gnu/binutils/binutils-2.16.1.tar.bz2; - md5 = "6a9d529efb285071dad10e1f3d2b2967"; - }; - inherit noSysDirs; - #configureFlags = if cross=="arm-linux" then "--target=arm-linux" else if cross=="mips-linux" then "--target=mips-linux" else if cross=="sparc-linux" then "--target=sparc-linux"; - inherit cross; -} From 60a2fc1fec78f2653b3ef71b24ec8ae72b99d38b Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 24 Feb 2014 01:07:57 +0100 Subject: [PATCH 03/37] openssl: Fix Windows compat in cert-file.patch. In Windows there is no get(e)uid() call available, so the build fails. The patch now checks whether OPENSSL_SYS_WINDOWS is defined and only uses those calls if _not_ on Windows. Signed-off-by: aszlig --- pkgs/development/libraries/openssl/cert-file.patch | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/openssl/cert-file.patch b/pkgs/development/libraries/openssl/cert-file.patch index 6b7a60e90267..26b51c0295e0 100644 --- a/pkgs/development/libraries/openssl/cert-file.patch +++ b/pkgs/development/libraries/openssl/cert-file.patch @@ -12,7 +12,7 @@ diff -ru -x '*~' openssl-1.0.0e-orig/crypto/x509/x509_def.c openssl-1.0.0e/crypt #include "cryptlib.h" #include #include -@@ -71,7 +75,19 @@ +@@ -71,7 +75,25 @@ { return(X509_CERT_DIR); } const char *X509_get_default_cert_file(void) @@ -23,9 +23,15 @@ diff -ru -x '*~' openssl-1.0.0e-orig/crypto/x509/x509_def.c openssl-1.0.0e/crypt + if (!init) { + init = 1; + char * s = getenv("OPENSSL_X509_CERT_FILE"); -+ if (s && getuid() == geteuid()) { -+ strncpy(buf, s, sizeof(buf)); -+ buf[sizeof(buf) - 1] = 0; ++ if (s) { ++#ifndef OPENSSL_SYS_WINDOWS ++ if (getuid() == geteuid()) { ++#endif ++ strncpy(buf, s, sizeof(buf)); ++ buf[sizeof(buf) - 1] = 0; ++#ifndef OPENSSL_SYS_WINDOWS ++ } ++#endif + } + } + return buf; From 92c59d37a7e7567567e5e84c7747818850e69d0b Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 24 Feb 2014 02:22:57 +0100 Subject: [PATCH 04/37] gcc-cross-wrapper: Enable dontStrip in setup hook. At least for x86_64-w64-mingw32, it doesn't make sense to use the native strip tool for stripping of symbols. To the contrary it results in unusable archive files. Signed-off-by: aszlig --- pkgs/build-support/gcc-cross-wrapper/setup-hook.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh index a7be09283ee0..433d36ced434 100644 --- a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh +++ b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh @@ -75,6 +75,9 @@ fi # native compilations. doCheck="" +# Don't strip foreign binaries with native "strip" tool. +dontStrip=1 + # Add the output as an rpath. if test "$NIX_NO_SELF_RPATH" != "1"; then export NIX_CROSS_LDFLAGS="-rpath $out/lib -rpath-link $out/lib $NIX_CROSS_LDFLAGS" From 423be7712bb710f10f2eb8198bae97e5aeb5f1fe Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 24 Feb 2014 02:25:46 +0100 Subject: [PATCH 05/37] bzip2/cross: Patch out erroneous path separator. Not sure why this even got into the upstream release, as _all_ other includes use forward slashes. Signed-off-by: aszlig --- pkgs/tools/compression/bzip2/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/tools/compression/bzip2/default.nix b/pkgs/tools/compression/bzip2/default.nix index a431cd30a21f..55fca6ca3cb9 100644 --- a/pkgs/tools/compression/bzip2/default.nix +++ b/pkgs/tools/compression/bzip2/default.nix @@ -14,6 +14,7 @@ stdenv.mkDerivation { crossAttrs = { patchPhase = '' + sed -i -e '//s|\\|/|' bzip2.c sed -i -e 's/CC=gcc/CC=${stdenv.cross.config}-gcc/' \ -e 's/AR=ar/AR=${stdenv.cross.config}-ar/' \ -e 's/RANLIB=ranlib/RANLIB=${stdenv.cross.config}-ranlib/' \ From 4fde72c7d64c78de2e41ba91153cebb907e63100 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 24 Feb 2014 04:43:00 +0100 Subject: [PATCH 06/37] mingw-w64: Fix typo in preConfigure hook. D'oh, no wonder the headers are of almost the same size as the main package. Signed-off-by: aszlig --- pkgs/os-specific/windows/mingw-w64/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/os-specific/windows/mingw-w64/default.nix b/pkgs/os-specific/windows/mingw-w64/default.nix index 0d7beb532fe7..f1c509a50984 100644 --- a/pkgs/os-specific/windows/mingw-w64/default.nix +++ b/pkgs/os-specific/windows/mingw-w64/default.nix @@ -13,7 +13,7 @@ stdenv.mkDerivation (rec { } // (if onlyHeaders then { name = name + "-headers"; - preConfingure = '' + preConfigure = '' cd mingw-w64-headers ''; configureFlags = "--without-crt --host=x86_64-w64-mingw32"; From 44cfba79509f6dd98ae306f62f2cc3183bbd1ab1 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 24 Feb 2014 04:44:43 +0100 Subject: [PATCH 07/37] mingw-w64-pthreads: Create based on mingw-w64. The winpthreads library is part of the same source package, so let's just override the name and the source directory. Signed-off-by: aszlig --- pkgs/os-specific/windows/mingw-w64/default.nix | 10 +++++++++- pkgs/top-level/all-packages.nix | 4 ++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/windows/mingw-w64/default.nix b/pkgs/os-specific/windows/mingw-w64/default.nix index f1c509a50984..c5b6017aae4d 100644 --- a/pkgs/os-specific/windows/mingw-w64/default.nix +++ b/pkgs/os-specific/windows/mingw-w64/default.nix @@ -1,4 +1,7 @@ -{stdenv, fetchurl, binutilsCross ? null, gccCross ? null, onlyHeaders ? false}: +{ stdenv, fetchurl, binutilsCross ? null, gccCross ? null +, onlyHeaders ? false +, onlyPthreads ? false +}: let name = "mingw-w64-3.1.0"; @@ -17,6 +20,11 @@ stdenv.mkDerivation (rec { cd mingw-w64-headers ''; configureFlags = "--without-crt --host=x86_64-w64-mingw32"; +} else if onlyPthreads then { + name = name + "-pthreads"; + preConfigure = '' + cd mingw-w64-libraries/winpthreads + ''; } else { buildInputs = [ gccCross binutilsCross ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 64f2bb688c4a..133ef21060c7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7191,6 +7191,10 @@ let onlyHeaders = true; }; + mingw_w64_pthreads = callPackage ../os-specific/windows/mingw-w64 { + onlyPthreads = true; + }; + pthreads = callPackage ../os-specific/windows/pthread-w32 { mingw_headers = mingw_headers3; }; From d0142e9b09ef8a30a26d4aad922c78bf8c83a7b7 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 24 Feb 2014 05:01:29 +0100 Subject: [PATCH 08/37] pcre/cross: Enable support for winpthreads. That way we're able to build with the JIT compiler enabled. Signed-off-by: aszlig --- pkgs/development/libraries/pcre/default.nix | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix index 51279701d4a5..067c3af43871 100644 --- a/pkgs/development/libraries/pcre/default.nix +++ b/pkgs/development/libraries/pcre/default.nix @@ -1,4 +1,8 @@ -{ stdenv, fetchurl, unicodeSupport ? true, cplusplusSupport ? true }: +{ stdenv, fetchurl, unicodeSupport ? true, cplusplusSupport ? true +, windows ? null +}: + +with stdenv.lib; stdenv.mkDerivation rec { name = "pcre-8.34"; @@ -16,12 +20,16 @@ stdenv.mkDerivation rec { --enable-jit ${if unicodeSupport then "--enable-unicode-properties" else ""} ${if !cplusplusSupport then "--disable-cpp" else ""} - '' + stdenv.lib.optionalString stdenv.isDarwin "CXXFLAGS=-O0"; + '' + optionalString stdenv.isDarwin "CXXFLAGS=-O0"; doCheck = with stdenv; !(isCygwin || isFreeBSD); # XXX: test failure on Cygwin # we are running out of stack on both freeBSDs on Hydra + crossAttrs = optionalAttrs (stdenv.cross.config == "x86_64-w64-mingw32") { + buildInputs = [ windows.mingw_w64_pthreads.crossDrv ]; + }; + meta = { homepage = "http://www.pcre.org/"; description = "A library for Perl Compatible Regular Expressions"; @@ -35,7 +43,7 @@ stdenv.mkDerivation rec { PCRE library is free, even for building proprietary software. ''; - platforms = stdenv.lib.platforms.all; - maintainers = [ stdenv.lib.maintainers.simons ]; + platforms = platforms.all; + maintainers = [ maintainers.simons ]; }; } From b9bc42d0f33e5490e8e1fbbf6048f2fc641bc546 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 24 Feb 2014 05:46:04 +0100 Subject: [PATCH 09/37] glew/cross: Fix building with mingw-w64. This also cleans up the package expression a bit and we no longer directly override the phases (except patchPhase). Also for cross-builds we're using the stock mingw target and pass CC, LD and STRIP to make, because the mingw-w64 targets of the upstream package are outdated. Signed-off-by: aszlig --- pkgs/development/libraries/glew/default.nix | 24 +++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/pkgs/development/libraries/glew/default.nix b/pkgs/development/libraries/glew/default.nix index ef81f210d39f..b79fa97047b9 100644 --- a/pkgs/development/libraries/glew/default.nix +++ b/pkgs/development/libraries/glew/default.nix @@ -1,5 +1,7 @@ { stdenv, fetchurl, mesa_glu, x11, libXmu, libXi }: +with stdenv.lib; + stdenv.mkDerivation rec { name = "glew-1.10.0"; @@ -8,23 +10,33 @@ stdenv.mkDerivation rec { sha256 = "01zki46dr5khzlyywr3cg615bcal32dazfazkf360s1znqh17i4r"; }; - - buildInputs = [ x11 libXmu libXi ]; - propagatedBuildInputs = [ mesa_glu ]; # GL/glew.h includes GL/glu.h + nativeBuildInputs = [ x11 libXmu libXi ]; + propagatedNativeBuildInputs = [ mesa_glu ]; # GL/glew.h includes GL/glu.h patchPhase = '' sed -i 's|lib64|lib|' config/Makefile.linux ''; -buildPhase = "make all"; - installPhase = '' - GLEW_DEST=$out make install.all + buildFlags = [ "all" ]; + installFlags = [ "install.all" ]; + + preInstall = '' + export GLEW_DEST="$out" + ''; + + postInstall = '' mkdir -pv $out/share/doc/glew mkdir -p $out/lib/pkgconfig cp glew*.pc $out/lib/pkgconfig cp -r README.txt LICENSE.txt doc $out/share/doc/glew ''; + crossAttrs.makeFlags = [ + "CC=${stdenv.cross.config}-gcc" + "LD=${stdenv.cross.config}-gcc" + "STRIP=" + ] ++ optional (stdenv.cross.config == "x86_64-w64-mingw32") "SYSTEM=mingw"; + meta = { description = "An OpenGL extension loading library for C(++)"; homepage = http://glew.sourceforge.net/; From fbc307a18322c42db500aaebeaa21e0e93e82162 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 24 Feb 2014 05:55:29 +0100 Subject: [PATCH 10/37] SDL/cross: Fix building with mingw-w64. This is to make sure that we don't get Xlibs or alsa in cross builds, because those aren't available on non-Linux/Unix platforms. Also, until we don't have the DirectX SDK packaged, let's disable it during cross builds. Signed-off-by: aszlig --- pkgs/development/libraries/SDL/default.nix | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/pkgs/development/libraries/SDL/default.nix b/pkgs/development/libraries/SDL/default.nix index e58397fa9a5b..0df130b11fb1 100644 --- a/pkgs/development/libraries/SDL/default.nix +++ b/pkgs/development/libraries/SDL/default.nix @@ -19,7 +19,7 @@ let --disable-oss --disable-video-x11-xme --disable-x11-shared --disable-alsa-shared --enable-rpath --disable-pulseaudio-shared --disable-osmesa-shared - ${if alsaSupport then "--with-alsa-prefix=${attrs.alsaLib}/lib" else ""} + ${if attrs.alsaSupport then "--with-alsa-prefix=${attrs.alsaLib}/lib" else ""} ''; in stdenv.mkDerivation rec { @@ -32,20 +32,24 @@ stdenv.mkDerivation rec { }; # Since `libpulse*.la' contain `-lgdbm', PulseAudio must be propagated. - propagatedBuildInputs = stdenv.lib.optionals x11Support [ x11 libXrandr ] ++ + propagatedNativeBuildInputs = + stdenv.lib.optionals x11Support [ x11 libXrandr ] ++ stdenv.lib.optional pulseaudioSupport pulseaudio; - buildInputs = [ pkgconfig audiofile ] ++ + nativeBuildInputs = [ pkgconfig audiofile ] ++ stdenv.lib.optional openglSupport [ mesa ] ++ stdenv.lib.optional alsaSupport alsaLib; # XXX: By default, SDL wants to dlopen() PulseAudio, in which case # we must arrange to add it to its RPATH; however, `patchelf' seems # to fail at doing this, hence `--disable-pulseaudio-shared'. - configureFlags = configureFlagsFun { inherit alsaLib; }; + configureFlags = configureFlagsFun { inherit alsaLib alsaSupport; }; crossAttrs = { - configureFlags = configureFlagsFun { alsaLib = alsaLib.crossDrv; }; + configureFlags = configureFlagsFun { + alsaSupport = stdenv.cross.config != "x86_64-w64-mingw32"; + alsaLib = alsaLib.crossDrv; + } + "--disable-directx"; }; passthru = {inherit openglSupport;}; From 4f69722ee55cd1a685da069e6683f1af9eae645b Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 24 Feb 2014 06:46:07 +0100 Subject: [PATCH 11/37] lua52/cross: Allow to cross-compile to mingw-w64. Signed-off-by: aszlig --- pkgs/development/interpreters/lua-5/5.2.nix | 25 ++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/pkgs/development/interpreters/lua-5/5.2.nix b/pkgs/development/interpreters/lua-5/5.2.nix index 70ab0c3bdf8b..609c6b3e404a 100644 --- a/pkgs/development/interpreters/lua-5/5.2.nix +++ b/pkgs/development/interpreters/lua-5/5.2.nix @@ -17,7 +17,7 @@ stdenv.mkDerivation rec { sha256 = "004zyh9p3lpvbwhyhlmrw6wwcia5abx84q4h2brkn4zdypipvmiz"; }; - buildInputs = [ readline ]; + nativeBuildInputs = [ readline ]; patches = [ dsoPatch ]; @@ -49,6 +49,29 @@ stdenv.mkDerivation rec { EOF ''; + crossAttrs = let + isMingwW64 = stdenv.cross.config == "x86_64-w64-mingw32"; + in { + configurePhase = '' + makeFlagsArray=( + INSTALL_TOP=$out + INSTALL_MAN=$out/share/man/man1 + CC=${stdenv.cross.config}-gcc + STRIP=: + RANLIB=${stdenv.cross.config}-ranlib + V=${majorVersion} + R=${version} + ${stdenv.lib.optionals isMingwW64 "mingw"} + ) + '' + stdenv.lib.optionalString isMingwW64 '' + installFlagsArray=( + TO_BIN="lua.exe luac.exe" + TO_LIB="liblua.a lua52.dll" + INSTALL_DATA="cp -d" + ) + ''; + }; + meta = { homepage = "http://www.lua.org"; description = "Powerful, fast, lightweight, embeddable scripting language"; From c5ab2bfd258501cbe5f440089039aff8e7595e3c Mon Sep 17 00:00:00 2001 From: aszlig Date: Thu, 27 Feb 2014 18:28:32 +0100 Subject: [PATCH 12/37] gcc-cross-wrapper: Explicitly add LD program name. This is because autoconf is passing -print-prog-name=ld to the cross-gcc, which in turn assumes a FHS compliant filesystem hierarchy and searches ../../../../$crossConfig/bin/ld for the correct ld. Of course, this won't work on Nix, hence we're explicitly passing the correct LD program name. Signed-off-by: aszlig --- pkgs/build-support/gcc-cross-wrapper/setup-hook.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh index 433d36ced434..497047a73b10 100644 --- a/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh +++ b/pkgs/build-support/gcc-cross-wrapper/setup-hook.sh @@ -70,6 +70,8 @@ fi if test "$dontSetConfigureCross" != "1"; then configureFlags="$configureFlags --build=$system --host=$crossConfig" + # This is because -print-prog-name tries to search FHS paths. + configureFlags="$configureFlags LD=$crossConfig-ld" fi # Disabling the tests when cross compiling, as usually the tests are meant for # native compilations. From ae0b5d6813362492e744b1ac10e21309bb4e238b Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 3 Mar 2014 22:22:12 +0100 Subject: [PATCH 13/37] libgcrypt/cross: Fix build for mingw-w64. Especially for the 64bit mingw target, because libgcrypt contains protected mode assembly. Also, this adds gettext to the crossAttrs of libgpg-error, because it tries to regenerate the MO files. Signed-off-by: aszlig --- pkgs/development/libraries/libgcrypt/1.6.nix | 6 ++++++ pkgs/development/libraries/libgpg-error/default.nix | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/libgcrypt/1.6.nix b/pkgs/development/libraries/libgcrypt/1.6.nix index ea981f7ed127..9dc8b8a23179 100644 --- a/pkgs/development/libraries/libgcrypt/1.6.nix +++ b/pkgs/development/libraries/libgcrypt/1.6.nix @@ -24,6 +24,12 @@ stdenv.mkDerivation rec { make check ''; + crossAttrs = let + isCross64 = stdenv.cross.config == "x86_64-w64-mingw32"; + in stdenv.lib.optionalAttrs isCross64 { + configureFlags = [ "--disable-asm" "--disable-padlock-support" ]; + }; + meta = { description = "GNU Libgcrypt, a general-pupose cryptographic library"; diff --git a/pkgs/development/libraries/libgpg-error/default.nix b/pkgs/development/libraries/libgpg-error/default.nix index da142a957ad7..8ce9a10701ec 100644 --- a/pkgs/development/libraries/libgpg-error/default.nix +++ b/pkgs/development/libraries/libgpg-error/default.nix @@ -1,4 +1,4 @@ -{ stdenv, fetchurl, bash }: +{ stdenv, fetchurl, bash, gettext }: stdenv.mkDerivation (rec { name = "libgpg-error-1.12"; @@ -8,6 +8,10 @@ stdenv.mkDerivation (rec { sha256 = "0pz58vr12qihq2f0bypjxsb6cf6ajq5258fmfm8s6lvwm3b9xz6a"; }; + # If architecture-dependant MO files aren't available, they're generated + # during build, so we need gettext for cross-builds. + crossAttrs.buildInputs = [ gettext ]; + doCheck = true; meta = { From e64b342fa8fda783a7247e0469943ce728498004 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 3 Mar 2014 22:31:18 +0100 Subject: [PATCH 14/37] Use mingw-w64 for 32bit Windows builds as well. Mingw(32) is rather poorly maintaned and has quite a lot of bugs. And because our Windows cross builds were also poorly maintained and most of the cross-tests were broken as well, I'm just taking this step and try to switch to mingw-w64 for everything "cross Windows". Signed-off-by: aszlig --- pkgs/development/compilers/gcc/4.6/default.nix | 6 ++---- pkgs/development/compilers/gcc/4.8/default.nix | 6 ++---- pkgs/development/interpreters/lua-5/5.2.nix | 6 +++--- pkgs/development/libraries/SDL/default.nix | 2 +- pkgs/development/libraries/glew/default.nix | 2 +- pkgs/development/libraries/pcre/default.nix | 2 +- pkgs/development/libraries/qt-4.x/4.8/default.nix | 3 +-- pkgs/os-specific/windows/mingw-w64/default.nix | 2 +- pkgs/top-level/all-packages.nix | 8 ++------ pkgs/top-level/release-cross.nix | 11 +++++------ 10 files changed, 19 insertions(+), 29 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.6/default.nix b/pkgs/development/compilers/gcc/4.6/default.nix index 3ed0f7ad0e6d..af1113226980 100644 --- a/pkgs/development/compilers/gcc/4.6/default.nix +++ b/pkgs/development/compilers/gcc/4.6/default.nix @@ -159,10 +159,8 @@ let version = "4.6.3"; # In any case, mingw32 g++ linking is broken by default with shared libs, # unless adding "-lsupc++" to any linking command. I don't know why. " --disable-shared" + - (if cross.config == "x86_64-w64-mingw32" then - # To keep ABI compatibility with upstream mingw-w64 - " --enable-fully-dynamic-string" - else "") + # To keep ABI compatibility with upstream mingw-w64 + " --enable-fully-dynamic-string" else (if cross.libc == "uclibc" then # In uclibc cases, libgomp needs an additional '-ldl' # and as I don't know how to pass it, I disable libgomp. diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index aea525933234..e2c887c368f5 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -175,10 +175,8 @@ let version = "4.8.2"; # In any case, mingw32 g++ linking is broken by default with shared libs, # unless adding "-lsupc++" to any linking command. I don't know why. " --disable-shared" + - (if cross.config == "x86_64-w64-mingw32" then - # To keep ABI compatibility with upstream mingw-w64 - " --enable-fully-dynamic-string" - else "") + # To keep ABI compatibility with upstream mingw-w64 + " --enable-fully-dynamic-string" else (if cross.libc == "uclibc" then # In uclibc cases, libgomp needs an additional '-ldl' # and as I don't know how to pass it, I disable libgomp. diff --git a/pkgs/development/interpreters/lua-5/5.2.nix b/pkgs/development/interpreters/lua-5/5.2.nix index 609c6b3e404a..b8fcbe5f242a 100644 --- a/pkgs/development/interpreters/lua-5/5.2.nix +++ b/pkgs/development/interpreters/lua-5/5.2.nix @@ -50,7 +50,7 @@ stdenv.mkDerivation rec { ''; crossAttrs = let - isMingwW64 = stdenv.cross.config == "x86_64-w64-mingw32"; + isMingw = stdenv.cross.libc == "msvcrt"; in { configurePhase = '' makeFlagsArray=( @@ -61,9 +61,9 @@ stdenv.mkDerivation rec { RANLIB=${stdenv.cross.config}-ranlib V=${majorVersion} R=${version} - ${stdenv.lib.optionals isMingwW64 "mingw"} + ${stdenv.lib.optionals isMingw "mingw"} ) - '' + stdenv.lib.optionalString isMingwW64 '' + '' + stdenv.lib.optionalString isMingw '' installFlagsArray=( TO_BIN="lua.exe luac.exe" TO_LIB="liblua.a lua52.dll" diff --git a/pkgs/development/libraries/SDL/default.nix b/pkgs/development/libraries/SDL/default.nix index 0df130b11fb1..56ac04bebe62 100644 --- a/pkgs/development/libraries/SDL/default.nix +++ b/pkgs/development/libraries/SDL/default.nix @@ -47,7 +47,7 @@ stdenv.mkDerivation rec { crossAttrs = { configureFlags = configureFlagsFun { - alsaSupport = stdenv.cross.config != "x86_64-w64-mingw32"; + alsaSupport = stdenv.cross.libc != "msvcrt"; alsaLib = alsaLib.crossDrv; } + "--disable-directx"; }; diff --git a/pkgs/development/libraries/glew/default.nix b/pkgs/development/libraries/glew/default.nix index b79fa97047b9..32083f96dfd1 100644 --- a/pkgs/development/libraries/glew/default.nix +++ b/pkgs/development/libraries/glew/default.nix @@ -35,7 +35,7 @@ stdenv.mkDerivation rec { "CC=${stdenv.cross.config}-gcc" "LD=${stdenv.cross.config}-gcc" "STRIP=" - ] ++ optional (stdenv.cross.config == "x86_64-w64-mingw32") "SYSTEM=mingw"; + ] ++ optional (stdenv.cross.libc == "msvcrt") "SYSTEM=mingw"; meta = { description = "An OpenGL extension loading library for C(++)"; diff --git a/pkgs/development/libraries/pcre/default.nix b/pkgs/development/libraries/pcre/default.nix index 067c3af43871..7138c44da643 100644 --- a/pkgs/development/libraries/pcre/default.nix +++ b/pkgs/development/libraries/pcre/default.nix @@ -26,7 +26,7 @@ stdenv.mkDerivation rec { # XXX: test failure on Cygwin # we are running out of stack on both freeBSDs on Hydra - crossAttrs = optionalAttrs (stdenv.cross.config == "x86_64-w64-mingw32") { + crossAttrs = optionalAttrs (stdenv.cross.libc == "msvcrt") { buildInputs = [ windows.mingw_w64_pthreads.crossDrv ]; }; diff --git a/pkgs/development/libraries/qt-4.x/4.8/default.nix b/pkgs/development/libraries/qt-4.x/4.8/default.nix index 16bd1ee65d2e..1bd027f52986 100644 --- a/pkgs/development/libraries/qt-4.x/4.8/default.nix +++ b/pkgs/development/libraries/qt-4.x/4.8/default.nix @@ -148,8 +148,7 @@ stdenv.mkDerivation rec { ''; crossAttrs = let - isMingw = stdenv.cross.config == "i686-pc-mingw32" || - stdenv.cross.config == "x86_64-w64-mingw32"; + isMingw = stdenv.cross.libc == "msvcrt"; in { # I've not tried any case other than i686-pc-mingw32. # -nomake tools: it fails linking some asian language symbols diff --git a/pkgs/os-specific/windows/mingw-w64/default.nix b/pkgs/os-specific/windows/mingw-w64/default.nix index c5b6017aae4d..bf15b208e1a7 100644 --- a/pkgs/os-specific/windows/mingw-w64/default.nix +++ b/pkgs/os-specific/windows/mingw-w64/default.nix @@ -19,7 +19,7 @@ stdenv.mkDerivation (rec { preConfigure = '' cd mingw-w64-headers ''; - configureFlags = "--without-crt --host=x86_64-w64-mingw32"; + configureFlags = "--without-crt"; } else if onlyPthreads then { name = name + "-pthreads"; preConfigure = '' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 133ef21060c7..952fe59734de 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2419,9 +2419,7 @@ let gccCrossStageStatic = let isMingw = (stdenv.cross.libc == "msvcrt"); - isMingw64 = isMingw && stdenv.cross.config == "x86_64-w64-mingw32"; - libcCross1 = if isMingw64 then windows.mingw_w64_headers else - if isMingw then windows.mingw_headers1 else null; + libcCross1 = if isMingw then windows.mingw_w64_headers else null; in wrapGCCCross { gcc = forceNativeDrv (lib.addMetaAttrs { hydraPlatforms = []; } ( @@ -4235,9 +4233,7 @@ let # We can choose: libcCrossChooser = name : if name == "glibc" then glibcCross else if name == "uclibc" then uclibcCross - else if name == "msvcrt" && stdenv.cross.config == "x86_64-w64-mingw32" then - windows.mingw_w64 - else if name == "msvcrt" then windows.mingw_headers3 + else if name == "msvcrt" then windows.mingw_w64 else throw "Unknown libc"; libcCross = assert crossSystem != null; libcCrossChooser crossSystem.libc; diff --git a/pkgs/top-level/release-cross.nix b/pkgs/top-level/release-cross.nix index 6871567ca8d1..cef3d2dffbdb 100644 --- a/pkgs/top-level/release-cross.nix +++ b/pkgs/top-level/release-cross.nix @@ -140,11 +140,11 @@ in { crossUltraSparcLinux = mapTestOnCross crossSystem basic; }) // ( -/* Test some cross builds on mingw32 */ +/* Test some cross builds on 32 bit mingw-w64 */ let crossSystem = { - config = "i686-pc-mingw32"; - arch = "x86"; + config = "i686-w64-mingw32"; + arch = "x86"; # Irrelevant libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain platform = {}; }; @@ -161,11 +161,10 @@ in { }; }) // ( -/* Test some cross builds on mingw-w64 */ +/* Test some cross builds on 64 bit mingw-w64 */ let crossSystem = { - # That's the triplet they use in the mingw-w64 docs, - # and it's relevant for nixpkgs conditions. + # That's the triplet they use in the mingw-w64 docs. config = "x86_64-w64-mingw32"; arch = "x86_64"; # Irrelevant libc = "msvcrt"; # This distinguishes the mingw (non posix) toolchain From a3cf381435345d25d9deeab8f5684d937cfc83e1 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 3 Mar 2014 22:36:43 +0100 Subject: [PATCH 15/37] SDL/cross: Drop --disable-directx. This is no longer needed, because we've already fixed the dynamic cross-linker. Signed-off-by: aszlig --- pkgs/development/libraries/SDL/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/SDL/default.nix b/pkgs/development/libraries/SDL/default.nix index 56ac04bebe62..89646f2e3e39 100644 --- a/pkgs/development/libraries/SDL/default.nix +++ b/pkgs/development/libraries/SDL/default.nix @@ -49,7 +49,7 @@ stdenv.mkDerivation rec { configureFlags = configureFlagsFun { alsaSupport = stdenv.cross.libc != "msvcrt"; alsaLib = alsaLib.crossDrv; - } + "--disable-directx"; + }; }; passthru = {inherit openglSupport;}; From 5e565754abcfcb726510e2f6c205b5b6bd0e091f Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Mar 2014 02:57:48 +0100 Subject: [PATCH 16/37] Add new package "xpwn" from @dborca's fork. This really hase some nice utilities for coping with HFS+ and DMG format. We're going to use it for extracting the xcode DMG, but it could be used for more, even generating DMGs. The reason I'm using the fork instead of the repository from @planetbeing is thet the fork contains a few fixes, especially for dealing with symlinks in HFS+ images. Signed-off-by: aszlig --- pkgs/development/mobile/xpwn/default.nix | 28 ++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 pkgs/development/mobile/xpwn/default.nix diff --git a/pkgs/development/mobile/xpwn/default.nix b/pkgs/development/mobile/xpwn/default.nix new file mode 100644 index 000000000000..b248107141f5 --- /dev/null +++ b/pkgs/development/mobile/xpwn/default.nix @@ -0,0 +1,28 @@ +{ stdenv, fetchgit, cmake, zlib, libpng, bzip2, libusb, openssl }: + +stdenv.mkDerivation { + name = "xpwn-0.5.8git"; + + src = fetchgit { + url = "git://github.com/dborca/xpwn.git"; + rev = "4534da88d4e8a32cdc9da9b5326e2cc482c95ef0"; + sha256 = + "1h1ak40fg5bym0hifpii9q2hqdp2m387cwfzb4bl6qq36xpkd6wv"; + }; + + preConfigure = '' + sed -r -i \ + -e 's/(install.*TARGET.*DESTINATION )\.\)/\1bin)/' \ + -e 's!(install.*(FILE|DIR).*DESTINATION )([^)]*)!\1share/xpwn/\3!' \ + */CMakeLists.txt + sed -i -e '/install/d' CMakeLists.txt + ''; + + buildInputs = [ cmake zlib libpng bzip2 libusb openssl ]; + + meta = { + homepage = "http://planetbeing.lighthouseapp.com/projects/15246-xpwn"; + description = "Custom NOR firmware loader/IPSW generator for the iPhone"; + license = stdenv.lib.licenses.gpl3Plus; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6cd584e6f1f8..9ab8331bce99 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3825,6 +3825,8 @@ let xmlindent = callPackage ../development/web/xmlindent {}; + xpwn = callPackage ../development/mobile/xpwn {}; + xxdiff = callPackage ../development/tools/misc/xxdiff { bison = bison2; }; From 83dd414ca221a8aff18a03b3ef9716fe0ca7d06d Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Mar 2014 03:39:33 +0100 Subject: [PATCH 17/37] Add new package for Apple's XCode. This package provides the SDK and standard library needed for cross-compiling to Mac US X. We're using xpwn here to extract the DMG. Also, this version (XCode 5.0.2) only contains the SDKs for version 10.9 and 10.8, so we might need to add requireFile directives for older versions as well. Signed-off-by: aszlig --- pkgs/os-specific/darwin/xcode/default.nix | 37 +++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 39 insertions(+) create mode 100644 pkgs/os-specific/darwin/xcode/default.nix diff --git a/pkgs/os-specific/darwin/xcode/default.nix b/pkgs/os-specific/darwin/xcode/default.nix new file mode 100644 index 000000000000..671e73a0fa52 --- /dev/null +++ b/pkgs/os-specific/darwin/xcode/default.nix @@ -0,0 +1,37 @@ +{ stdenv, requireFile, xpwn }: + +stdenv.mkDerivation rec { + name = "xcode-${version}"; + version = "5.0.2"; + + src = requireFile { + name = "xcode_${version}.dmg"; + url = meta.homepage; + sha256 = "0mrligqkfqwx8cy883pxm4w5w7a17nfh227zdspfll23r9agf32k"; + }; + + phases = [ "unpackPhase" "installPhase" "fixupPhase" ]; + + unpackCmd = let + basePath = "Xcode.app/Contents/Developer/Platforms/MacOSX.platform"; + sdkPath = "${basePath}/Developer/SDKs"; + in '' + ${xpwn}/bin/dmg extract "$curSrc" main.hfs > /dev/null + ${xpwn}/bin/hfsplus main.hfs extractall "${sdkPath}" > /dev/null + ''; + + setSourceRoot = "sourceRoot=MacOSX10.9.sdk"; + + installPhase = '' + ensureDir "$out/share/sysroot" + cp -a * "$out/share/sysroot/" + ln -s "$out/usr/lib" "$out/lib" + ln -s "$out/usr/include" "$out/include" + ''; + + meta = { + homepage = "https://developer.apple.com/downloads/"; + description = "Apple's XCode SDK"; + license = stdenv.lib.licenses.unfree; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9ab8331bce99..93caa5c7796b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6546,6 +6546,8 @@ let cramfsswap = callPackage ../os-specific/linux/cramfsswap { }; + darwin.xcode = callPackage ../os-specific/darwin/xcode { }; + devicemapper = lvm2; dmidecode = callPackage ../os-specific/linux/dmidecode { }; From dd10bb3181928bac42e5213125887d62555d6a3a Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Mar 2014 03:57:48 +0100 Subject: [PATCH 18/37] Add a cross-platform port of cctools. This basically is binutils for Mac OS X, but ported to work on (GNU/)Linux and FreeBSD. And it's up-to-date as well! I'm mentioning this, because it was quite hard to find a recent port of it and I just accidentally stumbled on it while trying to do the port by myself. So thanks to @tpoechtrager for doing this. Also, I've added two more patches, which essentially are: * ld-rpath-nonfinal: This allows -rpath to be used for linking non-final builds, which was allowed for earlier versions of cctools and got a check for that in more recent versions. * ld-ignore-rpath-link: Ignores the -rpath-link option, because the cross-wrapper uses it in different places. Unfortunately, the cctools linker doesn't support it, so we might need to implement this later if it's possible (I'm not a Mach-O man^H^H^Hexpert). Signed-off-by: aszlig --- .../darwin/cctools-port/default.nix | 55 +++++++++++++++++++ .../cctools-port/ld-ignore-rpath-link.patch | 16 ++++++ .../cctools-port/ld-rpath-nonfinal.patch | 31 +++++++++++ pkgs/top-level/all-packages.nix | 8 ++- 4 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 pkgs/os-specific/darwin/cctools-port/default.nix create mode 100644 pkgs/os-specific/darwin/cctools-port/ld-ignore-rpath-link.patch create mode 100644 pkgs/os-specific/darwin/cctools-port/ld-rpath-nonfinal.patch diff --git a/pkgs/os-specific/darwin/cctools-port/default.nix b/pkgs/os-specific/darwin/cctools-port/default.nix new file mode 100644 index 000000000000..0d40409a9944 --- /dev/null +++ b/pkgs/os-specific/darwin/cctools-port/default.nix @@ -0,0 +1,55 @@ +{ stdenv, cross, fetchurl, autoconf, automake, libtool +, libcxx, llvm, clang, openssl, libuuid +}: + +stdenv.mkDerivation rec { + name = "cctools-port-${version}"; + version = "845"; + + src = fetchurl { + url = "https://github.com/tpoechtrager/cctools-port/archive/" + + "cctools-${version}-ld64-136-1.tar.gz"; + sha256 = "06pg6h1g8avgx4j6cfykdpggf490li796gzhhyqn27jsagli307i"; + }; + + buildInputs = [ + autoconf automake libtool libcxx llvm clang openssl libuuid + ]; + + patches = [ ./ld-rpath-nonfinal.patch ./ld-ignore-rpath-link.patch ]; + + enableParallelBuilding = true; + + postPatch = '' + patchShebangs tools + sed -i -e 's/which/type -P/' tools/*.sh + sed -i -e 's|clang++|& -I${libcxx}/include/c++/v1|' cctools/autogen.sh + + # Workaround for https://www.sourceware.org/bugzilla/show_bug.cgi?id=11157 + cat > cctools/include/unistd.h < 0 ) { +- if ( !minOS(ld::mac10_5, ld::iOS_2_0) ) +- throw "-rpath can only be used when targeting Mac OS X 10.5 or later"; +- switch ( fOutputKind ) { +- case Options::kDynamicExecutable: +- case Options::kDynamicLibrary: +- case Options::kDynamicBundle: +- break; +- case Options::kStaticExecutable: +- case Options::kObjectFile: +- case Options::kDyld: +- case Options::kPreload: +- case Options::kKextBundle: +- throw "-rpath can only be used when creating a dynamic final linked image"; +- } +- } +- ++ if ( fRPaths.size() > 0 && !minOS(ld::mac10_5, ld::iOS_2_0) ) ++ throw "-rpath can only be used when targeting Mac OS X 10.5 or later"; ++ + if ( fPositionIndependentExecutable ) { + switch ( fOutputKind ) { + case Options::kDynamicExecutable: diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 93caa5c7796b..dfe977678ffd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6546,7 +6546,13 @@ let cramfsswap = callPackage ../os-specific/linux/cramfsswap { }; - darwin.xcode = callPackage ../os-specific/darwin/xcode { }; + darwin = { + cctools = forceNativeDrv (callPackage ../os-specific/darwin/cctools-port { + cross = assert crossSystem != null; crossSystem; + }); + + xcode = callPackage ../os-specific/darwin/xcode {}; + }; devicemapper = lvm2; From 9a0a85827c3bc903d7c82f251fa129e91f457e85 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Mar 2014 04:10:34 +0100 Subject: [PATCH 19/37] gcc-4.8: Hook in cross-darwin libc and binutils. Let's finally hook everything into the existing cross-building infrastructure. We're using --with-sysroot instead of --with-headers here, because the XCode SDK contains references to /usr/lib. I've tried to patch those references, but unfortunately (at least with install_name_tool) it isn't possible to change those refernces in stub dylibs. So after bugging @tpoechtrager with annoying questions (thanks again), I think my initial approach (patching the SDK itself and/or regenerating the dylib stubs) was way to complicated so I ended up with this implementation. Also, I've added a condition to binutilsCross to use cctools if the libc is set to libSystem. This might need some cleanups someday, mainly to figure out how to properly bridge cctools and binutils. So, as an example on how to cross-compile GNU Hello to Darwin, you can use something like this: (import { crossSystem = { config = "x86_64-apple-darwin13"; arch = "x86_64"; libc = "libSystem"; platform = {}; }; }).hello.crossDrv Signed-off-by: aszlig --- pkgs/development/compilers/gcc/4.8/default.nix | 10 ++++++++-- pkgs/top-level/all-packages.nix | 17 +++++++++++------ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index aea525933234..8a8a80c090ad 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -117,7 +117,8 @@ let version = "4.8.2"; withMode; /* Cross-gcc settings */ - crossMingw = (cross != null && cross.libc == "msvcrt"); + crossMingw = cross != null && cross.libc == "msvcrt"; + crossDarwin = cross != null && cross.libc == "libSystem"; crossConfigureFlags = let gccArch = stdenv.cross.gcc.arch or null; gccCpu = stdenv.cross.gcc.cpu or null; @@ -161,7 +162,12 @@ let version = "4.8.2"; " --disable-shared" + " --disable-decimal-float" # libdecnumber requires libc else - " --with-headers=${libcCross}/include" + + (if crossDarwin then + " --with-sysroot=${libcCross}/share/sysroot" + + " --with-as=${binutilsCross}/bin/${cross.config}-as" + + " --with-ld=${binutilsCross}/bin/${cross.config}-ld" + else + " --with-headers=${libcCross}/include") + " --enable-__cxa_atexit" + " --enable-long-long" + (if crossMingw then diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index dfe977678ffd..f65d493b9d6a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -2430,8 +2430,10 @@ let gccCrossStageStatic = let isMingw = (stdenv.cross.libc == "msvcrt"); isMingw64 = isMingw && stdenv.cross.config == "x86_64-w64-mingw32"; + isDarwin = stdenv.cross.libc == "libSystem"; libcCross1 = if isMingw64 then windows.mingw_w64_headers else - if isMingw then windows.mingw_headers1 else null; + if isMingw then windows.mingw_headers1 else + if isDarwin then darwin.xcode else null; in wrapGCCCross { gcc = forceNativeDrv (lib.addMetaAttrs { hydraPlatforms = []; } ( @@ -3452,11 +3454,13 @@ let gold = false; }); - binutilsCross = lowPrio (forceNativeDrv (import ../development/tools/misc/binutils { - inherit stdenv fetchurl zlib; - noSysDirs = true; - cross = assert crossSystem != null; crossSystem; - })); + binutilsCross = + if crossSystem != null && crossSystem.libc == "libSystem" then darwin.cctools + else lowPrio (forceNativeDrv (import ../development/tools/misc/binutils { + inherit stdenv fetchurl zlib; + noSysDirs = true; + cross = assert crossSystem != null; crossSystem; + })); bison2 = callPackage ../development/tools/parsing/bison/2.x.nix { }; bison3 = callPackage ../development/tools/parsing/bison/3.x.nix { }; @@ -4249,6 +4253,7 @@ let else if name == "msvcrt" && stdenv.cross.config == "x86_64-w64-mingw32" then windows.mingw_w64 else if name == "msvcrt" then windows.mingw_headers3 + else if name == "libSystem" then darwin.xcode else throw "Unknown libc"; libcCross = assert crossSystem != null; libcCrossChooser crossSystem.libc; From 46e90f76c6d73a8ecd33cb8e3bfaff50b20f32e0 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Mar 2014 21:36:43 +0100 Subject: [PATCH 20/37] tzdata: Provide lib as an additional output. We're already using tzcode inside tzdata, so let's make it available as an output here. The reason we need it is in order to compile OpenCFLite. Signed-off-by: aszlig --- pkgs/data/misc/tzdata/default.nix | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkgs/data/misc/tzdata/default.nix b/pkgs/data/misc/tzdata/default.nix index da043da09678..57b1dddbda55 100644 --- a/pkgs/data/misc/tzdata/default.nix +++ b/pkgs/data/misc/tzdata/default.nix @@ -17,13 +17,17 @@ stdenv.mkDerivation rec { ]; sourceRoot = "."; + outputs = [ "out" "lib" ]; - makeFlags = "TOPDIR=$(out) TZDIR=$(out)/share/zoneinfo ETCDIR=$(TMPDIR)/etc LIBDIR=$(TMPDIR)/lib MANDIR=$(TMPDIR)/man AWK=awk"; + makeFlags = "TOPDIR=$(out) TZDIR=$(out)/share/zoneinfo ETCDIR=$(TMPDIR)/etc LIBDIR=$(lib)/lib MANDIR=$(TMPDIR)/man AWK=awk"; postInstall = '' mv $out/share/zoneinfo-posix $out/share/zoneinfo/posix mv $out/share/zoneinfo-leaps $out/share/zoneinfo/right + + ensureDir "$lib/include" + cp tzfile.h "$lib/include/tzfile.h" ''; meta = { From a9ef42f33ca4ea209c810ee42bf801eb485c68ad Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Mar 2014 21:41:56 +0100 Subject: [PATCH 21/37] gcc-4.8: Add ObjC and ObjC++ support for Darwin. Cross-compiling stuff against Mac OS X's CoreFoundation won't work without ObjC support, and we don't want to compile commandline utilities only, right? Signed-off-by: aszlig --- pkgs/development/compilers/gcc/4.8/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/compilers/gcc/4.8/default.nix b/pkgs/development/compilers/gcc/4.8/default.nix index 8a8a80c090ad..92bfdb683bb5 100644 --- a/pkgs/development/compilers/gcc/4.8/default.nix +++ b/pkgs/development/compilers/gcc/4.8/default.nix @@ -352,6 +352,7 @@ stdenv.mkDerivation ({ ++ optional langAda "ada" ++ optional langVhdl "vhdl" ++ optional langGo "go" + ++ optionals crossDarwin [ "objc" "obj-c++" ] ) ) } From c0d55fcc6ab1ac2c634e2b518440b26378b7abd7 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Mar 2014 21:46:09 +0100 Subject: [PATCH 22/37] xcode: Provide the commandline toolchain as well. This toolchain contains Mach-O binaries and might not be useful in the first place, but there are programs like dsymutil, where Apple didn't release the source code, so we need a Mach-O loader... Signed-off-by: aszlig --- pkgs/os-specific/darwin/xcode/default.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/darwin/xcode/default.nix b/pkgs/os-specific/darwin/xcode/default.nix index 671e73a0fa52..5c8e7a3ef6c1 100644 --- a/pkgs/os-specific/darwin/xcode/default.nix +++ b/pkgs/os-specific/darwin/xcode/default.nix @@ -11,6 +11,7 @@ stdenv.mkDerivation rec { }; phases = [ "unpackPhase" "installPhase" "fixupPhase" ]; + outputs = [ "out" "toolchain" ]; unpackCmd = let basePath = "Xcode.app/Contents/Developer/Platforms/MacOSX.platform"; @@ -25,8 +26,15 @@ stdenv.mkDerivation rec { installPhase = '' ensureDir "$out/share/sysroot" cp -a * "$out/share/sysroot/" - ln -s "$out/usr/lib" "$out/lib" - ln -s "$out/usr/include" "$out/include" + ln -s "$out/share/sysroot/usr/lib" "$out/lib" + ln -s "$out/share/sysroot/usr/include" "$out/include" + + ensureDir "$toolchain" + pushd "$toolchain" + ${xpwn}/bin/hfsplus "$(dirs +1)/../main.hfs" extractall \ + Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr \ + > /dev/null + popd ''; meta = { From 53a267e535381e33e7c6f0eabda56a8b04027e36 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Mar 2014 21:59:26 +0100 Subject: [PATCH 23/37] darwin: Add new package opencflite. This provides a port of Mac OS X's CoreFoundation and is needed if we want to be able to run dsymutil using maloader. Signed-off-by: aszlig --- .../os-specific/darwin/opencflite/default.nix | 21 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 pkgs/os-specific/darwin/opencflite/default.nix diff --git a/pkgs/os-specific/darwin/opencflite/default.nix b/pkgs/os-specific/darwin/opencflite/default.nix new file mode 100644 index 000000000000..a2408bfc5c8a --- /dev/null +++ b/pkgs/os-specific/darwin/opencflite/default.nix @@ -0,0 +1,21 @@ +{ stdenv, fetchurl, icu, libuuid, tzdata }: + +stdenv.mkDerivation rec { + name = "opencflite-${version}"; + version = "476.19.0"; + + src = fetchurl { + url = "mirror://sourceforge/opencflite/${name}.tar.gz"; + sha256 = "0jgmzs0ycl930hmzcvx0ykryik56704yw62w394q1q3xw5kkjn9v"; + }; + + configureFlags = [ "--with-uuid=${libuuid}" ]; + buildInputs = [ icu tzdata.lib ]; + enableParallelBuilding = true; + + meta = { + description = "Cross platform port of the OS X CoreFoundation"; + homepage = "http://sourceforge.net/projects/opencflite/"; + license = stdenv.lib.licenses.apsl20; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f65d493b9d6a..514f5c24b32d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6556,6 +6556,8 @@ let cross = assert crossSystem != null; crossSystem; }); + opencflite = callPackage ../os-specific/darwin/opencflite {}; + xcode = callPackage ../os-specific/darwin/xcode {}; }; From 45cd9994bc01641d0ed9ed9691cfdfa15fb87a54 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Mar 2014 22:02:46 +0100 Subject: [PATCH 24/37] darwin: Add new package maloader. This is the mentioned Mach-O loader that we're yoing to use to execute Apple's proprietary binaries. Signed-off-by: aszlig --- pkgs/os-specific/darwin/maloader/default.nix | 36 ++++++++++++++++++++ pkgs/top-level/all-packages.nix | 6 +++- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 pkgs/os-specific/darwin/maloader/default.nix diff --git a/pkgs/os-specific/darwin/maloader/default.nix b/pkgs/os-specific/darwin/maloader/default.nix new file mode 100644 index 000000000000..f5bfe890735c --- /dev/null +++ b/pkgs/os-specific/darwin/maloader/default.nix @@ -0,0 +1,36 @@ +{ stdenv, fetchgit, opencflite, clang, libcxx }: + +stdenv.mkDerivation { + name = "maloader-0git"; + + src = fetchgit { + url = "git://github.com/shinh/maloader.git"; + rev = "5f220393e0b7b9ad0cf1aba0e89df2b42a1f0442"; + sha256 = "07j9b7n0grrbxxyn2h8pnk6pa8b370wq5z5zwbds8dlhi7q37rhn"; + }; + + postPatch = '' + sed -i \ + -e '/if.*loadLibMac.*mypath/s|mypath|"'"$out/lib/"'"|' \ + -e 's|libCoreFoundation\.so|${opencflite}/lib/&|' \ + ld-mac.cc + ''; + + NIX_CFLAGS_COMPILE = "-I${libcxx}/include/c++/v1"; + buildInputs = [ clang libcxx ]; + buildFlags = [ "USE_LIBCXX=1" "release" ]; + + installPhase = '' + install -vD libmac.so "$out/lib/libmac.so" + + for bin in extract macho2elf ld-mac; do + install -vD "$bin" "$out/bin/$bin" + done + ''; + + meta = { + description = "Mach-O loader for Linux"; + homepage = "https://github.com/shinh/maloader"; + license = stdenv.lib.licenses.bsd2; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 514f5c24b32d..c6ea2cbc3fee 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6551,11 +6551,15 @@ let cramfsswap = callPackage ../os-specific/linux/cramfsswap { }; - darwin = { + darwin = rec { cctools = forceNativeDrv (callPackage ../os-specific/darwin/cctools-port { cross = assert crossSystem != null; crossSystem; }); + maloader = callPackage ../os-specific/darwin/maloader { + inherit opencflite; + }; + opencflite = callPackage ../os-specific/darwin/opencflite {}; xcode = callPackage ../os-specific/darwin/xcode {}; From 3940b219882f873314cd36c261cf807e94fa5f3b Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Mar 2014 22:08:51 +0100 Subject: [PATCH 25/37] cctools-port: Pass through wrapped XCToolchain. At the moment, this includes only dyldinfo, dwarfdump and dsymutil, but we'll see whether we need more of these utilities later. Tho reason those are wrapped in cctools-port is because it is the binutils used to cross-compile for Mac OS X. Signed-off-by: aszlig --- pkgs/os-specific/darwin/cctools-port/default.nix | 11 ++++++++++- pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/pkgs/os-specific/darwin/cctools-port/default.nix b/pkgs/os-specific/darwin/cctools-port/default.nix index 0d40409a9944..cdc259c1e2a0 100644 --- a/pkgs/os-specific/darwin/cctools-port/default.nix +++ b/pkgs/os-specific/darwin/cctools-port/default.nix @@ -1,5 +1,6 @@ { stdenv, cross, fetchurl, autoconf, automake, libtool , libcxx, llvm, clang, openssl, libuuid +, maloader, makeWrapper, xctoolchain }: stdenv.mkDerivation rec { @@ -13,7 +14,7 @@ stdenv.mkDerivation rec { }; buildInputs = [ - autoconf automake libtool libcxx llvm clang openssl libuuid + autoconf automake libtool libcxx llvm clang openssl libuuid makeWrapper ]; patches = [ ./ld-rpath-nonfinal.patch ./ld-ignore-rpath-link.patch ]; @@ -47,6 +48,14 @@ stdenv.mkDerivation rec { "--target=${cross.config}" ]; + postInstall = '' + for tool in dyldinfo dwarfdump dsymutil; do + makeWrapper "${maloader}/bin/ld-mac" "$out/bin/${cross.config}-$tool" \ + --add-flags "${xctoolchain}/bin/$tool" + ln -s "$out/bin/${cross.config}-$tool" "$out/bin/$tool" + done + ''; + meta = { homepage = "http://www.opensource.apple.com/source/cctools/"; description = "Mac OS X Compiler Tools (cross-platform port)"; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index c6ea2cbc3fee..9109e1e59522 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6554,6 +6554,8 @@ let darwin = rec { cctools = forceNativeDrv (callPackage ../os-specific/darwin/cctools-port { cross = assert crossSystem != null; crossSystem; + inherit maloader; + xctoolchain = xcode.toolchain; }); maloader = callPackage ../os-specific/darwin/maloader { From 745c4779305490816682bb95b319923d27c4a8fe Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Mar 2014 22:17:04 +0100 Subject: [PATCH 26/37] lua5.2/cross: Fix build for Darwin. The ld from cctools doesn't like the -soname argument, so let's strip it off for now until we have a binutils <-> cctools bridge. Signed-off-by: aszlig --- pkgs/development/interpreters/lua-5/5.2.nix | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/pkgs/development/interpreters/lua-5/5.2.nix b/pkgs/development/interpreters/lua-5/5.2.nix index 70ab0c3bdf8b..c496d14083e7 100644 --- a/pkgs/development/interpreters/lua-5/5.2.nix +++ b/pkgs/development/interpreters/lua-5/5.2.nix @@ -49,6 +49,30 @@ stdenv.mkDerivation rec { EOF ''; + crossAttrs = let + isDarwin = stdenv.cross.libc == "libSystem"; + in { + configurePhase = '' + makeFlagsArray=( + INSTALL_TOP=$out + INSTALL_MAN=$out/share/man/man1 + CC=${stdenv.cross.config}-gcc + STRIP=: + RANLIB=${stdenv.cross.config}-ranlib + V=${majorVersion} + R=${version} + ${stdenv.lib.optionalString isDarwin '' + AR="${stdenv.cross.config}-ar rcu" + macosx + ''} + ) + ''; + } // stdenv.lib.optionalAttrs isDarwin { + postPatch = '' + sed -i -e 's/-Wl,-soname[^ ]* *//' src/Makefile + ''; + }; + meta = { homepage = "http://www.lua.org"; description = "Powerful, fast, lightweight, embeddable scripting language"; From 3d73bf6c57d9406accfdbe89a46f38c492364ec3 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Mar 2014 22:22:21 +0100 Subject: [PATCH 27/37] glew/cross: Fix build for Darwin. The Makefile still contained calls to install with the -s (strip) option, which we don't want because it uses the native strip utility and we're going to crossStrip in fixupPhase later anyway. Signed-off-by: aszlig --- pkgs/development/libraries/glew/default.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkgs/development/libraries/glew/default.nix b/pkgs/development/libraries/glew/default.nix index ef81f210d39f..1106a0139497 100644 --- a/pkgs/development/libraries/glew/default.nix +++ b/pkgs/development/libraries/glew/default.nix @@ -1,5 +1,7 @@ { stdenv, fetchurl, mesa_glu, x11, libXmu, libXi }: +with stdenv.lib; + stdenv.mkDerivation rec { name = "glew-1.10.0"; @@ -14,6 +16,9 @@ stdenv.mkDerivation rec { patchPhase = '' sed -i 's|lib64|lib|' config/Makefile.linux + ${optionalString (stdenv ? cross) '' + sed -i -e 's/\(INSTALL.*\)-s/\1/' Makefile + ''} ''; buildPhase = "make all"; @@ -25,6 +30,13 @@ buildPhase = "make all"; cp -r README.txt LICENSE.txt doc $out/share/doc/glew ''; + crossAttrs.makeFlags = [ + "CC=${stdenv.cross.config}-gcc" + "LD=${stdenv.cross.config}-gcc" + "AR=${stdenv.cross.config}-ar" + "STRIP=" + ] ++ optional (stdenv.cross.libc == "libSystem") "SYSTEM=darwin"; + meta = { description = "An OpenGL extension loading library for C(++)"; homepage = http://glew.sourceforge.net/; From 30962765e07336eecfe959d5834f8d4eecc56df4 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Mar 2014 22:27:54 +0100 Subject: [PATCH 28/37] openssl/cross: Fix build for Darwin. This is just a minor fix, because when using "darwin64-x86_64-cc" for config.openssl.system, the OpenSSL build scripts try to compile with $prefix-cc, which is not available with the gcc-cross-wrapper. Signed-off-by: aszlig --- pkgs/development/libraries/openssl/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix index 7d7ccacd14ad..4dd63078d667 100644 --- a/pkgs/development/libraries/openssl/default.nix +++ b/pkgs/development/libraries/openssl/default.nix @@ -91,6 +91,8 @@ stdenv.mkDerivation { rm $out/bin/c_rehash $out/ssl/misc/CA.pl $out/ssl/misc/tsget ''; configureScript = "./Configure"; + } // stdenv.lib.optionalAttrs (opensslCrossSystem == "darwin64-x86_64-cc") { + CC = "gcc"; }; meta = { From 8c053312b5633c0e180edff68335b3652cc5c6df Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Mar 2014 22:30:13 +0100 Subject: [PATCH 29/37] zlib/cross: Fix build for Darwin. Provide the correct cross ranlib, because native ranlib will fail. Signed-off-by: aszlig --- pkgs/development/libraries/zlib/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix index 0d4abaf25e0a..37675e4a5bca 100644 --- a/pkgs/development/libraries/zlib/default.nix +++ b/pkgs/development/libraries/zlib/default.nix @@ -36,6 +36,8 @@ stdenv.mkDerivation rec { "-f" "win32/Makefile.gcc" "PREFIX=${stdenv.cross.config}-" ] ++ (if static then [] else [ "SHARED_MODE=1" ]); + } // stdenv.lib.optionalAttrs (stdenv.cross.libc == "libSystem") { + makeFlags = [ "RANLIB=${stdenv.cross.config}-ranlib" ]; }; # zlib doesn't like the automatic --disable-shared from the Cygwin stdenv. From 2d17335f6869f88e5bbcef4f1c7a3329e5860ccb Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 12 Mar 2014 06:21:17 +0100 Subject: [PATCH 30/37] gcc-cross-wrapper: Allow to pass US X min version. This allows to pass a new attribute osxMinVersion to crossSystem, which specifies the minimum Mac OS X version you want to be compatible to. Signed-off-by: aszlig --- pkgs/build-support/gcc-cross-wrapper/builder.sh | 4 ++++ pkgs/build-support/gcc-cross-wrapper/default.nix | 1 + 2 files changed, 5 insertions(+) diff --git a/pkgs/build-support/gcc-cross-wrapper/builder.sh b/pkgs/build-support/gcc-cross-wrapper/builder.sh index 5a5bd45a8f81..18d26b3e9451 100644 --- a/pkgs/build-support/gcc-cross-wrapper/builder.sh +++ b/pkgs/build-support/gcc-cross-wrapper/builder.sh @@ -26,6 +26,10 @@ if test -z "$nativeLibc"; then fi fi + if [ -n "$osxMinVersion" ]; then + cflagsCompile="$cflagsCompile -mmacosx-version-min=$osxMinVersion" + fi + echo "$cflagsCompile -B$libc/lib/ -idirafter $libc/include -idirafter $gcc/lib/gcc/*/*/include-fixed" > $out/nix-support/libc-cflags echo "-L$libc/lib -rpath $libc/lib -rpath-link $libc/lib" > $out/nix-support/libc-ldflags diff --git a/pkgs/build-support/gcc-cross-wrapper/default.nix b/pkgs/build-support/gcc-cross-wrapper/default.nix index b2e30be10ef7..d3494b83a87b 100644 --- a/pkgs/build-support/gcc-cross-wrapper/default.nix +++ b/pkgs/build-support/gcc-cross-wrapper/default.nix @@ -46,6 +46,7 @@ stdenv.mkDerivation { addFlags = ./add-flags; inherit nativeTools nativeLibc nativePrefix gcc libc binutils; crossConfig = if cross != null then cross.config else null; + osxMinVersion = cross.osxMinVersion or null; gccLibs = if gcc != null then gccLibs else null; name = chosenName; langC = if nativeTools then true else gcc.langC; From 5e95800f267a848e4a75591363872c5eb10f3ee5 Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 12 Mar 2014 06:25:54 +0100 Subject: [PATCH 31/37] openssl: Use Darwin patch for cross-builds too. Might be better to have something like stdenv.isDarwinTarget, which can be used to test for native Darwin _and_ cross-built Darwin as a target. Signed-off-by: aszlig --- pkgs/development/libraries/openssl/default.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/development/libraries/openssl/default.nix b/pkgs/development/libraries/openssl/default.nix index 4dd63078d667..39e6cb3692d3 100644 --- a/pkgs/development/libraries/openssl/default.nix +++ b/pkgs/development/libraries/openssl/default.nix @@ -8,7 +8,9 @@ let (throw "openssl needs its platform name cross building" null) stdenv.cross; - patchesCross = isCross: + patchesCross = isCross: let + isDarwin = stdenv.isDarwin || (isCross && stdenv.cross.libc == "libSystem"); + in [ # Allow the location of the X509 certificate file (the CA # bundle) to be set through the environment variable # ‘OPENSSL_X509_CERT_FILE’. This is necessary because the @@ -29,7 +31,7 @@ let ./kfreebsd-gnu.patch ] - ++ stdenv.lib.optional stdenv.isDarwin ./darwin-arch.patch; + ++ stdenv.lib.optional isDarwin ./darwin-arch.patch; in From f73851710ebe3d951fb98ee286f42e4398243333 Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 12 Mar 2014 06:28:21 +0100 Subject: [PATCH 32/37] audiofile: Use alsaLib for native Linux only. Using ALSA for non-Linux systems really doesn't make much sense, so using buildNativeInputs to ensure it won't be used for cross-builds. Of course, if you're cross-building to Linux, the dependency won't be used, but right now we don't have a good way to easily check whether the cross target is Linux. Signed-off-by: aszlig --- pkgs/development/libraries/audiofile/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/audiofile/default.nix b/pkgs/development/libraries/audiofile/default.nix index a5fd80dc0db9..c8fb8c53dc0c 100644 --- a/pkgs/development/libraries/audiofile/default.nix +++ b/pkgs/development/libraries/audiofile/default.nix @@ -3,7 +3,7 @@ stdenv.mkDerivation rec { name = "audiofile-0.3.6"; - buildInputs = stdenv.lib.optional (!stdenv.isDarwin) alsaLib; + nativeBuildInputs = stdenv.lib.optional stdenv.isLinux alsaLib; src = fetchurl { url = "http://audiofile.68k.org/${name}.tar.gz"; From cdaced58aec376965e3e5ee422e098df526e4726 Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 12 Mar 2014 06:34:42 +0100 Subject: [PATCH 33/37] libpng12/cross: Don't add zlib for Darwin builds. Cross builds for Darwin already include the CoreFoundation and the libraries from XCode, so zlib already exists on that platform. Signed-off-by: aszlig --- pkgs/development/libraries/libpng/12.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/libpng/12.nix b/pkgs/development/libraries/libpng/12.nix index 031e2aa1a914..b7fad76acaa3 100644 --- a/pkgs/development/libraries/libpng/12.nix +++ b/pkgs/development/libraries/libpng/12.nix @@ -1,6 +1,6 @@ { stdenv, fetchurl, zlib, xz }: -assert zlib != null; +assert !(stdenv ? cross) -> zlib != null; stdenv.mkDerivation rec { name = "libpng-1.2.50"; @@ -16,6 +16,11 @@ stdenv.mkDerivation rec { passthru = { inherit zlib; }; + crossAttrs = stdenv.lib.optionalAttrs (stdenv.cross.libc == "libSystem") { + propagatedBuildInputs = []; + passthru = {}; + }; + meta = { description = "The official reference implementation for the PNG file format"; homepage = http://www.libpng.org/pub/png/libpng.html; From 6998a866a86e934d13c29078963ebfa59fe0f438 Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 12 Mar 2014 06:36:34 +0100 Subject: [PATCH 34/37] SDL: Refactor package and fix Darwin cross-builds. First of all, this needs two upstream patches for supporting OS X 10.9, also the cross-gcc doesn't accept -fpascal-strings, so drop the flag. And except putting all configure flags into a multiline string, we're now using a list, which is easier when it comes to handling optional components. As X isn't used on recent Mac OS X versions and Windows, I'm temporarily using --without-x for cross-builds until we have a better way to check for those things. Also, don't add audiofile to buildInputs if we're cross-compiling for MinGW. Signed-off-by: aszlig --- pkgs/development/libraries/SDL/default.nix | 43 +++++++++++++++------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/pkgs/development/libraries/SDL/default.nix b/pkgs/development/libraries/SDL/default.nix index e58397fa9a5b..476ec73ba18c 100644 --- a/pkgs/development/libraries/SDL/default.nix +++ b/pkgs/development/libraries/SDL/default.nix @@ -7,21 +7,13 @@ # OSS is no longer supported, for it's much crappier than ALSA and # PulseAudio. -assert alsaSupport || pulseaudioSupport; +assert !(stdenv ? cross) -> alsaSupport || pulseaudioSupport; assert openglSupport -> (mesa != null && x11Support); assert x11Support -> (x11 != null && libXrandr != null); assert alsaSupport -> alsaLib != null; assert pulseaudioSupport -> pulseaudio != null; -let - configureFlagsFun = attrs: '' - --disable-oss --disable-video-x11-xme - --disable-x11-shared --disable-alsa-shared --enable-rpath --disable-pulseaudio-shared - --disable-osmesa-shared - ${if alsaSupport then "--with-alsa-prefix=${attrs.alsaLib}/lib" else ""} - ''; -in stdenv.mkDerivation rec { version = "1.2.15"; name = "SDL-${version}"; @@ -35,17 +27,42 @@ stdenv.mkDerivation rec { propagatedBuildInputs = stdenv.lib.optionals x11Support [ x11 libXrandr ] ++ stdenv.lib.optional pulseaudioSupport pulseaudio; - buildInputs = [ pkgconfig audiofile ] ++ + buildInputs = let + notMingw = !(stdenv ? cross) || stdenv.cross.libc != "msvcrt"; + in stdenv.lib.optional notMingw audiofile; + + nativeBuildInputs = [ pkgconfig ] ++ stdenv.lib.optional openglSupport [ mesa ] ++ stdenv.lib.optional alsaSupport alsaLib; # XXX: By default, SDL wants to dlopen() PulseAudio, in which case # we must arrange to add it to its RPATH; however, `patchelf' seems # to fail at doing this, hence `--disable-pulseaudio-shared'. - configureFlags = configureFlagsFun { inherit alsaLib; }; + configureFlags = [ + "--disable-oss" + "--disable-video-x11-xme" + "--disable-x11-shared" + "--disable-alsa-shared" + "--enable-rpath" + "--disable-pulseaudio-shared" + "--disable-osmesa-shared" + ] ++ stdenv.lib.optionals (stdenv ? cross) ([ + "--without-x" + ] ++ stdenv.lib.optional alsaSupport "--with-alsa-prefix=${alsaLib}/lib"); - crossAttrs = { - configureFlags = configureFlagsFun { alsaLib = alsaLib.crossDrv; }; + crossAttrs =stdenv.lib.optionalAttrs (stdenv.cross.libc == "libSystem") { + patches = let + f = rev: sha256: fetchurl { + url = "http://hg.libsdl.org/SDL/raw-rev/${rev}"; + inherit sha256; + }; + in [ + (f "e9466ead70e5" "0ygir3k83d0vxp7s3k48jn3j8n2bnv9wm6613wpx3ybnjrxabrip") + (f "bbfb41c13a87" "17v29ybjifvka19m8qf14rjc43nfdwk9v9inaizznarhb17amlnv") + ]; + postPatch = '' + sed -i -e 's/ *-fpascal-strings//' configure + ''; }; passthru = {inherit openglSupport;}; From 5eb3dd8a1b952aba821aa55557232ee443dc19bb Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 12 Mar 2014 06:42:05 +0100 Subject: [PATCH 35/37] cmake: Add patch for fixing Darwin cross-builds. This is an upstream patch and will eventually get into the next release. Signed-off-by: aszlig --- pkgs/development/tools/build-managers/cmake/default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pkgs/development/tools/build-managers/cmake/default.nix b/pkgs/development/tools/build-managers/cmake/default.nix index 9ce69374cd88..42277b22036b 100644 --- a/pkgs/development/tools/build-managers/cmake/default.nix +++ b/pkgs/development/tools/build-managers/cmake/default.nix @@ -26,7 +26,13 @@ stdenv.mkDerivation rec { patches = # Don't search in non-Nix locations such as /usr, but do search in # Nixpkgs' Glibc. - optional (stdenv ? glibc) ./search-path.patch; + optional (stdenv ? glibc) ./search-path.patch ++ + optional (stdenv ? cross) (fetchurl { + name = "fix-darwin-cross-compile.patch"; + url = "http://public.kitware.com/Bug/file_download.php?" + + "file_id=4981&type=bug"; + sha256 = "16acmdr27adma7gs9rs0dxdiqppm15vl3vv3agy7y8s94wyh4ybv"; + }); buildInputs = [ curl expat zlib bzip2 libarchive ] ++ optional useNcurses ncurses From a6621202af47c826bd731ebefcbe5f573dc16ddd Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 12 Mar 2014 06:43:57 +0100 Subject: [PATCH 36/37] xcode: Drop use of weak_import on enumerators. GCC doesn't support attributes on enumerators, which could pose a problem but fortunately not in this case. Here a __attribute__((weak_import)) is used, which doesn't make much sense for enumerators anyway (noone will die because the corresponding enumerator won't be referenced either in older OS X versions). Signed-off-by: aszlig --- pkgs/os-specific/darwin/xcode/default.nix | 13 ++++++++++--- .../darwin/xcode/gcc-fix-enum-attributes.patch | 13 +++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 pkgs/os-specific/darwin/xcode/gcc-fix-enum-attributes.patch diff --git a/pkgs/os-specific/darwin/xcode/default.nix b/pkgs/os-specific/darwin/xcode/default.nix index 5c8e7a3ef6c1..5d4546d63bf7 100644 --- a/pkgs/os-specific/darwin/xcode/default.nix +++ b/pkgs/os-specific/darwin/xcode/default.nix @@ -1,6 +1,10 @@ { stdenv, requireFile, xpwn }: -stdenv.mkDerivation rec { +with stdenv.lib; + +let + osxVersion = "10.9"; +in stdenv.mkDerivation rec { name = "xcode-${version}"; version = "5.0.2"; @@ -10,9 +14,10 @@ stdenv.mkDerivation rec { sha256 = "0mrligqkfqwx8cy883pxm4w5w7a17nfh227zdspfll23r9agf32k"; }; - phases = [ "unpackPhase" "installPhase" "fixupPhase" ]; + phases = [ "unpackPhase" "patchPhase" "installPhase" "fixupPhase" ]; outputs = [ "out" "toolchain" ]; + unpackCmd = let basePath = "Xcode.app/Contents/Developer/Platforms/MacOSX.platform"; sdkPath = "${basePath}/Developer/SDKs"; @@ -21,7 +26,9 @@ stdenv.mkDerivation rec { ${xpwn}/bin/hfsplus main.hfs extractall "${sdkPath}" > /dev/null ''; - setSourceRoot = "sourceRoot=MacOSX10.9.sdk"; + setSourceRoot = "sourceRoot=MacOSX${osxVersion}.sdk"; + + patches = optional (osxVersion == "10.9") ./gcc-fix-enum-attributes.patch; installPhase = '' ensureDir "$out/share/sysroot" diff --git a/pkgs/os-specific/darwin/xcode/gcc-fix-enum-attributes.patch b/pkgs/os-specific/darwin/xcode/gcc-fix-enum-attributes.patch new file mode 100644 index 000000000000..1e1895c28945 --- /dev/null +++ b/pkgs/os-specific/darwin/xcode/gcc-fix-enum-attributes.patch @@ -0,0 +1,13 @@ +diff --git a/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h b/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h +index fa0c290..7da7e0c 100644 +--- a/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h ++++ b/System/Library/Frameworks/Foundation.framework/Headers/NSUserNotification.h +@@ -13,7 +13,7 @@ typedef NS_ENUM(NSInteger, NSUserNotificationActivationType) { + NSUserNotificationActivationTypeNone = 0, + NSUserNotificationActivationTypeContentsClicked = 1, + NSUserNotificationActivationTypeActionButtonClicked = 2, +- NSUserNotificationActivationTypeReplied NS_AVAILABLE(10_9, NA) = 3 ++ NSUserNotificationActivationTypeReplied = 3 + } NS_ENUM_AVAILABLE(10_8, NA); + + NS_CLASS_AVAILABLE(10_8, NA) From a445199db42a99560ae15838444a67bc19498cc1 Mon Sep 17 00:00:00 2001 From: aszlig Date: Wed, 12 Mar 2014 09:12:10 +0100 Subject: [PATCH 37/37] xcode: Update to new version 5.1. This version just got released two days ago, while we were working for cross-builds on 5.0.2. From the release notes it shouldn't introduce any incompatibilities. Signed-off-by: aszlig --- pkgs/os-specific/darwin/xcode/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/os-specific/darwin/xcode/default.nix b/pkgs/os-specific/darwin/xcode/default.nix index 5d4546d63bf7..b80682b7550f 100644 --- a/pkgs/os-specific/darwin/xcode/default.nix +++ b/pkgs/os-specific/darwin/xcode/default.nix @@ -6,12 +6,12 @@ let osxVersion = "10.9"; in stdenv.mkDerivation rec { name = "xcode-${version}"; - version = "5.0.2"; + version = "5.1"; src = requireFile { name = "xcode_${version}.dmg"; url = meta.homepage; - sha256 = "0mrligqkfqwx8cy883pxm4w5w7a17nfh227zdspfll23r9agf32k"; + sha256 = "0zkggbmsfc5w53j1ncbpayvnn1vzpyzyjjjzhawq1jjfq465bfvh"; }; phases = [ "unpackPhase" "patchPhase" "installPhase" "fixupPhase" ];