From 4116754f4583b2f7502c05aa52d4fe09eafad253 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 23 Jul 2018 17:58:48 -0400 Subject: [PATCH 1/8] elfutils: Don't use crossAttrs --- .../tools/misc/elfutils/default.nix | 70 +++++++++---------- 1 file changed, 32 insertions(+), 38 deletions(-) diff --git a/pkgs/development/tools/misc/elfutils/default.nix b/pkgs/development/tools/misc/elfutils/default.nix index 2ee573e4ba18..af140bfb1d65 100644 --- a/pkgs/development/tools/misc/elfutils/default.nix +++ b/pkgs/development/tools/misc/elfutils/default.nix @@ -28,46 +28,40 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; - crossAttrs = { + # This program does not cross-build fine. So I only cross-build some parts + # I need for the linux perf tool. + # On the awful cross-building: + # http://comments.gmane.org/gmane.comp.sysutils.elfutils.devel/2005 + # + # I wrote this testing for the nanonote. - /* Having bzip2 will harm, because anything using elfutils - as buildInput cross-building, will not be able to run 'bzip2' */ - propagatedBuildInputs = [ zlib.crossDrv ]; + buildPhase = if stdenv.hostPlatform == stdenv.buildPlatform then null else '' + pushd libebl + make + popd + pushd libelf + make + popd + pushd libdwfl + make + popd + pushd libdw + make + popd + ''; - # This program does not cross-build fine. So I only cross-build some parts - # I need for the linux perf tool. - # On the awful cross-building: - # http://comments.gmane.org/gmane.comp.sysutils.elfutils.devel/2005 - # - # I wrote this testing for the nanonote. - buildPhase = '' - pushd libebl - make - popd - pushd libelf - make - popd - pushd libdwfl - make - popd - pushd libdw - make - popd - ''; - - installPhase = '' - pushd libelf - make install - popd - pushd libdwfl - make install - popd - pushd libdw - make install - popd - cp version.h $out/include - ''; - }; + installPhase = if stdenv.hostPlatform == stdenv.buildPlatform then null else '' + pushd libelf + make install + popd + pushd libdwfl + make install + popd + pushd libdw + make install + popd + cp version.h $out/include + ''; meta = { homepage = https://sourceware.org/elfutils/; From 1833a04aed4ba5658b71bf7a88492829fc882d6d Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 23 Jul 2018 17:35:23 -0400 Subject: [PATCH 2/8] flex: Don't use crossAttrs --- .../development/tools/parsing/flex/2.5.35.nix | 10 ++++----- pkgs/development/tools/parsing/flex/2.6.1.nix | 21 ++++++++----------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/pkgs/development/tools/parsing/flex/2.5.35.nix b/pkgs/development/tools/parsing/flex/2.5.35.nix index 4f78b0c71c16..1062a361413c 100644 --- a/pkgs/development/tools/parsing/flex/2.5.35.nix +++ b/pkgs/development/tools/parsing/flex/2.5.35.nix @@ -12,12 +12,10 @@ stdenv.mkDerivation rec { propagatedBuildInputs = [ m4 ]; - crossAttrs = { - preConfigure = '' - export ac_cv_func_malloc_0_nonnull=yes - export ac_cv_func_realloc_0_nonnull=yes - ''; - }; + preConfigure = stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "ac_cv_func_malloc_0_nonnull=yes" + "ac_cv_func_realloc_0_nonnull=yes" + ]; meta = { branch = "2.5.35"; diff --git a/pkgs/development/tools/parsing/flex/2.6.1.nix b/pkgs/development/tools/parsing/flex/2.6.1.nix index f27fac9bcb5d..954c2bbcb245 100644 --- a/pkgs/development/tools/parsing/flex/2.6.1.nix +++ b/pkgs/development/tools/parsing/flex/2.6.1.nix @@ -12,22 +12,19 @@ stdenv.mkDerivation rec { propagatedBuildInputs = [ m4 ]; + preConfigure = stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ + "ac_cv_func_malloc_0_nonnull=yes" + "ac_cv_func_realloc_0_nonnull=yes" + ]; + postConfigure = stdenv.lib.optionalString (stdenv.isDarwin || stdenv.isCygwin) '' sed -i Makefile -e 's/-no-undefined//;' ''; - crossAttrs = { - - # disable tests which can't run on build machine - postPatch = '' - substituteInPlace Makefile.in --replace "tests" " "; - ''; - - preConfigure = '' - export ac_cv_func_malloc_0_nonnull=yes - export ac_cv_func_realloc_0_nonnull=yes - ''; - }; + # disable tests which can't run on build machine + postPatch = stdenv.lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' + substituteInPlace Makefile.in --replace "tests" " "; + ''; meta = { homepage = https://github.com/westes/flex; From 519e87a44995ba33916075655bd0b2966747417b Mon Sep 17 00:00:00 2001 From: John Ericson Date: Mon, 23 Jul 2018 17:03:39 -0400 Subject: [PATCH 3/8] util-linux: No more crossAttrs More cleanup will come later --- pkgs/os-specific/linux/util-linux/default.nix | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/pkgs/os-specific/linux/util-linux/default.nix b/pkgs/os-specific/linux/util-linux/default.nix index 87741d29f8e5..d2f75f5875ea 100644 --- a/pkgs/os-specific/linux/util-linux/default.nix +++ b/pkgs/os-specific/linux/util-linux/default.nix @@ -1,5 +1,5 @@ { lib, stdenv, fetchurl, pkgconfig, zlib, shadow -, ncurses ? null, perl ? null, pam, systemd, minimal ? false }: +, ncurses ? null, perl ? null, pam, systemd ? null, minimal ? false }: let version = lib.concatStringsSep "." ([ majorVersion ] @@ -28,12 +28,6 @@ in stdenv.mkDerivation rec { --replace "/bin/umount" "$out/bin/umount" ''; - crossAttrs = { - # Work around use of `AC_RUN_IFELSE'. - preConfigure = "export scanf_cv_type_modifier=ms" + lib.optionalString (systemd != null) - "\nconfigureFlags+=\" --with-systemd --with-systemdsystemunitdir=$bin/lib/systemd/system/\""; - }; - preConfigure = lib.optionalString (systemd != null) '' configureFlags+=" --with-systemd --with-systemdsystemunitdir=$bin/lib/systemd/system/" ''; @@ -49,8 +43,10 @@ in stdenv.mkDerivation rec { "--disable-use-tty-group" "--enable-fs-paths-default=/run/wrappers/bin:/var/run/current-system/sw/bin:/sbin" "--disable-makeinstall-setuid" "--disable-makeinstall-chown" - ] - ++ lib.optional (ncurses == null) "--without-ncurses"; + ] ++ lib.optional (ncurses == null) "--without-ncurses" + ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) + "scanf_cv_type_modifier=ms" + ; makeFlags = "usrbin_execdir=$(bin)/bin usrsbin_execdir=$(bin)/sbin"; From 6bee6b8f4b60a320c23aa221ffad18506984b280 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 24 Jul 2018 16:25:18 -0400 Subject: [PATCH 4/8] qt-4.8: Don't use crossAttrs --- .../libraries/qt-4.x/4.8/default.nix | 114 ++++++++---------- 1 file changed, 53 insertions(+), 61 deletions(-) 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 01d0fc510aaa..471f11ad107b 100644 --- a/pkgs/development/libraries/qt-4.x/4.8/default.nix +++ b/pkgs/development/libraries/qt-4.x/4.8/default.nix @@ -1,5 +1,4 @@ -{ stdenv, fetchurl, fetchpatch, substituteAll -, hostPlatform +{ stdenv, lib, fetchurl, fetchpatch, substituteAll , libXrender, libXinerama, libXcursor, libXv, libXext , libXfixes, libXrandr, libSM, freetype, fontconfig, zlib, libjpeg, libpng , libmng, which, libGLSupported, libGLU, openssl, dbus, cups, pkgconfig @@ -17,8 +16,6 @@ , cf-private, libobjc, ApplicationServices, OpenGL, Cocoa, AGL, libcxx }: -with stdenv.lib; - let v_maj = "4.8"; v_min = "7"; @@ -51,12 +48,12 @@ stdenv.mkDerivation rec { substituteInPlace configure --replace /bin/pwd pwd substituteInPlace src/corelib/global/global.pri --replace /bin/ls ${coreutils}/bin/ls sed -e 's@/\(usr\|opt\)/@/var/empty/@g' -i config.tests/*/*.test -i mkspecs/*/*.conf - '' + stdenv.lib.optionalString stdenv.isDarwin '' + '' + lib.optionalString stdenv.isDarwin '' # remove impure reference to /usr/lib/libstdc++.6.dylib # there might be more references, but this is the only one I could find substituteInPlace tools/macdeployqt/tests/tst_deployment_mac.cpp \ --replace /usr/lib/libstdc++.6.dylib "${stdenv.cc}/lib/libstdc++.6.dylib" - '' + stdenv.lib.optionalString stdenv.cc.isClang '' + '' + lib.optionalString stdenv.cc.isClang '' substituteInPlace src/3rdparty/webkit/Source/WebCore/html/HTMLImageElement.cpp \ --replace 'optionalHeight > 0' 'optionalHeight != NULL' @@ -65,14 +62,15 @@ stdenv.mkDerivation rec { ''; patches = - [ ./glib-2.32.patch + lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [ + ./glib-2.32.patch ./libressl.patch ./parallel-configure.patch ./clang-5-darwin.patch ./qt-4.8.7-unixmake-darwin.patch (substituteAll { src = ./dlopen-absolute-paths.diff; - cups = if cups != null then stdenv.lib.getLib cups else null; + cups = if cups != null then lib.getLib cups else null; icu = icu.out; libXfixes = libXfixes.out; glibc = stdenv.cc.libc.out; @@ -89,25 +87,25 @@ stdenv.mkDerivation rec { sha256 = "07lrva7bjh6i40p7b3ml26a2jlznri8bh7y7iyx5zmvb1gfxmj34"; }) ] - ++ stdenv.lib.optional gtkStyle (substituteAll ({ + ++ lib.optional gtkStyle (substituteAll ({ src = ./dlopen-gtkstyle.diff; # substituteAll ignores env vars starting with capital letter gtk = gtk2.out; - } // stdenv.lib.optionalAttrs gnomeStyle { + } // lib.optionalAttrs gnomeStyle { gconf = GConf.out; libgnomeui = libgnomeui.out; gnome_vfs = gnome_vfs.out; })) - ++ stdenv.lib.optional flashplayerFix (substituteAll { + ++ lib.optional flashplayerFix (substituteAll { src = ./dlopen-webkit-nsplugin.diff; gtk = gtk2.out; gdk_pixbuf = gdk_pixbuf.out; }) - ++ stdenv.lib.optional stdenv.isAarch64 (fetchpatch { + ++ lib.optional stdenv.isAarch64 (fetchpatch { url = "https://src.fedoraproject.org/rpms/qt/raw/ecf530486e0fb7fe31bad26805cde61115562b2b/f/qt-aarch64.patch"; sha256 = "1fbjh78nmafqmj7yk67qwjbhl3f6ylkp6x33b1dqxfw9gld8b3gl"; }) - ++ stdenv.lib.optionals stdenv.hostPlatform.isMusl [ + ++ lib.optionals stdenv.hostPlatform.isMusl [ ./qt-musl.patch ./qt-musl-iconv-no-bom.patch ./patch-qthread-stacksize.diff @@ -127,15 +125,27 @@ stdenv.mkDerivation rec { --jobs=$NIX_BUILD_CORES " unset LD # Makefile uses gcc for linking; setting LD interferes - '' + optionalString stdenv.cc.isClang '' + '' + lib.optionalString stdenv.cc.isClang '' sed -i 's/QMAKE_CC = gcc/QMAKE_CC = clang/' mkspecs/common/g++-base.conf sed -i 's/QMAKE_CXX = g++/QMAKE_CXX = clang++/' mkspecs/common/g++-base.conf + '' + lib.optionalString stdenv.hostPlatform.isWindows '' + sed -i -e 's/ g++/ ${stdenv.cc.targetPrefix}g++/' \ + -e 's/ gcc/ ${stdenv.cc.targetPrefix}gcc/' \ + -e 's/ ar/ ${stdenv.cc.targetPrefix}ar/' \ + -e 's/ strip/ ${stdenv.cc.targetPrefix}strip/' \ + -e 's/ windres/ ${stdenv.cc.targetPrefix}windres/' \ + mkspecs/win32-g++/qmake.conf ''; prefixKey = "-prefix "; - configureFlags = - '' + ${if stdenv.hostPlatform == stdenv.buildPlatform then null else "configurePlatforms"} = []; + configureFlags = let + platformFlag = + if stdenv.hostPlatform != stdenv.buildPlatform + then "-xplatform" + else "-platform"; + in (if stdenv.hostPlatform == stdenv.buildPlatform then '' -v -no-separate-debug-info -release -fast -confirm-license -opensource -${if stdenv.isFreeBSD then "no-" else ""}opengl -xrender -xrandr -xinerama -xcursor -xinput -xfixes -fontconfig @@ -152,23 +162,30 @@ stdenv.mkDerivation rec { -no-phonon ${if buildWebkit then "" else "-no"}-webkit ${if buildMultimedia then "" else "-no"}-multimedia -audio-backend ${if developerBuild then "-developer-build" else ""} - '' + optionalString stdenv.isDarwin "-platform unsupported/macx-clang-libc++"; + '' else '' + -static -release -confirm-license -opensource + -no-opengl -no-phonon + -no-svg + -make qmake -make libs -nomake tools + -nomake demos -nomake examples -nomake docs + '') + lib.optionalString stdenv.hostPlatform.isDarwin "${platformFlag} unsupported/macx-clang-libc++" + + lib.optionalString stdenv.hostPlatform.isMinGW "${platformFlag} win32-g++-4.6"; propagatedBuildInputs = [ libXrender libXrandr libXinerama libXcursor libXext libXfixes libXv libXi libSM zlib libpng openssl dbus freetype fontconfig glib ] # Qt doesn't directly need GLU (just GL), but many apps use, it's small and doesn't remain a runtime-dep if not used - ++ optional libGLSupported libGLU - ++ optional ((buildWebkit || buildMultimedia) && stdenv.isLinux ) alsaLib - ++ optionals (buildWebkit || buildMultimedia) [ gstreamer gst-plugins-base ]; + ++ lib.optional libGLSupported libGLU + ++ lib.optional ((buildWebkit || buildMultimedia) && stdenv.isLinux ) alsaLib + ++ lib.optionals (buildWebkit || buildMultimedia) [ gstreamer gst-plugins-base ]; # The following libraries are only used in plugins buildInputs = [ cups # Qt dlopen's libcups instead of linking to it postgresql sqlite libjpeg libmng libtiff icu ] - ++ optionals (mysql != null) [ mysql.connector-c ] - ++ optionals gtkStyle [ gtk2 gdk_pixbuf ] - ++ optionals stdenv.isDarwin [ cf-private ApplicationServices OpenGL Cocoa AGL libcxx libobjc ]; + ++ lib.optionals (mysql != null) [ mysql.connector-c ] + ++ lib.optionals gtkStyle [ gtk2 gdk_pixbuf ] + ++ lib.optionals stdenv.isDarwin [ cf-private ApplicationServices OpenGL Cocoa AGL libcxx libobjc ]; nativeBuildInputs = [ perl pkgconfig which ]; @@ -177,14 +194,14 @@ stdenv.mkDerivation rec { NIX_CFLAGS_COMPILE = # with gcc7 the warnings blow the log over Hydra's limit [ "-Wno-expansion-to-defined" "-Wno-unused-local-typedefs" ] - ++ optional stdenv.isLinux "-std=gnu++98" # gnu++ in (Obj)C flags is no good on Darwin - ++ optionals (stdenv.isFreeBSD || stdenv.isDarwin) + ++ lib.optional stdenv.isLinux "-std=gnu++98" # gnu++ in (Obj)C flags is no good on Darwin + ++ lib.optionals (stdenv.isFreeBSD || stdenv.isDarwin) [ "-I${glib.dev}/include/glib-2.0" "-I${glib.out}/lib/glib-2.0/include" ] - ++ optional stdenv.isDarwin "-I${libcxx}/include/c++/v1"; + ++ lib.optional stdenv.isDarwin "-I${libcxx}/include/c++/v1"; - NIX_LDFLAGS = optionalString (stdenv.isFreeBSD || stdenv.isDarwin) "-lglib-2.0"; + NIX_LDFLAGS = lib.optionalString (stdenv.isFreeBSD || stdenv.isDarwin) "-lglib-2.0"; - preBuild = optionalString stdenv.isDarwin '' + preBuild = lib.optionalString stdenv.isDarwin '' # resolve "extra qualification on member" error sed -i 's/struct ::TabletProximityRec;/struct TabletProximityRec;/' \ src/gui/kernel/qt_cocoa_helpers_mac_p.h @@ -196,44 +213,19 @@ stdenv.mkDerivation rec { postInstall = '' rm -rf $out/tests + '' + # I don't know why it does not install qmake + + lib.optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' + cp bin/qmake* $out/bin ''; - crossAttrs = { - # I've not tried any case other than i686-pc-mingw32. - # -nomake tools: it fails linking some asian language symbols - # -no-svg: it fails to build on mingw64 - configureFlags = '' - -static -release -confirm-license -opensource - -no-opengl -no-phonon - -no-svg - -make qmake -make libs -nomake tools - -nomake demos -nomake examples -nomake docs - '' + optionalString hostPlatform.isMinGW " -xplatform win32-g++-4.6"; - patches = []; - preConfigure = '' - sed -i -e 's/ g++/ ${stdenv.cc.targetPrefix}g++/' \ - -e 's/ gcc/ ${stdenv.cc.targetPrefix}gcc/' \ - -e 's/ ar/ ${stdenv.cc.targetPrefix}ar/' \ - -e 's/ strip/ ${stdenv.cc.targetPrefix}strip/' \ - -e 's/ windres/ ${stdenv.cc.targetPrefix}windres/' \ - mkspecs/win32-g++/qmake.conf - ''; - - # I don't know why it does not install qmake - postInstall = '' - cp bin/qmake* $out/bin - ''; - configurePlatforms = []; - dontStrip = true; - } // optionalAttrs hostPlatform.isMinGW { - propagatedBuildInputs = [ ]; - }; + dontStrip = if stdenv.hostPlatform == stdenv.buildPlatform then null else true; meta = { homepage = http://qt-project.org/; description = "A cross-platform application framework for C++"; - license = licenses.lgpl21Plus; # or gpl3 - maintainers = with maintainers; [ orivej lovek323 phreedom sander ]; - platforms = platforms.unix; + license = lib.licenses.lgpl21Plus; # or gpl3 + maintainers = with lib.maintainers; [ orivej lovek323 phreedom sander ]; + platforms = lib.platforms.unix; }; } From 87b4a5d6a70dc08168edf81f4cbcfccc2c1dd919 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 24 Jul 2018 16:27:06 -0400 Subject: [PATCH 5/8] stdenv: Remove crossAttrs, now that it is no longer used Fix #33302 --- pkgs/stdenv/adapters.nix | 2 +- pkgs/stdenv/generic/make-derivation.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 18a9c7f38098..8268dd5b0896 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -87,7 +87,7 @@ rec { (hostPlatform.isAarch64 || hostPlatform.isMips || hostPlatform.libc == "musl") pkgs.updateAutotoolsGnuConfigScriptsHook ; - } // args.crossAttrs or {}); + }); }; diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 778f107f71e1..6afd4e3a05eb 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -164,7 +164,7 @@ rec { derivationArg = (removeAttrs attrs - ["meta" "passthru" "crossAttrs" "pos" + ["meta" "passthru" "pos" "doCheck" "doInstallCheck" "checkInputs" "installCheckInputs" "__impureHostDeps" "__propagatedImpureHostDeps" From c12b50b267d9ac578ada7b268ffc2aa6b574c4a3 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 24 Jul 2018 16:32:40 -0400 Subject: [PATCH 6/8] stdenv cross adapter: Use `extraNativeBuildInputs` This means we don't need to hackily avoid overwriting `mkDerivation`. --- pkgs/stdenv/adapters.nix | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 8268dd5b0896..c05b6a05f4d8 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -63,33 +63,24 @@ rec { # with this run on a different platform, so disable by # default. overrides ? _: _: {} - } @ overrideArgs: let - stdenv = overrideArgs.stdenv.override { + } @ overrideArgs: + overrideArgs.stdenv.override (old: { inherit buildPlatform hostPlatform targetPlatform cc overrides; allowedRequisites = null; + extraNativeBuildInputs = old.extraNativeBuildInputs + # without proper `file` command, libtool sometimes fails + # to recognize 64-bit DLLs + ++ stdenv.lib.optional (hostPlatform.config == "x86_64-w64-mingw32") pkgs.file + ++ stdenv.lib.optional + (hostPlatform.isAarch64 || hostPlatform.isMips || hostPlatform.libc == "musl") + pkgs.updateAutotoolsGnuConfigScriptsHook + ; + extraBuildInputs = [ ]; # Old ones run on wrong platform - }; - in stdenv // { - mkDerivation = - { nativeBuildInputs ? [] - , ... - } @ args: - - stdenv.mkDerivation (args // { - nativeBuildInputs = nativeBuildInputs - # without proper `file` command, libtool sometimes fails - # to recognize 64-bit DLLs - ++ stdenv.lib.optional (hostPlatform.config == "x86_64-w64-mingw32") pkgs.file - ++ stdenv.lib.optional - (hostPlatform.isAarch64 || hostPlatform.isMips || hostPlatform.libc == "musl") - pkgs.updateAutotoolsGnuConfigScriptsHook - ; - }); - }; - + }); /* Modify a stdenv so that the specified attributes are added to every derivation returned by its mkDerivation function. From 839f96a4c5c4e5565239adbdf8a40667056a2652 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 24 Jul 2018 16:39:13 -0400 Subject: [PATCH 7/8] crossLibcStdenv: Just use `overrideCC` Now that we don't hackily override `mkDerivation`, the TODO is solved and we just can! --- pkgs/top-level/all-packages.nix | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index da44294f6379..f078a901c8bd 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6334,13 +6334,7 @@ with pkgs; { substitutions = { gcc = gcc-unwrapped; }; } ../development/compilers/gcc/libstdc++-hook.sh; - # Can't just overrideCC, because then the stdenv-cross mkDerivation will be - # thrown away. TODO: find a better solution for this. - crossLibcStdenv = buildPackages.makeStdenvCross { - inherit (buildPackages.buildPackages) stdenv; - inherit buildPlatform hostPlatform targetPlatform; - cc = buildPackages.gccCrossStageStatic; - }; + crossLibcStdenv = overrideCC stdenv buildPackages.gccCrossStageStatic; # The GCC used to build libc for the target platform. Normal gccs will be # built with, and use, that cross-compiled libc. From b81ee9df9f4724b7c9ac611999758a85cf684cc4 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Tue, 24 Jul 2018 16:46:52 -0400 Subject: [PATCH 8/8] makeStdenvCross: Remove It is inlined into the cross stdenv, which is its last use-case after the previous commit. --- pkgs/stdenv/adapters.nix | 29 ----------------------------- pkgs/stdenv/cross/default.nix | 20 +++++++++++++++++--- 2 files changed, 17 insertions(+), 32 deletions(-) diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index c05b6a05f4d8..66570cba946e 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -53,35 +53,6 @@ rec { }); }; - - # Return a modified stdenv that adds a cross compiler to the - # builds. - makeStdenvCross = { stdenv - , cc - , buildPlatform, hostPlatform, targetPlatform - , # Prior overrides are surely not valid as packages built - # with this run on a different platform, so disable by - # default. - overrides ? _: _: {} - } @ overrideArgs: - overrideArgs.stdenv.override (old: { - inherit - buildPlatform hostPlatform targetPlatform - cc overrides; - - allowedRequisites = null; - extraNativeBuildInputs = old.extraNativeBuildInputs - # without proper `file` command, libtool sometimes fails - # to recognize 64-bit DLLs - ++ stdenv.lib.optional (hostPlatform.config == "x86_64-w64-mingw32") pkgs.file - ++ stdenv.lib.optional - (hostPlatform.isAarch64 || hostPlatform.isMips || hostPlatform.libc == "musl") - pkgs.updateAutotoolsGnuConfigScriptsHook - ; - - extraBuildInputs = [ ]; # Old ones run on wrong platform - }); - /* Modify a stdenv so that the specified attributes are added to every derivation returned by its mkDerivation function. diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix index ab42dd319a62..29521874d1eb 100644 --- a/pkgs/stdenv/cross/default.nix +++ b/pkgs/stdenv/cross/default.nix @@ -34,17 +34,31 @@ in lib.init bootStages ++ [ (buildPackages: { inherit config overlays; selfBuild = false; - stdenv = buildPackages.makeStdenvCross { - inherit (buildPackages) stdenv; + stdenv = buildPackages.stdenv.override (old: rec { buildPlatform = localSystem; hostPlatform = crossSystem; targetPlatform = crossSystem; + + # Prior overrides are surely not valid as packages built with this run on + # a different platform, and so are disabled. + overrides = _: _: {}; + extraBuildInputs = [ ]; # Old ones run on wrong platform + cc = if crossSystem.useiOSPrebuilt or false then buildPackages.darwin.iosSdkPkgs.clang else if crossSystem.useAndroidPrebuilt then buildPackages.androidenv."androidndkPkgs_${crossSystem.ndkVer}".gcc else buildPackages.gcc; - }; + + extraNativeBuildInputs = old.extraNativeBuildInputs + # without proper `file` command, libtool sometimes fails + # to recognize 64-bit DLLs + ++ lib.optional (hostPlatform.config == "x86_64-w64-mingw32") buildPackages.file + ++ lib.optional + (hostPlatform.isAarch64 || hostPlatform.isMips || hostPlatform.libc == "musl") + buildPackages.updateAutotoolsGnuConfigScriptsHook + ; + }); }) ]