From 95c8277701fb746ad4d91841de494ee869886991 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Fri, 23 Jun 2017 17:45:27 -0400 Subject: [PATCH] misc pkgs: Remove unneeded *Platform == *Platform comparisons PR #26007 used these to avoid causing a mass rebuild. Now that we know things work, we do that to clean up. --- pkgs/applications/audio/mpg123/default.nix | 4 +- pkgs/applications/editors/ed/default.nix | 8 ++- pkgs/development/compilers/rust/rustc.nix | 3 +- pkgs/development/libraries/glew/1.10.nix | 4 +- pkgs/development/libraries/glew/default.nix | 4 +- pkgs/development/libraries/libelf/default.nix | 5 +- ...{cross-ar.patch => dont-hardcode-ar.patch} | 0 pkgs/development/libraries/zlib/default.nix | 58 +++++++++---------- .../tools/misc/binutils/default.nix | 12 +++- pkgs/development/tools/misc/gdb/default.nix | 5 +- pkgs/os-specific/darwin/binutils/default.nix | 13 +++-- pkgs/os-specific/darwin/cctools/port.nix | 15 +++-- pkgs/os-specific/linux/busybox/default.nix | 6 +- pkgs/tools/archivers/unzip/default.nix | 5 +- ...{cross-cc.patch => dont-hardcode-cc.patch} | 4 +- pkgs/tools/misc/coreutils/default.nix | 6 +- pkgs/tools/system/ddrescue/default.nix | 5 -- pkgs/tools/text/gnupatch/default.nix | 2 +- 18 files changed, 84 insertions(+), 75 deletions(-) rename pkgs/development/libraries/libelf/{cross-ar.patch => dont-hardcode-ar.patch} (100%) rename pkgs/tools/archivers/unzip/{cross-cc.patch => dont-hardcode-cc.patch} (74%) diff --git a/pkgs/applications/audio/mpg123/default.nix b/pkgs/applications/audio/mpg123/default.nix index 2909dd70ce9a..59012432caf6 100644 --- a/pkgs/applications/audio/mpg123/default.nix +++ b/pkgs/applications/audio/mpg123/default.nix @@ -1,6 +1,6 @@ { stdenv , fetchurl, alsaLib -, buildPlatform, hostPlatform +, hostPlatform }: stdenv.mkDerivation rec { @@ -13,7 +13,7 @@ stdenv.mkDerivation rec { buildInputs = stdenv.lib.optional (!stdenv.isDarwin) alsaLib; - ${if buildPlatform != hostPlatform then "configureFlags" else null} = + configureFlags = stdenv.lib.optional (hostPlatform ? mpg123) "--with-cpu=${hostPlatform.mpg123.cpu}"; meta = { diff --git a/pkgs/applications/editors/ed/default.nix b/pkgs/applications/editors/ed/default.nix index 053e1d22af31..2404405c307f 100644 --- a/pkgs/applications/editors/ed/default.nix +++ b/pkgs/applications/editors/ed/default.nix @@ -32,7 +32,13 @@ stdenv.mkDerivation rec { */ doCheck = !(hostPlatform.isDarwin || hostPlatform != buildPlatform); - configureFlags = if hostPlatform == buildPlatform then null else [ + # TODO(@Ericson2314): Use placeholder to make this a configure flag once Nix + # 1.12 is released. + preConfigure = '' + export DESTDIR=$out + ''; + + configureFlags = [ "--exec-prefix=${stdenv.cc.prefix}" "CC=${stdenv.cc.prefix}cc" ]; diff --git a/pkgs/development/compilers/rust/rustc.nix b/pkgs/development/compilers/rust/rustc.nix index 717c0092c946..28863e450a7a 100644 --- a/pkgs/development/compilers/rust/rustc.nix +++ b/pkgs/development/compilers/rust/rustc.nix @@ -138,8 +138,7 @@ stdenv.mkDerivation { inherit doCheck; - ${if buildPlatform == hostPlatform then "dontSetConfigureCross" else null} = true; - ${if buildPlatform != hostPlatform then "configurePlatforms" else null} = []; + configurePlatforms = []; # https://github.com/NixOS/nixpkgs/pull/21742#issuecomment-272305764 # https://github.com/rust-lang/rust/issues/30181 diff --git a/pkgs/development/libraries/glew/1.10.nix b/pkgs/development/libraries/glew/1.10.nix index b2e1b26704f3..159bf47e130a 100644 --- a/pkgs/development/libraries/glew/1.10.nix +++ b/pkgs/development/libraries/glew/1.10.nix @@ -38,8 +38,8 @@ stdenv.mkDerivation rec { cp -r README.txt LICENSE.txt doc $out/share/doc/glew ''; - makeFlags = if hostPlatform == buildPlatform then null else [ - "SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel}" + makeFlags = [ + "SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel.name}" ]; meta = with stdenv.lib; { diff --git a/pkgs/development/libraries/glew/default.nix b/pkgs/development/libraries/glew/default.nix index ecf1e914a7b1..814e4496b77d 100644 --- a/pkgs/development/libraries/glew/default.nix +++ b/pkgs/development/libraries/glew/default.nix @@ -39,8 +39,8 @@ stdenv.mkDerivation rec { rm $out/lib/*.a ''; - makeFlags = if hostPlatform == buildPlatform then null else [ - "SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel}" + makeFlags = [ + "SYSTEM=${if hostPlatform.isMinGW then "mingw" else hostPlatform.parsed.kernel.name}" ]; meta = with stdenv.lib; { diff --git a/pkgs/development/libraries/libelf/default.nix b/pkgs/development/libraries/libelf/default.nix index dcd5d1d7a93e..5cf74164f0fb 100644 --- a/pkgs/development/libraries/libelf/default.nix +++ b/pkgs/development/libraries/libelf/default.nix @@ -11,9 +11,8 @@ stdenv.mkDerivation rec { sha256 = "0vf7s9dwk2xkmhb79aigqm0x0yfbw1j0b9ksm51207qwr179n6jr"; }; - # TODO(@Ericson2314) Make unconditional next hash break - patches = if hostPlatform == buildPlatform then null else [ - ./cross-ar.patch + patches = [ + ./dont-hardcode-ar.patch ]; doCheck = true; diff --git a/pkgs/development/libraries/libelf/cross-ar.patch b/pkgs/development/libraries/libelf/dont-hardcode-ar.patch similarity index 100% rename from pkgs/development/libraries/libelf/cross-ar.patch rename to pkgs/development/libraries/libelf/dont-hardcode-ar.patch diff --git a/pkgs/development/libraries/zlib/default.nix b/pkgs/development/libraries/zlib/default.nix index eab36c21dc2b..ef9f2569c45e 100644 --- a/pkgs/development/libraries/zlib/default.nix +++ b/pkgs/development/libraries/zlib/default.nix @@ -4,10 +4,9 @@ , static ? false }: -let version = "1.2.11"; in - stdenv.mkDerivation rec { name = "zlib-${version}"; + version = "1.2.11"; src = fetchurl { urls = @@ -19,7 +18,7 @@ stdenv.mkDerivation rec { patches = stdenv.lib.optional hostPlatform.isCygwin ./disable-cygwin-widechar.patch; - postPatch = stdenv.lib.optionalString stdenv.isDarwin '' + postPatch = stdenv.lib.optionalString hostPlatform.isDarwin '' substituteInPlace configure \ --replace '/usr/bin/libtool' 'ar' \ --replace 'AR="libtool"' 'AR="ar"' \ @@ -30,14 +29,6 @@ stdenv.mkDerivation rec { setOutputFlags = false; outputDoc = "dev"; # single tiny man3 page - # TODO(@Dridus) CC set by cc-wrapper setup-hook, so just empty out the preConfigure script when cross building, but leave the old incorrect script when not - # cross building to avoid hash breakage. Once hash breakage is acceptable, remove preConfigure entirely. - preConfigure = stdenv.lib.optionalString (hostPlatform == buildPlatform) '' - if test -n "$crossConfig"; then - export CC=$crossConfig-gcc - fi - ''; - # FIXME needs gcc 4.9 in bootstrap tools hardeningDisable = [ "stackprotector" ]; @@ -49,37 +40,42 @@ stdenv.mkDerivation rec { # jww (2015-01-06): Sometimes this library install as a .so, even on # Darwin; others time it installs as a .dylib. I haven't yet figured out # what causes this difference. - + stdenv.lib.optionalString stdenv.isDarwin '' + + stdenv.lib.optionalString hostPlatform.isDarwin '' for file in $out/lib/*.so* $out/lib/*.dylib* ; do install_name_tool -id "$file" $file done + '' + # Non-typical naming confuses libtool which then refuses to use zlib's DLL + # in some cases, e.g. when compiling libpng. + + stdenv.lib.optionalString (hostPlatform.libc == "msvcrt") '' + ln -s zlib1.dll $out/bin/libz.dll ''; # As zlib takes part in the stdenv building, we don't want references # to the bootstrap-tools libgcc (as uses to happen on arm/mips) - NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (!stdenv.isDarwin) "-static-libgcc"; + NIX_CFLAGS_COMPILE = stdenv.lib.optionalString (!hostPlatform.isDarwin) "-static-libgcc"; - crossAttrs = { - dontStrip = static; - configurePlatforms = []; - } // stdenv.lib.optionalAttrs (hostPlatform.libc == "msvcrt") { - installFlags = [ - "BINARY_PATH=$(out)/bin" - "INCLUDE_PATH=$(dev)/include" - "LIBRARY_PATH=$(out)/lib" - ]; - makeFlags = [ - "-f" "win32/Makefile.gcc" - "PREFIX=${stdenv.cc.prefix}" - ] ++ stdenv.lib.optional (!static) "SHARED_MODE=1"; + dontStrip = hostPlatform != buildPlatform && static; + configurePlatforms = []; - # Non-typical naming confuses libtool which then refuses to use zlib's DLL - # in some cases, e.g. when compiling libpng. - postInstall = postInstall + "ln -s zlib1.dll $out/bin/libz.dll"; + installFlags = stdenv.lib.optionals (hostPlatform.libc == "msvcrt") [ + "BINARY_PATH=$(out)/bin" + "INCLUDE_PATH=$(dev)/include" + "LIBRARY_PATH=$(out)/lib" + ]; + + makeFlags = [ + "PREFIX=${stdenv.cc.prefix}" + ] ++ stdenv.lib.optionals (hostPlatform.libc == "msvcrt") [ + "-f" "win32/Makefile.gcc" + ] ++ stdenv.lib.optionals (!static) [ + "SHARED_MODE=1" + ]; + + passthru = { + inherit version; }; - passthru.version = version; - meta = with stdenv.lib; { description = "Lossless data-compression library"; license = licenses.zlib; diff --git a/pkgs/development/tools/misc/binutils/default.nix b/pkgs/development/tools/misc/binutils/default.nix index 82eb7f77bb4c..ae58c72b786d 100644 --- a/pkgs/development/tools/misc/binutils/default.nix +++ b/pkgs/development/tools/misc/binutils/default.nix @@ -8,10 +8,13 @@ let version = "2.28"; basename = "binutils-${version}"; inherit (stdenv.lib) optional optionals optionalString; + # The prefix prepended to binary names to allow multiple binuntils on the + # PATH to both be usable. + prefix = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-"; in stdenv.mkDerivation rec { - name = optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-" + basename; + name = prefix + basename; src = fetchurl { url = "mirror://gnu/binutils/${basename}.tar.bz2"; @@ -78,15 +81,20 @@ stdenv.mkDerivation rec { then "-Wno-string-plus-int -Wno-deprecated-declarations" else "-static-libgcc"; + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; configureFlags = [ "--enable-shared" "--enable-deterministic-archives" "--disable-werror" ] ++ optional (stdenv.system == "mips64el-linux") "--enable-fix-loongson2f-nop" - ++ optional (targetPlatform != hostPlatform) "--target=${targetPlatform.config}" # TODO: make this unconditional ++ optionals gold [ "--enable-gold" "--enable-plugins" ] ++ optional (stdenv.system == "i686-linux") "--enable-targets=x86_64-linux-gnu"; enableParallelBuilding = true; + passthru = { + inherit prefix; + }; + meta = with stdenv.lib; { description = "Tools for manipulating binaries (linker, assembler, etc.)"; longDescription = '' diff --git a/pkgs/development/tools/misc/gdb/default.nix b/pkgs/development/tools/misc/gdb/default.nix index 1e9cf910857c..78dd4a1e3f55 100644 --- a/pkgs/development/tools/misc/gdb/default.nix +++ b/pkgs/development/tools/misc/gdb/default.nix @@ -48,6 +48,9 @@ stdenv.mkDerivation rec { NIX_CFLAGS_COMPILE = "-Wno-format-nonliteral"; + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; + configureFlags = with stdenv.lib; [ "--with-gmp=${gmp.dev}" "--with-mpfr=${mpfr.dev}" "--with-system-readline" "--with-system-zlib" "--with-expat" "--with-libexpat-prefix=${expat.dev}" @@ -55,8 +58,6 @@ stdenv.mkDerivation rec { # TODO(@Ericson2314): make this conditional on whether host platform is NixOS "--with-separate-debug-dir=/run/current-system/sw/lib/debug" ++ stdenv.lib.optional (!pythonSupport) "--without-python" - # TODO(@Ericson2314): This should be done in stdenv, not per-package - ++ stdenv.lib.optional (targetPlatform != hostPlatform) "--target=${targetPlatform.config}" ++ stdenv.lib.optional multitarget "--enable-targets=all"; postInstall = diff --git a/pkgs/os-specific/darwin/binutils/default.nix b/pkgs/os-specific/darwin/binutils/default.nix index f88f761f65a3..933e7558dbbf 100644 --- a/pkgs/os-specific/darwin/binutils/default.nix +++ b/pkgs/os-specific/darwin/binutils/default.nix @@ -2,11 +2,12 @@ , hostPlatform, targetPlatform }: -let - prefix = stdenv.lib.optionalString - (targetPlatform != hostPlatform) - "${targetPlatform.config}-"; +# Make sure both underlying packages claim to have prepended their binaries +# with the same prefix. +assert binutils-raw.prefix == cctools.prefix; +let + inherit (binutils-raw) prefix; cmds = [ "ar" "ranlib" "as" "dsymutil" "install_name_tool" "ld" "strip" "otool" "lipo" "nm" "strings" "size" @@ -50,4 +51,8 @@ stdenv.mkDerivation { ln -s ${cctools}/libexec $out/libexec ''; + + passthru = { + inherit prefix; + }; } diff --git a/pkgs/os-specific/darwin/cctools/port.nix b/pkgs/os-specific/darwin/cctools/port.nix index 222c51603fdd..9fdb00d66be9 100644 --- a/pkgs/os-specific/darwin/cctools/port.nix +++ b/pkgs/os-specific/darwin/cctools/port.nix @@ -1,10 +1,12 @@ { stdenv, fetchFromGitHub, makeWrapper, autoconf, automake, libtool_2 , llvm, libcxx, libcxxabi, clang, libuuid , libobjc ? null, maloader ? null, xctoolchain ? null -, buildPlatform, hostPlatform, targetPlatform +, hostPlatform, targetPlatform }: let + # The prefix prepended to binary names to allow multiple binuntils on the + # PATH to both be usable. prefix = stdenv.lib.optionalString (targetPlatform != hostPlatform) "${targetPlatform.config}-"; @@ -38,13 +40,10 @@ let enableParallelBuilding = true; + # TODO(@Ericson2314): Always pass "--target" and always prefix. + configurePlatforms = [ "build" "host" ] ++ stdenv.lib.optional (targetPlatform != hostPlatform) "target"; configureFlags = stdenv.lib.optionals (!stdenv.isDarwin) [ "CXXFLAGS=-I${libcxx}/include/c++/v1" - ] ++ stdenv.lib.optionals (targetPlatform != buildPlatform) [ - # TODO make unconditional next hash break - "--build=${buildPlatform.config}" - "--host=${hostPlatform.config}" - "--target=${targetPlatform.config}" ]; postPatch = '' @@ -104,6 +103,10 @@ let done ''; + passthru = { + inherit prefix; + }; + meta = { homepage = "http://www.opensource.apple.com/source/cctools/"; description = "Mac OS X Compiler Tools (cross-platform port)"; diff --git a/pkgs/os-specific/linux/busybox/default.nix b/pkgs/os-specific/linux/busybox/default.nix index e1ea8fa8fdd2..815e2e0f6ef6 100644 --- a/pkgs/os-specific/linux/busybox/default.nix +++ b/pkgs/os-specific/linux/busybox/default.nix @@ -63,7 +63,7 @@ stdenv.mkDerivation rec { CONFIG_DEFAULT_SETFONT_DIR "/etc/kbd" ${extraConfig} - $extraCrossConfig + CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cc.prefix}" EOF make oldconfig @@ -79,10 +79,6 @@ stdenv.mkDerivation rec { buildInputs = lib.optionals (enableStatic && !useMusl) [ stdenv.cc.libc stdenv.cc.libc.static ]; - extraCrossConfig = if hostPlatform == buildPlatform then null else '' - CONFIG_CROSS_COMPILER_PREFIX "${stdenv.cc.prefix}" - ''; - enableParallelBuilding = true; meta = with stdenv.lib; { diff --git a/pkgs/tools/archivers/unzip/default.nix b/pkgs/tools/archivers/unzip/default.nix index ad484b3d4d97..896cdd50973c 100644 --- a/pkgs/tools/archivers/unzip/default.nix +++ b/pkgs/tools/archivers/unzip/default.nix @@ -1,7 +1,6 @@ { stdenv, fetchurl , bzip2 , enableNLS ? false, libnatspec -, buildPlatform, hostPlatform }: stdenv.mkDerivation { @@ -23,13 +22,13 @@ stdenv.mkDerivation { ./CVE-2015-7697.diff ./CVE-2014-9913.patch ./CVE-2016-9844.patch + ./dont-hardcode-cc.patch ] ++ stdenv.lib.optional enableNLS (fetchurl { url = "http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/app-arch/unzip/files/unzip-6.0-natspec.patch?revision=1.1"; name = "unzip-6.0-natspec.patch"; sha256 = "67ab260ae6adf8e7c5eda2d1d7846929b43562943ec4aff629bd7018954058b1"; - }) - ++ stdenv.lib.optional (hostPlatform != buildPlatform) ./cross-cc.patch; + }); nativeBuildInputs = [ bzip2 ]; buildInputs = [ bzip2 ] ++ stdenv.lib.optional enableNLS libnatspec; diff --git a/pkgs/tools/archivers/unzip/cross-cc.patch b/pkgs/tools/archivers/unzip/dont-hardcode-cc.patch similarity index 74% rename from pkgs/tools/archivers/unzip/cross-cc.patch rename to pkgs/tools/archivers/unzip/dont-hardcode-cc.patch index 3d38ffdef6e3..15dbbfe4c533 100644 --- a/pkgs/tools/archivers/unzip/cross-cc.patch +++ b/pkgs/tools/archivers/unzip/dont-hardcode-cc.patch @@ -1,12 +1,14 @@ --- a/unix/Makefile +++ b/unix/Makefile -@@ -42,9 +42,7 @@ +@@ -42,9 +42,9 @@ # such as -DDOSWILD). # UnZip flags -CC = cc# try using "gcc" target rather than changing this (CC and LD ++CC ?= cc# try using "gcc" target rather than changing this (CC and LD LD = $(CC)# must match, else "unresolved symbol: ___main" is possible) -AS = as ++AS ?= as LOC = $(D_USE_BZ2) $(LOCAL_UNZIP) AF = $(LOC) CFLAGS = -O diff --git a/pkgs/tools/misc/coreutils/default.nix b/pkgs/tools/misc/coreutils/default.nix index 42f8e74df313..9a988a2b4311 100644 --- a/pkgs/tools/misc/coreutils/default.nix +++ b/pkgs/tools/misc/coreutils/default.nix @@ -70,7 +70,7 @@ stdenv.mkDerivation rec { && builtins.storeDir == "/nix/store"; # Prevents attempts of running 'help2man' on cross-built binaries. - ${if hostPlatform == buildPlatform then null else "PERL"} = "missing"; + PERL = if hostPlatform == buildPlatform then null else "missing"; # Saw random failures like ‘help2man: can't get '--help' info from # man/sha512sum.td/sha512sum’. @@ -83,11 +83,11 @@ stdenv.mkDerivation rec { # Works around a bug with 8.26: # Makefile:3440: *** Recursive variable 'INSTALL' references itself (eventually). Stop. - ${if hostPlatform == buildPlatform then null else "preInstall"} = '' + preInstall = optionalString (hostPlatform != buildPlatform) '' sed -i Makefile -e 's|^INSTALL =.*|INSTALL = ${buildPackages.coreutils}/bin/install -c|' ''; - ${if hostPlatform == buildPlatform then null else "postInstall"} = '' + postInstall = optionalString (hostPlatform != buildPlatform) '' rm $out/share/man/man1/* cp ${buildPackages.coreutils}/share/man/man1/* $out/share/man/man1 ''; diff --git a/pkgs/tools/system/ddrescue/default.nix b/pkgs/tools/system/ddrescue/default.nix index 0b94f328b84a..5f439ccdb530 100644 --- a/pkgs/tools/system/ddrescue/default.nix +++ b/pkgs/tools/system/ddrescue/default.nix @@ -17,11 +17,6 @@ stdenv.mkDerivation rec { doCheck = hostPlatform == buildPlatform; - ${if hostPlatform != buildPlatform then "crossPlatforms" else null} = [ ]; - ${if hostPlatform != buildPlatform then "configureFlags" else null} = [ - "CXX=${stdenv.cc.prefix}c++" - ]; - meta = with stdenv.lib; { description = "GNU ddrescue, a data recovery tool"; diff --git a/pkgs/tools/text/gnupatch/default.nix b/pkgs/tools/text/gnupatch/default.nix index 57543eb303b0..13579b57e796 100644 --- a/pkgs/tools/text/gnupatch/default.nix +++ b/pkgs/tools/text/gnupatch/default.nix @@ -13,7 +13,7 @@ stdenv.mkDerivation rec { buildInputs = stdenv.lib.optional doCheck ed; - configureFlags = if hostPlatform == buildPlatform then null else [ + configureFlags = stdenv.lib.optionals (hostPlatform != buildPlatform) [ "ac_cv_func_strnlen_working=yes" ];